MDMC.MD.packmol package
Submodules
MDMC.MD.packmol.packmol_setup module
A module containing a class for storing packmol systems and their metadata
- class MDMC.MD.packmol.packmol_setup.PackmolSetup[source]
Bases:
object
A class that stores structures and their metadata for use in a packmol generation. For an explanation of all the settings and constraints see: https://m3g.github.io/packmol/userguide.shtml#basic
- add_box(structure: Structure, lengths: Tuple[float], origin: Tuple[float] = (0.0, 0.0, 0.0), density: float = 0.0, n_structures: int = 0) None [source]
Add a cuboid box of randomly-packed structures. At least two of “lengths”, “density” or “number” must be filled in order to properly create the box. If “density” is provided, the size of the box may change to allow for a whole number of structures.
- Parameters:
structure (Structure) – The Structure (atom or molecule) object to randomly fill the box with.
lengths (tuple) – A 3-tuple of xyz lengths for the box in angstroms.
origin (optional, tuple) – A 3-tuple of xyz coordinates for the origin of the box. Defaults to (0.,0.,0.).
density (optional, float) – The density of the structures within the box. Defaults to 0.
n_structures (optional, int) – An integer number of structures to fill the box with. Defaults to 0.
- add_container(structure: Structure, dimensions: tuple, origin: tuple = (0.0, 0.0, 0.0), density: float = 0.0, n_structures: int = 0, container_type: str = None) None [source]
Adds a container to the setup Only density or n_structures need to be provided at one time, as n_structures can be inferred from the density
- Parameters:
structure (Structure) – A Structure (atom or molecule) object to be added to the container.
dimensions (tuple) – The size of the container either in xyz (3-tuple) or a single size (1-tuple) depending on the container type.
origin (tuple) – A 3-tuple containing the xyz coordinate for the origin of the container.
density (float) – A floating point number describing the density of the structures in the container in Ang^-3.
n_structures (int) – An integer number of structures to add to the container.
container_type (str) – The type of container to add. Currently only “cube”, “box” and “sphere” are supported.
- add_cube(structure: Structure, size: float, origin: Tuple[float] = (0.0, 0.0, 0.0), density: float = 0.0, n_structures: int = 0) None [source]
Add a cube of randomly-packed structures. At least two of “size”, “density” or “number” must be filled in order to properly create the cube. If “density” is provided, the size of the cube may change to allow for a whole number of structures.
- Parameters:
structure (Structure) – The Structure (atom or molecule) object to randomly fill the cube with.
size (float) – The size (x y and z) of the cube in angstroms.
origin (tuple) – A 3-tuple of xyz coordinates indicating the origin of the cube. Defaults to (0.,0.,0.).
density (optional, float) – The density of the structures within the cube in Ang^-3.
n_structures (optional, int) – An integer number of structures to fill the cube with.
- add_fixed_structure(structure: Structure, position: Tuple[float] = (0.0, 0.0, 0.0), rotation: Tuple[float] = (0.0, 0.0, 0.0), centre: bool = True) None [source]
Add a single structure (atom or molecule) in a fixed position to the setup.
- Parameters:
structure (Structure) – The Structure object (atom or molecule) to be added to the setup.
position (optional, tuple) – A 3-tuple containing the xyz coordinates of the structure. Defaults to the origin (0.,0.,0.)
rotation (optional, tuple) – A 3-tuple containing the rotational angles of the structure (in radians). Defaults to (0.,0.,0.) (0 rotation in any direction). Meaningless if the structure is not a Molecule.
centre (optional, bool) – True if the structure is to be centred around the position or not. Defaults to True. Meaningless if the structure is not a Molecule.
- add_sphere(structure: Structure, radius: float, origin: Tuple[float] = (0.0, 0.0, 0.0), density: float = 0.0, n_structures: int = 0) None [source]
Add a sphere of randomly-packed structures. At least two of “size”, “density” or “number” must be filled in order to properly create the box. If “density” is provided, the size of the box may change to allow for a whole number of structures.
- Parameters:
structure (Structure) – The Structure (atom or molecule) object to randomly fill the sphere with.
radius (float) – The radius of the sphere in angstroms.
origin (optional, tuple) – A 3-tuple of xyz coordinates for the centre of the sphere.
density (optional, float) – The density of the structures within the box. Defaults to 0.
n_structures (optional, int) – An integer number of structures to fill the box with. Defaults to 0.
- get_max_sizes() Tuple[float] [source]
- Returns:
A 6-tuple of the minimum and maximum sizes of the setup in the following format: (x_min, y_min, z_min, x_max, y_max, z_max)
- Return type:
tuple
- get_settings() Tuple[dict, list[dict]] [source]
- Returns:
A tuple containing the whole-system and per-structure settings
- Return type:
tuple
- get_structures() Tuple[Structure] [source]
- Returns:
The set of Structure objects in the setup
- Return type:
list
- remove_structure(structure: Structure) None [source]
Remove a structure and associated setups from the system.
- Parameters:
structure – The Structure (atom or molecule) object to remove from the setup.
- static resolve_density(dimensions: Tuple[float], density: float = 0.0, container_type: str = None) tuple [source]
Takes a volume of type “box”, “cube”, or “sphere”, with nominal dimensions, tries to fill that volume to the given density, and changes the dimensions to ensure an integer number of structures will fit with the desired density.
- Parameters:
dimensions (optional, tuple) – A tuple of the dimensions that affect the volume of the container.
density (optional, float) – A target density to achieve within the system.
container_type (str) – A string describing the type of container to use. Currently only “cube”, “box” and “sphere” are supported.
- Returns:
A tuple containing (in order): 1) A tuple of the (possibly) revised dimensions of the volume 2) The number of structures needed to meet the density
- Return type:
tuple
- MDMC.MD.packmol.packmol_setup.calculate_volume(dimensions: Tuple[float], container_type: str = None) float [source]
A method to calculate the volume of a container given the dimensions.
- Parameters:
dimensions – A tuple of floats that define the dimensions of the container.
container_type (str) – A string specifying the type of container. Currently only “cube”, “box” and “sphere” are supported.
- Returns:
The volume of the container.
- Return type:
float
MDMC.MD.packmol.packmol_wrapper module
A module that integrates packmol into MDMC
- class MDMC.MD.packmol.packmol_wrapper.PackmolFiller(setup_data: PackmolSetup)[source]
Bases:
object
A class representing a packmol run based on a PackmolSetup object.
- fill_with_packmol() Universe [source]
- Parameters:
setup_data – A PackmolSetup object containing the data for the packmol run.
- Returns:
A Universe object filled with the structures requested by the PackmolSetup object.
- Return type:
Universe
- property filled_universe: Universe
Get the Universe filled via the packmol run.
- Returns:
An MDMC Universe.
- Return type:
- get_packmol_files_path() str [source]
Get the path in which packmol files are placed and run.
- Returns:
The path to the packmol files directory.
- Return type:
- get_packmol_output_path() str [source]
Obtains the name of the packmol output file, as defined by the input file. Returns an empty string if there is no input file name defined.
- Returns:
The name of the packmol output file name.
- Return type:
- static get_packmol_path() str [source]
Returns a string containing the path to packmol from the PATH environment variable, if it exists. Otherwise, returns the current working directory if packmol is not in PATH.
- property setup_data: PackmolSetup
The Packmol setup data for this run.
- Returns:
The setup data for this run.
- Return type:
Module contents
Interface with Packmol (https://m3g.github.io/packmol/)