ls1-MarDyn
ls1-MarDyn molecular dynamics code
ChemicalPotential.h
1
2#pragma once
3
4#include <list>
5
6#include "utils/Random.h"
7#include "molecules/Molecule.h"
8
11class CellProcessor;
12class Domain;
14
17public:
19
20 void setMu(int cid, double chempot) { _mu = chempot; _componentid = cid; }
21 unsigned getInterval() { return _interval; }
22 void setInterval(unsigned delta) { _interval = delta; }
23 void setInstances(unsigned n) { _instances = n; }
24 void setSystem(double x, double y, double z, double m);
25 void setGlobalN(unsigned long N) { _globalN = N; }
26 void setNextID(unsigned long id) { _nextid = id; }
27 void setSubdomain(int rank, double x0, double x1, double y0, double y1, double z0, double z1);
28 void setIncrement(unsigned idi) { _id_increment = idi; }
29
30 void prepareTimestep(ParticleContainer* moleculeContainer, DomainDecompBase* comm); // C must not contain the halo!
31
32 // false if no deletion remains for this subdomain
33 ParticleIterator getDeletion(ParticleContainer* moleculeContainer, double* minco, double* maxcoy);
34 unsigned long getInsertion(double* ins); // 0 if no insertion remains for this subdomain
35 bool decideDeletion(double deltaUTilde);
36 bool decideInsertion(double deltaUTilde);
37
38 Molecule loadMolecule();
39 void storeMolecule( Molecule& old )
40 {
41 if(hasSample()) return;
42 mardyn_assert(old.componentid() == _componentid);
43#ifndef NDEBUG
44 old.check(old.getID());
45#endif
46 _reservoir = new Molecule(old);
47 }
48 bool hasSample() { return _reservoir != NULL; }
49
50 void setPlanckConstant(double h_in) { _h = h_in; }
51 void submitTemperature(double T_in);
52 void setControlVolume(
53 double x0, double y0, double z0, double x1, double y1, double z1
54 );
55
56 unsigned long getGlobalN() { return _globalN; }
57 double getGlobalRho() { return (double)(_globalN) / _globalV; }
58
59 void outputIX() { std::cout << " r" << _ownrank << "[IX" << _rnd.getIX() << "] "; }
60
61 void assertSynchronization(DomainDecompBase* comm);
62
63 double getMu() { return _mu; }
64 unsigned int getComponentID() { return _componentid; }
65 int rank() { return _ownrank; }
66
67 void disableWidom() { _widom = false; }
68 void enableWidom() { _widom = true; }
69 bool isWidom() { return _widom; }
70
71 double getLambda() { return _lambda; }
72 float getDensityCoefficient() { return _decisive_density; }
73
74 /* Moved from LinkedCells! */
75 int getLocalGrandcanonicalBalance() {
76 return _localInsertionsMinusDeletions;
77 }
78 /* Moved from LinkedCells! */
79 void grandcanonicalStep(ParticleContainer * moleculeContainer, double T, Domain* domain, CellProcessor* cellProcessor);
80 /* Moved from LinkedCells! */
81 int grandcanonicalBalance(DomainDecompBase* comm);
82
83
84private:
86 unsigned countParticles(ParticleContainer * moleculeContainer, unsigned int cid) const;
88 unsigned countParticles(ParticleContainer * moleculeContainer, unsigned int cid, double * cbottom, double * ctop) const;
89
90 bool moleculeStrictlyNotInBox(const Molecule& m, const double l[3], const double u[3]) const;
91
92 int _ownrank; // only for debugging purposes (indicate rank in console output)
93
94 double _h; // Plancksches Wirkungsquantum
95 double _T;
96
97 double _mu;
98 double _muTilde;
99 unsigned int _componentid;
100 unsigned _interval; // how often?
101 unsigned _instances; // how many trial insertions and deletions?
102 Random _rnd, _rndmomenta;
103 double _system[3]; // extent of the system
104 float _minredco[3]; // minimal coordinates of the subdomain reduced w. r. t. the system size
105 float _maxredco[3]; // maximal coordinates of the subdomain reduced w. r. t. the system size
106
107 unsigned long _nextid; // ID given to the next inserted particle
108 unsigned _id_increment;
109 std::list<unsigned> _remainingDeletions; // position of the vector that should be deleted
110 std::list<double> _remainingInsertions[3];
111 std::list<unsigned long> _remainingInsertionIDs;
112 std::list<float> _remainingDecisions; // first deletions, then insertions
113
114 unsigned long _globalN;
115 double _globalV;
116 double _molecularMass;
117 double _globalReducedVolume;
118
119 bool _restrictedControlVolume;
120 double _control_bottom[3];
121 double _control_top[3];
122
123 float _decisive_density;
124
125 double _lambda;
126
127 bool _widom; // Widom method -> determine mu (the chemical potential) by test insertions which are all rejected.
128 // Using the widom method is just a way to determine the potential. This has nothing to do with actual insertions or
129 // deletions!
130
131 Molecule* _reservoir;
132
133 /* Moved from LinkedCells! */
134 int _localInsertionsMinusDeletions;
135};
Definition: CellProcessor.h:29
Definition: ChemicalPotential.h:16
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
FullMolecule modeled as LJ sphere with point polarities.
Definition: FullMolecule.h:18
void check(unsigned long id) override
Definition: FullMolecule.cpp:636
unsigned long getID() const override
Definition: FullMolecule.h:41
This Interface is used to get access to particles and pairs of particles.
Definition: ParticleContainer.h:69
Definition: ParticleIterator.h:50
Definition: Random.h:12
::xsd::cxx::tree::id< char, ncname > id
C++ type corresponding to the ID XML Schema built-in type.
Definition: vtk-punstructured.h:322