Molgen

Molecule generator description

The initial configurations can be generated by employing a Plug-Ins (named Molgen) of GALAMOST and output in XML format.

The head of script:

#!/usr/bin/python
import sys
sys.path.append('/opt/galamost3/lib')
import molgen
# sets the path of molgen.so and imports an extended Python module of molgen.

Two steps to employ this tool: 1. Defines each single molecule or object (the object module is usually used to describe the objects with various shape). 2. Sets box size and the number of defined molecules and objects. A molecule is defined by “Molecule” class with the number of particles, particle types, topology, and so on. An object is defined by “Object” class with the number of particles and shape.

Examples:

mol1=molgen.Molecule(4)
mol1.setParticleTypes("A,A,A,A")
mol1.setTopology("0-1,1-2, 2-3")
mol1.setBondLength(0.75)
mol1.setMass(1.0)
mol1.setAngleDegree("A","A","A",90.0)

One or more molecules or objects can be defined in this way. Then the box size and the number of these molecules should be specified by “Generators”.

Examples:

gen=molgen.Generators(10,10,10)
gen.addMolecule(mol1,10)
gen.setMinimumDistance(0.7)
gen.outPutXml("test")

The configuration of a molecule can be partially read from a XML file and partially defined in the script.

Examples:

mol0=molgen.Molecule("sphere.xml",65)
# total 65 particles with 60 read from "sphere.xml".
mol0.setParticleTypes("B*5")
# define the types of the particles which will be generated.
mol0.setTopology("59-60,60-61,61-62,62-63,63-64")
# add the bonds.

If the configuration of a molecule (including particle positions, types, topology and so on) has been completely given in a XML file, we only need to randomly put it by employing “object”.

Examples:

mol1 = molgen.Object("mol1.xml", 65, molgen.Object.Shape.none)
gen=molgen.Generators(30,30,30)
gen.addMolecule(mol1,20)
gen.outPutXml("test")

Molecule definition

class Molecule(np)

The constructor of a molecule with the number of particles.

Parameters:np (int) – The number of particles.
class Molecule(filename, np)

The constructor of a molecule and reads particles data from the XML file with file name and the number of particles.

Parameters:
  • filename (str) – The name of inputting file.
  • np (int) – The number of particles.
setParticleTypes(string type)

specifies the particle types separated by comma according to particle index form 0 to N-1 in sequence.

setTopology(string topo)

specifies the bonds separated by comma which connect two particles separated by crossband.

setIsotactic(bool switch)

switches the isotactic configuration of molecule.

setBondLength(double bl)

specifies the bond length of all bonds.

setBondLength(string type1, string type2, double bl)

specifies the bond length of the bond which connect two kind particles with particle type1, type2, and bond length.

setAngleDegree(string type1, sstring type2, string type2, double degree)

specifies the angle with particle type 1, type2, type3, and degree.

setAngleDegree(unsigned int idx1, unsigned int idx2, unsigned int idx3, double degree)

specifies the angle with particle idx1, idx2, idx3, and degree.

setDihedralDegree(string type1, string type2, string type3, string type4, double degree)

specifies the dihedral with particle type1, type2, type3, type4, and degree.

setDihedralDegree(unsigned int idx1, unsigned int idx2, unsigned int idx3, unsigned int idx4, double degree)

specifies the dihedral with particle idx1, idx2, idx3, idx4, and degree.

setMass(double mass)

specifies the mass of all particles.

setMass(string type, double mass)

specifies the mass of a kind of particles.

setMass(unsigned int particle_index, double mass)

specifies the mass of a particle.

setCharge(double charge)

specifies the charge of all particles.

setCharge(string type, double charge)

specifies the charge of a kind of particles.

setCharge(unsigned int particle_index, double charge)

specifies the charge of a particle.

setOrientation()

specifies all particles having orientation.

setOrientation(string type)

specifies a kind of particles having orientation.

setOrientation(unsigned int particle_index)

specifies a particle having orientation.

setInert(double inertx, double inerty, double inertz)

specifies the inert in x, y, z directions of all particles.

setInert(string type, double inertx, double inerty, double inertz)

specifies the inert in x, y, z directions of a kind of particles.

setInert(unsigned int particle_index, double inertx, double inerty, double inertz)

specifies the inert in x, y, z directions of a particle.

setQuaternion()

specifies all particles having quaternion.

setQuaternion(string type)

specifies a kind of particles having quaternion.

setQuaternion(unsigned int particle_index)

specifies a particle having quaternion.

setDiameter(double di)

specifies the diameter of all particles.

setDiameter(string type, double di)

specifies the diameter of a kind of particles.

setDiameter(unsigned int particle_index, double di)

specifies the diameter of a particle.

setCris(unsigned int cris)

specifies the cris of all particles.

setCris(string type, unsigned int cris)

specifies the cris of a kind of particles.

setCris(unsigned int particle_index, unsigned int cris)

specifies the cris of a particle.

setInit(unsigned int init)

