Skip to content

Commit

Permalink
adding comments to inputs.json files description in docs; and possibi…
Browse files Browse the repository at this point in the history
…lity to not generate nanoscale logs
  • Loading branch information
mvassaux committed Nov 4, 2020
1 parent 03a4c7a commit 958c590
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 66 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ ll /path/to/simulation
... lammps_scripts_ffname -> /path/to/SCEMa/lammps_scripts_opls
... macroscale_input
... nanoscale_input
... clustering -> /path/to/SCEMa/clustering
... clustering -> /path/to/SCEMa/clustering # when using clustering algorithm to determine and eliminate redundant molecular simulations
... surrogate_model -> /path/to/SCEMa/surrogate_model # when using a surrogate for molecular simulations ("stress computation method: 2")
```

Most, if not all, of the simulation parameters are found in the configuration file `inputs_testname.json`:
Expand All @@ -70,7 +71,7 @@ cat /path/to/simulation/inputs_testname.json
"strain rate": 0.002
},
"scale-bridging":{
"activate md update": 1,
"stress computation method": 0,
"approximate md with hookes law": 0,
"use pjm scheduler": 0
},
Expand Down Expand Up @@ -140,7 +141,7 @@ cat /path/to/simulation/inputs_testname.json
"macroscale restart": "./macroscale_restart",
"nanoscale restart": "./nanoscale_restart",
"macroscale log": "./macroscale_log",
"nanoscale log": "./nanoscale_log"
"nanoscale log": "none"
}
}
```
Expand Down
11 changes: 4 additions & 7 deletions dealammps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ namespace HMM
std::string nanostatelocout;
std::string nanostatelocres;
std::string nanologloc;
std::string nanologloctmp;
std::string nanologlochom;

std::string md_scripts_directory;

Expand Down Expand Up @@ -391,9 +389,9 @@ namespace HMM

mkdir(nanostatelocout.c_str(), ACCESSPERMS);
mkdir(nanostatelocres.c_str(), ACCESSPERMS);
mkdir(nanologloc.c_str(), ACCESSPERMS);
nanologloctmp = nanologloc+"/tmp"; mkdir(nanologloctmp.c_str(), ACCESSPERMS);
nanologlochom = nanologloc+"/homog"; mkdir(nanologlochom.c_str(), ACCESSPERMS);
if(nanologloc != "none"){
mkdir(nanologloc.c_str(), ACCESSPERMS);
}

