add support for writing/reading equilibrium bond/angle data
This commit is contained in:
@ -285,6 +285,14 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
}
|
||||
writer.emit_block("angle_coeff", block);
|
||||
|
||||
// equilibrium angle
|
||||
std::stringstream eqstr;
|
||||
eqstr << lmp->force->angle->equilibrium_angle(1);
|
||||
for (std::size_t i=1; i < config.angle_coeff.size(); ++i) {
|
||||
eqstr << " " << lmp->force->angle->equilibrium_angle(i+1);
|
||||
}
|
||||
writer.emit("equilibrium", eqstr.str());
|
||||
|
||||
// extract
|
||||
block.clear();
|
||||
std::stringstream outstr;
|
||||
|
||||
@ -285,6 +285,14 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
}
|
||||
writer.emit_block("bond_coeff", block);
|
||||
|
||||
// equilibrium distance
|
||||
std::stringstream eqstr;
|
||||
eqstr << lmp->force->bond->equilibrium_distance(1);
|
||||
for (std::size_t i=1; i < config.bond_coeff.size(); ++i) {
|
||||
eqstr << " " << lmp->force->bond->equilibrium_distance(i+1);
|
||||
}
|
||||
writer.emit("equilibrium", eqstr.str());
|
||||
|
||||
// extract
|
||||
block.clear();
|
||||
std::stringstream outstr;
|
||||
|
||||
@ -47,6 +47,7 @@ public:
|
||||
std::vector<std::string> angle_coeff;
|
||||
std::vector<std::string> dihedral_coeff;
|
||||
std::vector<std::string> improper_coeff;
|
||||
std::vector<double> equilibrium;
|
||||
std::vector<std::pair<std::string,int>> extract;
|
||||
int natoms;
|
||||
double init_energy;
|
||||
|
||||
@ -50,13 +50,11 @@ TestConfigReader::TestConfigReader(TestConfig & config)
|
||||
|
||||
consumers["bond_style"] = &TestConfigReader::bond_style;
|
||||
consumers["bond_coeff"] = &TestConfigReader::bond_coeff;
|
||||
consumers["init_energy"] = &TestConfigReader::init_energy;
|
||||
consumers["run_energy"] = &TestConfigReader::run_energy;
|
||||
|
||||
consumers["angle_style"] = &TestConfigReader::angle_style;
|
||||
consumers["angle_coeff"] = &TestConfigReader::angle_coeff;
|
||||
consumers["init_energy"] = &TestConfigReader::init_energy;
|
||||
consumers["run_energy"] = &TestConfigReader::run_energy;
|
||||
consumers["equilibrium"] = &TestConfigReader::equilibrium;
|
||||
}
|
||||
|
||||
void TestConfigReader::prerequisites(const yaml_event_t & event) {
|
||||
@ -220,6 +218,20 @@ void TestConfigReader::angle_coeff(const yaml_event_t & event) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestConfigReader::equilibrium(const yaml_event_t & event) {
|
||||
std::string vals = (char *)event.data.scalar.value;
|
||||
config.equilibrium.clear();
|
||||
std::size_t found = vals.find_first_of(" \t");
|
||||
while (found != std::string::npos) {
|
||||
double value = atof(vals.substr(0,found).c_str());
|
||||
config.equilibrium.push_back(value);
|
||||
printf("vals=%s ->",vals.c_str());
|
||||
vals = vals.substr(found+1);
|
||||
printf("%s\n",vals.c_str());
|
||||
found = vals.find_first_of(" \t");
|
||||
}
|
||||
}
|
||||
|
||||
void TestConfigReader::init_vdwl(const yaml_event_t & event) {
|
||||
config.init_vdwl = atof((char *)event.data.scalar.value);
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ public:
|
||||
void bond_coeff(const yaml_event_t & event);
|
||||
void angle_style(const yaml_event_t & event);
|
||||
void angle_coeff(const yaml_event_t & event);
|
||||
void equilibrium(const yaml_event_t & event);
|
||||
void init_vdwl(const yaml_event_t & event);
|
||||
void init_coul(const yaml_event_t & event);
|
||||
void run_vdwl(const yaml_event_t & event);
|
||||
|
||||
Reference in New Issue
Block a user