specifies the init of all particles.

setInit(string type, unsigned int init)

specifies the init of a kind of particles.

setInit(unsigned int particle_index, unsigned int init)

specifies the init of a particle.

setBody(unsigned int body_id)

specifies the body id of all particles (start form 0).

setBody(string type, unsigned int body_id)

specifies the body id of a kind of particles (start form 0).

setBody(unsigned int particle_index, unsigned int body_id)

specifies the body id of a particle (start form 0).

setMolecule(unsigned int mol_id)

specifies the molecule id of all particles (start form 0).

setMolecule(string type, unsigned int mol_id)

specifies the mlecule id of a kind of particles (start form 0).

setMolecule(unsigned int particle_index, unsigned int mol_id)

specifies the molecule id of a particle (start form 0).

setBox(double lx, double ly, double lz)

specifies the size of box where the molecules are generated.

setBox(double lx_min, double lx_max, double ly_min, double ly_max, double lz_min, double lz_max)

specifies the box where the molecules are generated with box boundaries: lx_min, lx_max, ly_min, ly_max, lz_min, lz_max.

setSphere(double sx, double sy, double sz, double r_min, double r_max)

specifies the sphere where the molecules are generated with sphere center position(sx, sy, sz), spherical shell radius r_min, and r_max. The molecules are generated in the range r_min< r < r_max.

setCylinder(double px, double py, double pz, double ax, double ay, double az, double r_min, double r_max)

specifies the cylinder where the molecules are generated with cylinder center position(px, py, pz), cylinder axe vecter(ax, ay, ax), cyliner radius r_min, and r_max. The molecules are generated in the range r_min< r<r_max.

setBodyEvacuation()

specifies the generation of molecules outside bodies.

Example:

mol0=molgen.Molecule(8)
# initializes a molecule object with the number of particles.
mol0.setParticleTypes("A,A,A,A,A,A,A,A")
# sets particle types.
mol0.setTopology("0-1,0-3,0-4,2-3,1-2,1-5,2-6,3-7,4-5,4-7,5-6,6-7")
# sets topology.
mol0.setBondLength(0.75)
# sets bond length for all bonds.
mol0.setMass(1.0)
# sets mass for all particle.
mol0.setAngleDegree("A","A","A",90.0)
# sets the degree of the angle of particles with the type 1, 2 and 3.

Objects definition

class Object(np, shape)

The constructor of an object with the number of particles and shape.

Parameters:
  • np (int) – The number of particles.
  • shape (Shape) – The shape of object.
class Object(string filename, unsigned int, Object::Shape)

The constructor of an object by reading partial data from a file with file name, the number of particles, and shape (the candidates are “none” and “sphere”).

Parameters:
  • filename (str) – The name of inputting file.
  • np (int) – The number of particles.
  • shape (Shape) – The shape of object.
setRadius(double radius)

specifies the radius of the sphere which will be generated(only works for “sphere” shape) with radius.

Example:

mol0 = molgen.Object("sphere.xml", 65, molgen.Object.Shape.none)
# initializes an object by the reading file (containing 60 particles),
# the number of particles, and object shape.
mol0.setParticleTypes("A*5")
# sets particle types (the former 60 types can be read form the file).
mol0.setTopology("59-60,60-61,61-62,62-63,63-64")
# sets topology.
mol0.setBody("C", 0)
# sets body index (the type "C" particles are thereby rigid body particles).

Generator definition

class Generators(double lx, double ly, double lz)

The constructor of a molecule generator with box length in x y z directions.

Parameters:
  • lx (float) – The box length in x direction.
  • ly (float) – The box length in y direction.
  • lz (float) – The box length in z direction.
addMolecule(Molecule mol, unsigned int num)

adds a molecule into generator with molecule object and number.

setMinimumDistance(double min_dis)

sets the minimum separated distance of all particles.

setMinimumDistance(string type1, string type2, double min_dis)

sets the minimum separated distance between two particle types with particle type 1, particle type 2 and minimum distance.

setParam(string type1, string type2, double epsilon, double sigma, double r_cut)

sets the LJ potential parameters between two particle types for Rosenblueth method with particle type1, particle type2, epsilon, sigma, and cut-off radius.

setDimension(unsigned int dimension)

specifies system dimension, the default value is 3.

outPutXml(string filename)

switch the function of outputting XML filename.

outPutMol2(string filename)

switch the function of outputting Mol2 files.

Example:

gen=molgen.Generators(10, 10, 10)
# initializes a generator object by box length in x, y, and z direction.
gen.addMolecule(mol0, 10)
# adds a molecule by molecule name and the number of molecules.
gen.setParam("A","A", 1.0, 0.7, 1.0)
# sets the parameters of LJ potential which is used for Rosenblueth method.
gen.setMinimumDistance(0.7)
# sets the minimum separated distance of all particles.
gen.setMinimumDistance("A","A", 0.7)
# sets the minimum separated distance between the particle types.
gen.outPutXml("test")
# sets the name of output XML file.