diff --git a/README.md b/README.md index 8772cf7..d6ee14c 100644 --- a/README.md +++ b/README.md @@ -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`: @@ -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 }, @@ -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" } } ``` diff --git a/dealammps.cc b/dealammps.cc index bf731d8..33c1d57 100644 --- a/dealammps.cc +++ b/dealammps.cc @@ -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; @@ -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()); @@ -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); diff --git a/docs/configuration.md b/docs/configuration.md index 37c7323..245d025 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -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, @@ -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":{ @@ -51,7 +51,7 @@ 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":{ @@ -59,18 +59,19 @@ The JSON configuration file must be shaped as follows: "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":{ @@ -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 +``` diff --git a/headers/md_sim.h b/headers/md_sim.h index e3a4ce2..416df78 100644 --- a/headers/md_sim.h +++ b/headers/md_sim.h @@ -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; @@ -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: diff --git a/headers/stmd_problem.h b/headers/stmd_problem.h index 8d8532c..bf9a0ea 100644 --- a/headers/stmd_problem.h +++ b/headers/stmd_problem.h @@ -82,7 +82,11 @@ STMDProblem::~STMDProblem () template SymmetricTensor<2,dim> STMDProblem::lammps_straining (MDSim 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*/ @@ -95,8 +99,10 @@ SymmetricTensor<2,dim> STMDProblem::lammps_straining (MDSim 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(), @@ -141,7 +147,8 @@ SymmetricTensor<2,dim> STMDProblem::lammps_straining (MDSim 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; @@ -149,7 +156,7 @@ SymmetricTensor<2,dim> STMDProblem::lammps_straining (MDSim md_sim) // 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 @@ -271,10 +278,11 @@ SymmetricTensor<2,dim> STMDProblem::lammps_straining (MDSim 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 @@ -301,7 +309,7 @@ SymmetricTensor<2,dim> STMDProblem::lammps_straining (MDSim 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); @@ -399,15 +407,17 @@ SymmetricTensor<2,dim> STMDProblem::lammps_straining (MDSim 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 < mdt, Tensor<1,dim> cgd, unsigned int nr, bool ups, boost::property_tree::ptree inconfig, bool approx_md_with_hookes_law); @@ -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; @@ -368,7 +366,7 @@ void STMDSync::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); } } @@ -523,7 +521,7 @@ std::vector< MDSim > STMDSync::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("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); @@ -745,7 +743,7 @@ void STMDSync::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"); @@ -918,8 +916,7 @@ void STMDSync::store_md_simulations(std::vector > md_simulations template void STMDSync::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 mdt, Tensor<1,dim> cgd, unsigned int nr, bool ups, boost::property_tree::ptree inconfig, bool hookeslaw){ @@ -939,8 +936,6 @@ void STMDSync::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; diff --git a/init_material.cc b/init_material.cc index 42d324a..50bdcd3 100644 --- a/init_material.cc +++ b/init_material.cc @@ -101,7 +101,6 @@ namespace HMM std::string nanostatelocin; std::string nanostatelocout; std::string nanologloc; - std::string nanologloctmp; std::string md_scripts_directory; @@ -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()); diff --git a/input_configurations/inputs_dogbone_file3D.json b/input_configurations/inputs_dogbone_file3D.json index b36b96b..f809eaa 100644 --- a/input_configurations/inputs_dogbone_file3D.json +++ b/input_configurations/inputs_dogbone_file3D.json @@ -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, @@ -69,6 +69,6 @@ "macroscale restart": "./macroscale_restart", "nanoscale restart": "./nanoscale_restart", "macroscale log": "./macroscale_log", - "nanoscale log": "./nanoscale_log" + "nanoscale log": "none" } }