10.7 The molecule module
Keywords: viewmol

## 10.7 The `molecule` module

`molecule`()
  Creates a new instance of a molecule object and returns a reference to it. Note: To obtain object references to molecules already loaded into VIEWMOL use the `getMolecules` function of the `viewmol` module.

`translate`(x, y, z)
  Translates (shifts) molecule by x, y, and z along the x, y, and z axis, respectively. x, y, and z have to be integers and are measured in pixels of the screen.

`rotate`(x, y, z)
  Rotates molecule by x, y, and z about x, y, and z axis, respectively. x, y, and z have to be integers and are measured in degrees.

`getSpectrum`()
  Creates a new instance of a spectrum object and returns a reference to it if there is spectral information associated with this molecule.

`getEnergyLevels`()
  Creates a new instance of an energy level object and returns a reference to it if there is information about energy levels associated with this molecule.

`getHistory`()
  Creates a new instance of a history object and returns a reference to it if there is information about the optimization history associated with this molecule.

`showForces`(status)
  Sets the display of forces for all molecules to status. status has to be one of the integer constants `ON` or `OFF` defined in the `viewmol` module.

`getAtoms`()
  Returns a list containing references to all atom objects the molecule is composed off.

`getBonds`()
  Returns a list of tupels describing all bonds in the molecule. The tupels consists of three integers `(atom1, atom2, order)` where `atom1` and `atom2` are the indices of the two atoms forming the bond and `order` is the bond order. The bond order can be one of the constants `HYDROGENBOND, CONJUGATED, SINGLE, DOUBLE`, or `TRIPLE` for hydrogen/Van der Waals, conjugated, single, double, and triple bonds, respectively. These constants are defined in the `molecule` module.

`getWavenumbers`()
  Returns a list of tupels describing all wave numbers of the molecule. The tupel consists of four floats and one string `(waveNumber, IRIntensity,` `RamanIntensity, INSIntensity, symmetry)` where `waveNumber` is the wave number in cm-1, `IRIntensity`, `RamanIntensity`, and `INSIntensity` are the IR, Raman, and inelastic neutron scattering intensities in per cent, and `symmetry` is a label describing the symmetry of the mode.

`getMOEnergies`()
  Returns a list of tupels providing information about all molecular orbitals of the molecule. The tupel consists of two floats, one integer, and one string `(energy, occupation, spin, symmetry)` where `energy` is the energy of the molecular orbital in Hartrees, `occupation` is the number of electrons in this orbital, `spin` in one of the constants `ALPHA+BETA, ALPHA`, or `BETA` describing what spin has been assigned to this orbital, and `symmetry` is a label describing the symmetry of the molecular orbital. The constants are defined in the `molecule` module.

`title`([title])
  Sets or returns the title of a molecule. title has to be a string. The maximum length of the title is limited to 255 characters.

`bondAverage`(atom)
  Returns the average of the lengths of all bonds involving atom atom in Ångstrøms. atom is an atom object.

`bondLength`(atom1, atom2, [length, unit])
  Returns or sets the length of the bond between atoms atom1 and atom2. atom1 and atom2 have to be atom objects, the bond length is returned in Ångstrøms. If length and unit are given, the bond length is set. length is a double, unit a string containing either `Ang`, `au` or `bohr`, or `pm` for Ångstrøms, atomic units, or picometers. Everything else is interpreted as Ångstrøms.

`bondAngle`(atom1, atom2, atom3, [angle])
  Returns or sets the bond angle atom1-atom2-atom3. atom1, atom2, atom3 are atom objects. If angle is given the bond angle is set. angle has to be a double and is measured in degrees.

`torsionAngle`(atom1, atoms2, atom3, atom4, [torsionAngle])
  Returns or sets the torsion angle atom1-atom2-atom3-atom4. atom1, atom2, atom3, atom4 are atom objects. If torsionAngle is given the torsion angle is set. torsionAngle has to be a double and is measured in degrees.

`getThermodynamics`(property, type)
  Returns a thermodynamical property of the molecule. property and type are integers. property can be one of the integer constants `ENTHALPY`, `ENTROPY`, `GIBBS_ENERGY`, or `HEAT_CAPACITY` defined in the `molecule` module. type can be one of the integer constants `TRANSLATION`, `PV`, `ROTATION`, `VIBRATION`, or `TOTAL` also defined in the `molecule` module. The returned thermodynamic property will be in SI units.

`reaction`([side])
  Sets or returns whether the molecule is a reactant or a product in a reaction. side is an integer and can be set to one of the integer constants `REACTANT`, `PRODUCT`, or `ALLREACTIONS` defined in the `molecule` module.

`showElectrons`(type, [gridResolution, interpolation])
  Displays wave function related properties of the molecule. type is an integer and can be set to one of the integer constants `BASIS_FUNCTION`, `BASIS_IN_MO`, `MO`, or `DENSITY` defined in the `molecule` module. gridResolution is a double specifying the resolution of the grid used to calculate the isosurface. Larger values for gridResolution result in smoother displays. interpolation is an optional integer and can be one of the integer constants `IP_NONE` (no interpolation), `IP_LINEAR` (linear interpolation), or `IP_LOG` (logarithmic interpolation) defined in the `molecule` module.

`showGrid`(which, [interpolation])
  Displays a property which has been read as a grid. which is an integer between 1 and the number of grids which have been read for this molecule and identifies the grid to be shown. interpolation is an optional integer and can be one of the integer constants `IP_NONE` (no interpolation), `IP_LINEAR` (linear interpolation), or `IP_LOG` (logarithmic interpolation) defined in the `molecule` module.

`selectBasisfunction`(atom, name, count)
  Selects a basis function for display. atom is an atom object specifying which atom the basis function belongs to. name is a string specifying what kind of basis function (s, p, d, etc.) to select. count is an integer specifying which of the s, p, d, etc. functions to select. Assume atom 1 is a carbon atom in a calculation using a DZVP basis set. It therefore has three s functions. `selectBasisfunction(1, "s", 1)` would select the 1s function, `selectBasisfunction(1, "s", 2)` the first 2s function, and `selectBasisfunction(1, "s", 3)` the second 2s function.

`unitCell`(visible, [afac, bfac, cfac])
  Sets visibility and number of replicas of unit cell. visible has to be one of the integer constants `ON` or `OFF` defined in the `viewmol` module to turn display of the unit cell on or off. afac, bfac, and cfac are doubles specifying the number of replicas of the unit cell to be displayed along the a, b, and c axis, respectively. Fractions are allowed for afac, bfac, and cfac.

`millerPlane`(visible, [h, k, l])
  Sets visibility and orientation of Miller plane. visible has to be one of the integer constants `ON` or `OFF` defined in the `viewmol` module to turn display of a Miller plane on or off. h, k, and l are integers specifying the Miller indices of the plane to display.

`addAtom`(symbol, [attach])
  Adds an atom to the molecule. symbol is a string containing the element symbol of the atom to add. attach is an atom object specifying the atom the newly added atom should be attached to. attach can be omitted, but this is only useful for adding the first atom to a molecule.