Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Molecule

There are several different ways to create molecule objects such as using chemical names, SMILES strings, xyz-strings, molecule strings, or xyz-files.

By default, coordinates are given in units of Ångström but atomic units is also available.

Python script

caffeine = vlx.Molecule.read_name("caffeine")

aspirin = vlx.Molecule.read_smiles("CC(=O)OC1=CC=CC=C1C(=O)O")

h2o = vlx.Molecule.read_xyz_string("""
3
water
O    0.0000000    0.0000000   -0.1653507
H    0.7493682    0.0000000    0.4424329
H   -0.7493682    0.0000000    0.4424329
""")

co = vlx.Molecule.read_molecule_string("""
C    0.0  0.0  0.0
O    0.0  0.0  1.128
""")

tq = vlx.Molecule.read_xyz_file("../input_files/tq-polymer.xyz")

3D illustrations of molecular structures are available with the show method.

caffeine.show()
aspirin.show(atom_indices=True, atom_labels=True)
tq.show()
Loading...
Loading...
Loading...

Molecular conformations can be altered using the set_dihedral_in_degrees function.

h2o2 = vlx.Molecule.read_smiles("OO")
h2o2.set_dihedral_in_degrees([3, 1, 2, 4], 180.0)

h2o2.show(atom_indices=True)
Loading...

The molecular charge and spin multiplicity can be adjusted using the set_charge and set_multiplicity functions. In the example below, we create a molecule object for the phenyl radical cation.

phenyl = vlx.Molecule.read_smiles("c1ccccc1")
phenyl.set_charge(1)
phenyl.set_multiplicity(2)

Text file

Using input text files, molecule specifications are exemplified below.

@molecule
charge: 0
multiplicity: 1
xyz:
O    0.0000000    0.0000000   -0.1653507
H    0.7493682    0.0000000    0.4424329
H   -0.7493682    0.0000000    0.4424329                     
@end
@molecule
charge: 0
multiplicity: 1
xyz_file: "../input_files/tq-polymer.xyz"
@end

A detailed list of keywords is available.