Build¶
Overview
General building methods of Hoobas. |
|
Building methods specialized for the HOOMD package |
|
Building methods specialized for ESPResSO++ simulation package. |
|
Building methods specialized for the openMM simulation package |
|
This class provides functionality for cross MD package functionalities. |
|
Object to manage adding biases to the system in the form of bonds, e.g. |
|
Class dealing with charge normalization in the system and permittivity values. |
|
Handles file writing from builder objects |
Details
-
class
hoobas.Build.Bias(parent)[source]¶ Object to manage adding biases to the system in the form of bonds, e.g. for umbrella sampling or thermodynamic integration
-
add_bonds_colloids(bond_name=None, colloid_test=None)[source]¶ Add bonds between every center of colloid objects in the domain
- Parameters
bond_name – Name of the bond type created
colloid_test (dict) – Dictionary of properties the colloid must satisfy
- Returns
-
add_einstein_crystal_lattice(additional_offsets=None, beadopts=None, bond_name=None, colloid_test=None)[source]¶ Creates additional beads on each center of the colloids. Default type is ‘EC’ with a default mass of 1.0. Bonds are appended between this particle and the colloid center for thermodynamic integration. Bond name is ‘EC-bond’ by default. Additional points to append can be supplied by additional_offsets, which are offsets from the center of the colloid by index.
Conditions to evaluate on the properties of the colloid can be specified by a colloid dict.
- Parameters
additional_offsets – additional points where to add beads
beadopts – options to be passed to the bead constructor
bond_name – name of the bond to append
colloid_test – dict of properties that has to be specified
- Returns
None
-
-
class
hoobas.Build.Builder(domain, **kwargs)[source]¶ General building methods of Hoobas. This class only assembles the system and related commands. It is composed with the following classes for specialized post-processing:
Electrostatics: charge normalization (permittivity)
Bias: adding biasing potentials in the form of bonds, fixed Einstein lattices, etc.
FileWriter: writing simulation information to files
- Args:
domain: Simulation domain used
-
add_N_ext_obj(ext_obj, N)[source]¶ Adds N composite objects to the system positioned at random locations, with random rotation
- Parameters
ext_obj (
CompositeObject) – external object to be copied.N (
int) – number of objects
- Return type
None- Returns
-
add_ions(N, qtype='ion', ion_mass=1.0, q=1.0, ion_diam=1.0)[source]¶ Adds N ions in the simulation, randomly positioned
- Parameters
N (int) – Number of ions
qtype (str) – ion beadtype
ion_mass (float) – mass of ions
q (float) – charge of ions
ion_diam (float) – diameter of ions
- Returns
None
-
add_layer(multilayer, midplane=0.0, displace_elements=True)[source]¶ Adds a 2D object in the simulation box. It is automatically added in the (001) plane, crossing the z=0 plane. For most simulation boxes, this is a flat plane laying in the XY plane. By default, the box size is increased and the simulation contents that would had overlapped are pushed away. This behavior is controlled by displace_elements
- Parameters
multilayer (Layers.Multilayer) – 2D layer to add
midplane (float) – location of the plane
displace_elements (bool) – whether to displace existing contents away from the layer
- Return type
None- Returns
None
-
add_rho_molar_ions(rho, qtype='ion', ion_mass=1.0, q=1.0, ion_diam=1.0)[source]¶ Adds a volumetric density of rho ions to the simulation domain
- Parameters
rho (float) – molar density (mol / L)
qtype (basestring) – beadtype for added ions
q (float) – charge of the ions
ion_mass (float) – mass of added ions
ion_diam (float) – size of ions
- Return type
None- Returns
None
-
property
bead_types¶ Beadtypes in the simulation
- Returns
beadtypes
- Return type
list
Tags of the center of rigid bodies in the simulation
- Returns
tags
- Return type
list
-
property
center_types¶ Beadtypes of centers of rigid bodies in the simulation
- Returns
beadtypes
- Return type
list
-
property
charge_list¶ Returns the list of charged beadtypes in the simulation
- Returns
charged beadtypes
- Return type
list
-
copy_ext_obj(ext_obj)[source]¶ Directly imports a composite object into the simulation domain without performing any changes
- Parameters
ext_obj (
CompositeObject) – object to import- Return type
None- Returns
-
enforce_PBC(z_box_multi=None)[source]¶ enforces periodic boundary conditions on particles. The last vector length can be multiplied by a constant to create empty space
- Parameters
z_box_multi (float) – z multiplier for PBC
- Return type
None- Returns
-
enforce_XYPBC()[source]¶ Enforces a special 2D periodic conditions in the XY plane while leaving Z free. (x,y) components of the last box vectors are assumed to be zero, while the z components of the first two vectors are assumed to be zero. This is called when making crystal slabs.
- Return type
None- Returns
None
-
fix_remaining_charge(ptype='ion', ntype='ion', pion_mass=1.0, nion_mass=1.0, qp=1.0, qn=-1.0, pion_diam=1.0, nion_diam=1.0, isrerun=False)[source]¶ Enforces electroneutrality of the system
- Parameters
ptype (
str) – type name of cationntype (
str) – type name of anionpion_mass (
float) – mass of cationnion_mass (
float) – mass of anionqp (
float) – charge of cationqn (
float) – charge of anionpion_diam (
float) – diameter of cationnion_diam (
float) – diameter of anionisrerun (
bool) – internal parameter; should not be used from outside
- Return type
None- Returns
None
-
property
num_beads¶ Number of beads in the simulation
- Returns
number of beads
- Return type
int
-
property
obj_end_index¶ Queries the list of last indexes of each object added to the simulation. This can be used to create groups in HOOMD-blue, when used in conjunction with the starting indexes
- Returns
Ending indexes
- Return type
list
-
property
obj_start_index¶ Queries the list of starting indexes of each object added to the simulation. This can be used to create groups in HOOMD-blue for instance, in conjunction with ending indexes
- Returns
Starting indexes
- Return type
list
-
set_rotation_function(mode=None, key_search=None)[source]¶ Sets the rotation of rigid bodies in the domain. Note that all rigid bodies will be rotated according to their orientations, which includes rigid objects that are grafted on other objects. For these cases, the key_search option must be employed.
- Parameters
mode (
Optional[str]) – (string, None), either ‘none’ or ‘random’key_search (
Union[None,str,dict]) – (string, dict), used for random list of properties the rigid body must have in order to be rotated.
- Returns
-
shift_pos(displacement)[source]¶ shift positions of all beads by a constant displacement :type displacement:
ndarray:param displacement: Displacement to apply to all beads :rtype:None:return:
-
property
surface_types¶ Tags of the surfaces of rigid bodies in the simulation
- Returns
tags
- Return type
list
-
property
sys_box¶ Queries the simulation domain of the builder
- Returns
box
- Return type
iterable
-
class
hoobas.Build.CrossBuilder(domain, **kwargs)[source]¶ This class provides functionality for cross MD package functionalities. This inherits from all the classes defined in MetaBuilder.BuilderTypes and also copies all class methods in another namespace, such that if a class MD_Build has a method called read, it located in CrossBuilder.read and CrossBuilder.MD_Build.read. This is meant to avoid overriden methods by external builders added to BuilderTypes.
- Args:
domain: Simulation domain passed to Builder units(default = None): units of simulation. Defaults to reduced units
-
class
hoobas.Build.ESPResSOppBuilder(domain, **kwargs)[source]¶ Building methods specialized for ESPResSO++ simulation package. Imports yield mangled names as the simulation package has no internal string representation for bonded types.
- Args:
domain (SimulationDomain.Domain): domain to build units (SimulationUnits): units to use
-
pairlist_by_type(bondtype)[source]¶ In espresso++, a pairlist represents a bond interaction type. This returns all bonds corresponding to the supplied bondtype argument
- Parameters
bondtype (str) – builder bondtype representation
- Returns
bonds
- Return type
list[Composite.Bond]
-
quadruplelist_by_type(dihedral_type)[source]¶ In espresso++, a triple list represents an angle interaction type. This returns all angles corresponding to the supplied angletype argument
- Parameters
dihedral_type (str) – builder dihedral representation
- Returns
dihedrals
- Return type
list[Composite.Dihedral]
-
read(system)[source]¶ Reads an espresso++ system into the builder object. Bonded force-field names obtained are mangled
- Parameters
system (espressopp.system) – espresso++ system
- Returns
None
-
triplelist_by_type(angletype)[source]¶ In espresso++, a triple list represents an angle interaction type. This returns all angles corresponding to the supplied angletype argument
- Parameters
angletype (str) – builder angletype representation
- Returns
angles
- Return type
list[Composite.Angle]
-
class
hoobas.Build.Electrostatics(beads, units)[source]¶ Class dealing with charge normalization in the system and permittivity values.
- Args:
beads: list of beads for which charge is managed units: units to which beads correspond
-
denormalize()[source]¶ Removes the normalization of charges in the system
- Return type
None- Returns
None
-
get_type_charge_product(typeA, typeB)[source]¶ returns the charge product of two types of beads in the lists. Will not return correct values if multiple beads of a given type can have different charges
- Parameters
typeA (str) – first beadtype
typeB (str) – second beadtype
- Returns
charge product
- Return type
float
-
property
normalization¶ The normalization constant of charges in the system. This is equivalent to \(\epsilon^{1/2} / \mathcal{q}\), where \(\epsilon\) is the permittivity and \(\mathcal{q}\) the charge unit
- Getter
returns the normalization constant
- Setter
sets the normalization constant
- Type
float
- Return type
float
-
normalize()[source]¶ Normalizes the charges in the simulation. Normally, this should be done automatically by builders
- Return type
None- Returns
None
-
property
permittivity¶ Defines the relative permittivity of the system. For atomistic simulations, this value should be 1. For CG systems, this depends on the force-field. For Martini, this is 10.0.
- Getter
Returns the permittivity value
- Setter
Sets the permittivity value
- Type
float
- Return type
float
-
set_eps_salt_water(salt_concentration)[source]¶ Sets the permittivity of the simulation to known values for water-NaCl mixtures at a given ion concentration. These values are taken from: J.-W. Shen, C. Li, N. F. A. Vegt, C. Peter, “Transferability of coarse-grained potentials: implicit solver models for hydrated ions”, J. Chem. Th. and Comp., 2011
- Parameters
salt_concentration (float) – Salt concentration in water (M)
- Return type
None- Returns
None
-
set_eps_water_temperature(temperature)[source]¶ Sets the permittivity of the simulation to known values for water at different temperatures. Fit is taken from D. M. Hinckley, J. J. De Pablo, “Coarse-grained Ions for Nucleic Acid Modeling”, J. Chem. Th. Comp. 2015, with data from D. P. Fernandez et al. “A formulation for the static permittivity of water and steam at temperatures from 238K to 873K at pressures up to 1200 MPa including derivatives and Debye-Huckel coefficients”, J. Phys. and Chem. Ref. Data, 1997 :type temperature:
float:param temperature: temperature (K) :type temperature: float :rtype:None:return:
-
class
hoobas.Build.FileWriter(parent)[source]¶ Handles file writing from builder objects
This is automatically made by the builder class and methods can be accessed by builder.FileWriter.method
- Args:
parent: Parent builder object
-
class
hoobas.Build.HOOMDBuilder(domain, **kwargs)[source]¶ Building methods specialized for the HOOMD package
- Args:
domain (SimulationDomain.Domain): simulation domain used by the builder shapes (list of GenShape objects): list of shapes to build colloids with
- kwargs:
units (SimulationUnits): units used by the builder
-
aggregate_rigid_tuples()[source]¶ Provides a method to obtain arguments for constrain.rigid(). This is required for rigid body dynamics
- Returns
parameters to pass to hoomd
- Return type
list[tuple]
-
charge_to_types_per_rigid_body(types)[source]¶ Sets a charge to every bead listed in types. This charge only depends on the rigid body number. This was used in O’Brien et al., “Exploring the zone of anisotropy and broken symmetries in DNA-mediated nanoparticle self-assembly”, PNAS 2016
- Parameters
types – beadtypes to apply charge on
- Returns
None
-
correct_pnum_body_lists()[source]¶ Fixes the body attribute of beads to their particle tag number to fit HOOMD blue standards
- Returns
None
-
import_snapshot(snapshot)[source]¶ Imports a hoomd snapshot as a HOOMDBuilder object.
- Parameters
snapshot (hoomd.data.snapshot) – snapshot to import
- Returns
None
-
class
hoobas.Build.MetaBuilder[source]¶ Syntaxic sugar to have the CrossBuilder class inherits from all classes defined in BuilderTypes
-
class
hoobas.Build.openMMBuilder(domain, **kwargs)[source]¶ Building methods specialized for the openMM simulation package
- Args:
domain (SimulationDomain.Domain): domain to build kwargs: units to build this