MDStressLab++
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1/*
2 * main.cpp
3 *
4 * Created on: Nov 3, 2019
5 * Author: Nikhil Admal
6 */
7#include "MethodSphere.h"
8#include <string>
9#include <iostream>
10#include <tuple>
11#include <fstream>
12#include "BoxConfiguration.h"
13#include "calculateStress.h"
14#include "Grid.h"
15#include "typedef.h"
16#include <regex>
17
18
19int main()
20{
21 int numberOfParticles;
22 int referenceAndFinal= true;
23 std::string prefix= "defANDundefSystem_";
24 std::vector<std::string> modelnames={
25 "MEAM_LAMMPS_DuLenoskyHennig_2011_Si__MO_883726743759_002",
26 "EDIP_JustoBazantKaxiras_1998_Si__MO_958932894036_002",
27 "Tersoff_LAMMPS_Tersoff_1988T3_Si__MO_186459956893_004", // - has processdEdr
28 "ThreeBodyCluster_Gong_Gong_1993_Si__MO_407755720412_000",
29 "SW_BalamaneHauchShi_2017Brittle_Si__MO_381114941873_002"};
30
31
32 /*
33 "MEAM_LAMMPS_DuLenoskyHennig_2011_Si__MO_883726743759_002",
34 "SNAP_ZuoChenLi_2019_Si__MO_869330304805_000",
35 "SNAP_ZuoChenLi_2019quadratic_Si__MO_721469752060_000",
36 "ThreeBodyBondOrder_PPM_PurjaPunMishin_2017_Si__MO_566683736730_000",
37 "EDIP_JustoBazantKaxiras_1998_Si__MO_958932894036_002",
38 "EDIP_LAMMPS_JustoBazantKaxiras_1998_Si__MO_315965276297_000",
39 "Tersoff_LAMMPS_Tersoff_1988T2_Si__MO_245095684871_004", // - has processdEdr
40 "Tersoff_LAMMPS_Tersoff_1988T3_Si__MO_186459956893_004", // - has processdEdr
41 "ThreeBodyBondOrder_KDS_KhorDasSarma_1988_Si__MO_722489435928_000",
42 "ThreeBodyBondOrder_PPM_PurjaPunMishin_2017_Si__MO_566683736730_000",
43 "ThreeBodyBondOrder_WR_WangRockett_1991_Si__MO_081872846741_000",
44 "ThreeBodyCluster_BH_BiswasHamann_1987_Si__MO_019616213550_000",
45 "ThreeBodyCluster_Gong_Gong_1993_Si__MO_407755720412_000",
46 "ThreeBodyCluster_KP_KaxirasPandey_1988_Si__MO_072486242437_000",
47 "SW_BalamaneHauchShi_2017Brittle_Si__MO_381114941873_002",// - has processdEdr
48 "ThreeBodyCluster_SRS_StephensonRadnySmith_1996_Si__MO_604248666067_000"
49 */
50
51// -------------------------------------------------------------------
52// Create grid
53// -------------------------------------------------------------------
54 int ngrid;
55 ngrid= 250;
56 Vector3d lowerLimit(20*5.5,20*5.5,2*5.5);
57 Vector3d upperLimit(80*5.5,80*5.5,10*5.5);
58 Grid<Current> gridFromFile(lowerLimit,upperLimit,ngrid,ngrid,1);
59
60// -------------------------------------------------------------------
61// Calculate stress on the grid
62// -------------------------------------------------------------------
63 // Create hardyStress object
64
65 // Hardy stress
66 MethodSphere hardy5(2,"hardy");
67 MethodSphere hardy10(4,"hardy");
68 MethodSphere hardy15(6,"hardy");
69 MethodSphere hardy20(8,"hardy");
70
71 for (const auto modelname : modelnames)
72 {
73 // -------------------------------------------------------------------
74 // Input configuration and potential
75 // -------------------------------------------------------------------
76 Kim kim(modelname);
77
78 std::string configFileName= prefix+modelname+".data";
79 //std::string configFileName= prefix+modelname+".lmp";
80 std::ifstream file(configFileName);
81 if(!file) MY_ERROR("ERROR: config.dat could not be opened for reading!");
82
83 // get number of particles
84 std::string line;
85 while (std::getline(file, line)) {
86 std::istringstream ss(line);
87 if (ss >> numberOfParticles)
88 break;
89 }
90 if (numberOfParticles < 0) MY_ERROR("Error: Negative number of particles.\n");
91 BoxConfiguration body{numberOfParticles,referenceAndFinal};
92 body.read(configFileName,referenceAndFinal);
93 //body.readLMP(configFileName);
94
95
96
97 // stress calculation using projected forces
98 try {
99 Stress<MethodSphere,Cauchy> hardyStress5 (hardy5,&gridFromFile);
100 Stress<MethodSphere,Cauchy> hardyStress10(hardy10,&gridFromFile);
101 Stress<MethodSphere,Cauchy> hardyStress15(hardy15,&gridFromFile);
102 Stress<MethodSphere,Cauchy> hardyStress20(hardy20,&gridFromFile);
103
104 // Calculate stress using the projected forces
105 calculateStress(body, kim,
106 std::tie(),
107 std::tie(hardyStress5, hardyStress10, hardyStress15, hardyStress20), true);
108 hardyStress5.write("project_hardy5_" + modelname);
109 hardyStress10.write("project_hardy10_" + modelname);
110 hardyStress15.write("project_hardy15_" + modelname);
111 hardyStress20.write("project_hardy20_" + modelname);
112 }
113 catch(const std::runtime_error& e){
114 std::cout << e.what() << std::endl;
115 std::cout << "Compute stress with projected forces failed. Moving on" << std::endl;
116 }
117
118 // stress calculation using process_dedr
119 try{
120 Stress<MethodSphere,Cauchy> hardyStress5 (hardy5,&gridFromFile);
121 Stress<MethodSphere,Cauchy> hardyStress10(hardy10,&gridFromFile);
122 Stress<MethodSphere,Cauchy> hardyStress15(hardy15,&gridFromFile);
123 Stress<MethodSphere,Cauchy> hardyStress20(hardy20,&gridFromFile);
124
125 // Calculate stress using the process_dedr, if possible
126 calculateStress(body, kim,
127 std::tie(),
128 std::tie(hardyStress5, hardyStress10, hardyStress15, hardyStress20));
129 hardyStress5.write("hardy5_" + modelname);
130 hardyStress10.write("hardy10_" + modelname);
131 hardyStress15.write("hardy15_" + modelname);
132 hardyStress20.write("hardy20_" + modelname);
133 }
134 catch(const std::runtime_error& e){
135 std::cout << e.what() << std::endl;
136 std::cout << "Compute stress with process_dedr failed. Moving on" << std::endl;
137 }
138 }
139
140 return 0;
141}
142
143
int calculateStress(const BoxConfiguration &body, Kim &kim, std::tuple<> stress, const bool &projectForces=false)
Represents a particle configuration including simulation box information.
void read(std::string configFileName, int referenceAndFinal)
A function to read the properties of atoms from a file in a MDStressLab format.
Definition Grid.h:31
Definition kim.h:21
Implements radially symmetric weighting functions (Hardy, Virial) and its associated bond function fo...
void write()
Definition Stress.h:90
int main()
#define MY_ERROR(message)
Definition typedef.h:17
Eigen::Matrix< double, 1, DIM, Eigen::RowMajor > Vector3d
Definition typedef.h:60