GROMACS particle definitions¶
ParticleType
dataclass
¶
Represents a particle type in a molecular dynamics simulation.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the particle type. |
mass |
float
|
The mass of the particle type. |
charge |
float
|
The charge of the particle type. |
ptype |
str
|
The type of the particle (e.g., atomistic, coarse-grained). |
c6 |
float
|
The Lennard-Jones C6 parameter for the particle type. |
c12 |
float
|
The Lennard-Jones C12 parameter for the particle type. |
Source code in martignac/parsers/gromacs_particle_definitions.py
find_particle_type_from_name(itp_filename, particle_name)
¶
Finds and returns a ParticleType object from a GROMACS .itp file based on the particle name.
This function searches through the particle types defined in a specified .itp file, looking for a particle
type that matches the given name. It utilizes the parse_particle_types_from_itp
function to read and parse
the .itp file, extracting all defined particle types into a list of ParticleType objects. It then iterates
through this list to find a particle type with a name that matches the particle_name
parameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
itp_filename |
str
|
The path to the .itp file to be searched. |
required |
particle_name |
str
|
The name of the particle type to find. |
required |
Returns:
Name | Type | Description |
---|---|---|
ParticleType |
ParticleType
|
The ParticleType object corresponding to the specified particle name. |
Raises:
Type | Description |
---|---|
StopIteration
|
If no particle type with the specified name is found in the .itp file. |
Source code in martignac/parsers/gromacs_particle_definitions.py
generate_gro_for_particle_type(particle_type, gro_filename, box_length=100.0)
¶
Generates a GROMACS .gro file for a single particle type with specified box dimensions.
This function creates a .gro file representing a simulation box containing a single particle of the specified type. The particle is placed at the origin of the box. The function uses MDAnalysis to create an empty universe, sets the particle's attributes, and then writes the .gro file with the specified box dimensions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particle_type |
ParticleType
|
The particle type for which to generate the .gro file. This should be an instance of the ParticleType class, containing the necessary attributes like name, mass, and charge. |
required |
gro_filename |
str
|
The path and filename where the .gro file will be saved. If the file already exists, it will be overwritten. |
required |
box_length |
float
|
The length of the sides of the cubic simulation box in which the particle is placed. The default value is 100.0 Ångströms. |
100.0
|
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
This function does not return a value but writes directly to a file specified by |
Source code in martignac/parsers/gromacs_particle_definitions.py
generate_itp_file_for_particle(particle, itp_filename)
¶
Generates a GROMACS .itp file for a single particle type.
This function writes to a .itp file specific information about a particle type, including its name, type, and charge. The .itp (include topology) file format is used by GROMACS to define molecule types in simulations. This function creates a minimal .itp file containing a single [moleculetype] entry and one [atoms] entry for the specified particle.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particle |
ParticleType
|
The particle type for which to generate the .itp file. This should be an instance of the ParticleType class, containing the necessary attributes like name, mass, and charge. |
required |
itp_filename |
str
|
The path and filename where the .itp file will be saved. If the file already exists, it will be overwritten. |
required |
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
This function does not return a value but writes directly to a file specified by |
Source code in martignac/parsers/gromacs_particle_definitions.py
generate_top_file_for_particle(particle, force_field_filenames, top_filename, num_molecules=1)
¶
Generates a GROMACS topology (.top) file for a single particle type.
This function creates a .top file for a specified particle type, incorporating the specified force field files.
The generated .top file includes the definition of the particle type and the number of molecules of that type
to be included in the simulation. It delegates the actual writing of the file to the
generate_top_file_for_generic_molecule
function, which handles the formatting and inclusion of force field
parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particle |
ParticleType
|
The particle type for which to generate the .top file. This should be an instance of the ParticleType class, containing the necessary attributes like name, mass, and charge. |
required |
force_field_filenames |
list[str]
|
A list of paths to the force field files to be included in the .top file. These files contain the parameters necessary for the simulation, such as bond lengths, angles, and Lennard-Jones parameters. |
required |
top_filename |
str
|
The path and filename where the .top file will be saved. If the file already exists, it will be overwritten. |
required |
num_molecules |
int
|
The number of molecules of the specified particle type to include in the simulation. Defaults to 1. |
1
|
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
This function does not return a value but writes directly to a file specified by |
Source code in martignac/parsers/gromacs_particle_definitions.py
parse_particle_types_from_itp(filename)
¶
Parses particle types from a GROMACS .itp file.
This function reads a GROMACS topology (.itp) file and extracts the definitions of particle types
listed under the [ atomtypes ] section. Each particle type is represented by a ParticleType
object,
which includes properties such as name, mass, charge, particle type (ptype), and Lennard-Jones parameters (c6, c12).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
The path to the .itp file to be parsed. |
required |
Returns:
Type | Description |
---|---|
list[ParticleType]
|
list[ParticleType]: A list of |