schrodinger.application.matsci.equilibrium_md module¶
Equilibrium molecular dynamics classes/function shared by transport property calculations using Einstein and Green-Kubo methods. Added Onsager coefficient calculation using MS3, MS2 and MS1 methods. There is a bifurcation in workflow after displacement is calculated. We either compute stephan maxwell diffusion coefficient or self diffusion coefficient.
Copyright Schrodinger, LLC. All rights reserved.
- schrodinger.application.matsci.equilibrium_md.log_debug(msg)¶
Add a message to debug logger file.
- Parameters:
msg (str) – The message to debug logging
- schrodinger.application.matsci.equilibrium_md.get_core_num()¶
Return the number of the cores specified by users. None means not specified.
- Returns:
the number of cores specified by users.
- Return type:
int or None
- schrodinger.application.matsci.equilibrium_md.get_reserves_cores_state(options)¶
Return the state of reserves cores so that some python standard library functions can have access to all CPU resources.
- Parameters:
check_runtype (bool) – If true, the FLAG_RUN_TYPE in the options is checked
- Returns:
True, if reserves_cores_state should be set as True to allow some python function to utilize multiple CPUs.
- Return type:
bool
- schrodinger.application.matsci.equilibrium_md.clearProps(cms_model, str_in_key='Diffusion')¶
Clear the diffusion related properties and should be called before new calculations.
- Parameters:
cms_model ('schrodinger.application.desmond.cms.Cms') – A cms model to clear the properties
- schrodinger.application.matsci.equilibrium_md.get_files(filename, ext)¶
Get all the files with same extension, if ext is provided.
- Parameters:
filename (str) – file to be located and returned
ext (str or None) – extension to search files of the same type
- Return type:
list of str
- Returns:
list of filenames with path
- schrodinger.application.matsci.equilibrium_md.check_finite_molecules(struct, atom_ids=None)¶
Check whether the molecules in structure are finite.
- Parameters:
struct (
schrodinger.structure.Structure
) – the structure whose molecules will be checkedatom_ids (set of int, list of int, list of list, or None) – molecules sharing atoms with this set will be checked. If None, all the molecules are checked.
- Returns:
message if any molecules are infinite
- Return type:
string or None
- schrodinger.application.matsci.equilibrium_md.get_md_results(basename, options, log, log_error, save_opts=None, smart_distribution=True)¶
From parsed options, setup and run md simulation.
- Parameters:
basename (str) – basename for md simulation job
options (Named tuple) – The parsed command line option
log (function) – log information
log_error (function) – log error information and exit
smart_distribution (bool) – turn on / off the smart_distribution
- Return type:
str, str, str
- Returns:
output cms, trj folder, and enegrp_dat
- schrodinger.application.matsci.equilibrium_md.setup_md_job(name_base, md_opts, enegrp_opts=None, save_opts=None, command_dir=None, **kwargs)¶
Write the .msj file, form the command, figure out the output filenames, and register files to backend for molecular dynamics simulations.
Note: if command_dir is not None, please call this method inside the command_dir as the returned ocms_name doesn’t have command_dir in the file path.
- Parameters:
name_base (base name for the md job) – str
md_opts – ‘type.SimpleNamespace’
enegrp_opts (this data struct has attributes: energy_groups for the list of keywords for desmond energy_groups, interval for output time interval in ps, start for the output starting time in ps. If None, no enegrp file is generated.) – ‘type.SimpleNamespace’ or None
save_opts (this data struct has boolean attributes to save files likes: msj, ene, multisim_log, ocms, log, trj, cfg, write_velocity, enegrp, last, autocorrelation_file, zip_outputs, viscosity_file. If None, use default settings to decide the files to be copied back.) – ‘type.SimpleNamespace’ or None
command_dir (this is the path from the job start dir to the subjob dir. The setup function is expected to run in the subjob setup stage, and thus the subjob dir should be passed. If there is only one master job (no sub dir), current dir is used. In addition, the returned file paths are the the basename, and then users need to form the full file path when they decide to run in subfolder or master folder directly.) – str
- Return type:
‘type.SimpleNamespace’
- Returns:
data struct with cmd command to submit md, output cms, trj folder, enegrp file, jobname
- schrodinger.application.matsci.equilibrium_md.type_model_file(arg, model_formats=None)¶
Validate that the argument is a file that contains a model.
- Parameters:
arg (str) – the filename
model_formats (list of str) – the supported formats of the model
- Raises:
ArgumentTypeError – when the file cannot be open by cms or structure reader
- Returns:
filename with path
- Return type:
str
- schrodinger.application.matsci.equilibrium_md.add_md_basic_argument(parser, model_formats=None)¶
Add necessary parser arguments for setting up a MD simulation.
- Parameters:
parser (
argparse.ArgumentParser
) – The parser to add additional optionsmodel_formats (list of str) – the supported formats of the model
- Return type:
‘argparse._ArgumentGroup’
- Returns:
argparse ArgumentGroup with MD setting options
- schrodinger.application.matsci.equilibrium_md.add_md_output_argument(parser, extra_options)¶
Add parser arguments to record output information for MD simulations.
- Parameters:
parser (
argparse.ArgumentParser
) – The parser to add additional optionsextra_options (extra options can be added according to these keywords) – list of str
- Return type:
‘argparse._ArgumentGroup’
- Returns:
argparse ArgumentGroup with MD output recording information
- schrodinger.application.matsci.equilibrium_md.add_analysis_argument(parser, extra_options)¶
Add parser arguments for analysis.
- Parameters:
parser (
argparse.ArgumentParser
) – The parser to add additional optionsextra_options (extra options can be added according to these keywords) – list of str
- Return type:
‘argparse._ArgumentGroup’
- Returns:
argparse ArgumentGroup with analysis options
- schrodinger.application.matsci.equilibrium_md.add_parser_opts(parser, final_prop, mid_prop, use_tau=True, extra_options=None, model_formats=None)¶
Add all necessary parser arguments for setting up a MD simulation and optional arguments for certain green-kubo property calculation.
- Parameters:
parser (
argparse.ArgumentParser
) – The parser for error informationfinal_prop (the final property needs to be calculated) – str
mid_prop (the property needs to be calculated before the final prop) – str
use_tau (Tau limits are added, if True) – bool
extra_options (extra options can be added according to these keywords) – None or list of str
model_formats (list of str) – the supported formats of the model
- Return type:
‘argparse._ArgumentGroup’, ‘argparse._ArgumentGroup’, ‘argparse._ArgumentGroup’
- Returns:
argparse ArgumentGroups with setting options
- schrodinger.application.matsci.equilibrium_md.check_options(options, parser, option_flag, min_data_point, check_tau=True, check_gpu=False)¶
Validate the options.
- Parameters:
options (Named tuple) – The parsed command line options
parser (
argparser.ArgumentParser
) – parser to log error informationoption_flag (str) – time interval is defined by this flag
min_data_point (int) – minimum required data point
check_tau (bool) – validate tau range against available time range
check_gpu (bool) – check GPU/CPU resource availability. For a remote host, -gpu flag requires a GPU host, and no -gpu flag requires a CPU HOST. For localhost and no job control, only check whether GPU resource is available when -gpu flag exists.
- schrodinger.application.matsci.equilibrium_md.check_tau_options(options, parser, option_flag, min_data_point)¶
Validate the Tau options.
- Parameters:
options (Named tuple) – The parsed command line options
parser (
argparser.ArgumentParser
) – parser to log error informationoption_flag (str) – time interval is defined by this flag
min_data_point (int) – minimum required data point
- class schrodinger.application.matsci.equilibrium_md.Model(filename)¶
Bases:
object
Wrapper around a structure.
- __init__(filename)¶
- Parameters:
filename (str) – file path pointing to a cms or mae file.
- load()¶
Load a model.
- setProperty(key, value)¶
Set the property to the model.
- Parameters:
key (str) – property name
value (str, float, int) – the value of the property
- property property¶
Return the model property.
- Returns:
a dictionary
- Return type:
dict
- getExtension()¶
Return the extension of the filename.
- Returns:
the extension of the filename
- Return type:
str
- getStruct()¶
Return the ‘structure.Structure’ object.
- Returns:
structure of the model
- Return type:
‘structure.Structure’
- class schrodinger.application.matsci.equilibrium_md.MaeModel(filename)¶
Bases:
Model
Wrapper around Structure.
- load()¶
Load a model from the mae file.
- setProperty(key, value)¶
Set the property to the mae model.
- Parameters:
key (str) – property name
value (str, float, int) – the value of the property
- removeTrajProp()¶
Remove the trajectory property.
- write(fname, wam_type=22)¶
Write the model into a file with the source_path and feature’s WAM
- Parameters:
fname (str) – filename to write out the model.
wam_type (str) – default WAM type
- class schrodinger.application.matsci.equilibrium_md.CmsModel(filename)¶
Bases:
Model
Wrapper around Cms.
- load()¶
load a model from a cms file.
- setProperty(key, value)¶
Set the property to the cms model.
- Parameters:
key (str) – property name
value (str, float, int) – the value of the property
- removeTrajProp()¶
Remove the trajectory property.
- write(fname, wam_type=22)¶
Write the model into a file with the source_path and feature’s WAM
- Parameters:
fname (str) – filename to write out the model.
wam_type (str) – default WAM type
- setWam(wam_type=22)¶
Set the feature’s WAM for the model.
- Parameters:
wam_type (str) – default WAM type
- getStruct()¶
Return the ‘structure.Structure’ object.
- Returns:
structure of the model
- Return type:
‘structure.Structure’
- schrodinger.application.matsci.equilibrium_md.get_model(filename)¶
Get the model from a cms or mae file.
- Parameters:
filename (str) – file path pointing to a cms or mae file.
- Returns:
the model in the file.
- Return type:
‘CmsModel’ or ‘MaeModel’
- class schrodinger.application.matsci.equilibrium_md.EquilibriumMdBase(input_cms, logger=False)¶
Bases:
object
This is a base class for equilibrium MD subclass, and should be not be instantiated directly.
- __init__(input_cms, logger=False)¶
- Parameters:
input_cms (cms input file) – str
logger (loggerobj.logger prints to logfilename; None prints to stdout; False mutes logging and raises errors) –
logging.Logger
, None or False
- log(msg, **kwargs)¶
Add a message to the log file in driver mode, or ignore the logging in module mode.
- Parameters:
msg (str) – The information message
Additional keyword arguments are passed to the textlogger.log_msg function
- log_error(msg)¶
Exit with the error printed in driver mode, or raise the error in module mode.
- Parameters:
str (msg) – The error message
- Raise:
RuntimeError in module mode
- checkSetTimeInterval(time_intervals=None)¶
Time interval must be the same for all trajectery.
- Parameters:
time_intervals (list or None) – time intervals between every two frames.
- checkConstantVol(allow_npt=True)¶
Calculate volume and check whether it changes.
- Parameters:
allow_npt (bool) – allow volume to change, if True
- calDensity()¶
Caluate the average system density.
- savePropAndCms(cms_out=None, wam_type=None)¶
Save properties to cms model, delete trj information if needed, and write out cms file.
- Parameters:
cms_out (str) – name of the output cms.
wam_type (int or None) – One of the enums defined in workflow_action_menu.h if the results should have a Workflow Action Menu in Maestro
- class schrodinger.application.matsci.equilibrium_md.TrjBase(input_cms, logger=False)¶
Bases:
EquilibriumMdBase
This is a base class for equilibrium MD subclass that uses trajectory, and should be not be instantiated directly.
- readTrj(make_whole=False)¶
Read trj frames from trj folder.
- Parameters:
make_whole (bool) – if True, bond across PBCs are fixed so that two bonded particles won’t be on opposite sides of the system
- trajFrames(make_whole=False)¶
Fix pbc bonds (if needed), yield the trajectory frame, and garbage-collect to release the occupied memory.
- Parameters:
make_whole (bool) – if True, bond across PBCs are fixed so that two bonded particles won’t be on opposite sides of the system
- Return type:
schrodinger.application.desmond.packages.traj.frame
- Returns:
a trajectory frame
- checkTau(frame_num, min_tau_data_point)¶
Check whether trj frame number is large enough.
- Parameters:
frame_num (number of total data point) – int
min_tau_data_point (minimum requested data) – int
- checkVel()¶
Check whether each frame contains velocity information.
- class schrodinger.application.matsci.equilibrium_md.MsdTrajBase(options, **kwargs)¶
Bases:
TrjBase
Trajectory base class for Mean squared displacement method.
- ATOM = 'atom'¶
- METHOD = 'MSD'¶
- X = 'x'¶
- Y = 'y'¶
- Z = 'z'¶
- TAU_PS = 'Tau(ps)'¶
- MSD_ANG2 = 'MSD(angstrom^2)'¶
- STDEV_ANG2 = 'Std Dev(angstrom^2)'¶
- Y_HEADERS = ['MSD(angstrom^2)', 'Std Dev(angstrom^2)']¶
- CSV_HEADER_3D = ['Tau(ps)', '3D MSD(angstrom^2)', '3D Std Dev(angstrom^2)']¶
- ANISO_DIMS = ['1D', '1D', '2D', '2D']¶
- CSV_HEADER_PLANE = ['1D MSD(angstrom^2)', '1D Std Dev(angstrom^2)', '2D MSD(angstrom^2)', '2D Std Dev(angstrom^2)']¶
- AXES = ['x', 'x', 'y', 'y', 'z', 'z']¶
- CSV_HEADER_AXIS = ['x MSD(angstrom^2)', 'x Std Dev(angstrom^2)', 'y MSD(angstrom^2)', 'y Std Dev(angstrom^2)', 'z MSD(angstrom^2)', 'z Std Dev(angstrom^2)']¶
- TAU_START_PROP = 'r_matsci_Diffusion_Coefficient_MSD_Tau_Start_(ns)'¶
- TAU_END_PROP = 'r_matsci_Diffusion_Coefficient_MSD_Tau_End_(ns)'¶
- VECTOR_DELIM = ','¶
- VECTOR_DELIM_WITH_SPACE = ', '¶
- NORMAL = 'Normal'¶
- DIFFUSION_FILE_PROP = 's_matsci_Diffusion_MSD_File'¶
- DIFFUSIVITY_VECTOR_PROP = 's_matsci_Diffusion_Coefficient_MSD_Normal'¶
- DIFFUSIVITY_1D_PROP = 'r_matsci_Diffusion_Coefficient_1D_MSD_(m^2/s)'¶
- DIFFUSIVITY_2D_PROP = 'r_matsci_Diffusion_Coefficient_2D_MSD_(m^2/s)'¶
- DIFFUSIVITY_3D_PROP = 'r_matsci_Diffusion_Coefficient_3D_MSD_(m^2/s)'¶
- DIFFUSIVITY_X_PROP = 'r_matsci_Diffusion_Coefficient_X_MSD_(m^2/s)'¶
- DIFFUSIVITY_Y_PROP = 'r_matsci_Diffusion_Coefficient_Y_MSD_(m^2/s)'¶
- DIFFUSIVITY_Z_PROP = 'r_matsci_Diffusion_Coefficient_Z_MSD_(m^2/s)'¶
- STDEV = 'stdev'¶
- SD_EXT = 'MSD_stdev'¶
- DIFFUSIVITY_1D_SD_PROP = 'r_matsci_Diffusion_Coefficient_1D_MSD_stdev_(m^2/s)'¶
- DIFFUSIVITY_2D_SD_PROP = 'r_matsci_Diffusion_Coefficient_2D_MSD_stdev_(m^2/s)'¶
- DIFFUSIVITY_3D_SD_PROP = 'r_matsci_Diffusion_Coefficient_3D_MSD_stdev_(m^2/s)'¶
- DIFFUSIVITY_X_SD_PROP = 'r_matsci_Diffusion_Coefficient_X_MSD_stdev_(m^2/s)'¶
- DIFFUSIVITY_Y_SD_PROP = 'r_matsci_Diffusion_Coefficient_Y_MSD_stdev_(m^2/s)'¶
- DIFFUSIVITY_Z_SD_PROP = 'r_matsci_Diffusion_Coefficient_Z_MSD_stdev_(m^2/s)'¶
- DIFFUSIVITY_1D_R2_PROP = 'r_matsci_Diffusion_Coefficient_1D_MSD_R2'¶
- DIFFUSIVITY_2D_R2_PROP = 'r_matsci_Diffusion_Coefficient_2D_MSD_R2'¶
- DIFFUSIVITY_3D_R2_PROP = 'r_matsci_Diffusion_Coefficient_3D_MSD_R2'¶
- DIFFUSIVITY_X_R2_PROP = 'r_matsci_Diffusion_Coefficient_X_MSD_R2'¶
- DIFFUSIVITY_Y_R2_PROP = 'r_matsci_Diffusion_Coefficient_Y_MSD_R2'¶
- DIFFUSIVITY_Z_R2_PROP = 'r_matsci_Diffusion_Coefficient_Z_MSD_R2'¶
- class DIFFUSIVITY(diffusivity, std_dev, r2)¶
Bases:
tuple
- diffusivity¶
Alias for field number 0
- r2¶
Alias for field number 2
- std_dev¶
Alias for field number 1
- ISOTROPIC = 'isotropic'¶
- ANISOTROPIC = 'anisotropic'¶
- ISOTROPIC_3D = 'isotropic:3D'¶
- ANISOTROPIC_1D = 'anisotropic:1D'¶
- ANISOTROPIC_2D = 'anisotropic:2D'¶
- DIMENSION_MAP = {'anisotropic:1D': 1, 'anisotropic:2D': 2, 'isotropic:3D': 3}¶
- DIFFUSION_PROPS_MAP = {1: DIFFUSIVITY(diffusivity='r_matsci_Diffusion_Coefficient_1D_MSD_(m^2/s)', std_dev='r_matsci_Diffusion_Coefficient_1D_MSD_stdev_(m^2/s)', r2='r_matsci_Diffusion_Coefficient_1D_MSD_R2'), 2: DIFFUSIVITY(diffusivity='r_matsci_Diffusion_Coefficient_2D_MSD_(m^2/s)', std_dev='r_matsci_Diffusion_Coefficient_2D_MSD_stdev_(m^2/s)', r2='r_matsci_Diffusion_Coefficient_2D_MSD_R2'), 3: DIFFUSIVITY(diffusivity='r_matsci_Diffusion_Coefficient_3D_MSD_(m^2/s)', std_dev='r_matsci_Diffusion_Coefficient_3D_MSD_stdev_(m^2/s)', r2='r_matsci_Diffusion_Coefficient_3D_MSD_R2'), 'x': DIFFUSIVITY(diffusivity='r_matsci_Diffusion_Coefficient_X_MSD_(m^2/s)', std_dev='r_matsci_Diffusion_Coefficient_X_MSD_stdev_(m^2/s)', r2='r_matsci_Diffusion_Coefficient_X_MSD_R2'), 'y': DIFFUSIVITY(diffusivity='r_matsci_Diffusion_Coefficient_Y_MSD_(m^2/s)', std_dev='r_matsci_Diffusion_Coefficient_Y_MSD_stdev_(m^2/s)', r2='r_matsci_Diffusion_Coefficient_Y_MSD_R2'), 'z': DIFFUSIVITY(diffusivity='r_matsci_Diffusion_Coefficient_Z_MSD_(m^2/s)', std_dev='r_matsci_Diffusion_Coefficient_Z_MSD_stdev_(m^2/s)', r2='r_matsci_Diffusion_Coefficient_Z_MSD_R2')}¶
- DIFFUSION_COL_MAP = {1: (0, 3, 4), 2: (0, 5, 6), 3: (0, 1, 2), 'x': (0, 3, 4), 'y': (0, 5, 6), 'z': (0, 7, 8)}¶
- __init__(options, **kwargs)¶
- Parameters:
options (Named tuple) – The parsed command line options
- static fitMsd(time_msd_std, start_idx, end_idx, dimension=3)¶
Fit the mean squared displacement
- Parameters:
time_msd_std (numpy.ndarray) – first column is time in ps, second column is mean squared displacement in angstrom^2.
start_idx (int) – index to select the starting frame
end_idx (int) – index to select the ending frame
dimension (int) – 1 stands for 1D; 2 stands for 2D; 3 stands for 3D
- Returns:
diffusivity coefficient in m^2/s, diffusivity_std in m^2/s, R-squared in linear regression
- Return type:
float, float, float
- classmethod vectorStr(vector)¶
Convert vector array to str format.
- Parameters:
vector (1 x 3 array of floats) – a vector
- Returns:
vector in str format
- Return type:
str
- getMsdHeader()¶
Get the MSD csv header.
- Returns:
column labels separated by comma.
- Return type:
str
- setTauFrame(tau_start=None, tau_end=None)¶
Set Tau frame start and end limits.
- Parameters:
float (tau_end) – the starting tau value in ps
float – the ending tau value in ps
- setIsotropicMSD()¶
Set the isotropic 3d diffusion coefficients.
- setPlaneMSD()¶
Set the anisotropic in-plane 2d diffusion coefficients.
- setAxisMSD()¶
Set the anisotropic along-axis 1d diffusion coefficients.
- class schrodinger.application.matsci.equilibrium_md.MultiToOneConverter(msd_files, jobname, options, save=True)¶
Bases:
MsdTrajBase
The class to gather multiple files and merge them into one.
- OUTFILE_EXT = '_msd.log'¶
- ERR_MSG = 'No MSD files found.'¶
- __init__(msd_files, jobname, options, save=True)¶
- Parameters:
msd_files (list of str) – the msd files (with path) for diffusion data.
jobname (str) – the jobname
options (SimpleNamespace or namedtuple) – commandline options
save (bool) – If True, add output files to the backend
- run()¶
Main function to load data, process data, and fit.
- loadData(use_numpy=True)¶
Read in all msd files.
- calculateMeanAndStd()¶
Calculate mean and std of the diffusion from multi runs.
- writeMeanAndStd()¶
Write the mean and std of the diffusion.
- combineTrace()¶
Combine the trace files from MSD diffusion calculations.
- getMSDRelatedFiles(ext)¶
Get related files with given extension which are similar msd log file :param str ext: extension name
- Return type:
list
- Returns:
list of file names
- class schrodinger.application.matsci.equilibrium_md.TrajectoryFrame(frame, ids, com_type='atom', vel=False)¶
Bases:
object
Container of cms_model and trajectory frame with custom functions and storage
- ATOM = 'atom'¶
- COL_NUM_POS = 3¶
- cms_model = None¶
- msys_model = None¶
- __init__(frame, ids, com_type='atom', vel=False)¶
Crease a TrajectoryFrame object, update gids, mass, and positions.
- Parameters:
frame (
traj.Frame
) – One trajectory frameids (list) – atom id list [int1, int2…] or [(int1, int2…), (…)…]
com_type (string) – mass center of atoms within each com_type group
vel (bool) – velocity in trajectry frame is used to calculate system translation and shift the system before unwrapping displacements
- setGids()¶
Get global ids of beads (atom or mass center) to extra positions and velocities.
- setMass()¶
Set the mass of each bead (atom or mass center of atoms).
- setGrpMass()¶
Set the total mass of each grouped atoms.
- setFrame(frame)¶
Update trajectry, time, sel coordinates, box, and reduced positions.
- Parameters:
frame (
traj.Frame
objects) – Trajectory
- setXYZ()¶
Set the xyz coordinates obtaioned from trajectory frame. If -com_type != ATOM, the the center of mass is calculated first.
- setBox()¶
Set the stored pbc box size.
- reducedUnitNumpyPos()¶
Convert the XYZ in real unit to reduced unit.
- momentum2Velocity()¶
Calculate the mean velocity of system using velocity information from trajectory frame.
- class schrodinger.application.matsci.equilibrium_md.BaseDiffusivitiyAnalysis(options, jobname, command_dir='.', save=True, **kwargs)¶
Bases:
MsdTrajBase
Base class for diffusivity analysis.
- MIN_TAU_DATA_POINT_NUM = 10¶
- COL_NUM_POS = 3¶
- ATOM = 'atom'¶
- MOLECULE = 'molecule'¶
- MONOMER = 'monomer'¶
- SMARTS = 'SMARTS'¶
- DIFFUSION_FILE_EXT = '_msd.log'¶
- DEFAULT_REF = 'all'¶
- MAX_REDUCED_DISPLACEMENT = 0.45¶
- INDICES = 'indices'¶
- __init__(options, jobname, command_dir='.', save=True, **kwargs)¶
- Parameters:
options (SimpleNamespace or namedtuple) – commandline options
jobname (str) – the jobname
command_dir (str) – the command dir with respect to the launch dir
save (bool) – If True, add output files to the backend
log (function to log information) – function
log_error (log error information and exit calculation) – function
- setSelectionAndLoadTrj()¶
Set the atom selection and load trajectory.
- setDisplacementTimeSerial()¶
Set the atom selection, time intervals, and displacements.
- static isIterable(item)¶
Whether the input is iterable. Currently, list, set, and tuple are treated as iterable.
- Parameters:
item – str, list, tuple, or other data type
- Returns:
Whether the input is iterable
- Return type:
bool
- classmethod flatten(an_iterable_item)¶
Robust function to flatten list recursively.
- Parameters:
an_iterable_item (list, tuple or set) – The iterable item to be flatten. (an iterable that describes the whole or part of the workflow)
- Returns:
The flatten items in a list ([uniterable value 1, uniterable value 2, uniterable value 3 …])
- Return type:
list of uniterable values (str or dict)
- setMakeWholeState()¶
Set the make_whole state. If true, the bonds across the PBCs will be fixed before trajectory analysis. This happens when the mass center of a group covalently bonded atoms (e.g molecule) is needed.
Only set state here as make_whole on per-frame reduces peak memory usage
- readTrj(make_whole=False)¶
See parent methods for docs.
make_whole removes the bond broken by PBC.
- checkVel()¶
See parent methods for docs.
- checkSetTimeInterval(time_intervals=None)¶
See parent methods for docs.
- savePropAndCms()¶
See parent methods for docs.
- getIdx(asl, com_type='atom', smarts_pattern=None)¶
Get atom indices from asl selection.
- Parameters:
asl (str) – ASL search string.
com_type (string) – mass center of atoms within each com_type group is calculated
smarts_pattern (string) – SMARTS pattern
- Return type:
list
- Returns:
index of atoms that matche the asl string. [int1, int2…], if use_type == ATOM; [(int1, int2…), (…)…], if if use_com != ATOM
- classmethod groupIdx(struct, atom_ids, com_type='atom', smarts_atom_list=None)¶
Group atoms according to com_type, or find the SMARTS matches within the atom selection.
- Parameters:
struct (
schrodinger.structure
) – structure containing atomsatom_ids (list) – atom id list of atom selection
com_type (string) – atom, molecule, monomer, or SMARTS as in COM_TYPE
smarts_atom_list (list) – [[a1, a2..],[b1, b2..]..], each sublist contains atom ids that match the SMARTS pattern.
- Return type:
list
- Returns:
[a1, a2, ..], if com_type=ATOM. [(a1, a2..), (c1, c2..)..], union of atom selection and SMARTS matches or each (..) is a subset of atom selection that belongs to one molecule or residue
- setIds()¶
Evaluate asl string and save selected atom ids.
- setFinalDisplacement()¶
Choose functions to get the displacement matrix if self.momentum=True, do recentering using ref atoms,
- setFinalDisplacementCenter()¶
Calculate the displacement between adjacent trajectories, unwrap the coordinates, and correct the mass center.
- setFinalDisplacementNoCenter()¶
Calculate the displacement between adjacent trajectories, unwrap the coordinates directly (no mass center shift).
- getDisplacementFromConstTranslation(cur_frame, pre_frame)¶
Estimate the position shift between two frames by time x mean velocity.
- Parameters:
cur_frame (
traj.Frame
objects) – current trajectory framepre_frame (
traj.Frame
objects) – previous trajectory frame
- Return type:
list or None
- Returns:
list of float (xyz coordinates), if vel=True
- unwrapReducedDisplacement(cur_frame, pre_frame, cons_acceleration_shift=None)¶
Calculate wrapped XYZ displacement, shift the mass center, and unwrap displacement.
- Parameters:
cur_frame (
traj.Frame
objects) – current trajectory framepre_frame (
traj.Frame
objects) – previous trajectory framecons_acceleration_shift (list of float) – xyz shift of mass center due to ref atom collective translation assuming constant acceleration
- Return type:
numpy.matrix
- Returns:
unwrapped coordinates MXN matrix in reduced unit after const momentum shift
- getShiftVectorByRecenterMass(mass, adj_displacement)¶
Get the XYZ shift vetor of the unwrapped mass center (reduced unit).
- Parameters:
mass (list) – list of atom mass
adj_displacement (numpy.matrix) – unwrapped displacement matrix in reduced unit
- Return type:
list
- Returns:
list of float
- getAdjustedDisplacement(selected_adj_displacement, shift_centered_mass, box)¶
Get the “correct” displacement in xyz coordinates (real unit) for adjacent trajectory.
- Parameters:
selected_adj_displacement (numpy.matrix) – wrapped adjacent trajectory displacement
shift_centered_mass (list) – vector to zero mass center of ref atoms
box (list) – list of float, the periodic boundary dimensions
- Return type:
numpy.matrix
- Returns:
MXN matrix in real unit, wrapped adjacent trajectory displacement
- realUnitCoordinate(selected_adj_displacement, box)¶
Change reduced unit to real unit for displacement matrix.
- Parameters:
selected_adj_displacement (numpy.matrix) – displacement matrix in reduced unit
box (list) – pbc box size
- Return type:
numpy.matrix
- Returns:
displacement matrix in real unit
- setDisplacementLength()¶
Set the displacement matrix length.
- class schrodinger.application.matsci.equilibrium_md.DiffusivityMsdAnalysis(options, jobname, command_dir='.', save=True, **kwargs)¶
Bases:
BaseDiffusivitiyAnalysis
Main class that performs coordinate unwrap, displacement calculation, and diffusivity fit.
- TRACE_FILE_EXT = '_trace.csv'¶
- TRACE_HEADER = 'X1, Y1, Z1, X2, Y2, Z2, ...'¶
- MAX_NUM_TRACE = 1000¶
- __init__(options, jobname, command_dir='.', save=True, **kwargs)¶
- Parameters:
options (SimpleNamespace or namedtuple) – commandline options
jobname (str) – the jobname
command_dir (str) – the command dir with respect to the launch dir
save (bool) – If True, add output files to the backend
log (function to log information) – function
log_error (log error information and exit calculation) – function
- run()¶
Calculate unwrapped displacement, check time interval, and calculate diffusivity.
- setSquaredDisplacementTimeserial()¶
Set the atom selection and load trajectory.
- exportTrace()¶
Export trace to file
- setSquaredDisplacement()¶
Loop over all adjacent displacement matrix to run MSD calculation
- sdFromDisplacement(start_id)¶
Calculate the squared displacement from start_id trj frame to proper frame
- Parameters:
start_id (int) – calculation starts from the frame of start_id
- collectData()¶
Collect the msd and std from displacement matrix.
# Std is calculated from sqrt(E[X^2] - (E[X])^2) and X is the mean # squared displacement at one Tau (one time point pair) # https://en.wikipedia.org/wiki/Standard_deviation#Definition_of_population_values
- saveMsdTxt()¶
Save MSD matrix: [time(ps), MSD(Angstrom^2), STD(Angstrom^2)]
- setTauRange()¶
Set Tau start and end limits.
- class schrodinger.application.matsci.equilibrium_md.MSDiffusivityMsdAnalysis(options, jobname, command_dir='.', save=True, **kwargs)¶
Bases:
BaseDiffusivitiyAnalysis
Subclass of DiffusivityMsdAnalysis to calculate Onsager coefficient.
- DIFFUSION_FILE_EXT = '_onsager.csv'¶
- __init__(options, jobname, command_dir='.', save=True, **kwargs)¶
- Parameters:
options (SimpleNamespace or namedtuple) – commandline options
jobname (str) – the jobname
command_dir (str) – the command dir with respect to the launch dir
save (bool) – If True, add output files to the backend
log (function to log information) – function
log_error (log error information and exit calculation) – function
- run()¶
Run the analysis
- checkTau(frame_num, min_tau_data_point)¶
Check the tau parameters for block averaging
- Parameters:
frame_num (int) – The number of frames
min_tau_data_point (int) – The minimum number of data points
- Return type:
bool
- Returns:
True if tau parameters are valid else False
- setMSDiffusionParams()¶
Set the Stephan maxwell mean squared displacement information.
- setComponents()¶
Set the molecular components for the models.
- static splitComponents(cms_model=None, ms_method='MS1', use_ctname_smiles=False)¶
Split the components of the system into different groups.
- Parameters:
cms_model (cms.Cms) – the cms model
ms_method (str) – the method to generate the component name
use_ctname_smiles (bool) – If True, use the smiles string of the molecule as component name else use CATION, ANION and SOLVENT for component names.
- Return type:
dict
- Returns:
A dictionary with the name of species as key and Simplenamespace containing total number of species, molecule number of the species, total molecular weight of the species, charge and weight fraction
- static getCompCtName(struct, method='MS1', use_ctname_smiles=False)¶
Get the component name based on the MS method.
- Parameters:
struct (structure.Structure) – The input structure
method (str) – The method to generate the component name
use_ctname_smiles (bool) – If True, use the smiles string of the molecule as component name for MS1 method. If False, use CATION, ANION and SOLVENT for names.
- Returns:
The component name
- Return type:
str
- computeOnsagerCoefficients()¶
Compute the displacement of each molecule center of mass
- validateBlockTau()¶
Validate tau parameters for block averaging
- Return type:
bool
- Returns:
True if tau parameters are valid else False
- computeOnsagerLambda()¶
Compute the average molecule displacement as a function of time
- static getActiveCompPair(components, method='MS1', use_ctname_smiles=False)¶
Get the active component pairs for the calculation of onsager coefficient.
- Parameters:
components (dict) – A dictionary containing smiles as key and information about the component as value
method (str) – The method to generate the component name
use_ctname_smiles (bool) – If True, use the smiles string of the molecule as component name for MS1 method. If False, use CATION, ANION and SOLVENT for names.
- Return type:
list
- Returns:
list of active component pairs for which onsager coefficient will be calculated
- getPerWindowCoefficients(start_frame, end_frame)¶
Compute the average molecule displacement as a function of time for a defined time window
- Parameters:
start_frame (int) – start frame of the time window
end_frame (int) – end frame of the time window
- Return type:
numpy.ndarray
- Returns:
average molecule displacement coefficient as a function of time
- getMSCoeffcientMS1(disps_window)¶
Compute the Onsager coefficient based on MS1 method
- Parameters:
disps_window (list[numpy.ndarray]) – list of displacement between each time step for every molecule. The array shape is [[t=0, nmol, 3], [t=1, nmol, 3], …].
- Return type:
numpy.ndarray
- Returns:
Onsager coefficient as a function of time
- getMSCoeffcientMS2(disps_window)¶
Compute the Onsager coefficient based on MS2 method
- Parameters:
disps_window (list[numpy.ndarray]) – list of displacement between each time step for every molecule. The array shape is [[t=0, nmol, 3], [t=1, nmol, 3], …].
- Return type:
numpy.ndarray
- Returns:
Onsager coefficient as a function of time
- getMSCoefficientMS3(disps_window)¶
Compute the Onsager coefficient based on MS2 method
- Parameters:
disps_window (list[numpy.ndarray]) – list of displacement between each time step for every molecule. The array shape is [[t=0, nmol, 3], [t=1, nmol, 3], …].
- Return type:
numpy.ndarray
- Returns:
Onsager coefficient as a function of time
- static getActivePairFromModel(model)¶
Get the column name for the onsager coefficient
- Parameters:
model (cms.Cms) – the cms model
- Return type:
dict, list[tuple(str, str)]
- Returns:
A dictionary containing smiles as key and information about the component as value and a list of active component pairs for which the onsager coefficient will be calculated.
- static getColumnLabels(active_pairs)¶
Get column label for the onsager coefficient
- Parameters:
active_pairs (list) – list of active component pairs for the label needs to be generated
- Return type:
list[str]
- Returns:
A list of column labels for the onsager coefficient
- writeOnsagerCoefficients()¶
Write onsager coefficient to a file.
- logComponentInfo()¶
Save the onsager coefficient to the project table and log to file.
- class schrodinger.application.matsci.equilibrium_md.SingleMDJob(jobname, md_opts, enegrp_opts, save_opts, command_dir='.', **kwargs)¶
Bases:
RobustSubmissionJob
Job class to submit a molecular dynamics simulation.
- __init__(jobname, md_opts, enegrp_opts, save_opts, command_dir='.', **kwargs)¶
- Parameters:
jobname (str) – The basename for the job
md_opts ('SimpleNamespace') – molecular dynamics options
enegrp_opts ('SimpleNamespace') – enegrp options
save_opts ('SimpleNamespace') – files to save
command_dir (str) – the job launch dir
- setup()¶
Over write parent class method.
- class schrodinger.application.matsci.equilibrium_md.MultiDriver(options, jobname_base, logger=None, smart_jdj=False)¶
Bases:
object
Class to fire off multiple subjobs.
- __init__(options, jobname_base, logger=None, smart_jdj=False)¶
- Parameters:
options (Named tuple) – The parsed command line options
jobname_base (str) – base name of this job
logger (
logging.Logger
) – The logger for this buildersmart_jdj (bool) – whether to use smart distribution of jobs
- run()¶
Run multiple calculation and perform ensemble average.
- convertMultiToOne()¶
Convert data from files from multiple subjobs into one single file.
- loadDataFromAllInOneFile()¶
Set the all-in-one file based on user input.
- setUpQue()¶
Setup job queue.
- initiateAndAddMdJobs(SingleMDJob=<class 'schrodinger.application.matsci.equilibrium_md.SingleMDJob'>, has_enegrp=False, additional_save_info=None, **kwargs)¶
Construct options, and initiate SingleMDJob jobs, and added them to jobdj.
- Parameters:
SingleMDJob ('queue.JobControlJob') – instantiate this class to an object that can be added to jobdj
has_enegrp (bool) – if False, no enegrp file is generated.
additional_save_info ('types.SimpleNamespace') – additional information on what files to be copied back.
- log(msg, **kwargs)¶
Add a message to the log file
- Parameters:
msg (str) – The message to log
Additional keyword arguments are passed to the textlogger.log_msg function
- log_error(msg)¶
Add a message to the log file and exit with an error code
- Parameters:
msg (str) – The message to log
- runSubjobs()¶
Run molecular dynamics jobs and Summarize the status of the runs.