From 7ad4dd2397ef3519fad04d1dbfc44d51b4b149e7 Mon Sep 17 00:00:00 2001 From: HomesGH Date: Fri, 5 May 2023 11:32:19 +0200 Subject: [PATCH 01/24] Fix to make mixing rules work --- examples/DropletCoalescence/liq/config_1_generateLiq.xml | 2 +- examples/DropletCoalescence/liq/config_2_replicateLiq.xml | 2 +- examples/DropletCoalescence/vap/config_3_generateVap.xml | 2 +- examples/DropletCoalescence/vap/config_4_replicateVap.xml | 2 +- examples/DropletCoalescence/vle/config_5_droplet.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/DropletCoalescence/liq/config_1_generateLiq.xml b/examples/DropletCoalescence/liq/config_1_generateLiq.xml index fcc9af1d64..eae208ac96 100644 --- a/examples/DropletCoalescence/liq/config_1_generateLiq.xml +++ b/examples/DropletCoalescence/liq/config_1_generateLiq.xml @@ -30,7 +30,7 @@ ../components.xml - ../mixing_2c.xml + ../mixing_2c.xml diff --git a/examples/DropletCoalescence/liq/config_2_replicateLiq.xml b/examples/DropletCoalescence/liq/config_2_replicateLiq.xml index 70811ce4e0..f05ecde47f 100755 --- a/examples/DropletCoalescence/liq/config_2_replicateLiq.xml +++ b/examples/DropletCoalescence/liq/config_2_replicateLiq.xml @@ -30,7 +30,7 @@ ../components.xml - ../mixing_2c.xml + ../mixing_2c.xml diff --git a/examples/DropletCoalescence/vap/config_3_generateVap.xml b/examples/DropletCoalescence/vap/config_3_generateVap.xml index 855bded805..dbf84366dc 100644 --- a/examples/DropletCoalescence/vap/config_3_generateVap.xml +++ b/examples/DropletCoalescence/vap/config_3_generateVap.xml @@ -30,7 +30,7 @@ ../components.xml - ../mixing_2c.xml + ../mixing_2c.xml diff --git a/examples/DropletCoalescence/vap/config_4_replicateVap.xml b/examples/DropletCoalescence/vap/config_4_replicateVap.xml index 80f7102264..33df6ebabf 100755 --- a/examples/DropletCoalescence/vap/config_4_replicateVap.xml +++ b/examples/DropletCoalescence/vap/config_4_replicateVap.xml @@ -30,7 +30,7 @@ ../components.xml - ../mixing_2c.xml + ../mixing_2c.xml diff --git a/examples/DropletCoalescence/vle/config_5_droplet.xml b/examples/DropletCoalescence/vle/config_5_droplet.xml index be3eaabee7..d48a9afbe8 100755 --- a/examples/DropletCoalescence/vle/config_5_droplet.xml +++ b/examples/DropletCoalescence/vle/config_5_droplet.xml @@ -30,7 +30,7 @@ ../components.xml - ../mixing_2c.xml + ../mixing_2c.xml From 5e46bfa871b48654989332e7aefc64d7b329cb41 Mon Sep 17 00:00:00 2001 From: HomesGH Date: Fri, 5 May 2023 11:35:21 +0200 Subject: [PATCH 02/24] Fixes and logging/warnings regarding shifted parameter; Print booleans as true/false instead of 1/0 --- examples/DropletCoalescence/components.xml | 4 ++-- examples/SpinodalDecomposition/components_1c.xml | 2 +- src/molecules/Component.cpp | 5 +++++ src/molecules/Site.h | 11 ++++++++++- src/utils/Logger.cpp | 3 +++ 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/examples/DropletCoalescence/components.xml b/examples/DropletCoalescence/components.xml index 17e8adabcb..494e38421d 100755 --- a/examples/DropletCoalescence/components.xml +++ b/examples/DropletCoalescence/components.xml @@ -8,7 +8,7 @@ 39.948 3.3916 137.90 - 1 + true 0.0 @@ -23,7 +23,7 @@ 39.948 3.3916 137.90 - 1 + true 0.0 diff --git a/examples/SpinodalDecomposition/components_1c.xml b/examples/SpinodalDecomposition/components_1c.xml index 9d8d8b4ba3..507bf6e73a 100644 --- a/examples/SpinodalDecomposition/components_1c.xml +++ b/examples/SpinodalDecomposition/components_1c.xml @@ -8,7 +8,7 @@ 1.0 1.0 1.0 - 1 + true 0.0 diff --git a/src/molecules/Component.cpp b/src/molecules/Component.cpp index 6ddc431b3e..5821a6c5b9 100644 --- a/src/molecules/Component.cpp +++ b/src/molecules/Component.cpp @@ -53,14 +53,18 @@ void Component::readXML(XMLfileUnits& xmlconfig) { LJcenter ljSite; ljSite.readXML(xmlconfig); addLJcenter(ljSite); + global_log->info() << "sigma = " << ljSite.sigma() << " ; epsilon = " << ljSite.eps() + << " ; mass = " << ljSite.m() << " ; shifted = " << ljSite.shiftRequested() << endl; } else if (siteType == "Charge") { Charge chargeSite; chargeSite.readXML(xmlconfig); addCharge(chargeSite); + global_log->info() << "charge = " << chargeSite.q() << endl; } else if (siteType == "Dipole") { Dipole dipoleSite; dipoleSite.readXML(xmlconfig); addDipole(dipoleSite); + global_log->info() << "dipoleMoment = " << dipoleSite.absMy() << endl; } else if (siteType == "Stockmayer") { _isStockmayer = true; _rot_dof = 2; @@ -77,6 +81,7 @@ void Component::readXML(XMLfileUnits& xmlconfig) { Quadrupole quadrupoleSite; quadrupoleSite.readXML(xmlconfig); addQuadrupole(quadrupoleSite); + global_log->info() << "quadrupoleMoment = " << quadrupoleSite.absQ() << endl; } else if (siteType == "Tersoff") { global_log->error() << "Tersoff no longer supported:" << siteType << endl; Simulation::exit(-1); diff --git a/src/molecules/Site.h b/src/molecules/Site.h index f84381758a..1d4f559f34 100644 --- a/src/molecules/Site.h +++ b/src/molecules/Site.h @@ -8,6 +8,7 @@ #include #include #include +#include using Log::global_log; @@ -126,7 +127,15 @@ class LJcenter : public Site { Site::readXML(xmlconfig); xmlconfig.getNodeValueReduced("epsilon", _epsilon); xmlconfig.getNodeValueReduced("sigma", _sigma); - xmlconfig.getNodeValue("shifted", _shiftRequested); + // Read shifted value and check if its boolean (true/false) to avoid legacy-errors + std::string strShifted; + xmlconfig.getNodeValue("shifted", strShifted); + if (strShifted == "true" || strShifted == "false") { + xmlconfig.getNodeValue("shifted", _shiftRequested); + } else { + global_log->error() << "Parameter of components has to be either set to 'true' or 'false'" << std::endl; + mardyn_exit(1); + } } /// write to stream diff --git a/src/utils/Logger.cpp b/src/utils/Logger.cpp index d9e0ef069a..988d9eab28 100644 --- a/src/utils/Logger.cpp +++ b/src/utils/Logger.cpp @@ -14,12 +14,14 @@ Logger::Logger(logLevel level, std::ostream *os) #ifdef ENABLE_MPI MPI_Comm_rank(MPI_COMM_WORLD, &_rank); #endif + *_log_stream << std::boolalpha; // Print boolean as true/false } Logger::Logger(logLevel level, std::string prefix) : _log_level(level), _msg_log_level(Log::Error), _do_output(true), _filename(""), _log_stream(0), logLevelNames(), _starttime(), _rank(0) { init_starting_time(); + this->init_log_levels(); std::stringstream filenamestream; filenamestream << prefix; #ifdef ENABLE_MPI @@ -29,6 +31,7 @@ Logger::Logger(logLevel level, std::string prefix) : _log_level(level), _msg_lo filenamestream << ".log"; _filename = filenamestream.str(); _log_stream = new std::ofstream(_filename.c_str()); + *_log_stream << std::boolalpha; // Print boolean as true/false } Logger::~Logger() { From a27030037831c987716b10a37f0bd532c423eaa9 Mon Sep 17 00:00:00 2001 From: HomesGH Date: Fri, 5 May 2023 11:37:47 +0200 Subject: [PATCH 03/24] Major update of ResultWriter to improve parsing of output, doc, error-fixes, cleanup, etc. --- src/io/ResultWriter.cpp | 118 ++++++++++++++++++++++++---------------- src/io/ResultWriter.h | 48 ++++++++-------- 2 files changed, 95 insertions(+), 71 deletions(-) diff --git a/src/io/ResultWriter.cpp b/src/io/ResultWriter.cpp index abf522f28f..976bc3940c 100644 --- a/src/io/ResultWriter.cpp +++ b/src/io/ResultWriter.cpp @@ -1,29 +1,21 @@ #include "io/ResultWriter.h" #include "Domain.h" -#include "parallel/DomainDecompBase.h" #include "Simulation.h" +#include "parallel/DomainDecompBase.h" #include "utils/Logger.h" -#include + +#include using Log::global_log; void ResultWriter::readXML(XMLfileUnits& xmlconfig) { - _writeFrequency = 1; xmlconfig.getNodeValue("writefrequency", _writeFrequency); global_log->info() << "[ResultWriter] Write frequency: " << _writeFrequency << endl; - _outputPrefix = "mardyn"; xmlconfig.getNodeValue("outputprefix", _outputPrefix); global_log->info() << "[ResultWriter] Output prefix: " << _outputPrefix << endl; - size_t acc_steps = 1000; - xmlconfig.getNodeValue("accumulation_steps", acc_steps); - _U_pot_acc = new Accumulator(acc_steps); - _p_acc = new Accumulator(acc_steps); - global_log->info() << "[ResultWriter] Accumulation steps: " << acc_steps << endl; - - _writePrecision = 5; xmlconfig.getNodeValue("writeprecision", _writePrecision); global_log->info() << "[ResultWriter] Write precision: " << _writePrecision << endl; } @@ -31,59 +23,89 @@ void ResultWriter::readXML(XMLfileUnits& xmlconfig) { void ResultWriter::init(ParticleContainer * /*particleContainer*/, DomainDecompBase *domainDecomp, Domain * /*domain*/) { + // Only main rank writes data to file if(domainDecomp->getRank() == 0) { - const auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - tm unused{}; - const auto nowStr = std::put_time(localtime_r(&now, &unused), "%c"); - string resultfile(_outputPrefix+".res"); - _resultStream.open(resultfile.c_str(), std::ios::out); - _resultStream << "# ls1 MarDyn simulation started at " << nowStr << endl; - _resultStream << "# Averages are the accumulated values over " << _U_pot_acc->getWindowLength() << " time steps."<< endl; - _resultStream << std::setw(10) << "# step" << std::setw(_writePrecision+15) << "time" - << std::setw(_writePrecision+15) << "U_pot" + const string resultfile(_outputPrefix+".res"); + std::ofstream resultStream; + resultStream.open(resultfile.c_str(), std::ios::out); + resultStream << std::setw(10) << "#step" + << std::setw(_writePrecision+15) << "time" << std::setw(_writePrecision+15) << "U_pot_avg" - << std::setw(_writePrecision+15) << "p" + << std::setw(_writePrecision+15) << "U_kin_avg" + << std::setw(_writePrecision+15) << "U_kinTrans_avg" + << std::setw(_writePrecision+15) << "U_kinRot_avg" << std::setw(_writePrecision+15) << "p_avg" - << std::setw(_writePrecision+15) << "beta_trans" - << std::setw(_writePrecision+15) << "beta_rot" << std::setw(_writePrecision+15) << "c_v" << std::setw(_writePrecision+15) << "N" << endl; + resultStream.close(); } } void ResultWriter::endStep(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain, unsigned long simstep) { - // Writing of cavities now handled by CavityWriter + const uint64_t globalNumMolecules = domain->getglobalNumMolecules(true, particleContainer, domainDecomp); - unsigned long globalNumMolecules = domain->getglobalNumMolecules(true, particleContainer, domainDecomp); - double cv = domain->cv(); + _uPot_acc += domain->getGlobalUpot(); + _p_acc += domain->getGlobalPressure(); - _U_pot_acc->addEntry(domain->getGlobalUpot()); - _p_acc->addEntry(domain->getGlobalPressure()); - if((domainDecomp->getRank() == 0) && (simstep % _writeFrequency == 0)){ - _resultStream << std::setw(10) << simstep << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _simulation.getSimulationTime() - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << domain->getGlobalUpot() - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _U_pot_acc->getAverage() - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << domain->getGlobalPressure() - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _p_acc->getAverage() - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << domain->getGlobalBetaTrans() - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << domain->getGlobalBetaRot() - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << cv - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << globalNumMolecules - << endl; + double uKinLocal = 0.0F; + double uKinGlobal = 0.0F; + double uKinTransLocal = 0.0F; + double uKinTransGlobal = 0.0F; + double uKinRotLocal = 0.0F; + double uKinRotGlobal = 0.0F; + #if defined(_OPENMP) + #pragma omp parallel reduction(+:uKinLocal,uKinTransLocal,uKinRotLocal) + #endif + { + for (auto moleculeIter = particleContainer->iterator(ParticleIterator::ONLY_INNER_AND_BOUNDARY); + moleculeIter.isValid(); ++moleculeIter) { + uKinLocal += moleculeIter->U_kin(); + uKinTransLocal += moleculeIter->U_trans(); + uKinRotLocal += moleculeIter->U_rot(); + } } -} +#ifdef ENABLE_MPI + MPI_Allreduce(&uKinLocal, &uKinGlobal, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(&uKinTransLocal, &uKinTransGlobal, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(&uKinRotLocal, &uKinRotGlobal, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); +#else + uKinGlobal = uKinLocal; + uKinTransGlobal = uKinTransLocal; + uKinRotGlobal = uKinRotLocal; +#endif + _uKin_acc += uKinGlobal; + _uKinTrans_acc += uKinTransGlobal; + _uKinRot_acc += uKinRotGlobal; -void ResultWriter::finish(ParticleContainer * /*particleContainer*/, - DomainDecompBase *domainDecomp, Domain * /*domain*/){ + _numSamples++; - if(domainDecomp->getRank() == 0) { - const auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - tm unused{}; - const auto nowStr = std::put_time(localtime_r(&now, &unused), "%c"); - _resultStream << "# ls1 mardyn simulation finished at " << nowStr << endl; - _resultStream.close(); + if ((simstep % _writeFrequency == 0) and (simstep > 0UL)) { + // Only main rank writes data to file + if (domainDecomp->getRank() == 0) { + const string resultfile(_outputPrefix+".res"); + std::ofstream resultStream; + resultStream.open(resultfile.c_str(), std::ios::app); + resultStream << std::setw(10) << simstep << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _simulation.getSimulationTime() + << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _uPot_acc/_numSamples + << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _uKin_acc/_numSamples + << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _uKinTrans_acc/_numSamples + << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _uKinRot_acc/_numSamples + << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _p_acc/_numSamples + << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << domain->cv() + << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << globalNumMolecules + << endl; + resultStream.close(); + } + + // Reset values + _numSamples = 0UL; + _uPot_acc = 0.0F; + _uKin_acc = 0.0F; + _uKinTrans_acc = 0.0F; + _uKinRot_acc = 0.0F; + _p_acc = 0.0F; } } diff --git a/src/io/ResultWriter.h b/src/io/ResultWriter.h index 8c24892fb9..2ff2957371 100644 --- a/src/io/ResultWriter.h +++ b/src/io/ResultWriter.h @@ -1,12 +1,11 @@ #ifndef SRC_IO_RESULTWRITER_H_ #define SRC_IO_RESULTWRITER_H_ -#include -#include - #include "plugins/PluginBase.h" #include "utils/Accumulator.h" +#include + /** @brief Writes thermodynamic properties to a file. * @@ -15,27 +14,27 @@ * The following values are written to the file: * - Simulation time step * - time since the simulation started (dimensionless) - * - Average potential Energy - * - Pressure - * - BetaTrans - * - BetaRot + * - Average potential energy + * - Average kinetic energy + * - Average kinetic translational energy + * - Average kinetic rotational energy + * - Average Pressure + * - Isochoric heat capacity + * - Global number of particles */ class ResultWriter : public PluginBase { public: - ResultWriter() : _U_pot_acc(nullptr), _p_acc(nullptr) {} - ~ResultWriter() { - delete _U_pot_acc; - delete _p_acc; - } + ResultWriter() = default; + ~ResultWriter() override = default; + /** @brief Read in XML configuration for ResultWriter and all its included objects. * * The following xml object structure is handled by this method: * \code{.xml} - INTEGER - STRING - INTEGER + UINTEGER + STRING UINTEGER \endcode @@ -51,8 +50,8 @@ class ResultWriter : public PluginBase { unsigned long simstep ); - void finish(ParticleContainer *particleContainer, - DomainDecompBase *domainDecomp, Domain *domain); + void finish(ParticleContainer* /* particleContainer */, + DomainDecompBase* /* domainDecomp */, Domain* /* domain */) override {} std::string getPluginName() { return std::string("ResultWriter"); @@ -60,12 +59,15 @@ class ResultWriter : public PluginBase { static PluginBase* createInstance() { return new ResultWriter(); } private: - std::ofstream _resultStream; - long _writeFrequency; - int _writePrecision; - std::string _outputPrefix; - Accumulator *_U_pot_acc; - Accumulator *_p_acc; + uint64_t _writeFrequency{1000UL}; + unsigned int _writePrecision{5}; + std::string _outputPrefix{"mardyn"}; + uint64_t _numSamples{0UL}; + double _uPot_acc{0.0F}; + double _uKin_acc{0.0F}; + double _uKinTrans_acc{0.0F}; + double _uKinRot_acc{0.0F}; + double _p_acc{0.0F}; }; #endif // SRC_IO_RESULTWRITER_H_ From 1485f7ccaba1529e1b986b575f72700cd5d1b5c7 Mon Sep 17 00:00:00 2001 From: HomesGH Date: Fri, 5 May 2023 12:20:02 +0200 Subject: [PATCH 04/24] Minor fixes --- src/io/ResultWriter.h | 15 +++++---------- src/molecules/Site.h | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/io/ResultWriter.h b/src/io/ResultWriter.h index 2ff2957371..c01f83ebf6 100644 --- a/src/io/ResultWriter.h +++ b/src/io/ResultWriter.h @@ -39,23 +39,18 @@ class ResultWriter : public PluginBase { \endcode */ - virtual void readXML(XMLfileUnits& xmlconfig); + virtual void readXML(XMLfileUnits& xmlconfig) override; void init(ParticleContainer *particleContainer, - DomainDecompBase *domainDecomp, Domain *domain); + DomainDecompBase *domainDecomp, Domain *domain) override; - void endStep( - ParticleContainer *particleContainer, - DomainDecompBase *domainDecomp, Domain *domain, - unsigned long simstep - ); + void endStep(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, + Domain *domain, unsigned long simstep) override; void finish(ParticleContainer* /* particleContainer */, DomainDecompBase* /* domainDecomp */, Domain* /* domain */) override {} - std::string getPluginName() { - return std::string("ResultWriter"); - } + std::string getPluginName() override {return std::string("ResultWriter");} static PluginBase* createInstance() { return new ResultWriter(); } private: diff --git a/src/molecules/Site.h b/src/molecules/Site.h index 1d4f559f34..2270329c49 100644 --- a/src/molecules/Site.h +++ b/src/molecules/Site.h @@ -128,7 +128,7 @@ class LJcenter : public Site { xmlconfig.getNodeValueReduced("epsilon", _epsilon); xmlconfig.getNodeValueReduced("sigma", _sigma); // Read shifted value and check if its boolean (true/false) to avoid legacy-errors - std::string strShifted; + std::string strShifted = "false"; xmlconfig.getNodeValue("shifted", strShifted); if (strShifted == "true" || strShifted == "false") { xmlconfig.getNodeValue("shifted", _shiftRequested); From 0d151cb9212fb29fc87e7a94bb3d24f004ca6687 Mon Sep 17 00:00:00 2001 From: HomesGH Date: Fri, 19 May 2023 14:49:28 +0200 Subject: [PATCH 05/24] Fixes according to comments --- src/io/ResultWriter.cpp | 55 ++++++++++++++++++++++------------------- src/io/ResultWriter.h | 1 + src/molecules/Site.h | 3 +++ 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/io/ResultWriter.cpp b/src/io/ResultWriter.cpp index 976bc3940c..5b24253196 100644 --- a/src/io/ResultWriter.cpp +++ b/src/io/ResultWriter.cpp @@ -11,13 +11,14 @@ using Log::global_log; void ResultWriter::readXML(XMLfileUnits& xmlconfig) { xmlconfig.getNodeValue("writefrequency", _writeFrequency); - global_log->info() << "[ResultWriter] Write frequency: " << _writeFrequency << endl; + global_log->info() << "[ResultWriter] Write frequency: " << _writeFrequency << std::endl; xmlconfig.getNodeValue("outputprefix", _outputPrefix); - global_log->info() << "[ResultWriter] Output prefix: " << _outputPrefix << endl; + global_log->info() << "[ResultWriter] Output prefix: " << _outputPrefix << std::endl; xmlconfig.getNodeValue("writeprecision", _writePrecision); - global_log->info() << "[ResultWriter] Write precision: " << _writePrecision << endl; + global_log->info() << "[ResultWriter] Write precision: " << _writePrecision << std::endl; + _writeWidth = _writePrecision + 15; // Adding a width of 15 to have enough whitespace between chars } void ResultWriter::init(ParticleContainer * /*particleContainer*/, @@ -28,16 +29,16 @@ void ResultWriter::init(ParticleContainer * /*particleContainer*/, const string resultfile(_outputPrefix+".res"); std::ofstream resultStream; resultStream.open(resultfile.c_str(), std::ios::out); - resultStream << std::setw(10) << "#step" - << std::setw(_writePrecision+15) << "time" - << std::setw(_writePrecision+15) << "U_pot_avg" - << std::setw(_writePrecision+15) << "U_kin_avg" - << std::setw(_writePrecision+15) << "U_kinTrans_avg" - << std::setw(_writePrecision+15) << "U_kinRot_avg" - << std::setw(_writePrecision+15) << "p_avg" - << std::setw(_writePrecision+15) << "c_v" - << std::setw(_writePrecision+15) << "N" - << endl; + resultStream << std::setw(10) << "timestep" + << std::setw(_writeWidth) << "time" + << std::setw(_writeWidth) << "U_pot_avg" + << std::setw(_writeWidth) << "U_kin_avg" + << std::setw(_writeWidth) << "U_kinTrans_avg" + << std::setw(_writeWidth) << "U_kinRot_avg" + << std::setw(_writeWidth) << "p_avg" + << std::setw(_writeWidth) << "c_v" + << std::setw(_writeWidth) << "N" + << std::endl; resultStream.close(); } } @@ -68,9 +69,9 @@ void ResultWriter::endStep(ParticleContainer *particleContainer, DomainDecompBas } } #ifdef ENABLE_MPI - MPI_Allreduce(&uKinLocal, &uKinGlobal, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - MPI_Allreduce(&uKinTransLocal, &uKinTransGlobal, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - MPI_Allreduce(&uKinRotLocal, &uKinRotGlobal, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(&uKinLocal, &uKinGlobal, 1, MPI_DOUBLE, MPI_SUM, domainDecomp->getCommunicator()); + MPI_Allreduce(&uKinTransLocal, &uKinTransGlobal, 1, MPI_DOUBLE, MPI_SUM, domainDecomp->getCommunicator()); + MPI_Allreduce(&uKinRotLocal, &uKinRotGlobal, 1, MPI_DOUBLE, MPI_SUM, domainDecomp->getCommunicator()); #else uKinGlobal = uKinLocal; uKinTransGlobal = uKinTransLocal; @@ -88,15 +89,19 @@ void ResultWriter::endStep(ParticleContainer *particleContainer, DomainDecompBas const string resultfile(_outputPrefix+".res"); std::ofstream resultStream; resultStream.open(resultfile.c_str(), std::ios::app); - resultStream << std::setw(10) << simstep << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _simulation.getSimulationTime() - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _uPot_acc/_numSamples - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _uKin_acc/_numSamples - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _uKinTrans_acc/_numSamples - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _uKinRot_acc/_numSamples - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << _p_acc/_numSamples - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << domain->cv() - << std::setw(_writePrecision+15) << std::scientific << std::setprecision(_writePrecision) << globalNumMolecules - << endl; + auto printOutput = [&](auto value) { + resultStream << std::setw(_writeWidth) << std::scientific << std::setprecision(_writePrecision) << value; + }; + resultStream << std::setw(10) << simstep; + printOutput(_simulation.getSimulationTime()); + printOutput(_uPot_acc/_numSamples); + printOutput(_uKin_acc/_numSamples); + printOutput(_uKinTrans_acc/_numSamples); + printOutput(_uKinRot_acc/_numSamples); + printOutput(_p_acc/_numSamples); + printOutput(domain->cv()); + printOutput(globalNumMolecules); + resultStream << std::endl; resultStream.close(); } diff --git a/src/io/ResultWriter.h b/src/io/ResultWriter.h index c01f83ebf6..87ee2edbfb 100644 --- a/src/io/ResultWriter.h +++ b/src/io/ResultWriter.h @@ -56,6 +56,7 @@ class ResultWriter : public PluginBase { private: uint64_t _writeFrequency{1000UL}; unsigned int _writePrecision{5}; + unsigned int _writeWidth{20}; std::string _outputPrefix{"mardyn"}; uint64_t _numSamples{0UL}; double _uPot_acc{0.0F}; diff --git a/src/molecules/Site.h b/src/molecules/Site.h index 2270329c49..39ecc702ac 100644 --- a/src/molecules/Site.h +++ b/src/molecules/Site.h @@ -9,6 +9,7 @@ #include #include #include +#include using Log::global_log; @@ -130,6 +131,8 @@ class LJcenter : public Site { // Read shifted value and check if its boolean (true/false) to avoid legacy-errors std::string strShifted = "false"; xmlconfig.getNodeValue("shifted", strShifted); + // Convert to lower case to avoid input errors + std::transform(strShifted.begin(), strShifted.end(), strShifted.begin(), [](auto c) { return std::tolower(c); }); if (strShifted == "true" || strShifted == "false") { xmlconfig.getNodeValue("shifted", _shiftRequested); } else { From be04e8b88298bb0eaf9e4ceab5fc6f2be9ca040d Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Wed, 24 May 2023 14:16:07 +0200 Subject: [PATCH 06/24] Avoid second read of xml config --- src/molecules/Site.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/molecules/Site.h b/src/molecules/Site.h index 39ecc702ac..f1b92124e7 100644 --- a/src/molecules/Site.h +++ b/src/molecules/Site.h @@ -134,7 +134,7 @@ class LJcenter : public Site { // Convert to lower case to avoid input errors std::transform(strShifted.begin(), strShifted.end(), strShifted.begin(), [](auto c) { return std::tolower(c); }); if (strShifted == "true" || strShifted == "false") { - xmlconfig.getNodeValue("shifted", _shiftRequested); + std::istringstream(strShifted) >> std::boolalpha >> _shiftRequested; } else { global_log->error() << "Parameter of components has to be either set to 'true' or 'false'" << std::endl; mardyn_exit(1); From a9b4f2208159697df86300b34d4072ed1919e616 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Wed, 24 May 2023 14:19:47 +0200 Subject: [PATCH 07/24] Add missing header files --- src/molecules/Site.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/molecules/Site.h b/src/molecules/Site.h index f1b92124e7..3176d56de0 100644 --- a/src/molecules/Site.h +++ b/src/molecules/Site.h @@ -8,7 +8,9 @@ #include #include #include +#include #include +#include #include using Log::global_log; From 9bd80020307f8e643e5ba3ed3f9e0f9d4f8638d1 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Thu, 22 Jun 2023 11:34:24 +0200 Subject: [PATCH 08/24] Add default values to SpatialProfile plugin as fix --- src/plugins/SpatialProfile.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/plugins/SpatialProfile.h b/src/plugins/SpatialProfile.h index 8fbff06962..db540d5fd2 100644 --- a/src/plugins/SpatialProfile.h +++ b/src/plugins/SpatialProfile.h @@ -48,6 +48,7 @@ class Virial2DProfile; * \code{.xml} * * cylinder (cartesian) + all 1 20 20 @@ -59,7 +60,7 @@ class Virial2DProfile; 1 1 - comparison + profile 1 0 @@ -115,14 +116,14 @@ class SpatialProfile : public PluginBase { VirialProfile* _virialProfile; Virial2DProfile* _virial2DProfile; - unsigned long _writeFrequency; // Write frequency for all profiles -> Length of recording frame before output - unsigned long _initStatistics; // Timesteps to skip at start of the simulation - unsigned long _profileRecordingTimesteps; // Record every Nth timestep during recording frame - long _accumulatedDatasets; // Number of Datasets between output writes / profile resets - std::string _outputPrefix; // File prefix for all profiles - std::string _mode; - std::string _profiledCompString; - unsigned int _profiledComp; + unsigned long _writeFrequency {100}; // Write frequency for all profiles -> Length of recording frame before output + unsigned long _initStatistics {1}; // Timesteps to skip at start of the simulation + unsigned long _profileRecordingTimesteps {1UL}; // Record every Nth timestep during recording frame + long _accumulatedDatasets {0}; // Number of Datasets between output writes / profile resets + std::string _outputPrefix {"profile"}; // File prefix for all profiles + std::string _mode {"cylinder"}; + std::string _profiledCompString {"all"}; + unsigned int _profiledComp {0}; unsigned long _uIDs; //!< Total number of unique IDs with the selected Grid. This is the number of total bins in the Sampling grid. From 7610d51504a94e9e13085eca9ccc3442a7b195fa Mon Sep 17 00:00:00 2001 From: HomesGH Date: Mon, 24 Jul 2023 15:20:21 +0200 Subject: [PATCH 09/24] Use global calc. values in ResultWriter plugin --- src/Domain.cpp | 16 ++++++++-------- src/Domain.h | 13 ++++++++++++- src/io/ResultWriter.cpp | 37 ++++--------------------------------- src/io/ResultWriter.h | 3 +-- 4 files changed, 25 insertions(+), 44 deletions(-) diff --git a/src/Domain.cpp b/src/Domain.cpp index 27a2bb4333..41cfba701d 100644 --- a/src/Domain.cpp +++ b/src/Domain.cpp @@ -221,33 +221,33 @@ void Domain::calculateGlobalValues( domainDecomp->collCommAppendUnsLong(numMolecules); domainDecomp->collCommAppendUnsLong(rotDOF); domainDecomp->collCommAllreduceSumAllowPrevious(); - summv2 = domainDecomp->collCommGetDouble(); - sumIw2 = domainDecomp->collCommGetDouble(); + _globalsummv2 = domainDecomp->collCommGetDouble(); + _globalsumIw2 = domainDecomp->collCommGetDouble(); numMolecules = domainDecomp->collCommGetUnsLong(); rotDOF = domainDecomp->collCommGetUnsLong(); domainDecomp->collCommFinalize(); global_log->debug() << "[ thermostat ID " << thermit->first << "]\tN = " << numMolecules << "\trotDOF = " << rotDOF - << "\tmv2 = " << summv2 << "\tIw2 = " << sumIw2 << endl; + << "\tmv2 = " << _globalsummv2 << "\tIw2 = " << _globalsumIw2 << endl; this->_universalThermostatN[thermit->first] = numMolecules; this->_universalRotationalDOF[thermit->first] = rotDOF; - mardyn_assert((summv2 > 0.0) || (numMolecules == 0)); + mardyn_assert((_globalsummv2 > 0.0) || (numMolecules == 0)); /* calculate the temperature of the entire system */ if(numMolecules > 0) _globalTemperatureMap[thermit->first] = - (summv2 + sumIw2) / (double)(3*numMolecules + rotDOF); + (_globalsummv2 + _globalsumIw2) / (double)(3*numMolecules + rotDOF); else _globalTemperatureMap[thermit->first] = _universalTargetTemperature[thermit->first]; double Ti = Tfactor * _universalTargetTemperature[thermit->first]; if((Ti > 0.0) && (numMolecules > 0) && !_universalNVE) { - _universalBTrans[thermit->first] = pow(3.0*numMolecules*Ti / summv2, 0.4); - if( sumIw2 == 0.0 ) + _universalBTrans[thermit->first] = pow(3.0*numMolecules*Ti / _globalsummv2, 0.4); + if( _globalsumIw2 == 0.0 ) _universalBRot[thermit->first] = 1.0; else - _universalBRot[thermit->first] = pow(rotDOF*Ti / sumIw2, 0.4); + _universalBRot[thermit->first] = pow(rotDOF*Ti / _globalsumIw2, 0.4); } else { diff --git a/src/Domain.h b/src/Domain.h index 4f340fc33b..59d9751a8a 100644 --- a/src/Domain.h +++ b/src/Domain.h @@ -219,7 +219,14 @@ class Domain { //! Before this method is called, it has to be sure that the //! global potential has been calculated (method calculateGlobalValues) double getAverageGlobalUpot(); - double getGlobalUpot() const; + double getGlobalUpot() const; + + //! @brief get the global kinetic energy + //! + //! Before this method is called, it has to be sure that the + //! global energies has been calculated (method calculateGlobalValues) + double getGlobalUkinTrans() { return 0.5*_globalsummv2; } + double getGlobalUkinRot() { return 0.5*_globalsumIw2; } //! by Stefan Becker: return the average global potential of the fluid-fluid and fluid-solid interaction (but NOT solid-solid interaction) double getAverageGlobalUpotCSpec(); @@ -415,6 +422,10 @@ class Domain { double _globalUpot; //! global component specific potential (fluid-fluid and fluid-solid but NOT solid-solid) double _globalUpotCspecif; + //! global two times translational kinetic energy + double _globalsummv2; + //! global two times rotational kinetic energy + double _globalsumIw2; //! global virial double _globalVirial; //! global density diff --git a/src/io/ResultWriter.cpp b/src/io/ResultWriter.cpp index 5b24253196..83a796084c 100644 --- a/src/io/ResultWriter.cpp +++ b/src/io/ResultWriter.cpp @@ -50,36 +50,8 @@ void ResultWriter::endStep(ParticleContainer *particleContainer, DomainDecompBas _uPot_acc += domain->getGlobalUpot(); _p_acc += domain->getGlobalPressure(); - - double uKinLocal = 0.0F; - double uKinGlobal = 0.0F; - double uKinTransLocal = 0.0F; - double uKinTransGlobal = 0.0F; - double uKinRotLocal = 0.0F; - double uKinRotGlobal = 0.0F; - #if defined(_OPENMP) - #pragma omp parallel reduction(+:uKinLocal,uKinTransLocal,uKinRotLocal) - #endif - { - for (auto moleculeIter = particleContainer->iterator(ParticleIterator::ONLY_INNER_AND_BOUNDARY); - moleculeIter.isValid(); ++moleculeIter) { - uKinLocal += moleculeIter->U_kin(); - uKinTransLocal += moleculeIter->U_trans(); - uKinRotLocal += moleculeIter->U_rot(); - } - } -#ifdef ENABLE_MPI - MPI_Allreduce(&uKinLocal, &uKinGlobal, 1, MPI_DOUBLE, MPI_SUM, domainDecomp->getCommunicator()); - MPI_Allreduce(&uKinTransLocal, &uKinTransGlobal, 1, MPI_DOUBLE, MPI_SUM, domainDecomp->getCommunicator()); - MPI_Allreduce(&uKinRotLocal, &uKinRotGlobal, 1, MPI_DOUBLE, MPI_SUM, domainDecomp->getCommunicator()); -#else - uKinGlobal = uKinLocal; - uKinTransGlobal = uKinTransLocal; - uKinRotGlobal = uKinRotLocal; -#endif - _uKin_acc += uKinGlobal; - _uKinTrans_acc += uKinTransGlobal; - _uKinRot_acc += uKinRotGlobal; + _uKinTrans_acc += domain->getGlobalUkinTrans(); + _uKinRot_acc += domain->getGlobalUkinRot(); _numSamples++; @@ -95,7 +67,7 @@ void ResultWriter::endStep(ParticleContainer *particleContainer, DomainDecompBas resultStream << std::setw(10) << simstep; printOutput(_simulation.getSimulationTime()); printOutput(_uPot_acc/_numSamples); - printOutput(_uKin_acc/_numSamples); + printOutput((_uKinTrans_acc+_uKinRot_acc)/_numSamples); printOutput(_uKinTrans_acc/_numSamples); printOutput(_uKinRot_acc/_numSamples); printOutput(_p_acc/_numSamples); @@ -108,9 +80,8 @@ void ResultWriter::endStep(ParticleContainer *particleContainer, DomainDecompBas // Reset values _numSamples = 0UL; _uPot_acc = 0.0F; - _uKin_acc = 0.0F; + _p_acc = 0.0F; _uKinTrans_acc = 0.0F; _uKinRot_acc = 0.0F; - _p_acc = 0.0F; } } diff --git a/src/io/ResultWriter.h b/src/io/ResultWriter.h index 87ee2edbfb..41852befda 100644 --- a/src/io/ResultWriter.h +++ b/src/io/ResultWriter.h @@ -60,10 +60,9 @@ class ResultWriter : public PluginBase { std::string _outputPrefix{"mardyn"}; uint64_t _numSamples{0UL}; double _uPot_acc{0.0F}; - double _uKin_acc{0.0F}; + double _p_acc{0.0F}; double _uKinTrans_acc{0.0F}; double _uKinRot_acc{0.0F}; - double _p_acc{0.0F}; }; #endif // SRC_IO_RESULTWRITER_H_ From 93ab85cde6f478461589d9cafdd08f227464ddc6 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Fri, 29 Sep 2023 14:06:18 +0200 Subject: [PATCH 10/24] Use correct quaternion identity --- src/molecules/AutoPasSimpleMolecule.h | 9 +++++---- src/molecules/FullMolecule.h | 2 +- src/molecules/MoleculeRMM.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/molecules/AutoPasSimpleMolecule.h b/src/molecules/AutoPasSimpleMolecule.h index ab4cb31415..bd5900bd96 100644 --- a/src/molecules/AutoPasSimpleMolecule.h +++ b/src/molecules/AutoPasSimpleMolecule.h @@ -17,10 +17,11 @@ */ class AutoPasSimpleMolecule final : public MoleculeInterface, public autopas::ParticleFP64 { public: - explicit AutoPasSimpleMolecule(unsigned long id = 0, Component* component = nullptr, double rx = 0., double ry = 0., - double rz = 0., double vx = 0., double vy = 0., double vz = 0., double q0 = 1., - double q1 = 1., double q2 = 0., double q3 = 0., double Dx = 0., double Dy = 0., - double Dz = 0.); + explicit AutoPasSimpleMolecule(unsigned long id = 0, Component* component = nullptr, + double rx = 0., double ry = 0., double rz = 0., + double vx = 0., double vy = 0., double vz = 0., + double q0 = 1., double q1 = 0., double q2 = 0., double q3 = 0., + double Dx = 0., double Dy = 0., double Dz = 0.); AutoPasSimpleMolecule(const AutoPasSimpleMolecule& m) = default; diff --git a/src/molecules/FullMolecule.h b/src/molecules/FullMolecule.h index a834e221ce..edaa2f416d 100644 --- a/src/molecules/FullMolecule.h +++ b/src/molecules/FullMolecule.h @@ -25,7 +25,7 @@ class FullMolecule : public MoleculeInterface { FullMolecule(unsigned long id = 0, Component *component = nullptr, double rx = 0., double ry = 0., double rz = 0., double vx = 0., double vy = 0., double vz = 0., - double q0 = 1., double q1 = 1., double q2 = 0., double q3 = 0., + double q0 = 1., double q1 = 0., double q2 = 0., double q3 = 0., double Dx = 0., double Dy = 0., double Dz = 0. ); FullMolecule(const FullMolecule& m); diff --git a/src/molecules/MoleculeRMM.h b/src/molecules/MoleculeRMM.h index 6ece45d5b6..5185ecd667 100644 --- a/src/molecules/MoleculeRMM.h +++ b/src/molecules/MoleculeRMM.h @@ -21,7 +21,7 @@ class MoleculeRMM : public MoleculeInterface { MoleculeRMM(unsigned long id = 0, Component *component = nullptr, double rx = 0., double ry = 0., double rz = 0., double vx = 0., double vy = 0., double vz = 0., - double = 0., double = 0., double = 0., double = 0., /*q0, q1, q2, q3*/ + double = 1., double = 0., double = 0., double = 0., /*q0, q1, q2, q3*/ double = 0., double = 0., double = 0. /*Dx, Dy, Dz*/ ) { _state = STORAGE_AOS; From 845b160608485d5dda8cf9ee3155fa07033fd59b Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Fri, 29 Sep 2023 14:08:14 +0200 Subject: [PATCH 11/24] AutoPas writes full checkpoint for compatibility --- src/molecules/AutoPasSimpleMolecule.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/molecules/AutoPasSimpleMolecule.h b/src/molecules/AutoPasSimpleMolecule.h index bd5900bd96..aae8e51e97 100644 --- a/src/molecules/AutoPasSimpleMolecule.h +++ b/src/molecules/AutoPasSimpleMolecule.h @@ -292,13 +292,24 @@ class AutoPasSimpleMolecule final : public MoleculeInterface, public autopas::Pa } void writeBinary(std::ostream& ostrm) const override { + unsigned int cid = _component->ID() + 1; + double zero = 0.0; + double one = 1.0; ostrm.write(reinterpret_cast(&_id), 8); + ostrm.write(reinterpret_cast(&cid), 4); ostrm.write(reinterpret_cast(&(_r[0])), 8); ostrm.write(reinterpret_cast(&(_r[1])), 8); ostrm.write(reinterpret_cast(&(_r[2])), 8); ostrm.write(reinterpret_cast(&(_v[0])), 8); ostrm.write(reinterpret_cast(&(_v[1])), 8); ostrm.write(reinterpret_cast(&(_v[2])), 8); + ostrm.write(reinterpret_cast(&one), 8); // qw + ostrm.write(reinterpret_cast(&zero), 8); // qx + ostrm.write(reinterpret_cast(&zero), 8); // qy + ostrm.write(reinterpret_cast(&zero), 8); // qz + ostrm.write(reinterpret_cast(&zero), 8); // Lx + ostrm.write(reinterpret_cast(&zero), 8); // Ly + ostrm.write(reinterpret_cast(&zero), 8); // Lz } void clearFM() override { From 0e11435aef92a5a286ae198323b89549158b1c37 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Fri, 29 Sep 2023 14:16:53 +0200 Subject: [PATCH 12/24] Undo AutoPas checkpoint writing --- src/molecules/AutoPasSimpleMolecule.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/molecules/AutoPasSimpleMolecule.h b/src/molecules/AutoPasSimpleMolecule.h index aae8e51e97..bd5900bd96 100644 --- a/src/molecules/AutoPasSimpleMolecule.h +++ b/src/molecules/AutoPasSimpleMolecule.h @@ -292,24 +292,13 @@ class AutoPasSimpleMolecule final : public MoleculeInterface, public autopas::Pa } void writeBinary(std::ostream& ostrm) const override { - unsigned int cid = _component->ID() + 1; - double zero = 0.0; - double one = 1.0; ostrm.write(reinterpret_cast(&_id), 8); - ostrm.write(reinterpret_cast(&cid), 4); ostrm.write(reinterpret_cast(&(_r[0])), 8); ostrm.write(reinterpret_cast(&(_r[1])), 8); ostrm.write(reinterpret_cast(&(_r[2])), 8); ostrm.write(reinterpret_cast(&(_v[0])), 8); ostrm.write(reinterpret_cast(&(_v[1])), 8); ostrm.write(reinterpret_cast(&(_v[2])), 8); - ostrm.write(reinterpret_cast(&one), 8); // qw - ostrm.write(reinterpret_cast(&zero), 8); // qx - ostrm.write(reinterpret_cast(&zero), 8); // qy - ostrm.write(reinterpret_cast(&zero), 8); // qz - ostrm.write(reinterpret_cast(&zero), 8); // Lx - ostrm.write(reinterpret_cast(&zero), 8); // Ly - ostrm.write(reinterpret_cast(&zero), 8); // Lz } void clearFM() override { From d729d6f1280e1df0c6021f12462498cd2b19fb60 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:25:58 +0200 Subject: [PATCH 13/24] Change default version of MMPLD in MMPLDWriter --- src/io/MmpldWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io/MmpldWriter.cpp b/src/io/MmpldWriter.cpp index 6b26c11f01..f2ba1ad2e9 100644 --- a/src/io/MmpldWriter.cpp +++ b/src/io/MmpldWriter.cpp @@ -32,7 +32,7 @@ // default version to use for mmpld format writing. possible values: 100 or 102 -#define MMPLD_DEFAULT_VERSION 100 +#define MMPLD_DEFAULT_VERSION 102 #define MMPLD_HEADER_DATA_SIZE 60 #define MMPLD_SEEK_TABLE_OFFSET MMPLD_HEADER_DATA_SIZE From d4e5c8f2c0dfbacb84459db33e7d1e952cc1d645 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Fri, 20 Oct 2023 19:08:44 +0200 Subject: [PATCH 14/24] Tentative fix of MMPLDWriter --- src/io/MmpldWriter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/io/MmpldWriter.cpp b/src/io/MmpldWriter.cpp index f2ba1ad2e9..a1a4273f65 100644 --- a/src/io/MmpldWriter.cpp +++ b/src/io/MmpldWriter.cpp @@ -32,7 +32,7 @@ // default version to use for mmpld format writing. possible values: 100 or 102 -#define MMPLD_DEFAULT_VERSION 102 +#define MMPLD_DEFAULT_VERSION 100 #define MMPLD_HEADER_DATA_SIZE 60 #define MMPLD_SEEK_TABLE_OFFSET MMPLD_HEADER_DATA_SIZE @@ -82,7 +82,7 @@ void MmpldWriter::readXML(XMLfileUnits& xmlconfig) global_log->info() << "[MMPLD Writer] Split files every " << _numFramesPerFile << "th frame."<< std::endl; global_log->info() << "[MMPLD Writer] Write buffer size: " << _writeBufferSize << " Byte" << std::endl; - int mmpldversion = 100; + int mmpldversion = MMPLD_DEFAULT_VERSION; xmlconfig.getNodeValue("mmpldversion", mmpldversion); _mmpldversion = mmpldversion; switch(_mmpldversion) { @@ -332,7 +332,7 @@ void MmpldWriter::finish(ParticleContainer * /*particleContainer*/, DomainDecomp MPI_File_get_position(_mpifh, &endPosition); uint64_t seektablePos = MMPLD_HEADER_DATA_SIZE + (_frameCount * sizeof(uint64_t)); - uint64_t seekPosition = htole64(endPosition); /** @todo end of frame offset may not be identical to file end! */ + uint64_t seekPosition = std::max(_seekTable.back(), htole64(endPosition)); /** @todo end of frame offset may not be identical to file end! */ MPI_Status status; MPI_File_write_at(_mpifh, seektablePos, &seekPosition, sizeof(seekPosition), MPI_BYTE, &status); uint32_t frameCount = htole32(_frameCount); // set final number of frames From 5629359521c108812ff24fae5a10ad53a7f1b938 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:10:41 +0200 Subject: [PATCH 15/24] Delete finish() in MMPLDWriter as it does wrong stuff --- src/io/MmpldWriter.cpp | 28 ---------------------------- src/io/MmpldWriter.h | 12 ++++++------ 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/src/io/MmpldWriter.cpp b/src/io/MmpldWriter.cpp index a1a4273f65..30532f7ae8 100644 --- a/src/io/MmpldWriter.cpp +++ b/src/io/MmpldWriter.cpp @@ -319,34 +319,6 @@ void MmpldWriter::endStep(ParticleContainer *particleContainer, write_frame(particleContainer, domainDecomp); } -void MmpldWriter::finish(ParticleContainer * /*particleContainer*/, DomainDecompBase *domainDecomp, Domain * /*domain*/) -{ - string filename = getOutputFilename(); - -#ifdef ENABLE_MPI - int rank = domainDecomp->getRank(); - if (rank == 0){ - MPI_File_open(MPI_COMM_WORLD, const_cast(filename.c_str()), MPI_MODE_WRONLY, MPI_INFO_NULL, &_mpifh); - MPI_File_seek(_mpifh, 0, MPI_SEEK_END); - MPI_Offset endPosition; - MPI_File_get_position(_mpifh, &endPosition); - - uint64_t seektablePos = MMPLD_HEADER_DATA_SIZE + (_frameCount * sizeof(uint64_t)); - uint64_t seekPosition = std::max(_seekTable.back(), htole64(endPosition)); /** @todo end of frame offset may not be identical to file end! */ - MPI_Status status; - MPI_File_write_at(_mpifh, seektablePos, &seekPosition, sizeof(seekPosition), MPI_BYTE, &status); - uint32_t frameCount = htole32(_frameCount); // set final number of frames - // 8: frame count position in file header - MPI_File_write_at(_mpifh, 8, &frameCount, sizeof(frameCount), MPI_BYTE, &status); - MPI_File_close(&_mpifh); - }else{ - MPI_File_open(MPI_COMM_WORLD, const_cast(filename.c_str()), MPI_MODE_WRONLY, MPI_INFO_NULL, &_mpifh); - MPI_File_close(&_mpifh); - } - _seekTable.clear(); -#endif -} - void MmpldWriter::InitSphereData() { if(_bInitSphereData == ISD_READ_FROM_XML) diff --git a/src/io/MmpldWriter.h b/src/io/MmpldWriter.h index 5e559fc354..4be227c74d 100644 --- a/src/io/MmpldWriter.h +++ b/src/io/MmpldWriter.h @@ -63,19 +63,19 @@ class MmpldWriter : public PluginBase void InitSphereData(); public: - void readXML(XMLfileUnits& xmlconfig); + void readXML(XMLfileUnits& xmlconfig) override; void init(ParticleContainer *particleContainer, - DomainDecompBase *domainDecomp, Domain *domain); + DomainDecompBase *domainDecomp, Domain *domain) override; void endStep( ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain, - unsigned long simstep - ); + unsigned long simstep) override; + void finish(ParticleContainer *particleContainer, - DomainDecompBase *domainDecomp, Domain *domain); + DomainDecompBase *domainDecomp, Domain *domain) override {}; - std::string getPluginName() { + std::string getPluginName() override { return std::string("MmpldWriter"); } static PluginBase* createInstance() { return new MmpldWriter(); } From 753d6c17fd98f395af4fb430db49cdf428d14e77 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:14:29 +0200 Subject: [PATCH 16/24] Fix set of initial simulation time Until now, it was updated too late --- src/Simulation.cpp | 2 +- src/Simulation.h | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index c96310caaa..311222ad27 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -931,7 +931,7 @@ void Simulation::prepare_start() { _ensemble->prepare_start(); - _simstep = _initSimulation = (unsigned long) round(_simulationTime / _integrator->getTimestepLength() ); + _simstep = _initSimulation; global_log->info() << "Set initial time step to start from to " << _initSimulation << endl; global_log->info() << "System initialised with " << _domain->getglobalNumMolecules(true, _moleculeContainer, _domainDecomposition) << " molecules." << endl; diff --git a/src/Simulation.h b/src/Simulation.h index a81ea891c6..fd12f75809 100644 --- a/src/Simulation.h +++ b/src/Simulation.h @@ -5,6 +5,7 @@ #include #include "ensemble/CavityEnsemble.h" +#include "integrators/Integrator.h" #include "io/TimerProfiler.h" #include "thermostats/VelocityScalingThermostat.h" #include "utils/FixedSizeQueue.h" @@ -279,7 +280,11 @@ class Simulation { void initStatistics(unsigned long t) { this->_initStatistics = t; } unsigned long getInitStatistics() const { return this->_initStatistics; } - void setSimulationTime(double curtime) { _simulationTime = curtime; } + void setSimulationTime(double curtime) { + _simulationTime = curtime; + // Also change corresponding initial timestep + _initSimulation = (unsigned long) round(_simulationTime / _integrator->getTimestepLength() ); + } void advanceSimulationTime(double timestep) { _simulationTime += timestep; } double getSimulationTime() { return _simulationTime; } From 922b0cb15d309c7cf6b531e88d77df27c126aca9 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:29:45 +0200 Subject: [PATCH 17/24] Minor fixes regarding setSimulationTime() --- src/Simulation.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 311222ad27..ecf1baca76 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -194,7 +194,8 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { /* run section */ if(xmlconfig.changecurrentnode("run")) { xmlconfig.getNodeValueReduced("currenttime", _simulationTime); - global_log->info() << "Simulation start time: " << _simulationTime << endl; + setSimulationTime(_simulationTime); + global_log->info() << "Simulation start time: " << getSimulationTime() << endl; /* steps */ xmlconfig.getNodeValue("equilibration/steps", _initStatistics); global_log->info() << "Number of equilibration steps: " << _initStatistics << endl; @@ -656,7 +657,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { bool ignoreCheckpointTime = false; if(xmlconfig.getNodeValue("ignoreCheckpointTime", ignoreCheckpointTime)) { if(ignoreCheckpointTime) - _simulationTime = 0; + setSimulationTime(0); } } From f81d9198991f5ed26ab9d8915323f8e25f42cca8 Mon Sep 17 00:00:00 2001 From: HomesGH Date: Tue, 24 Oct 2023 19:05:14 +0200 Subject: [PATCH 18/24] Add std:: and Log:: --- src/molecules/Component.cpp | 10 +++++----- src/molecules/Site.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/molecules/Component.cpp b/src/molecules/Component.cpp index 0433d8dca9..686cb82a4c 100644 --- a/src/molecules/Component.cpp +++ b/src/molecules/Component.cpp @@ -51,18 +51,18 @@ void Component::readXML(XMLfileUnits& xmlconfig) { LJcenter ljSite; ljSite.readXML(xmlconfig); addLJcenter(ljSite); - global_log->info() << "sigma = " << ljSite.sigma() << " ; epsilon = " << ljSite.eps() - << " ; mass = " << ljSite.m() << " ; shifted = " << ljSite.shiftRequested() << endl; + Log::global_log->info() << "sigma = " << ljSite.sigma() << " ; epsilon = " << ljSite.eps() + << " ; mass = " << ljSite.m() << " ; shifted = " << ljSite.shiftRequested() << std::endl; } else if (siteType == "Charge") { Charge chargeSite; chargeSite.readXML(xmlconfig); addCharge(chargeSite); - global_log->info() << "charge = " << chargeSite.q() << endl; + Log::global_log->info() << "charge = " << chargeSite.q() << std::endl; } else if (siteType == "Dipole") { Dipole dipoleSite; dipoleSite.readXML(xmlconfig); addDipole(dipoleSite); - global_log->info() << "dipoleMoment = " << dipoleSite.absMy() << endl; + Log::global_log->info() << "dipoleMoment = " << dipoleSite.absMy() << std::endl; } else if (siteType == "Stockmayer") { _isStockmayer = true; _rot_dof = 2; @@ -79,7 +79,7 @@ void Component::readXML(XMLfileUnits& xmlconfig) { Quadrupole quadrupoleSite; quadrupoleSite.readXML(xmlconfig); addQuadrupole(quadrupoleSite); - global_log->info() << "quadrupoleMoment = " << quadrupoleSite.absQ() << endl; + Log::global_log->info() << "quadrupoleMoment = " << quadrupoleSite.absQ() << std::endl; } else if (siteType == "Tersoff") { Log::global_log->error() << "Tersoff no longer supported:" << siteType << std::endl; Simulation::exit(-1); diff --git a/src/molecules/Site.h b/src/molecules/Site.h index d54d8dc3d6..fe77726401 100644 --- a/src/molecules/Site.h +++ b/src/molecules/Site.h @@ -138,7 +138,7 @@ class LJcenter : public Site { if (strShifted == "true" || strShifted == "false") { std::istringstream(strShifted) >> std::boolalpha >> _shiftRequested; } else { - global_log->error() << "Parameter of components has to be either set to 'true' or 'false'" << std::endl; + Log::global_log->error() << "Parameter of components has to be either set to 'true' or 'false'" << std::endl; mardyn_exit(1); } } From 5d4f89dc6a568cc5fbf2134fdba393800aabe5e6 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Tue, 24 Oct 2023 20:14:59 +0200 Subject: [PATCH 19/24] Fix in init of simulation steps --- src/Simulation.cpp | 4 +++- src/Simulation.h | 6 +----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 2d9b29db66..4484f1ef9c 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -195,7 +195,6 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { /* run section */ if(xmlconfig.changecurrentnode("run")) { xmlconfig.getNodeValueReduced("currenttime", _simulationTime); - setSimulationTime(_simulationTime); Log::global_log->info() << "Simulation start time: " << getSimulationTime() << std::endl; /* steps */ xmlconfig.getNodeValue("equilibration/steps", _initStatistics); @@ -676,6 +675,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { } xmlconfig.changecurrentnode(oldpath); + + // _simulationTime might be updated by readers -> also update _initSimulation + _initSimulation = (unsigned long) round(_simulationTime / _integrator->getTimestepLength() ); } diff --git a/src/Simulation.h b/src/Simulation.h index 1bbed84304..1b98dc77ba 100644 --- a/src/Simulation.h +++ b/src/Simulation.h @@ -281,11 +281,7 @@ class Simulation { void initStatistics(unsigned long t) { this->_initStatistics = t; } unsigned long getInitStatistics() const { return this->_initStatistics; } - void setSimulationTime(double curtime) { - _simulationTime = curtime; - // Also change corresponding initial timestep - _initSimulation = (unsigned long) round(_simulationTime / _integrator->getTimestepLength() ); - } + void setSimulationTime(double curtime) { _simulationTime = curtime; } void advanceSimulationTime(double timestep) { _simulationTime += timestep; } double getSimulationTime() { return _simulationTime; } From 6351286b9d378ca1fa623fe4576e36bdec217d94 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Tue, 24 Oct 2023 20:17:28 +0200 Subject: [PATCH 20/24] delete unnecessary header --- src/Simulation.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Simulation.h b/src/Simulation.h index 1b98dc77ba..93055edfd2 100644 --- a/src/Simulation.h +++ b/src/Simulation.h @@ -4,7 +4,6 @@ #include #include -#include "integrators/Integrator.h" #include "io/TimerProfiler.h" #include "thermostats/VelocityScalingThermostat.h" #include "utils/FixedSizeQueue.h" From 981cddfbf729484d9b2e30adb4019de07b166076 Mon Sep 17 00:00:00 2001 From: HomesGH Date: Wed, 25 Oct 2023 17:27:43 +0200 Subject: [PATCH 21/24] Parse boolean and check input type --- src/molecules/Site.h | 12 +----------- src/utils/xmlfile.cpp | 32 +++++++++++++++----------------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/molecules/Site.h b/src/molecules/Site.h index fe77726401..efa82a6174 100644 --- a/src/molecules/Site.h +++ b/src/molecules/Site.h @@ -130,17 +130,7 @@ class LJcenter : public Site { Site::readXML(xmlconfig); xmlconfig.getNodeValueReduced("epsilon", _epsilon); xmlconfig.getNodeValueReduced("sigma", _sigma); - // Read shifted value and check if its boolean (true/false) to avoid legacy-errors - std::string strShifted = "false"; - xmlconfig.getNodeValue("shifted", strShifted); - // Convert to lower case to avoid input errors - std::transform(strShifted.begin(), strShifted.end(), strShifted.begin(), [](auto c) { return std::tolower(c); }); - if (strShifted == "true" || strShifted == "false") { - std::istringstream(strShifted) >> std::boolalpha >> _shiftRequested; - } else { - Log::global_log->error() << "Parameter of components has to be either set to 'true' or 'false'" << std::endl; - mardyn_exit(1); - } + xmlconfig.getNodeValue("shifted", _shiftRequested); } /// write to stream diff --git a/src/utils/xmlfile.cpp b/src/utils/xmlfile.cpp index c2348e5e4b..91c9a477b1 100644 --- a/src/utils/xmlfile.cpp +++ b/src/utils/xmlfile.cpp @@ -589,23 +589,21 @@ template<> bool XMLfile::Node::getValue(bool& value) const { std::string v; bool found=getValue(v); - if(found) - { - int i=atoi(v.c_str()); - if(i!=0) - { - /* found integer value unequal 0 */ - value=true; - } - else - { - /* remove white spaces */ - v.erase( std::remove_if( v.begin(), v.end(), ::isspace ), v.end() ); - /* convert to upper case letters */ - std::transform(v.begin(), v.end(), v.begin(), ::toupper); - value=(v == "TRUE" || v == "YES" || v == "ON"); - } - } + if (found) { + // Remove white spaces + v.erase(std::remove_if(v.begin(), v.end(), ::isspace), v.end()); + // Convert to upper case letters + std::transform(v.begin(), v.end(), v.begin(), ::toupper); + + if (v == "TRUE" || v == "YES" || v == "ON" || v == "1") { + value = true; + } else if (v == "FALSE" || v == "NO" || v == "OFF" || v == "0") { + value = false; + } else { + std::cerr << "ERROR parsing \"" << v << "\" from xml file to boolean" << std::endl; + Simulation::exit(1); + } + } return found; } From 78db2ee6e013d7302ce8163c46212083840fc995 Mon Sep 17 00:00:00 2001 From: HomesGH Date: Wed, 25 Oct 2023 21:46:28 +0200 Subject: [PATCH 22/24] Add info to error message --- src/utils/xmlfile.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/utils/xmlfile.cpp b/src/utils/xmlfile.cpp index 91c9a477b1..1a3e2529b7 100644 --- a/src/utils/xmlfile.cpp +++ b/src/utils/xmlfile.cpp @@ -590,20 +590,20 @@ template<> bool XMLfile::Node::getValue(bool& value) const std::string v; bool found=getValue(v); if (found) { - // Remove white spaces - v.erase(std::remove_if(v.begin(), v.end(), ::isspace), v.end()); - // Convert to upper case letters - std::transform(v.begin(), v.end(), v.begin(), ::toupper); - - if (v == "TRUE" || v == "YES" || v == "ON" || v == "1") { - value = true; - } else if (v == "FALSE" || v == "NO" || v == "OFF" || v == "0") { - value = false; - } else { - std::cerr << "ERROR parsing \"" << v << "\" from xml file to boolean" << std::endl; - Simulation::exit(1); - } - } + // Remove white spaces + v.erase(std::remove_if(v.begin(), v.end(), ::isspace), v.end()); + // Convert to upper case letters + std::transform(v.begin(), v.end(), v.begin(), ::toupper); + + if (v == "TRUE" || v == "YES" || v == "ON" || v == "1") { + value = true; + } else if (v == "FALSE" || v == "NO" || v == "OFF" || v == "0") { + value = false; + } else { + std::cerr << "ERROR parsing \"" << v << "\" to boolean from tag \"<" << name() << ">\" in xml file" << std::endl; + Simulation::exit(1); + } + } return found; } From 43c1a2f0b2669129d8e21e8b317620b9d790e88d Mon Sep 17 00:00:00 2001 From: HomesGH Date: Wed, 25 Oct 2023 21:57:21 +0200 Subject: [PATCH 23/24] Realize suggestions --- src/Domain.h | 4 ++-- src/io/ResultWriter.cpp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Domain.h b/src/Domain.h index c979731fe0..be8689605f 100644 --- a/src/Domain.h +++ b/src/Domain.h @@ -422,9 +422,9 @@ class Domain { double _globalUpot; //! global component specific potential (fluid-fluid and fluid-solid but NOT solid-solid) double _globalUpotCspecif; - //! global two times translational kinetic energy + //! global translational kinetic energy times two double _globalsummv2; - //! global two times rotational kinetic energy + //! global rotational kinetic energy times two double _globalsumIw2; //! global virial double _globalVirial; diff --git a/src/io/ResultWriter.cpp b/src/io/ResultWriter.cpp index 4b46f96ce6..032e7b1294 100644 --- a/src/io/ResultWriter.cpp +++ b/src/io/ResultWriter.cpp @@ -11,6 +11,10 @@ void ResultWriter::readXML(XMLfileUnits& xmlconfig) { xmlconfig.getNodeValue("writefrequency", _writeFrequency); Log::global_log->info() << "[ResultWriter] Write frequency: " << _writeFrequency << std::endl; + if (_writeFrequency == 0) { + Log::global_log->error() << "[ResultWriter] Write frequency must be a positive nonzero integer, but is " << _writeFrequency << std::endl; + Simulation::exit(-1); + } xmlconfig.getNodeValue("outputprefix", _outputPrefix); Log::global_log->info() << "[ResultWriter] Output prefix: " << _outputPrefix << std::endl; From 0f8092e6329dc537d166008ec378c6ad7af36709 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:14:45 +0200 Subject: [PATCH 24/24] Add some basic checks for xml parsing --- src/utils/xmlfile.cpp | 53 +++++++++++++------------------------------ src/utils/xmlfile.h | 4 ---- 2 files changed, 16 insertions(+), 41 deletions(-) diff --git a/src/utils/xmlfile.cpp b/src/utils/xmlfile.cpp index 1a3e2529b7..dc88868cb4 100644 --- a/src/utils/xmlfile.cpp +++ b/src/utils/xmlfile.cpp @@ -532,59 +532,39 @@ template bool XMLfile::Node::getValue(T& value) const { if(m_xmlnode) { - //value=T(m_xmlnode->value()); std::stringstream ss(m_xmlnode->value()); - ss>>value; + ss >> value; + // Check if input has correct sign + if (std::is_unsigned_v) { + if (ss.str().at(0) == '-') { + std::cerr << "ERROR parsing \"" << ss.str() << "\" to data type " << typeid(T).name() << " from tag \"<" << name() << ">\" in xml file" << std::endl; + std::cerr << "The tag contains a negative value but an unsigned value was expected." << std::endl; + Simulation::exit(1); + } + } + // Check if the entire string was consumed + if (!ss.eof() || ss.fail()) { + std::cerr << "ERROR parsing all chars of \"" << ss.str() << "\" from tag \"<" << name() << ">\" in xml file" << std::endl; + std::cerr << "This might be the result of using a float while an integer is expected." << std::endl; + Simulation::exit(1); + } return true; } else return false; } - template<> bool XMLfile::Node::getValue(std::string& value) const { if(m_xmlnode) { value=std::string(m_xmlnode->value()); - return true; + return true; } else return false; } -template<> bool XMLfile::Node::getValue(int& value) const -{ - std::string v; - bool found=getValue(v); - if(found) value=atoi(v.c_str()); - return found; -} - -template<> bool XMLfile::Node::getValue(long& value) const -{ - std::string v; - bool found=getValue(v); - if(found) value=atol(v.c_str()); - return found; -} - -template<> bool XMLfile::Node::getValue(float& value) const -{ - std::string v; - bool found=getValue(v); - if(found) value=static_cast(atof(v.c_str())); - return found; -} - -template<> bool XMLfile::Node::getValue(double& value) const -{ - std::string v; - bool found=getValue(v); - if(found) value=atof(v.c_str()); - return found; -} - template<> bool XMLfile::Node::getValue(bool& value) const { std::string v; @@ -607,7 +587,6 @@ template<> bool XMLfile::Node::getValue(bool& value) const return found; } - std::string XMLfile::Node::value_string(std::string defaultvalue) const { std::string value(defaultvalue); diff --git a/src/utils/xmlfile.h b/src/utils/xmlfile.h index 1bea31be1f..83b6ff9ed9 100644 --- a/src/utils/xmlfile.h +++ b/src/utils/xmlfile.h @@ -687,10 +687,6 @@ inline std::ostream& operator << (std::ostream& ostrm, const XMLfile& xmlfile) /* // explicit instantiation template bool XMLfile::Node::getValue(std::string& value)const; -template bool XMLfile::Node::getValue(int& value)const; -template bool XMLfile::Node::getValue(long& value)const; -template bool XMLfile::Node::getValue(float& value)const; -template bool XMLfile::Node::getValue(double& value)const; template bool XMLfile::Node::getValue(bool& value)const; */