pysimm.cassandra
¶
Module Contents¶
Classes¶
pysimm.cassandra.MCSimulation |
|
pysimm.cassandra.GCMC |
|
pysimm.cassandra.NVT |
|
pysimm.cassandra.NPT |
|
pysimm.cassandra.InpSpec |
|
pysimm.cassandra.InpSpec |
|
pysimm.cassandra.McSystem |
|
pysimm.cassandra.Cassandra |
|
pysimm.cassandra.McfWriter |
Functions¶
pysimm.cassandra.check_cs_exec |
|
|
pysimm.cassandra.make_iterable |
Attributes¶
- class pysimm.cassandra.MCSimulation(mc_sst=None, init_sst=None, **kwargs)[source]¶
Bases:
object
pysimm.cassandra.MCSimulation
Object containing the settings and the logic necessary to partially set-up an abstract Monte Carlo simulation to be submitted to the CASSANDRA software. The object also will include the simulation results once the simulations are finished.
- init_sst¶
describes the optional initial fixed molecular configuration for MC simulations (default: empty cubic box with 1 nm side length). If the particles in the system are not attributed with the flag is_fixed all of them are considered to be fixed, and will be marked with this flag, otherwise all particles with is_fixed=False will be removed.
- Type
- Keyword Arguments
out_folder (str) – the relative path of the simulation results (all .dat, .mcf, as well as .chk, … files will go there). If the folder does not exist it will be created with 0755 permissions.
props_file (str) – the name of the .inp file.
Note
Other keyword arguments that are accepted are the GCMC simulation settings. The keywords of the settings are the same as they are described in CASSANDRA specification but without # symbol.
For example: the keyword argument Run_Name=’my_simulation’ will set #Run_Name setting in CASSANDRA input file to my_simulation value
- Parameters
props (dictionary) – include all simulation settings to be written to the CASSANDRA .inp file
input (str) – text stream that will be written to the CASSANDRA .inp file
tot_sst (
System
) – object containing the results of CASSANDRA simulations
- write(self)[source]¶
pysimm.cassandra.MCSimulation.write
Iterates through the
props
dictionary creating the text for correct CASSANDRA input
- group_by_id(self, group_key='matrix')[source]¶
pysimm.cassandra.MCSimulation.group_by_id
Method groups the atoms of the system
tot_sst
by a certain property. Will iterate through all atoms in the system and return indexes of only those atoms that match the property. Currently supports 3 properties defined by the input keyword argument argument.- Keyword Arguments
group_key (str) –
text constant defines the property to match. Possible keywords are:
matrix – (default) indexes of the atoms in
fxd_sst
rigid – indexes of all atoms that have rigid atomic bonds. It is assumed here that rigid and nonrigid atoms can interact only through intermolecular forces
nonrigid – opposite of previous, indexes of all atoms that have nonrigid atomic bonds
- Returns
string in format a1:b1 a2:b2 … where all indexes inside [ak, bk] belongs to the selected group and array of the form [[a1, b1], [a2, b2], …]
- Return type
str
- upd_simulation(self)[source]¶
pysimm.cassandra.MCSimulation.upd_simulation
Updates the
tot_sst
field using the MCSimulation.props[‘Run_Name’].chk file. Will try to parse the checkpoint file and read the coordinates of the molecules inserted by CASSANDRA. If neither of the molecules from themc_sst
can be fit to the text that was read the method will raise an exception. The fitting method:make_system
assumes that different molecules inserted by CASSANDRA have the same order of the atoms.
- __check_params__(self)[source]¶
pysimm.cassandra.MCSimulation.__check_params__
Private method designed for update the fields of the simulation object to make them conformed with each other
- class pysimm.cassandra.GCMC(mc_sst=None, init_sst=None, **kwargs)[source]¶
Bases:
MCSimulation
pysimm.cassandra.GCMC Initiates the specific type of Monte Carlo simulations for CASSANDRA: simulations using Grand-Canonical ensemble of particles (constant volume-temperature-chemical potential, muVT). See
MCSimulation
for the detailed description of the properties.
- class pysimm.cassandra.NVT(mc_sst=None, init_sst=None, **kwargs)[source]¶
Bases:
MCSimulation
pysimm.cassandra.NVT Initiates the specific type of Monte Carlo simulations for CASSANDRA: simulations using Canonical ensemble of particles (constant volume-temperature-number of particles, NVT). See
MCSimulation
for the detailed description of the properties.
- class pysimm.cassandra.NPT(mc_sst=None, init_sst=None, **kwargs)[source]¶
Bases:
MCSimulation
pysimm.cassandra.NPT Initiates the specific type of Monte Carlo simulations for CASSANDRA: simulations using Isobaric-Isothermal ensemble of particles (NPT). See
MCSimulation
for the detailed description of the properties.
- class pysimm.cassandra.InpSpec(key, value, default, **kwargs)[source]¶
Bases:
object
pysimm.cassandra.InpSpec
Represents the most common object used for carrying one logical unit of the CASSANDRA simulation options
- Parameters
key (str) – the keyword of the simulation option (literally the string that goes after the # sign in CASSANDRA .inp file)
value (object) – numerical or text values of the particular simulation option structured in a certain way. Here goes only the values that are wished to be changed (it might be just one field of a big dictionary)
default (object) – the most complete default description of the simulation option
- Keyword Arguments
write_headers (boolean) – if the
value
is dictionary defines whether the dictionary keys should be written to the outputnew_line (boolean) – if the
value
is iterable defines whether each new element will be written to the new line
- class pysimm.cassandra.InpProbSpec(key, value, default, **kwargs)[source]¶
Bases:
InpSpec
pysimm.cassandra.InpSpec
Extension of the
InpSpec
class that takes into account special representation of the movement probabilities in the CASSANDRA input file.
- class pysimm.cassandra.McSystem(sst, **kwargs)[source]¶
Bases:
object
pysimm.cassandra.McSystem
Wrapper around the list of
System
objects. Each element in the list represents single molecule of a different specie that will be used during MC simulations. Additionally, the object is responsible for creating .dat and .mcf files needed for the simulation and reading back the CASSANDRA simulation results.- sst¶
items representing single molecules of different species to be inserted by CASSANDRA. If the sst is a list (not a single value) it is assumed that all of the following properties are synchronized with it by indexes.
- Type
list of
System
- chem_pot¶
chemical potential for each specie [Joule/mol]
- Type
list of int
- Keyword Arguments
max_ins (list of int) – defines the highest possible number of molecules of corresponding specie. Basing on these values CASSANDRA allocates memory for simulations. (default: 5000).
is_rigid (list of boolean) – defines whether the atoms in the particular molecule should be marked as rigid or not. Important! In current implementation the module doesn’t support flexible molecule angles, so the is_rigid=False is designed to be used exclusively for single bead molecules.
- Parameters
made_ins (list of int) – number of particles of each specie inserted by CASSANDRA.
mcf_file (list of str) – defines full relative names of molecule configuration files (.mcf) required by CASSANDRA. Files will be created automatically.
frag_file (list of str) – defines full relative names of possible relative configuration files (.dat) required by CASSANDRA. Files will be created automatically.
- update_props(self, props)[source]¶
pysimm.cassandra.McSystem.update_props
For each specie in the system creates the .mcf file required for CASSANDRA simulation.
- Parameters
props (dictionary) – contains the .mcf file names and maximally allowed number of molecules insertions. The dictionary is to be assigned to ‘Molecule_Files’ property of the MC simulation
- Returns
updated input dictionary
- Return type
props
- update_frag_record(self, frag_record)[source]¶
pysimm.cassandra.McSystem.update_frag_record
For each specie in the system creates the single configuration .dat file required for CASSANDRA simulation.
- Parameters
frag_record – dictionary containing the .dat file names and their ids. The dictionary is to be assigned to
simulation ('Molecule_Files' property of the MC) –
- Returns
updated dictionary
- Return type
dictionary
- make_system(self, text_output)[source]¶
pysimm.cassandra.McSystem.make_system
Parses the checkpoint (.chk) file made by CASSANDRA and creates new molecules basing on the new coordinates information. Assumes that all atoms of a certain molecule are listed in .chk file together (molecule identifiers are not mixed).
Note
The logic of comparison of the xyz-like text record from the .chk file with the
System
object is most straightforward: It is the consecutive comparison of particle names and first letters (before the white space) in the text record. In this implementation order matters! For example, for CO2, if in the system atoms are ordered as C-O-O and in the text they are ordered as O-C-O fit will fail.- Parameters
text_output (str) – text stream from the CASSANDRA .chk file containing the coordinates of newly inserted molecules
- Returns
object containing all newly inserted molecules
- Return type
- __fit_atoms__(self, molec, text_lines)[source]¶
pysimm.cassandra.McSystem.__fit_atoms__
Implements simple logic of comparison of the xyz-like text record with the
System
object. The comparison is based on the consecutive comparison of particle names and first letters (before the white space) in the text. In this implementation order matters! E.g. for CO2, if in the system atoms are ordered as C-O-O and in the text they are ordered like O-C-O fit will return False.- Returns
flag whether the text record fit the molecule or not
- Return type
boolean
- class pysimm.cassandra.Cassandra(init_sst)[source]¶
Bases:
object
pysimm.cassandra.Cassandra
Organizational object for running CASSANDRA simulation tasks. In current implementation it is able to run Canonical, Grand Canonical, and Isothermal-Isobaric Monte Carlo simulations (
GCMC
,NVT
, andNPT
, correspondingly).- Parameters
system (
System
) – molecular updated during the simulationsrun_queue (list) – the list of scheduled tasks
- run(self)[source]¶
pysimm.cassandra.Cassandra.run
Method that triggers the simulations. Does two consecutive steps: (1) tries to write all files necessary for simulation (.dat, .inp, .mcf): (2) tries to invoke the CASSANDRA executable.
- add_simulation(self, ens_type, obj=None, **kwargs)[source]¶
pysimm.cassandra.Cassandra.add_simulation
Method for adding new Monte Carlo simulation to the run queue.
- Parameters
ens_type – Type of the molecular ensemble for the Monte-Carlo simulations. The supported options are: GCMC (Grand Canonical); NVT (canonical); NPT (isobaric-isothermal)
obj – the entity that should be added. Will be ignored if it is not of a type
MCSimulation
- Keyword Arguments
Note
Other keyword arguments of this method will be redirected to the
McSystem
andMCSimulation
constructors. See their descriptions for the possible keyword options.
- add_gcmc(self, obj=None, **kwargs)[source]¶
pysimm.cassandra.Cassandra.add_gcmc
Ads new simulation in grand-canonical ensemble to the run queue.
- Parameters
obj – the entity that should be added. Will be ignored if it is not of a type
GCMC
- Keyword Arguments
Note
- Other keyword arguments of this method will be redirected to the
McSystem
,MCSimulation
, and
GCMC
constructors. See their descriptions for the possible keyword options.
- add_npt_mc(self, obj=None, **kwargs)[source]¶
pysimm.cassandra.Cassandra.add_npt_mc
Ads new simulation in isobaric-isothermal ensemble to the run queue.
- Parameters
obj – the entity that should be added. Will be ignored if it is not of a type
NPT
- Keyword Arguments
Note
Other keyword arguments of this method will be redirected to the
McSystem
,MCSimulation
, andNPT
constructors. See their descriptions for the possible keyword options.
- add_nvt(self, obj=None, **kwargs)[source]¶
pysimm.cassandra.Cassandra.add_nvt
Ads new simulation in canonical ensemble to the run queue.
- Parameters
obj – the entity that should be added. Will be ignored if it is not of a type
NVT
- Keyword Arguments
Note
Other keyword arguments of this method will be redirected to the
McSystem
,MCSimulation
, andNVT
constructors. See their descriptions for the possible keyword options.
- read_input(self, inp_file)[source]¶
pysimm.cassandra.Cassandra.read_input
The method parses the CASSANDRA instructions file (.inp) split it into separate instructions and analyses each according to the instruction name.
- Parameters
inp_file (str) – the full relative path of the file to be read
- Returns
read CASSANDRA properties in the format required by
GCMC
- Return type
dictionary
- class pysimm.cassandra.McfWriter(syst, file_ref)[source]¶
Bases:
object
pysimm.cassandra.McfWriter
Object responsible for creating the CASSANDRA Molecular Configuration file (.mcf).
- file_ref¶
full relative path to the file that will be created
- Type
str
- mcf_tags = ['# Bond_Info', '# Angle_Info', '# Dihedral_Info', '# Improper_Info', '# Intra_Scaling', '#...[source]¶
- write(self, typing='all')[source]¶
pysimm.cassandra.McfWriter.write
Method creates the .mcf file writing only those sections of it that are marked to be written
- Parameters
typing (list) – the list of sections to be written or the text keyword. List items should be as they are defined in
mcf_tags
field); default ‘all’