_initclass: Which InputInit class to use to read the data.
_storageclass: Which data type to use to hold the data.
"""
attribs=deepcopy(InputValue.attribs)
attribs["mode"]=(InputAttribute,{"dtype":str,"default":"other","help":"The input data format. 'xyz' and 'pdb' stand for xyz and pdb input files respectively. 'chk' stands for initialization from a checkpoint file. 'manual' means that the value to initialize from is giving explicitly as a vector. 'thermal' means that the data is to be generated from a Maxwell-Boltzmann distribution at the given temperature.","options":None})
default_label="INITBASE"
default_help="This is the base class for initialization. Initializers for different aspects of the simulation can be inherit for it for the base methods."
forkinself.attribs:# store additional attributes from the input class
self.__dict__[k].store(ibase.__dict__[k])
defgetval(self):
"""Calculates the value from the data supplied in the xml file.
Either reads the string from the input file as an array of numbers,
or as a string specifying either a file name or a single value.
"""
value=super(InputInitBase,self).fetch()
ifself.mode.fetch()=="manual":
if'['invalueand']'invalue:# value appears to be a list
ifself._storageclassisfloat:
value=io_xml.read_array(np.float,value)
else:
value=io_xml.read_list(value)
else:
value=io_xml.read_type(self._storageclass,value)
else:
value=str(value)# typically this will be a no-op
returnvalue
deffetch(self,initclass=None):
"""Creates an input base object.
Returns:
An input base object.
"""
rdict={}
forkinself.attribs:
rdict[k]=self.__dict__[k].fetch()
ifinitclassisNone:# allows for some flexibility in return class
initclass=self._initclass
returninitclass(value=self.getval(),**rdict)
classInputInitFile(InputInitBase):
"""Class to handle initialization from a file."""
attribs=deepcopy(InputInitBase.attribs)
attribs["mode"][1]["default"]="chk"
attribs["mode"][1]["options"]=["xyz","pdb","chk"]
attribs["mode"][1]["help"]="The input data format. 'xyz' and 'pdb' stand for xyz and pdb input files respectively. 'chk' stands for initialization from a checkpoint file."
default_label="INITFILE"
default_help="This is the class to initialize from file."
classInputInitThermo(InputInitBase):
"""Class to handle initialization of the thermostat."""
attribs=deepcopy(InputInitBase.attribs)
attribs["mode"][1]["default"]="manual"
attribs["mode"][1]["options"]=["chk","manual"]
attribs["mode"][1]["help"]="'chk' stands for initialization from a checkpoint file. 'manual' means that the value to initialize from is giving explicitly as a vector."
default_label="INITTHERMO"
default_help="This is the class to initialize the thermostat (ethermo and fictitious momenta)."
classInputInitIndexed(InputInitBase):
"""Class to handle initialization of properties which the value of each
bead and atom can be specified.
Attributes:
index: Which atom to initialize the value of.
bead: Which bead to initialize the value of.
"""
attribs=deepcopy(InputInitBase.attribs)
attribs["index"]=(InputAttribute,{"dtype":int,"default":-1,"help":"The index of the atom for which the value will be set. If a negative value is specified, then all atoms are assumed."})
attribs["bead"]=(InputAttribute,{"dtype":int,"default":-1,"help":"The index of the bead for which the value will be set. If a negative value is specified, then all beads are assumed."})
default_label="INITINDEXED"
default_help="This is a helper class to initialize with an index."
classInputInitPositions(InputInitIndexed):
"""Class to handle initialization of the positions."""
attribs["mode"][1]["help"]="The input data format. 'xyz' and 'pdb' stand for xyz and pdb input files respectively. 'chk' stands for initialization from a checkpoint file. 'manual' means that the value to initialize from is giving explicitly as a vector."
default_label="INITPOSITIONS"
default_help="This is the class to initialize positions."
_initclass=ei.InitIndexed
classInputInitMomenta(InputInitPositions):
"""Class to handle initialization of the momenta."""
attribs=deepcopy(InputInitPositions.attribs)
attribs["mode"][1]["options"].append("thermal")
attribs["mode"][1]["help"]="The input data format. 'xyz' and 'pdb' stand for xyz and pdb input files respectively. 'chk' stands for initialization from a checkpoint file. 'manual' means that the value to initialize from is giving explicitly as a vector. 'thermal' means that the data is to be generated from a Maxwell-Boltzmann distribution at the given temperature."
default_label="INITMOMENTA"
default_help="This is the class to initialize momenta."
deffetch(self):
"""Creates an momentum initializer object.
Note that the momenta can be initialized by a single value, specifying
the temperature at which to thermalize the momenta.
"""Class to handle initialization of the velocities."""
attribs=deepcopy(InputInitMomenta.attribs)
default_label="INITVELOCITIES"
default_help="This is the class to initialize velocities."
classInputInitMasses(InputInitPositions):
"""Class to handle initialization of the masses."""
attribs=deepcopy(InputInitPositions.attribs)
default_label="INITMASSES"
default_help="This is the class to initialize atomic masses."
classInputInitLabels(InputInitPositions):
"""Class to handle initialization of the atom labels."""
attribs=deepcopy(InputInitPositions.attribs)
default_label="INITLABELS"
default_help="This is the class to initialize atomic labels."
_storageclass=str
classInputInitCell(InputInitBase):
"""Class to handle initialization of the cell."""
attribs=deepcopy(InputInitBase.attribs)
attribs["mode"]=(InputAttribute,{"dtype":str,
"default":"manual",
"options":["manual","pdb","chk","abc","abcABC"],
"help":"This decides whether the system box is created from a cell parameter matrix, or from the side lengths and angles between them. If 'mode' is 'manual', then 'cell' takes a 9-elements vector containing the cell matrix (row-major). If 'mode' is 'abcABC', then 'cell' takes an array of 6 floats, the first three being the length of the sides of the system parallelopiped, and the last three being the angles (in degrees) between those sides. Angle A corresponds to the angle between sides b and c, and so on for B and C. If mode is 'abc', then this is the same as for 'abcABC', but the cell is assumed to be orthorhombic. 'pdb' and 'chk' read the cell from a PDB or a checkpoint file, respectively."})
default_label="INITCELL"
default_help="This is the class to initialize cell."
deffetch(self):
"""Creates a cell initializer object.
Note that the cell can be initialized from the lengths of the sides and
the angles between them instead of by a vector, as specified by the
'abc' or 'abcABC' modes.
"""
mode=self.mode.fetch()
ibase=super(InputInitCell,self).fetch()
ifmode=="abc"ormode=="abcABC":
h=io_xml.read_array(np.float,ibase.value)
ifmode=="abc":
ifh.size!=3:
raiseValueError("If you are initializing cell from cell side lengths you must pass the 'cell' tag an array of 3 floats.")
nbeads: The number of beads to be used in the simulation.
Dynamic fields:
positions: An object to initialize the positions from.
velocities: An object to initialize the velocities from.
momenta: An object to initialize the momenta from.
cell: An object to initialize the cell from.
masses: An object to initialize the masses from.
labels: An object to initialize the labels from.
gle: An object to initialize the GLE matrices from.
file: A file from which to initialize multiple properties from. Anything
that can be initialized either directly or indirectly from this file
will be.
"""
attribs={"nbeads":(InputAttribute,{"dtype":int,
"help":"The number of beads. Will override any provision from inside the initializer. A ring polymer contraction scheme is used to scale down the number of beads if required. If instead the number of beads is scaled up, higher normal modes will be initialized to zero."})
}
dynamic={
"positions":(InputInitPositions,{"help":"Initializes atomic positions. Will take a 'units' attribute of dimension 'length'"}),
"velocities":(InputInitVelocities,{"help":"Initializes atomic velocities. Will take a 'units' attribute of dimension 'velocity'"}),
"momenta":(InputInitMomenta,{"help":"Initializes atomic momenta. Will take a 'units' attribute of dimension 'momentum'"}),
"masses":(InputInitMasses,{"help":"Initializes atomic masses. Will take a 'units' attribute of dimension 'mass'"}),
"cell":(InputInitCell,{"help":"Initializes the configuration of the cell. Will take a 'units' attribute of dimension 'length'"}),
"file":(InputInitFile,{"help":"Initializes everything possible for the given mode. Will take a 'units' attribute of dimension 'length'. The unit conversion will only be applied to the positions and cell parameters."}),
"gle":(InputInitThermo,{"help":"Initializes the additional momenta in a GLE thermostat."})
}
default_help="Specifies the number of beads, and how the system should be initialized."
default_label="INITIALIZER"
defwrite(self,name="",indent=""):
"""Overloads Input write() function so that we never write out
InputInitializer to restart files.
Returns:
An empty string.
"""
return""
defstore(self,ii):
"""Takes a Initializer instance and stores a minimal representation of it.