DriverMLMOD
-
struct DriverMLMOD
The driver of the functionality for the shared library class. This specifies the prototype for the API interface with lammps.
Public Functions
-
DriverMLMOD(class FixMLMOD*, class LAMMPS*, int, char**)
Main constructor for mlmod package driver.
- Parameters:
FixMLMOD* – reference to the mlmod-lammps “fix” interface
LAMMPS* – reference to the running lammps instance
narg – number of command arguments
args – list of strings for the arguments
-
DriverMLMOD()
Constructor for empy object which is used primarily for testing.
-
~DriverMLMOD()
The deconstructor.
-
int setmask()
Lammps interface code for signaling the type of simulation.
-
virtual void init()
Used for initializing the driver settings when created.
-
void setup(int vflag)
Used for setting up references in the driver after lammps is initialized.
-
virtual void initial_integrate(int)
Lammps calls this routine at the start of each time-step.
-
virtual void final_integrate()
Lammps calls this routine at the end of each time-step.
-
void reset_dt()
Lammps calls this routine when the time-step size changes.
-
void post_force(int vflag)
Lammps calls this routine after it finished computing forces.
-
void pre_exchange()
Lammps calls this routine before updating atom tables.
-
void end_of_step()
Lammps calls this at the end of a simulation step.
-
double compute_array(int i, int j)
Lammps calls this to extract an array of data from the fix.
-
void init_attributes()
This is called from mlmod routines in lammps to initializes the driver class attributes.
-
void init_from_fix()
This is called from mlmod routines in lammps when the “fix” is setup.
-
void parse_xml_params(char *filename)
Parses the parameters from the xml files associated with the model_type.
-
void params_parse(int narg, char **arg)
Parses the parameters from the xml files associated with the model_type.
-
void write_info()
Writes additional simulation data to disk each time-step. Writes a file giving information about the current simulation for post-processing scripts.
-
void write_final_info()
Writes a file for the final step of the simulation, see write_info().
-
void initial_integrate_dX_MF_Q1_ML1_Pair()
Dynamic integrator with ML model for the mobility tensor \(M(\mathbf{X})\) for a pair of particles with \( \left\{ \begin{array}{lll} {d\mathbf{X}}/{dt} & = & \mathbf{M}(\mathbf{X})\mathbf{F} + k_B{T}\nabla_X \cdot \mathbf{M}(\mathbf{X}) + \mathbf{g}, \\ \langle \mathbf{g}(s) \mathbf{g}(t)^T \rangle & = & 2 k_B{T} \mathbf{M}(\mathbf{X}) \delta(t - s). \\ \end{array} \right. \).
-
void initial_integrate_dX_MF_Q1_ML1_N2N()
Dynamic integrator with ML model for the mobility tensor \(M(\mathbf{X})\) for pairwise interactions for a collection of particles with \( \left\{ \begin{array}{lll} {d\mathbf{X}}/{dt} & = & \mathbf{M}(\mathbf{X})\mathbf{F} + k_B{T}\nabla_X \cdot \mathbf{M}(\mathbf{X}) + \mathbf{g}, \\ \langle \mathbf{g}(s) \mathbf{g}(t)^T \rangle & = & 2 k_B{T} \mathbf{M}(\mathbf{X}) \delta(t - s). \\ \end{array} \right. \).
-
void post_force_F_ML1()
Computes an ML model for a force determined and applied collectively for all the particles in the designated group \( \mathbf{X} = \{\mathbf{X}_i\}_{i \in \mathcal{G}} \), where \( F(\mathbf{X},\mathbf{V},\mathbf{F},\mathbf{I_T},t) \).
-
void post_force_F_X_ML1()
Computes an ML model for a force applied individually to each particle \( \mathbf{X}_i \), with \( F_i(\mathbf{X}_i,\mathbf{V}_i,\mathbf{F}_i,\mathbf{I_T}_i,t) \). To compute forces collectively over the particles, see post_force_F_ML1().
-
void post_force_F_Pair_ML1()
Computes an ML model for a force applied on pairs of particles within the designated group, \( \mathbf{X}_{ij} = (\mathbf{X}_i,\mathbf{X}_j) \) for $i,j \in \mathcal{G}$, with \( F_{ij}(\mathbf{X}_{ij},\mathbf{V}_{ij},\mathbf{F}_{ij},\mathbf{I_T}_{ij},t) \). To compute forces collectively over the particles, see post_force_F_ML1().
-
void initial_integrate_QoI_ML1()
Computes an ML model for a quantity of interest (QoI), \( Q(\mathbf{X},\mathbf{V},\mathbf{F}) \).
-
void initial_integrate_Dyn_ML1()
Computes an ML model for the particle dynamics, \( \mathbf{X}^{n+1} = \Gamma(\mathbf{X}^n,\mathbf{V}^n,\mathbf{F}^n,t_n) \)
. Depending on the mask_fix settings this can be a single time-step or Verlet-style integrator. The initial step uses the machine learning model specified in dyn1_filenmae and the final step the model in dyn2_filename.
See the documentation pages and examples for more details.
-
void final_integrate_dX_MF_ML1()
Dynamic integrator with ML model for the mobility tensor \(M(\mathbf{X})\) for pairwise interactions for a collection of particles with \( {d\mathbf{X}}/{dt} = \mathbf{M}(\mathbf{X})\mathbf{F}. \).
-
void final_integrate_dX_MF()
Dynamic integrator for a test mobility tensor \(M(\mathbf{X})\) for pairwise interactions for a collection of particles with \( {d\mathbf{X}}/{dt} = \mathbf{M}(\mathbf{X})\mathbf{F}. \).
-
void final_integrate_dX_MF_Q1_ML1_Pair()
-
void final_integrate_dX_MF_Q1_ML1_N2N()
-
void final_integrate_QoI_ML1()
-
void final_integrate_Dyn_ML1()
Dynamic integrator based on specified machine learning model. For a Verlet-style integrator this calls the second half of the integration step using the model specified by dyn2_filenmae. For more details, see initial_integrate_Dyn_ML1().
-
void parse_xml_params_dX_MF(XMLElement *model_data_element)
Parsers for the specific model cases.
-
double **create_db_vec(int num_rows, int num_cols, double **db_vec_block, int *db_vec_size)
Creates a vector array x[][] for storing double precision floating point values.
- Parameters:
num_cols – number of dimensions
num_rows – number of indices
db_vec_block – block of memory for vector (set to zero to allocate)
db_vec_size – size of the block of memory allocated
- Returns:
(double **) vector array with shape=[num_rows,num_cols].
-
void set_db_vec_to_tensor_full(double **z, at::Tensor output_m, int num_rows, int num_cols, int *rowII, int offset_tensor)
Sets a vector array x[][] from torch tensor data a[:][0].
This implements a copy of the form x[i][d] = a[I + offset][0], where I = i*num_cols + d x.shape=[n,num_cols], a.shape=[n*num_cols,1]
- Parameters:
double** – vector array, (typical shape=[n,num_cols])
output_m – torch tensor
num_cols – number of dimensions
num_rows – number of indices
rowII – subset of indices to set (rowII=NULL, use all)
offset_tensor – for tensor array, offset for start of values
-
void add_tensor_full_to_db_vec(double **z, at::Tensor output_m, int num_rows, int num_cols, int *rowII, int offset_tensor)
Sets a vector array x[][] from torch tensor data a[:][0].
This implements a copy of the form x[i][d] += a[I + offset][0], where I = i*num_cols + d x.shape=[n,num_cols], a.shape=[n*num_cols,1]
- Parameters:
double** – vector array, (typical shape=[n,num_cols])
output_m – torch tensor
num_cols – number of dimensions
num_rows – number of indices
rowII – subset of indices to set (rowII=NULL, use all)
offset_tensor – for tensor array, offset for start of values
-
void add_tensor_seg_to_db_vec(double **z, at::Tensor output_m, int num_rows, int num_cols, int *rowII, int offset_tensor)
Sets a vector array x[][] from torch tensor data a[:][0] which has the same overall size as x.
This implements a copy of the form x[iii][d] += a[I + offset][0], where I = iii*num_cols + d, iii = rowII[i], x.shape=[num_rows,num_cols], a.shape=[num_rows*num_cols,1].
- Parameters:
double** – vector array, (typical shape=[n,num_cols])
output_m – torch tensor
num_cols – number of dimensions
num_rows – number of indices
rowII – subset of indices to set (rowII=NULL, use all)
offset_tensor – for tensor array, offset for start of values
-
void set_to_zero_db_vec(double **z, int num_rows, int num_cols, int *rowII)
Sets a vector array x[][] to zero.
This implements a copy of the form x[i][d] = 0.0 x.shape=[n,num_cols], a.shape=[n*num_cols,1]
- Parameters:
double** – vector array, (typical shape=[n,num_cols])
num_cols – number of dimensions
num_rows – number of indices
rowII – subset of indices to set (rowII=NULL, use all)
-
int get_tensor_input_size(int num_II, int *II, int num_dim, int mask_input, int mask_list_n, int *mask_list, int groupbit, int *mask_atom)
Get tensor size given the masks and groups from lammps.
-
void build_tensor_from_masks(at::TensorAccessor<float, 2, at::DefaultPtrTraits, long> input_m_a, int num_indices, int *indices, int mask_input, int mask_list_n, int *mask_list, int groupbit, int *mask_atom, double **x, double **v, double **f, int *type, double time)
Creates tensors for positions, velocity, and forces from lammps.
-
void get_indices_for_group(int groupbit, int *mask_atom, int nlocal, int *II_size_ptr, int **II_ptr, int *num_II_ptr)
Get indices for group from lammps.
-
void print_tensor_2d(const char *name, at::Tensor t)
Display information.
-
void write_array_txt_1D(const char *filename, int n, double *v)
Writing tensor arrays to disk for processing and debugging.
-
void test1()
Test codes helpful in debugging.
Public Members
-
LAMMPS *lammps
lammps instance
-
FixMLMOD *fixMLMOD
our lammps “fix” interface instance
-
int mlmod_seed
seed for random number generator
-
string params_filename
level of output to print
-
RanMars *random
random number generator
-
int model_type
integer flag for the model type to use
-
string model_type_str
name of the model type for setting up integer flags and displaying information (note may be current length limit)
-
void *model_data
general model specific data
-
int MODEL_TYPE_NULL
Model types (constants)
Friends
- friend class FixMLMOD
-
struct ModelData_dX_MF_ML1_Type
Data for a basic ML mobility-based simulation
Public Members
-
string *M_ii_filename
filename for the ML model for the self-mobility tensor components
-
string *M_ij_filename
filename for the ML model for pair-mobility tensor components
-
torch::jit::Module *M_ii_model
torch ML model for self-mobility
-
torch::jit::Module *M_ij_model
torch ML model for pair-mobility
-
int flag_init
internal variables
-
string *M_ii_filename
-
struct ModelData_dX_MF_Q1_ML1_N2N_Type
State information for specified simulation modality.
Public Members
-
int flag_init
internal variables
-
int flag_init
-
struct ModelData_dX_MF_Q1_ML1_Pair_Type
Data for an overdamped stochastic ML mobility-based simulation, see initial_integrate_dX_MF_Q1_ML1_Pair() and final_integrate_dX_MF_Q1_ML1_Pair().
Public Members
-
int flag_init
internal variables
-
int flag_init
-
struct ModelData_dX_MF_Type
Data for hydrodynamic model case (used primarily for testing)
Public Members
-
int flag_init
internal variables
-
int flag_init
-
struct ModelData_Dyn_ML1_Type
State information for specified simulation modality.
-
struct ModelData_F_ML1_Type
State information for specified simulation modality.
-
struct ModelData_F_Pair_ML1_Type
State information for specified simulation modality.
-
struct ModelData_F_X_ML1_Type
State information for specified simulation modality.
-
struct ModelData_QoI_ML1_Type
State information for specified simulation modality.
-
DriverMLMOD(class FixMLMOD*, class LAMMPS*, int, char**)