56#include "brains/Register.hpp"
59#include "brains/Thermo.hpp"
60#include "brains/Velocitizer.hpp"
62#include "io/DumpWriter.hpp"
68int main(
int argc,
char* argv[]) {
70 std::string inputFileName;
71 std::string outputFileName;
74 if (cmdline_parser(argc, argv, &args_info) != 0) {
75 cmdline_parser_print_help();
80 if (args_info.input_given) {
81 inputFileName = args_info.input_arg;
83 if (args_info.inputs_num) {
84 inputFileName = args_info.inputs[0];
86 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
87 "No input file name was specified on the command line");
88 painCave.severity = OPENMD_ERROR;
95 outputFileName = args_info.output_arg;
97 if (!outputFileName.compare(inputFileName)) {
98 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
99 "Input and Output File names should be different!");
100 painCave.severity = OPENMD_ERROR;
101 painCave.isFatal = 1;
107 SimInfo* info = creator.createSim(inputFileName,
true);
114 std::unique_ptr<Velocitizer> veloSet {std::make_unique<Velocitizer>(info)};
119 veloSet->removeComDrift();
120 forceMan->calcForces();
122 RealType instPE = thermo.getPotential();
123 RealType instKE = thermo.getKinetic();
131 if (writer == NULL) {
132 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
133 "error in creating DumpWriter");
134 painCave.severity = OPENMD_ERROR;
135 painCave.isFatal = 1;
140 if (args_info.temperature_given) {
141 RealType temperature = args_info.temperature_arg;
143 if (temperature < 0.0) {
144 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
145 "Temperatures must be positive numbers.");
146 painCave.severity = OPENMD_ERROR;
147 painCave.isFatal = 1;
151 veloSet->randomize(temperature);
156 if (args_info.chargetemperature_given) {
157 RealType charge_temperature = args_info.chargetemperature_arg;
159 if (charge_temperature < 0.0) {
160 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
161 "Temperatures must be positive numbers.");
162 painCave.severity = OPENMD_ERROR;
163 painCave.isFatal = 1;
167 veloSet->randomizeChargeVelocity(charge_temperature);
171 if (args_info.energy_given) {
172 RealType energy = args_info.energy_arg;
173 RealType epsilon = 1e-6;
174 RealType lambda = 0.0;
176 if (energy < instPE) {
177 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
178 "Energy must be larger than current potential energy.");
179 painCave.severity = OPENMD_ERROR;
180 painCave.isFatal = 1;
183 if (instKE >= epsilon) {
184 lambda = sqrt((energy - instPE) / instKE);
185 veloSet->scale(lambda);
191 veloSet->randomize(10.0);
192 instKE = thermo.getKinetic();
193 lambda = sqrt((energy - instPE) / instKE);
194 veloSet->scale(lambda);
203 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
204 "A new OpenMD file called \"%s\" has been generated.\n",
205 outputFileName.c_str());
206 painCave.isFatal = 0;
207 painCave.severity = OPENMD_INFO;
ForceManager is responsible for calculating both the short range (bonded) interactions and long range...
The only responsibility of SimCreator is to parse the meta-data file and create a SimInfo instance ba...
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
SnapshotManager * getSnapshotManager()
Returns the snapshot manager.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Where the command line options are stored.
The header file for the command line option parser generated by GNU Gengetopt version 2....