API Documentation
- class hoomdxml_reader.molecule.Molecule[source]
A class to store information about an individual molecule in the system.
- Parameters
particle_index (int) – Index of the particle to add to the molecule
particle_type (str) – Type name associated with a given particle
molecule_name (str) – Name of the molecule
- Returns
n_particles (int) – Number of particles in the molecule
particles (list, shape=(1,n_particles), dtype=int) – List of particles in the system.
types (list, shape=(1,n_particles), dtype=str) – List of type names of particles in the molecule
pattern (str) – String constructed by concatenating entries in types list.
name (str) – Name of the molecule.
- property bonds
A list containing the bonds in the molecule. Integer particle ids refer to numbers in the entire system.
- property n_particles
The total number of particles in the molecule.
- property name
A string corresponding to the name of the molecule. Note, molecules with the same pattern will be assigned the same name.
- property particles
A list of indices correspoding to the particles in the molecule. These are listed in numerical order from lowest to highest. These correspond to the numbers assigned in the system class.
- property pattern
Returns a string constructed by concatenating entries in the types list. This is used to identify the total number of unique molecules in a system.
- property types
A list containing the type of the particle stores in the particles list, listed in the same order.
- class hoomdxml_reader.System(file=None, frame=0, identify_molecules=True, ignore_zero_bond_order=False, molecule_dict=None)[source]
Class that stores system information from XML and GSD files.
A class to load hoomd XML or GSD formatted configuration files and store the information encoded in these files. This class will also optionally goup the underlying particles into molecules, inferred based upon the connectivity of particles as defined in the bonds section of the configuration file. If an XML or GSD file is passed during instantiation, it will load and parse file provided.
- Parameters
file (string, optional, default=None) – Name of the hoomd xml or gsd file to load
frame (int, optional, default=0)
identify_molecules (bool, optional, default=True) – If True, the code will group the particles based upon their underlying connectivity. Particles bonded together will be considered a molecule
ignore_zero_bond_order (bool, optional, default=False) – If True, particles without any bonds (i.e., bond order = 0) will be ignored when identifying molecules (i.e., they will not appear in the molecule list). If False, a particle with bond order = 0 will be considered to be a molecule.
molecule_dict (dict, dtype=str, optional, default=None) – A dict that defines the molecule ‘pattern’ and associated user defined name. This is used for renaming molecules automatically identified.
- property angles
A list of all angles defined in the source file.
- Returns
angles – List of all angles in the system. The first entry per angles is the name of the angle (str) as defined in the source file.
- Return type
list, shape=(4, n_angles), dtype=(str, int, int, int)
- property bond_order
A list containing an integer bond order (i.e., total number of bonds) of each particle in the system.
- Returns
bond_order – A list of the bond order of each particle in the system.
- Return type
list, shape=(1,n_particles), dtype=int
- property bonds
A list of all bonds defined in the source file.
- Returns
bonds – List of all bonds in the system. The first entry per bond is the name of the bond (str) as defined in the source file.
- Return type
list, shape=(3, n_bonds), dtype=(str, int, int)
- property box
List of the box lengths defined in the source file.
- Returns
box – List of the box length formatted as [Lx, Ly, Lz]
- Return type
list, shape(3), dtype=float,
- property charges
A list of all charges defined in the source file.
- Returns
charges – List of charges of all particles in the system.
- Return type
list, shape=(1,n_particles), dtype=float
- property dihedrals
A list of all dihedrals defined in the source file
- Returns
dihedrals – List of all dihedrals in the system. The first entry per dihedral is the name of the dihedral (str) as defined in the source file.
- Return type
list, shape=(5, n_dihedrals), dtype=(str, int, int, int, int)
- property graph
A networkx graph generated from the bond information included in the source file.
- Returns
graph – NetworkX graph constructed from all bonds defined in the XML file
- Return type
networkx graph
- property impropers
A list of all impropers defined in the source file
- Returns
impropers – List of all impropers in the system. The first entry per improper is the name of the improper (str) as defined in the source file.
- Return type
list, shape=(5, n_impropers), dtype=(str, int, int, int, int)
- load(file=None, frame=0, identify_molecules=True, ignore_zero_bond_order=False, molecule_dict=None)[source]
Loads an xml or gsd file.
Load the xml or GSD file into the system class. This function will clear any information already loaded into the System class.
- Parameters
file (string, optional, default=None) – Name of the hoomd xml or gsd file to load
frame (int, optional, default=0)
identify_molecules (bool, optional, default=True) – If True, the code will group the particles based upon their underlying connectivity. Particles bonded together will be considered a molecule
ignore_zero_bond_order (bool, optional, default=False) – If True, particles without any bonds (i.e., bond order = 0) will be ignored when identifying molecules (i.e., they will not appear in the molecule list). If False, a particle with bond order = 0 will be considered to be a molecule.
molecule_dict (dict, dtype=str, optional, default=None) – A dict that defines the molecule ‘pattern’ and associated user defined name. This is used for renaming molecules automatically identified.
- property masses
A list of all masses defined in the source file.
- Returns
masses – List of masses of all particles in the system.
- Return type
list, shape=(1,n_particles), dtype=float
- property molecules
This is a list of all molecules found in the system, where each entry corresponds to an instance of the Molecule class.
- Returns
molecules – List containing each molecule identified by the code. Each entry in the list is an instance of the Molecule class.
- Return type
list, dtype=Molecule
- property n_angles
The total number of angles in the system
- Returns
n_angles – Number of angles in the system
- Return type
int
- property n_bonds
The total number of bonds in the system
- Returns
n_bonds – Number of bonds in the system
- Return type
int
- property n_dihedrals
The total number of dihedrals in the system
- Returns
n_dihedrals – Number of dihedrals in the system
- Return type
int
- property n_impropers
The total number of impropers in the system
- Returns
n_impropers – Number of impropers in the system
- Return type
int
- property n_particles
The total number of particles in the system
- Returns
n_particles – Number of particles in the system
- Return type
int
- set_molecule_name_by_dictionary(molecule_dict)[source]
Assign molecule names.
This function will assign names to the molecules in the system based upon the provided dictionary. A pattern is constructed by concatenating partice names together into a single string. Unique patterns in the system can be found in the unique_molecules dictionary.
- Parameters
molecule_dict (dict, dtype=str) – A dict that defines the molecule ‘pattern’ and associated user defined name. This is used for renaming molecules automatically identified. Molecule pattern as the key and associated molecule name as the value in the dict, i.e., {pattern: name}
- property types
A list of all particle types.
- Returns
types – List of type names of all particles in the system.
- Return type
list, shape=(1,n_particles), dtype=str
- property unique_molecules
A dict that contains the molecule pattern as the key and associated molecule name as the value, for each unique molecule in the system.
- Returns
unique_molecules – A dict that provides the molecule ‘pattern’ and associated assigned name (“molecule{i}”) for each unique molecule type identified in the system. This is useful for allowing definition of the molecule_dict for assigning molecules names.
- Return type
dict, dtype=str
- property xyz
A list of xyz coordinates for each particle.
- Returns
xyz – List containing a list of x, y, z coordinates of each particle.
- Return type
list shape=(3,n_particles), dtype=float