From c7f47295996110cdd50e503d794f2bc631899085 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Fri, 26 Jul 2024 09:48:47 +0200 Subject: [PATCH 1/2] Deprecate readPhaseSpaceHeader of ASCII reader This method was not used in the code anymore. The config xml was already used to set according values. --- src/io/ASCIIReader.cpp | 205 ----------------------------------------- src/io/ASCIIReader.h | 4 +- 2 files changed, 3 insertions(+), 206 deletions(-) diff --git a/src/io/ASCIIReader.cpp b/src/io/ASCIIReader.cpp index c0d1a6a76a..a3df701513 100644 --- a/src/io/ASCIIReader.cpp +++ b/src/io/ASCIIReader.cpp @@ -45,211 +45,6 @@ void ASCIIReader::readXML(XMLfileUnits& xmlconfig) { setPhaseSpaceFile(pspfile); } -void ASCIIReader::readPhaseSpaceHeader(Domain* domain, double timestep) { - std::string token; - - Log::global_log->info() << "Opening phase space header file " << _phaseSpaceHeaderFile << std::endl; - _phaseSpaceHeaderFileStream.open(_phaseSpaceHeaderFile.c_str()); - _phaseSpaceHeaderFileStream >> token; - if(token != "mardyn") { - Log::global_log->error() << _phaseSpaceHeaderFile << " not a valid mardyn input file." << std::endl; - Simulation::exit(1); - } - - std::string inputversion; - _phaseSpaceHeaderFileStream >> token >> inputversion; - // FIXME: remove tag trunk from file specification? - if(token != "trunk") { - Log::global_log->error() << "Wrong input file specifier (\'" << token << "\' instead of \'trunk\')." << std::endl; - Simulation::exit(1); - } - - if(std::stoi(inputversion) < 20080701) { - Log::global_log->error() << "Input version too old (" << inputversion << ")" << std::endl; - Simulation::exit(1); - } - - Log::global_log->info() << "Reading phase space header from file " << _phaseSpaceHeaderFile << std::endl; - - std::vector& dcomponents = *(_simulation.getEnsemble()->getComponents()); - bool header = true; // When the last header element is reached, "header" is set to false - - while(header) { - char c; - _phaseSpaceHeaderFileStream >> c; - if(c == '#') { - // comment line - _phaseSpaceHeaderFileStream.ignore(INT_MAX, '\n'); - continue; - } - _phaseSpaceHeaderFileStream.putback(c); - - token.clear(); - _phaseSpaceHeaderFileStream >> token; - Log::global_log->info() << "{{" << token << "}}" << std::endl; - - if((token == "currentTime") || (token == "t")) { - // set current simulation time - _phaseSpaceHeaderFileStream >> token; - _simulation.setSimulationTime(strtod(token.c_str(), NULL)); - } else if((token == "Temperature") || (token == "T")) { - // set global thermostat temperature - domain->disableComponentwiseThermostat(); //disable component wise thermostats - double targetT; - _phaseSpaceHeaderFileStream >> targetT; - domain->setGlobalTemperature(targetT); - } else if((token == "ThermostatTemperature") || (token == "ThT") || (token == "h")) { - // set up a new thermostat - int thermostat_id; - double targetT; - _phaseSpaceHeaderFileStream >> thermostat_id; - _phaseSpaceHeaderFileStream >> targetT; - Log::global_log->info() << "Thermostat number " << thermostat_id << " has T = " << targetT << ".\n"; - domain->setTargetTemperature(thermostat_id, targetT); - } else if((token == "ComponentThermostat") || (token == "CT") || (token == "o")) { - // specify a thermostat for a component - if(!domain->severalThermostats()) - domain->enableComponentwiseThermostat(); - int component_id; - int thermostat_id; - _phaseSpaceHeaderFileStream >> component_id >> thermostat_id; - Log::global_log->info() << "Component " << component_id << " (internally: " << component_id - 1 - << ") is regulated by thermostat number " << thermostat_id << ".\n"; - component_id--; // FIXME thermostat IDs start with 0 in the program but not in the config file?! - if(thermostat_id < 0) // thermostat IDs start with 0 - continue; - domain->setComponentThermostat(component_id, thermostat_id); - } else if((token == "Undirected") || (token == "U")) { - // set undirected thermostat - int thermostat_id; - _phaseSpaceHeaderFileStream >> thermostat_id; - domain->enableUndirectedThermostat(thermostat_id); - } else if((token == "Length") || (token == "L")) { - // simulation box dimensions - double globalLength[3]; - _phaseSpaceHeaderFileStream >> globalLength[0] >> globalLength[1] >> globalLength[2]; - delete _simulation.getEnsemble()->domain(); - _simulation.getEnsemble()->domain() = new BoxDomain(); - for(int d = 0; d < 3; d++) { - static_cast(_simulation.getEnsemble()->domain())->setLength(d, globalLength[d]); - domain->setGlobalLength(d, _simulation.getEnsemble()->domain()->length(d)); - } - } else if((token == "HeatCapacity") || (token == "cv") || (token == "I")) { - unsigned N; - double U, UU; - _phaseSpaceFileStream >> N >> U >> UU; - domain->init_cv(N, U, UU); - } else if((token == "NumberOfComponents") || (token == "C")) { - // read in component definitions and - // read in mixing coefficients - - // components: - unsigned int numcomponents = 0; - _phaseSpaceHeaderFileStream >> numcomponents; - Log::global_log->info() << "Reading " << numcomponents << " components" << std::endl; - dcomponents.resize(numcomponents); - for(unsigned int i = 0; i < numcomponents; i++) { - Log::global_log->info() << "comp. i = " << i << ": " << std::endl; - dcomponents[i].setID(i); - unsigned int numljcenters = 0; - unsigned int numcharges = 0; - unsigned int numdipoles = 0; - unsigned int numquadrupoles = 0; - unsigned int numtersoff = 0; //previously tersoff - _phaseSpaceHeaderFileStream >> numljcenters >> numcharges >> numdipoles - >> numquadrupoles >> numtersoff; - if(numtersoff != 0) { - Log::global_log->error() << "tersoff no longer supported." - << std::endl; - Simulation::exit(-1); - } - double x, y, z, m; - for(unsigned int j = 0; j < numljcenters; j++) { - double eps, sigma, tcutoff, do_shift; - _phaseSpaceHeaderFileStream >> x >> y >> z >> m >> eps >> sigma >> tcutoff >> do_shift; - dcomponents[i].addLJcenter(x, y, z, m, eps, sigma, tcutoff, (do_shift != 0)); - Log::global_log->info() << "LJ at [" << x << " " << y << " " << z << "], mass: " << m << ", epsilon: " - << eps << ", sigma: " << sigma << std::endl; - } - for(unsigned int j = 0; j < numcharges; j++) { - double q; - _phaseSpaceHeaderFileStream >> x >> y >> z >> m >> q; - dcomponents[i].addCharge(x, y, z, m, q); - Log::global_log->info() << "charge at [" << x << " " << y << " " << z << "], mass: " << m << ", q: " << q - << std::endl; - } - for(unsigned int j = 0; j < numdipoles; j++) { - double eMyx, eMyy, eMyz, absMy; - _phaseSpaceHeaderFileStream >> x >> y >> z >> eMyx >> eMyy >> eMyz >> absMy; - dcomponents[i].addDipole(x, y, z, eMyx, eMyy, eMyz, absMy); - Log::global_log->info() << "dipole at [" << x << " " << y << " " << z << "] " << std::endl; - } - for(unsigned int j = 0; j < numquadrupoles; j++) { - double eQx, eQy, eQz, absQ; - _phaseSpaceHeaderFileStream >> x >> y >> z >> eQx >> eQy >> eQz >> absQ; - dcomponents[i].addQuadrupole(x, y, z, eQx, eQy, eQz, absQ); - Log::global_log->info() << "quad at [" << x << " " << y << " " << z << "] " << std::endl; - } - double IDummy1, IDummy2, IDummy3; - // FIXME! Was soll das hier? Was ist mit der Initialisierung im Fall I <= 0. - _phaseSpaceHeaderFileStream >> IDummy1 >> IDummy2 >> IDummy3; - if(IDummy1 > 0.) dcomponents[i].setI11(IDummy1); - if(IDummy2 > 0.) dcomponents[i].setI22(IDummy2); - if(IDummy3 > 0.) dcomponents[i].setI33(IDummy3); - domain->setProfiledComponentMass(dcomponents[i].m()); - Log::global_log->info() << std::endl; - } - -#ifndef NDEBUG - for(unsigned int i = 0; i < numcomponents; i++) { - Log::global_log->debug() << "Component " << (i + 1) << " of " << numcomponents << std::endl; - Log::global_log->debug() << dcomponents[i] << std::endl; - } -#endif - - // Mixing coefficients - std::vector& dmixcoeff = domain->getmixcoeff(); - dmixcoeff.clear(); - for(unsigned int i = 1; i < numcomponents; i++) { - for(unsigned int j = i + 1; j <= numcomponents; j++) { - double xi, eta; - _phaseSpaceHeaderFileStream >> xi >> eta; - dmixcoeff.push_back(xi); - dmixcoeff.push_back(eta); - } - } - // read in global factor \epsilon_{RF} - // FIXME: Maybe this should go better to a seperate token?! - _phaseSpaceHeaderFileStream >> token; - domain->setepsilonRF(strtod(token.c_str(), NULL)); - long int fpos; - if(_phaseSpaceFile == _phaseSpaceHeaderFile) { - // in the case of a single phase space header + phase space file - // find out the actual position, because the phase space definition will follow - // FIXME: is there a more elegant way? - fpos = _phaseSpaceHeaderFileStream.tellg(); - _phaseSpaceFileStream.seekg(fpos, std::ios::beg); - } - // FIXME: Is there a better solution than skipping the rest of the file? - header = false; - } else if((token == "NumberOfMolecules") || (token == "N")) { - // set number of Molecules - // FIXME: Is this part called in any case as the token is handled in the readPhaseSpace method? - _phaseSpaceHeaderFileStream >> token; - domain->setglobalNumMolecules( strtoul(token.c_str(),NULL,0) ); - } - // LOCATION OF OLD PRESSURE GRADIENT TOKENS - else { - Log::global_log->error() << "Invalid token \'" << token << "\' found. Skipping rest of the header." << std::endl; - header = false; - } - } - - _simulation.getEnsemble()->setComponentLookUpIDs(); - - _phaseSpaceHeaderFileStream.close(); -} - unsigned long ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain, DomainDecompBase* domainDecomp) { diff --git a/src/io/ASCIIReader.h b/src/io/ASCIIReader.h index 56181199a4..f8c9196f91 100644 --- a/src/io/ASCIIReader.h +++ b/src/io/ASCIIReader.h @@ -24,6 +24,8 @@ class ASCIIReader : public InputBase { //! @brief For this class, header and data are in the same file, so there is no separate header file void setPhaseSpaceHeaderFile(std::string filename); + //! DEPRECATED! + //! The information stored in the header must be provided via the xml config file //! @brief reads in header of the input file (including component description) //! //! The Header in the input file consists of several elements. An element starts @@ -56,7 +58,7 @@ class ASCIIReader : public InputBase { //! - For each pair of different components: xi, eta (both double) //! - epsilonRF (double) //! \li NumberOfMolecules: One token follows with the number of molecules - void readPhaseSpaceHeader(Domain* domain, double timestep); + void readPhaseSpaceHeader(Domain* domain, double timestep) {}; //! @brief reads in the data of all molecules //! From b47d637567efa6967c9b4f2d64e0fbf81c4ec767 Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Fri, 26 Jul 2024 09:58:25 +0200 Subject: [PATCH 2/2] Add meaning full error message when using ASCII readPhaseSpaceHeader --- src/io/ASCIIReader.cpp | 6 ++++++ src/io/ASCIIReader.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/io/ASCIIReader.cpp b/src/io/ASCIIReader.cpp index a3df701513..ca3c5695ad 100644 --- a/src/io/ASCIIReader.cpp +++ b/src/io/ASCIIReader.cpp @@ -45,6 +45,12 @@ void ASCIIReader::readXML(XMLfileUnits& xmlconfig) { setPhaseSpaceFile(pspfile); } +void ASCIIReader::readPhaseSpaceHeader(Domain* domain, double timestep) { + Log::global_log->error() << "[ASCII Reader] Using the header of the ASCII checkpoints is deprecated" << std::endl; + Log::global_log->error() << "[ASCII Reader] Use the config xml file instead to set according values" << std::endl; + Simulation::exit(1); +} + unsigned long ASCIIReader::readPhaseSpace(ParticleContainer* particleContainer, Domain* domain, DomainDecompBase* domainDecomp) { diff --git a/src/io/ASCIIReader.h b/src/io/ASCIIReader.h index f8c9196f91..05a87f1616 100644 --- a/src/io/ASCIIReader.h +++ b/src/io/ASCIIReader.h @@ -58,7 +58,7 @@ class ASCIIReader : public InputBase { //! - For each pair of different components: xi, eta (both double) //! - epsilonRF (double) //! \li NumberOfMolecules: One token follows with the number of molecules - void readPhaseSpaceHeader(Domain* domain, double timestep) {}; + void readPhaseSpaceHeader(Domain* domain, double timestep); //! @brief reads in the data of all molecules //!