ls1-MarDyn
ls1-MarDyn molecular dynamics code
Domain.h
1
2#ifndef DOMAIN_H_
3#define DOMAIN_H_
4
5#include <string>
6#include <map>
7#include <array>
8#include <cstdint>
9
10#include "molecules/Comp2Param.h"
11#include "molecules/Component.h"
12#include "ensemble/EnsembleBase.h"
13#include "Simulation.h"
14#include "utils/CommVar.h"
15/*
16 * TODO add comments for variables
17 */
18#define CHECKPOINT_FILE_VERSION 20160512
20#define MIN_BETA 0.9
21#define KINLIMIT_PER_T 10.0
22
23#include "molecules/MoleculeForwardDeclaration.h"
26class XMLfileUnits;
27
47class Domain {
48
49private:
50 Domain();
51 Domain(Domain &domain);
52
53 Domain& operator=(Domain &domain);
54
55public:
57 Domain(int rank);
58
59 void readXML(XMLfileUnits& xmlconfig);
70 void writeCheckpoint( std::string filename, ParticleContainer* particleContainer,
71 DomainDecompBase* domainDecomp, double currentTime, bool useBinaryFormat = false);
72
84 ParticleContainer* particleContainer,
85 const DomainDecompBase* domainDecomp, double currentTime);
86
87 void writeCheckpointHeaderXML(std::string filename,
88 ParticleContainer* particleContainer,
89 const DomainDecompBase* domainDecomp, double currentTime);
90
119// void initFarFieldCorr(double cutoffRadius, double cutoffRadiusLJ);
120
126 void initParameterStreams(double cutoffRadius, double cutoffRadiusLJ);
127
129 void setLocalUpot(double Upot);
130
132 double getLocalUpot() const;
133
135 void setLocalUpotCompSpecific(double UpotCspec);
136
138 void setNumFluidComponents(unsigned nc);
139
141 unsigned getNumFluidComponents();
142
145
147 void setLocalVirial(double Virial);
148
150 double getLocalVirial() const;
151
153 double getGlobalBetaTrans();
154 double getGlobalBetaTrans(int thermostat);
155
157 double getGlobalBetaRot();
158 double getGlobalBetaRot(int thermostat);
159
163 double getGlobalLength(int d) const { return _globalLength[d]; }
164
169 void setGlobalLength(int index, double length);
170
172 double getGlobalCurrentTemperature() { return getCurrentTemperature(0); }
173 double getCurrentTemperature(int thermostatID) { return _globalTemperatureMap[thermostatID]; }
174 double getTargetTemperature(int thermostatID) { return _universalTargetTemperature[thermostatID]; }
175
177 void setGlobalTemperature(double T) { setTargetTemperature(0, T); }
178 void setTargetTemperature(int thermostatID, double T);
179
181 std::vector<double> & getmixcoeff();
182
184 double getepsilonRF() const;
185
187 void setepsilonRF(double erf);
188
190 unsigned long getglobalNumMolecules() const;
191
193 void setglobalNumMolecules(unsigned long glnummol);
194
196 void updateglobalNumMolecules(ParticleContainer* particleContainer, DomainDecompBase* domainDecomp);
197
200
202 void updateMaxMoleculeID(ParticleContainer* particleContainer, DomainDecompBase* domainDecomp);
203
205 double getGlobalPressure();
206
211 double getAverageGlobalUpot() const;
212 double getGlobalUpot() const;
213
216
219 unsigned long getNumFluidMolecules();
220
225 double getAverageGlobalVirial() const;
226
228 void setLocalSummv2(double summv2, int thermostat);
229
231 void setLocalSumIw2(double sumIw2, int thermostat);
232
234 void setLocalNrotDOF(int thermostat, unsigned long N, unsigned long rotDOF) {
235 this->_localThermostatN[thermostat] = N;
236 this->_localRotationalDOF[thermostat] = rotDOF;
237 }
238
240 double getglobalRho();
241
243 void setglobalRho(double grho);
244
246 unsigned long getglobalRotDOF();
247
249 void setglobalRotDOF(unsigned long grotdof);
250
253
283 DomainDecompBase* domainDecomp, ParticleContainer* particleContainer,
284 bool collectThermostatVelocities, double Tfactor
285 );
286
287 /* FIXME: alternatively: default values for function parameters */
289 void calculateGlobalValues(DomainDecompBase* domainDecomp, ParticleContainer* particleContainer) {
290 this->calculateGlobalValues(domainDecomp, particleContainer, false, 1.0);
291 }
292
304
311 bool thermostatIsUndirected(int thermostat) { return this->_universalUndirectedThermostat[thermostat]; }
319 double getThermostatDirectedVelocity(int thermostat, int d) { return this->_universalThermostatDirectedVelocity[thermostat][d]; }
320
322 bool severalThermostats() { return this->_componentwiseThermostat; }
325 int getThermostat(int cid) { return this->_componentToThermostatIdMap[cid]; }
327 void disableComponentwiseThermostat() { this->_componentwiseThermostat = false; }
336 unsigned maxThermostat() {
337 return (_componentwiseThermostat)? (_universalThermostatN.size() - 2): 0;
338 }
342 void setComponentThermostat(int cid, int thermostat) {
343 if((0 > cid) || (0 >= thermostat)) Simulation::exit(787);
344 this->_componentToThermostatIdMap[cid] = thermostat;
345 this->_universalThermostatN[thermostat] = 0;
346 }
349 void enableUndirectedThermostat(int thermostat);
350
351 unsigned long N() {return _globalNumMolecules;}
352
353 void Nadd(unsigned cid, int N, int localN);
354
355 double getGlobalVolume() const { return (_globalLength[0] * _globalLength[1] * _globalLength[2]); }
356
357 void thermostatOff() { this->_universalNVE = true; }
358 void thermostatOn() { this->_universalNVE = false; }
359 bool NVE() { return this->_universalNVE; }
360 bool thermostatWarning() { return (this->_universalSelectiveThermostatWarning > 0); }
361
362 void evaluateRho(unsigned long localN, DomainDecompBase* comm);
363 void submitDU(unsigned cid, double DU, double* r);
364 void setLambda(double lambda) { this->_universalLambda = lambda; }
365 void setDensityCoefficient(float coeff) { _globalDecisiveDensity = coeff; }
366 void setProfiledComponentMass(double m) { _universalProfiledComponentMass = m; }
367
368 void init_cv(unsigned N, double U, double UU) {
369 this->_globalUSteps = N;
370 this->_globalSigmaU = U;
371 this->_globalSigmaUU = UU;
372 }
373 void record_cv();
374 double cv();
375
376 // by Stefan Becker <stefan.becker@mv.uni-kl.de>
377 /* method returning the sigma parameter of a component
378 => needed in the output of the MmspdWriter (specifying the particles' radii in a movie) */
379 double getSigma(unsigned cid, unsigned nthSigma);
380 // needed for the MmspdWriter (MegaMol)
381 unsigned getNumberOfComponents();
382
383 void setUpotCorr(double upotcorr){ _UpotCorr = upotcorr; }
384 void setVirialCorr(double virialcorr){ _VirialCorr = virialcorr; }
385
386 // explosion heuristics, NOTE: turn off when using slab thermostat
387 void SetExplosionHeuristics(bool bVal) { _bDoExplosionHeuristics = bVal; }
388
389private:
390
392 int _localRank;
393
395 double _localUpot;
397 double _localUpotCspecif;
400 unsigned _numFluidComponent;
401
403 double _localVirial;
405 double _globalUpot;
407 double _globalUpotCspecif;
409 double _globalVirial;
411 double _globalRho;
414 unsigned long _globalNumMolecules;
415 CommVar<uint64_t> _maxMoleculeID;
417 double _globalLength[3];
418
420 bool _componentwiseThermostat;
424 std::map<int, int> _componentToThermostatIdMap;
425
428 std::map<int, unsigned long> _localThermostatN;
429 std::map<int, unsigned long> _universalThermostatN;
430 std::map<int, unsigned long> _localRotationalDOF;
431 std::map<int, unsigned long> _universalRotationalDOF;
436 std::map<int, double> _globalTemperatureMap;
437 std::map<int, double> _universalTargetTemperature;
438 std::map<int, double> _universalBTrans;
439 std::map<int, double> _universalBRot;
441 std::map<int, bool> _universalUndirectedThermostat;
443 std::map<int, std::array<double, 3> > _universalThermostatDirectedVelocity;
444 std::map<int, std::array<double, 3> > _localThermostatDirectedVelocity;
445
446 /* FIXME: This info should go into an ensemble class */
447 bool _universalNVE;
448
450 unsigned _globalUSteps;
451 double _globalSigmaU;
452 double _globalSigmaUU;
454 std::map<unsigned, bool> _universalProfiledComponents;
455 double _universalProfiledComponentMass; // set from outside
456 double _universalLambda; // set from outside
457 float _globalDecisiveDensity; // set from outside
458
459 int _universalSelectiveThermostatCounter;
460 int _universalSelectiveThermostatWarning;
461 int _universalSelectiveThermostatError;
462
464 std::map<int, double> _local2KETrans;
467 std::map<int, double> _local2KERot;
468
475 double _epsilonRF;
476
478 double _UpotCorr;
480 double _VirialCorr;
481
482
484 Comp2Param _comp2params;
487 std::vector<double> _mixcoeff;
488
489 // explosion heuristics, NOTE: turn off when using slab thermostat
490 bool _bDoExplosionHeuristics;
491};
492
493
494#endif /*DOMAIN_H_*/
Definition: CommVar.h:17
Definition: Comp2Param.h:15
handle boundary region and multiple processes
Definition: DomainDecompBase.h:51
This class is used to read in the phasespace and to handle macroscopic values.
Definition: Domain.h:47
int getThermostat(int cid)
thermostat to be applied to component cid
Definition: Domain.h:325
double getGlobalBetaTrans()
get thermostat scaling for translations
Definition: Domain.cpp:118
std::vector< double > & getmixcoeff()
get the mixcoeff
Definition: Domain.cpp:721
double getLocalUpotCompSpecific()
get the fluid and fluid-solid potential of the local process
Definition: Domain.cpp:833
unsigned maxThermostat()
returns the ID of the "last" thermostat in the system
Definition: Domain.h:336
double getLocalUpot() const
get the potential of the local process
Definition: Domain.cpp:111
void setComponentThermostat(int cid, int thermostat)
associates a component with a thermostat
Definition: Domain.h:342
void setLocalUpotCompSpecific(double UpotCspec)
set the fluid and fluid-solid potential of the local process
Definition: Domain.cpp:831
unsigned getNumFluidComponents()
get the numbr of fluid molecules as specified in the config file (*_1R.cfg)
Definition: Domain.cpp:844
bool severalThermostats()
returns whether there are several distinct thermostats in the system
Definition: Domain.h:322
void calculateGlobalValues(DomainDecompBase *domainDecomp, ParticleContainer *particleContainer)
calls this->calculateGlobalValues with Tfactor = 1 and without velocity collection
Definition: Domain.h:289
double getGlobalCurrentTemperature()
get the global temperature for the whole system (i.e. thermostat ID 0)
Definition: Domain.h:172
double getThermostatDirectedVelocity(int thermostat, int d)
returns the directed velocity associated with a thermostat
Definition: Domain.h:319
void setLocalNrotDOF(int thermostat, unsigned long N, unsigned long rotDOF)
sets _localThermostatN and _localRotationalDOF for thermostat
Definition: Domain.h:234
void setglobalRotDOF(unsigned long grotdof)
set globalRotDOF
Definition: Domain.cpp:770
unsigned long getglobalRotDOF()
get globalRotDOF
Definition: Domain.cpp:765
void calculateVelocitySums(ParticleContainer *partCont)
calculate _localSummv2 and _localSumIw2
Definition: Domain.cpp:426
void updateMaxMoleculeID(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp)
update max. moleculeID
Definition: Domain.cpp:746
double getGlobalLength(int d) const
return the length of the domain
Definition: Domain.h:163
void setLocalSummv2(double summv2, int thermostat)
sets _localSummv2 to the given value
Definition: Domain.cpp:123
void setLocalVirial(double Virial)
set the virial of the local process
Definition: Domain.cpp:113
bool thermostatIsUndirected(int thermostat)
Definition: Domain.h:311
void setLocalUpot(double Upot)
set the potential of the local process
Definition: Domain.cpp:109
unsigned long getNumFluidMolecules()
Definition: Domain.cpp:846
double getSigma(unsigned cid, unsigned nthSigma)
methods implemented by Stefan Becker stefan.becker@mv.uni-kl.de
Definition: Domain.cpp:802
double getGlobalPressure()
get the global pressure
Definition: Domain.cpp:136
void writeCheckpoint(std::string filename, ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, double currentTime, bool useBinaryFormat=false)
writes a checkpoint file that can be used to continue the simulation
Definition: Domain.cpp:597
void updateglobalNumMolecules(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp)
update globalNumMolecules
Definition: Domain.cpp:731
void setNumFluidComponents(unsigned nc)
set the number of fluid phase components (specified in the config-file)
Definition: Domain.cpp:842
double getLocalVirial() const
get the virial of the local process
Definition: Domain.cpp:115
void setepsilonRF(double erf)
set the epsilonRF
Definition: Domain.cpp:725
unsigned long getglobalNumMolecules() const
get globalNumMolecules
Definition: Domain.cpp:727
double getepsilonRF() const
get the epsilonRF
Definition: Domain.cpp:723
double getAverageGlobalVirial() const
get the global average virial per particle
Definition: Domain.cpp:142
double getAverageGlobalUpot() const
get the global average potential per particle
Definition: Domain.cpp:144
Comp2Param & getComp2Params()
get the parameter streams
Definition: Domain.cpp:147
void initParameterStreams(double cutoffRadius, double cutoffRadiusLJ)
initialize far field correction parameters
Definition: Domain.cpp:622
void setglobalRho(double grho)
set globalRho
Definition: Domain.cpp:763
void writeCheckpointHeader(std::string filename, ParticleContainer *particleContainer, const DomainDecompBase *domainDecomp, double currentTime)
writes a checkpoint file that can be used to continue the simulation
Definition: Domain.cpp:485
void enableUndirectedThermostat(int thermostat)
enables the "undirected" flag for the specified thermostat
Definition: Domain.cpp:714
double getglobalRho()
get globalRho
Definition: Domain.cpp:761
void enableComponentwiseThermostat()
enables the componentwise thermostat
Definition: Domain.cpp:700
void setGlobalLength(int index, double length)
set the length of the domain
Definition: Domain.cpp:775
void disableComponentwiseThermostat()
disables the componentwise thermostat (so that a single thermostat is applied to all DOF)
Definition: Domain.h:327
CommVar< uint64_t > getMaxMoleculeID() const
get local/global max. moleculeID
Definition: Domain.cpp:742
double getGlobalBetaRot()
get thermostat scaling for rotations
Definition: Domain.cpp:120
double getAverageGlobalUpotCSpec()
by Stefan Becker: return the average global potential of the fluid-fluid and fluid-solid interaction ...
Definition: Domain.cpp:836
void calculateGlobalValues(DomainDecompBase *domainDecomp, ParticleContainer *particleContainer, bool collectThermostatVelocities, double Tfactor)
calculate the global macroscopic values
Definition: Domain.cpp:151
void calculateThermostatDirectedVelocity(ParticleContainer *partCont)
Definition: Domain.cpp:368
void setglobalNumMolecules(unsigned long glnummol)
set globalNumMolecules
Definition: Domain.cpp:729
void setGlobalTemperature(double T)
set the global temperature
Definition: Domain.h:177
void setLocalSumIw2(double sumIw2, int thermostat)
sets _localSumIw2 to the given value
Definition: Domain.cpp:131
void readXML(XMLfileUnits &xmlconfig)
Definition: Domain.cpp:78
This Interface is used to get access to particles and pairs of particles.
Definition: ParticleContainer.h:69
static void exit(int exitcode)
Terminate simulation with given exit code.
Definition: Simulation.cpp:155
XML file with unit attributes abstraction.
Definition: xmlfileUnits.h:25
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
Definition: vtk-punstructured.h:270