Io traj
thmd.io.traj
¶
This module contains classes and functions to process molecular dynamics trajectories.
Classes:
-
Frame
–Create an Object for a single-FRAME of trajectories from MD simulation.
-
Traj
–Create an Object for a multi-FRAMEs of trajectories from MD simulation.
Frame(dump_file: str = None, data_file: str = None, atom_style: str = 'auto', pdb_file: str = None, xyz_file: str = None, from_df: pd.DataFrame = None, box: np.array = None, box_angle: np.array = None)
¶
Create an Object for a single-FRAME of trajectories from MD simulation.
This class create a data-object (single configuration) for the analysis of computing data from LAMMPS. The file formats implemented in this class
This class implemented several ways to create Frame
object
- create an empty data object
- create_DATA object with input data
- read from DUMP file
- read from DATA file
- read frome PDB file
Attributes:
-
filename
(str
) –name of input file
-
timestep
(int
) –the timestep of configuration
-
box
(array
) –3x2 array, the box size
-
box_angle
(array
) –1x3 array, the box angle
-
atom
(DataFrame
) –DataFrame of per-atom values
-
prop_key
(list
) –column-names of properties
-
mass
(DataFrame
) –DataFrame of per-type masses
-
fmt
(str
) –default format for float numbers, don't use %g because it will lost precision
Examples:
from thmd.traj import Frame
da = Frame() # empty object
da = Frame(from_df=df) # oject with input data
da = Frame(dump_file='test.cfg') # from DUMP file
da = Frame(data_file='mydata.dat') # from DATA file
da = Frame(pdb_file='test.pdb') # from PDB file
Refs: [1]. Use chain mutator calls
initilize the Frame object
Parameters:
-
dump_file
(str
, default:None
) –filename of DUMP file.
-
data_file
(str
, default:None
) –filename of DATA file.
-
pdb_file
(str
, default:None
) –filename of PBD file.
-
xyz_file
(str
, default:None
) –filename of XYZ file.
-
from_df
(DataFrame
, default:None
) –create FRAME from data.
-
atom_style
(str
, default:'auto'
) –atom_style of system. Only need when
data_file
is used. Possible values: 'atomic', 'molecular', 'charge', 'full', 'auto' -
box
(np.array list
, default:None
) –Define simulation box. Only need when
from_df
is used. -
box_angle
(np.array list
, default:None
) –Define angle of simulation box. Only need when
from_df
is used.
Returns:
-
Obj
(Frame
) –object of trajectories
Notes
Use mutator, so do not use self.* when define value
Methods:
-
create_DATA
–The method to create new FRAME object with input data.
-
copy
–The method to make an indepedent copy of Frame Obj. Then, the change values of the fields of the new object, the old object should not be affected by that.
-
check_exist
–The method to check whether something is existed in system or not.
Attributes:
-
filename
(str
) – -
timestep
(int
) – -
decimals
(int
) – -
box
– -
box_angle
– -
prop_key
(list[str]
) – -
atom
– -
mass
– -
pair_coeff
– -
bond_coeff
– -
angle_coeff
– -
dihedral_coeff
– -
improper_coeff
– -
bondBond_coeff
– -
bondAngle_coeff
– -
middleBondTorsion_coeff
– -
endBondTorsion_coeff
– -
angleTorsion_coeff
– -
angleAngleTorsion_coeff
– -
bondBond13_coeff
– -
angleAngle_coeff
– -
bond
– -
angle
– -
dihedral
– -
improper
–
filename: str = 'md_frame'
instance-attribute
¶
timestep: int = None
instance-attribute
¶
decimals: int = 7
instance-attribute
¶
box = np.asarray([[0, 1], [0, 1], [0, 1]], dtype=float)
instance-attribute
¶
box_angle = np.asarray([0, 0, 0], dtype=float)
instance-attribute
¶
prop_key: list[str] = None
instance-attribute
¶
atom = None
instance-attribute
¶
mass = None
instance-attribute
¶
pair_coeff = None
instance-attribute
¶
bond_coeff = None
instance-attribute
¶
angle_coeff = None
instance-attribute
¶
dihedral_coeff = None
instance-attribute
¶
improper_coeff = None
instance-attribute
¶
bondBond_coeff = None
instance-attribute
¶
bondAngle_coeff = None
instance-attribute
¶
middleBondTorsion_coeff = None
instance-attribute
¶
endBondTorsion_coeff = None
instance-attribute
¶
angleTorsion_coeff = None
instance-attribute
¶
angleAngleTorsion_coeff = None
instance-attribute
¶
bondBond13_coeff = None
instance-attribute
¶
angleAngle_coeff = None
instance-attribute
¶
bond = None
instance-attribute
¶
angle = None
instance-attribute
¶
dihedral = None
instance-attribute
¶
improper = None
instance-attribute
¶
create_DATA(df: pd.DataFrame, box: np.array = None, box_angle: np.array = None)
¶
The method to create new FRAME object with input data.
Parameters:
-
DataFrame
(DataFrame
) –of input data
-
box
(array
, default:None
) –3x2 array, option to input boxSize.
-
box_angle
(array
, default:None
) –1x3 array, option to input box_angle.
Returns:
-
Obj
(Frame
) –update Frame
Examples:
copy()
¶
The method to make an indepedent copy of Frame Obj. Then, the change values of the fields of the new object, the old object should not be affected by that.
Returns:
-
Obj
(Frame
) –new Frame Obj.
Examples:
Refs: [1]. "shallow copying" vs "deep copying": https://stackoverflow.com/questions/3975376/understanding-dict-copy-shallow-or-deep/3975388#3975388
check_exist(atom_types=None, mass_types=None)
¶
The method to check whether something is existed in system or not.
Parameters:
-
atom_types
(list
, default:None
) –list-of-int of atom-types. Default to None.
-
mass_types
(list
, default:None
) –list-of-int of atom-types. Default to None.
Returns:
-
mgs
(str
) –raise Message if error.
Examples:
Notes
set() also return unique values.