char fnset[1024]; sprintf(fnset, "%s/in.set.lammps", md_scripts_directory.c_str());
char fnstrain[1024]; sprintf(fnstrain, "%s/in.strain.lammps", md_scripts_directory.c_str());
Expand Down Expand Up @@ -508,8 +506,7 @@ namespace HMM
hcout << " Initialization of the Multiple Molecular Dynamics problem... " << std::endl;
if(mmd_pcolor==0) mmd_problem->init(start_timestep, md_timestep_length, md_temperature,
md_nsteps_sample, md_strain_rate, md_force_field, nanostatelocin,
nanostatelocout, nanostatelocres, nanologloc,
nanologloctmp, nanologlochom, macrostatelocout,
nanostatelocout, nanostatelocres, nanologloc, macrostatelocout,
md_scripts_directory, freq_checkpoint, freq_output_homog,
machine_ppn, mdtype, cg_dir, nrepl,
use_pjm_scheduler, input_config, approx_md_with_hookes_law);
Expand Down
41 changes: 21 additions & 20 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ mpirun /path/to/SCEMa/build/dealammps configuration.json
The JSON configuration file must be shaped as follows:
```
{
"problem type":{
"class": "testname",
"strain rate": 0.002
},
"problem type":{
"class": "dogbone" or "compact" or "dropweight",
"strain rate": 0.002
},
"scale-bridging":{
"activate md update": 1,
"approximate md with hookes law": 0,
"stress computation method": 0 (molecular model) or 1 (analytical hooke's law) or 2 (surrogate model),
"approximate md with hookes law": 0 (normal mode) or 1 (debug mode, replaces LAMMPS kernel with simple dot product operation),
"use pjm scheduler": 0
},
"continuum time":{
"timestep length": 5.0e-7,
"start timestep": 1,
"end timestep": 10
"end timestep": 500
},
"continuum mesh":{
"fe degree": 1,
"quadrature formula": 2,
"input": {
"style" : "cuboid",
"style" : "cuboid" (for dogbone or dropweight) or "file3D" (for dogbone or compact),
"x length" : 0.03,
"y length" : 0.03,
"z length" : 0.08,
Expand All @@ -39,10 +39,10 @@ The JSON configuration file must be shaped as follows:
"min quadrature strain norm": 1.0e-10
},
"clustering":{
"points": 10,
"min steps": 5,
"diff threshold": 0.000001,
"scripts directory": "./clustering"
"points": 10 (number of points in the spline approximation of the strain trajectory),
"min steps": 5 (number of steps before the clustering algorithm kicks in, if 5 then algorithm starts at timestep 6),
"diff threshold": 0.000001 (when the L2-norm distance of 2 splines exceeds this threshold they are considered different),
"scripts directory": "./clustering" (directory where the python scripts for the clustering algorithm are located)
}
},
"molecular dynamics material":{
Expand All @@ -51,26 +51,27 @@ The JSON configuration file must be shaped as follows:
"distribution": {
"style": "uniform",
"proportions": [1.0]
},
},
"rotation common ground vector":[1.0, 0.0, 0.0]
},
"molecular dynamics parameters":{
"temperature": 300.0,
"timestep length": 2.0,
"strain rate": 1.0e-4,
"number of sampling steps": 100,
"scripts directory": "./lammps_scripts_ffname",
"force field": "ffname"
"scripts directory": "./lammps_scripts_opls" or "./lammps_scripts_reax",
"force field": "opls" or "reax"
},
"computational resources":{
"machine cores per node": 24,
"number of nodes for FEM simulation": 1,
"minimum nodes per MD simulation": 1
"maximum number of cores for FEM simulation": 10,
"minimum number of cores for MD simulation": 1
},
"output data":{
"checkpoint frequency": 1,
"checkpoint frequency": 100,
"visualisation output frequency": 1,
"analytics output frequency": 1,
"loaded boundary force output frequency": 1,
"homogenization output frequency": 1000
},
"directory structure":{
Expand All @@ -81,9 +82,9 @@ The JSON configuration file must be shaped as follows:
"macroscale restart": "./macroscale_restart",
"nanoscale restart": "./nanoscale_restart",
"macroscale log": "./macroscale_log",
"nanoscale log": "./nanoscale_log"
"nanoscale log": "./nanoscale_log" or "none" (if no nanoscale log)
}
}
## Description
```

9 changes: 5 additions & 4 deletions headers/md_sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HMM {
}

