Skip to content

User Guides Short Intro

Short Introduction to molecule_lib

This is a short introduction to molecule_lib. It is intended to give a broad overview of how the library works. To see what each method or function does, look at Reference page.

We import molecule_lib as follows:

IN [1]
import molecule_lib as mol

Main objects in molecule_lib

In molecule_lib there are two main objects:

  1. ABCMolecule: a dataclass containing a molecular structure with a unit cell.

  2. XYZMolecule: a dataclass containing a molecular structure without a unit cell.

The ABCCoord, XYZCoord, and LatticeMatrix objects are sub dataclasses used in the creation of the Molecule objects. The Animation objects store molecular simulations with each image being a Molecule dataclass object.

Object creation

The easiest way to create an object is use a library function and an already existing structure file. See read_functions for more detailed information. The code below creates an ABCMolecule object from that existing .vasp structure file.

IN [2]
vasp_file = mol.read_vasp(filepath="test_files/slabs/a-001.vasp")

Common Molecule methods to learn:

Molecule.info() shows a quick summary of the Molecule object.

IN [3]
vasp_file.info()
OUT [3]
type: ABCMolecule
filetype: .vasp
total atoms: 96
species info: {'Al': '24', 'O': '48', 'H': '24'}
comment line: '3_OPT_cell (Generated by CrystalMaker X for Windows)'
lattice constant: 1.0
lattice matrix:
[8.7807035882, 0.1780459095, 3.7774054998]
[-1.0698364258, 0.1158044938, -9.5608328356]
[-0.9853331692, 23.1955056605, -0.2016342785]
positional: True
Converting from a positional unitcell coordinates to cartesian .xyz coordinates

IN [4]
xyz_file = vasp_file.convert()
IN [5]
xyz_file.info()
OUT [5]
type: XYZMolecule
filetype: .vasp
total atoms: 96
species info: {'Al': '24', 'O': '48', 'H': '24'}
comment line: '3_OPT_cell (Generated by CrystalMaker X for Windows)'