int qp_id;
int most_recent_qp_id;
int most_recent_qp_id;
int replica;
int material;
std::string matid;
Expand All @@ -47,10 +47,11 @@ namespace HMM {
bool output_homog; // what is this? seems to add an extra dump of atom coords
bool checkpoint;

void define_file_names(std::string nanologloctmp)
void define_file_names(std::string nanologloc)
{
log_file = nanologloctmp + "/" + time_id + "." + std::to_string(qp_id) + "." + matid + "_" + std::to_string(replica);
// Preparing directory to write MD simulation log files
if(nanologloc != "none") log_file = nanologloc + "/" + time_id + "." + std::to_string(qp_id) + "." + matid + "_" + std::to_string(replica);
else log_file = "none";
// Preparing directory to write MD simulation log files
//mkdir(log_file.c_str(), ACCESSPERMS);
}
private:
Expand Down
42 changes: 26 additions & 16 deletions headers/stmd_problem.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ STMDProblem<dim>::~STMDProblem ()
template <int dim>
SymmetricTensor<2,dim> STMDProblem<dim>::lammps_straining (MDSim<dim> md_sim)
{
mkdir(md_sim.log_file.c_str(), ACCESSPERMS);
bool store_log = true;
if (md_sim.log_file == "none") store_log = false;

if(store_log) mkdir(md_sim.log_file.c_str(), ACCESSPERMS);

char locff[1024]; /*reaxff*/
if (md_sim.force_field == "reax"){
sprintf(locff, "%s/ffield.reax.2", md_sim.scripts_folder.c_str()); /*reaxff*/
Expand All @@ -95,8 +99,10 @@ SymmetricTensor<2,dim> STMDProblem<dim>::lammps_straining (MDSim<dim> md_sim)
sprintf(initdata, "%s/init.%s.bin", md_sim.output_folder.c_str(), mdstate);

char homogdata_time[1024];
sprintf(homogdata_time, "%s/%s.%d.%s.lammpstrj", md_sim.log_file.c_str(),
md_sim.time_id.c_str(), md_sim.qp_id, mdstate);
if(store_log) {
sprintf(homogdata_time, "%s/%s.%d.%s.lammpstrj", md_sim.log_file.c_str(),
md_sim.time_id.c_str(), md_sim.qp_id, mdstate);
}

char straindata_lcts[1024];
sprintf(straindata_lcts, "%s/lcts.%d.%s.dump", md_sim.restart_folder.c_str(),
Expand Down Expand Up @@ -141,15 +147,16 @@ SymmetricTensor<2,dim> STMDProblem<dim>::lammps_straining (MDSim<dim> md_sim)
lmparg[2] = (char *) "none";
lmparg[3] = (char *) "-log";
lmparg[4] = new char[1024];
sprintf(lmparg[4], "%s/log.stress_strain", md_sim.log_file.c_str());
if(store_log) sprintf(lmparg[4], "%s/log.stress_strain", md_sim.log_file.c_str());
else sprintf(lmparg[4], "none");

// Creating LAMMPS instance
LAMMPS *lmp = NULL;
lmp = new LAMMPS(nargs,lmparg,md_batch_communicator);

// Passing location for output as variable
sprintf(cline, "variable mdt string %s", md_sim.matid.c_str()); lammps_command(lmp,cline);
sprintf(cline, "variable loco string %s", md_sim.log_file.c_str()); lammps_command(lmp,cline);
if(store_log) {sprintf(cline, "variable loco string %s", md_sim.log_file.c_str()); lammps_command(lmp,cline);}
sprintf(cline, "variable locs string %s", md_sim.scripts_folder.c_str()); lammps_command(lmp,cline);

// Setting testing temperature
Expand Down Expand Up @@ -271,10 +278,11 @@ SymmetricTensor<2,dim> STMDProblem<dim>::lammps_straining (MDSim<dim> md_sim)
<< "Homogenization of stiffness and stress using in.elastic.lammps... " << std::endl;*/

// Creating LAMMPS instance
sprintf(lmparg[4], "%s/log.homogenization", md_sim.log_file.c_str());
if(store_log) sprintf(lmparg[4], "%s/log.homogenization", md_sim.log_file.c_str());
else sprintf(lmparg[4], "none");
lmp = new LAMMPS(nargs,lmparg,md_batch_communicator);

sprintf(cline, "variable loco string %s", md_sim.log_file.c_str()); lammps_command(lmp,cline);
if(store_log) {sprintf(cline, "variable loco string %s", md_sim.log_file.c_str()); lammps_command(lmp,cline);}
sprintf(cline, "variable locs string %s", md_sim.scripts_folder.c_str()); lammps_command(lmp,cline);

// Setting testing temperature
Expand All @@ -301,7 +309,7 @@ SymmetricTensor<2,dim> STMDProblem<dim>::lammps_straining (MDSim<dim> md_sim)

sprintf(cline, "variable dts equal %f", md_sim.timestep_length); lammps_command(lmp,cline);

if(md_sim.output_homog){
if(md_sim.output_homog && store_log){
// Setting dumping of atom positions for post analysis of the MD simulation
// DO NOT USE CUSTOM DUMP: WRONG ATOM POSITIONS...
sprintf(cline, "dump atom_dump all atom %d %s", 1, homogdata_time); lammps_command(lmp,cline);
Expand Down Expand Up @@ -399,15 +407,17 @@ SymmetricTensor<2,dim> STMDProblem<dim>::lammps_straining (MDSim<dim> md_sim)
// close down LAMMPS
delete lmp;

// Clean "nanoscale_logs" of the finished timestep
char command[1024];
sprintf(command, "rm -rf %s", md_sim.log_file.c_str());
//std::cout<< "Logfile "<< md_simulation.log_file <<std::endl;
int ret = system(command);
if (ret!=0){
std::cout << "Failed removing the log files of the MD simulation: " << md_sim.log_file << std::endl;
if(store_log) {
// Clean "nanoscale_logs" of the finished timestep
char command[1024];
sprintf(command, "rm -rf %s", md_sim.log_file.c_str());
//std::cout<< "Logfile "<< md_simulation.log_file <<std::endl;
int ret = system(command);
if (ret!=0){
std::cout << "Failed removing the log files of the MD simulation: " << md_sim.log_file << std::endl;
}
//boost::filesystem::remove_all(md_sim.log_file.c_str());
}
//boost::filesystem::remove_all(md_sim.log_file.c_str());
return md_sim.stress;
}

Expand Down
15 changes: 5 additions & 10 deletions headers/stmd_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class STMDSync
~STMDSync ();
void init (int sstp, double mdtlength, double mdtemp, int nss, double strr, std::string ffi,
std::string nslocin, std::string nslocout, std::string nslocres, std::string nlogloc,
std::string nlogloctmp,std::string nloglochom, std::string mslocout, std::string mdsdir,
std::string mslocout, std::string mdsdir,
int fchpt, int fohom, unsigned int mppn,
std::vector<std::string> mdt, Tensor<1,dim> cgd, unsigned int nr, bool ups,
boost::property_tree::ptree inconfig, bool approx_md_with_hookes_law);
Expand Down Expand Up @@ -147,8 +147,6 @@ class STMDSync
std::string nanostatelocout;
std::string nanostatelocres;
std::string nanologloc;
std::string nanologloctmp;
std::string nanologlochom;

std::string md_scripts_directory;
bool use_pjm_scheduler;
Expand Down Expand Up @@ -368,7 +366,7 @@ void STMDSync<dim>::load_replica_equilibration_data ()
stressoutputfile[imdrun] = nanostatelocin + "/init." + mdtype[imdt] + "_" + std::to_string(numrepl) + ".stress";
stiffoutputfile[imdrun] = nanostatelocin + "/init." + mdtype[imdt] + "_" + std::to_string(numrepl) + ".stiff";
systemoutputfile[imdrun] = nanostatelocin + "/init." + mdtype[imdt] + "_" + std::to_string(numrepl) + ".bin";
qpreplogloc[imdrun] = nanologloctmp + "/init" + "." + mdtype[imdt] + "_" + std::to_string(numrepl);
qpreplogloc[imdrun] = nanologloc + "/init" + "." + mdtype[imdt] + "_" + std::to_string(numrepl);
}
}

Expand Down Expand Up @@ -523,7 +521,7 @@ std::vector< MDSim<dim> > STMDSync<dim>::prepare_md_simulations(ScaleBridgingDat
md_sim.checkpoint = checkpoint_save;
// Setting up location for temporary log outputs of md simulation, input strains and output stresses
std::string macrostatelocout = input_config.get<std::string>("directory structure.macroscale output");
if (approx_md_with_hookes_law == false) md_sim.define_file_names(nanologloctmp);
if (approx_md_with_hookes_law == false) md_sim.define_file_names(nanologloc);

// Argument of the MD simulation: strain to apply
SymmetricTensor<2,dim> cg_loc_rep_strain(scale_bridging_data.update_list[qp].update_strain);
Expand Down Expand Up @@ -745,7 +743,7 @@ void STMDSync<dim>::generate_job_list(bool& elmj, int& tta, char* filenamelist)

sprintf(command, "python ../optimization_pjm/optimization_hmm.py %s %d %d %s %s %s %s",
macrostatelocout.c_str(), 1, nrepl, time_id.c_str(),
nanostatelocout.c_str(), nanologloctmp.c_str(), filenamelist);
nanostatelocout.c_str(), nanologloc.c_str(), filenamelist);

// Executing the job list optimization script with fscanf to parse the printed values from the python script
FILE* in = popen(command, "r");
Expand Down Expand Up @@ -918,8 +916,7 @@ void STMDSync<dim>::store_md_simulations(std::vector<MDSim<dim> > md_simulations

template <int dim>
void STMDSync<dim>::init (int sstp, double mdtlength, double mdtemp, int nss, double strr, std::string ffi,
std::string nslocin, std::string nslocout, std::string nslocres, std::string nlogloc,
std::string nlogloctmp,std::string nloglochom, std::string mslocout,
std::string nslocin, std::string nslocout, std::string nslocres, std::string nlogloc, std::string mslocout,
std::string mdsdir, int fchpt, int fohom, unsigned int mppn,
std::vector<std::string> mdt, Tensor<1,dim> cgd, unsigned int nr, bool ups,
boost::property_tree::ptree inconfig, bool hookeslaw){
Expand All @@ -939,8 +936,6 @@ void STMDSync<dim>::init (int sstp, double mdtlength, double mdtemp, int nss, do
nanostatelocout = nslocout;
nanostatelocres = nslocres;
nanologloc = nlogloc;
nanologloctmp = nlogloctmp;
nanologlochom = nloglochom;

macrostatelocout = mslocout;
md_scripts_directory = mdsdir;
Expand Down
6 changes: 3 additions & 3 deletions init_material.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ namespace HMM
std::string nanostatelocin;
std::string nanostatelocout;
std::string nanologloc;
std::string nanologloctmp;

std::string md_scripts_directory;

Expand Down Expand Up @@ -238,8 +237,9 @@ namespace HMM
exit(1);
}

mkdir(nanologloc.c_str(), ACCESSPERMS);
nanologloctmp = nanologloc+"/tmp"; mkdir(nanologloctmp.c_str(), ACCESSPERMS);
if(nanologloc != "none"){
mkdir(nanologloc.c_str(), ACCESSPERMS);
}

char fnset[1024]; sprintf(fnset, "%s/in.set.lammps", md_scripts_directory.c_str());
char fnstrain[1024]; sprintf(fnstrain, "%s/in.strain.lammps", md_scripts_directory.c_str());
Expand Down
6 changes: 3 additions & 3 deletions input_configurations/inputs_dogbone_file3D.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"timestep length": 2.0,
"strain rate": 2.0e-4,
"number of sampling steps": 100,
"scripts directory": "./lammps_scripts_opls",
"force field": "opls"
"scripts directory": "./lammps_scripts_reax",
"force field": "reax"
},
"computational resources":{
"machine cores per node": 24,
Expand All @@ -69,6 +69,6 @@
"macroscale restart": "./macroscale_restart",
"nanoscale restart": "./nanoscale_restart",
"macroscale log": "./macroscale_log",
"nanoscale log": "./nanoscale_log"
"nanoscale log": "none"
}
}

0 comments on commit 958c590

Please sign in to comment.