ls1-MarDyn
ls1-MarDyn molecular dynamics code
DirectedPM.h
1/*
2 * DirectedPM.h
3 *
4 * Created on: 25 august 2020
5 * Author: Koch
6 */
7
8#pragma once
9
10// class DirectedPMTest;
11#include "Domain.h"
12#include "PluginBase.h"
13#include "parallel/DomainDecompBase.h"
14#include "particleContainer/ParticleContainer.h"
15
40class DirectedPM : public PluginBase {
41private:
42 // friend DirectedPMTest;
43
44 bool _enabled = true;
45
46 int _measureinterval = 1;
47 double _directedVelocityOld;
48
49 unsigned _outputFrequency;
50 unsigned _component;
51 double _rIncrements;
52 double _hIncrements;
53 double _phiIncrements;
54 double _boxLength[3];
55 double _binSize[3];
56 double _rohCutLiq;
57 double _heightWall;
58 double _heightMembrane;
59 double _percent;
60 int _yLowestBox;
61 int _yHighestBox;
62 double _yLow;
63 double _yHigh;
64 double _volumebox;
65 int _counter;
66
67 double _particles;
68 double _universalInvProfileUnit[3];
69 double _universalCentre[3];
70 double _minXZ;
71 double _R2max;
72
73 bool _firstTime;
74 double _rohCutLiqNew;
75
76 unsigned _iterationsSinceStart;
77
78 std::map<unsigned, std::map<unsigned, double>> _xyzEkin;
79 std::map<unsigned, std::map<unsigned, double>> _xzEkin;
80
81 std::map<unsigned, double> _localnumberOfParticles;
82 std::map<unsigned, std::map<unsigned, double>> _localXyzVi;
83 std::map<unsigned, std::map<unsigned, double>> _localXyzVelocities;
84 std::map<unsigned, std::map<unsigned, double>> _localXyzVelocities2;
85 std::map<unsigned, double> _localDirYVelocity2;
86
87 std::map<unsigned, double> _globalnumberOfParticles;
88 std::map<unsigned, std::map<unsigned, double>> _globalXyzVi;
89 std::map<unsigned, std::map<unsigned, double>> _globalXyzVelocities;
90 std::map<unsigned, std::map<unsigned, double>> _globalXyzVelocities2;
91 std::map<unsigned, double> _globalDirYVelocity2;
92
93 std::map<unsigned, double> _xyzEkinDroplet;
94 std::map<unsigned, double> _xyzEkinGas;
95 std::map<unsigned, double> _xzEkinDroplet;
96 std::map<unsigned, double> _xzEkinGas;
97
98 std::map<unsigned, double> _permissibleRange;
99
100 std::map<unsigned, double> _densityBox;
101 std::map<unsigned, double> _temperatureBox;
102 std::map<unsigned, double> _temperatureBoxXZ;
103 std::map<unsigned, double> _EkinBox;
104 std::map<unsigned, double> _virialBox;
105
106 std::ofstream DPMStreamDensity;
107 std::ofstream DPMStreamVirial;
108 std::ofstream DPMStreamTemperature;
109 std::ofstream DPMStreamTemperatureXZ;
110 std::ofstream DPMStreamEkin;
111
112 std::map<unsigned long, double> _simstepArray;
113 std::map<unsigned, std::map<unsigned, double>> _velocDroplet;
114 std::ofstream _DPMGlobalStream;
115
116public:
117 void init(ParticleContainer* particleContainer, DomainDecompBase* domainDecomp, Domain* domain) override {
118 global_log->debug() << "DirectPM enabled" << std::endl;
119 _firstTime = true;
120 for (unsigned d = 0; d < 3; d++) {
121 _boxLength[d] = domain->getGlobalLength(d);
122 }
123 _iterationsSinceStart = 0;
124 _binSize[0] = _boxLength[0] / _rIncrements;
125 _binSize[1] = _boxLength[1] / _hIncrements;
126 _binSize[2] = _boxLength[2] / _phiIncrements;
127 _yLowestBox = ceil(_heightWall / _binSize[1]);
128 _yHighestBox = floor(_heightMembrane / _binSize[1]);
129 _yLow = _yLowestBox * _binSize[1];
130 _yHigh = _yHighestBox * _binSize[1];
131
132 _directedVelocityOld = 0.;
133 _counter = 0;
134 _particles = 0.;
135 // GET CYLINDRICAL COORDINATES
136 _minXZ = _boxLength[0];
137 if (_boxLength[2] < _minXZ) {
138 _minXZ = _boxLength[2];
139 }
140 _R2max = 0.24 * _minXZ * _minXZ;
141 _universalInvProfileUnit[0] = _rIncrements / (_R2max); // delta_R2
142 _universalInvProfileUnit[1] = _hIncrements / _boxLength[1]; // delta_H
143 _universalInvProfileUnit[2] = _phiIncrements / (2 * M_PI); // delta_Phi
144 _universalCentre[0] = 0.5 * _boxLength[0];
145 _universalCentre[1] = 0.;
146 _universalCentre[2] = 0.5 * _boxLength[2];
147 _volumebox = M_PI / (_universalInvProfileUnit[0] * _universalInvProfileUnit[1] * _phiIncrements);
148
149 // SET PERMISSIBLE RANGE OF EVERY BOX TO ONE
150 for (int l = 0; l <= ((_rIncrements * _hIncrements * _phiIncrements)); l++) {
151 _permissibleRange[l] = 1.;
152 }
153 // SET PERMISSIBLE RANGE OF EVERY BOX BELOW ADSORPTION LAYER TO ZERO
154 for (int i = 0; i <= _yLowestBox; i++) {
155 for (int j = 0; j <= _rIncrements; j++) {
156 for (int k = 0; k <= _phiIncrements; k++) {
157 _permissibleRange[(i * _rIncrements * _phiIncrements) + (j * _phiIncrements) + k] = 0.;
158 }
159 }
160 }
161 // SET PERMISSIBLE RANGE OF EVERY BOX ABOVE MEMBRANE TO ZERO
162 for (int m = _yHighestBox; m <= (_hIncrements); m++) {
163 for (int n = 0; n <= _rIncrements; n++) {
164 for (int o = 0; o <= _phiIncrements; o++) {
165 _permissibleRange[(m * _rIncrements * _phiIncrements) + (n * _phiIncrements) + o] = 0.;
166 }
167 }
168 }
169 // WRITE ALL SIMSTEPS, gerichtete Geschwindigkeit, dichteGas, dichteLiq, druckGas, druckLiq, TGas, TLiq, EkinGas
170 // und EkinLiq IN AN OUTPUT FILE
171 _DPMGlobalStream.open("Global_output_DPM_MK.txt", std::ios::out);
172 _DPMGlobalStream << "Ausgabe der globalen Gr��en gerichtete Geschwindigkeit, dichteGas, dichteLiq, druckGas, "
173 "druckLiq, TGas, TLiq, EkinxyzGas, EkinxyzLiq, TGasXZ, TLiqXZ,EkinxzGas und EkinxzLiq,"
174 << endl;
175 _DPMGlobalStream << endl;
176 _DPMGlobalStream << "Timestept \t\t gerichtete Geschw. \t\t dichteGas \t\t dichteLiq \t\t druckGas \t\t "
177 "druckLiq \t\t TGas \t\t TLiq \t\t EkinxyzGas \t\t EkinxyzLiq\t\t TGasXZ\t\t "
178 "TLiqXZ\t\t EkinxzGas \t\t EkinxzLiq\t\t"
179 << endl;
180 _DPMGlobalStream.close();
181 }
182 void readXML(XMLfileUnits& xmlconfig) override;
183
184 void beforeForces(ParticleContainer* particleContainer, DomainDecompBase* domainDecomp,
185 unsigned long simstep) override;
186
187 void endStep(ParticleContainer* particleContainer, DomainDecompBase* domainDecomp, Domain* domain,
188 unsigned long simstep) override;
189
190 void finish(ParticleContainer* particleContainer, DomainDecompBase* domainDecomp, Domain* domain) override{};
191
192 std::string getPluginName() override { return std::string("DirectedPM"); }
193
194 static PluginBase* createInstance() { return new DirectedPM(); }
195};
Plugin: can be enabled via config.xml
Definition: DirectedPM.h:40
void init(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain) override
Method init will be called at the begin of the simulation.
Definition: DirectedPM.h:117
void finish(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain) override
Method finish will be called at the end of the simulation.
Definition: DirectedPM.h:190
std::string getPluginName() override
return the name of the plugin
Definition: DirectedPM.h:192
void readXML(XMLfileUnits &xmlconfig) override
will be called to read configuration
Definition: DirectedPM.cpp:15
void beforeForces(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, unsigned long simstep) override
Method beforeForces will be called before forcefields have been applied no alterations w....
Definition: DirectedPM.cpp:44
void endStep(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain, unsigned long simstep) override
Method endStep will be called at the end of each time step.
Definition: DirectedPM.cpp:559
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
double getGlobalLength(int d) const
return the length of the domain
Definition: Domain.h:163
This Interface is used to get access to particles and pairs of particles.
Definition: ParticleContainer.h:69
The PluginBase class provides the interface for any kind of output/plugin classes - called "(output) ...
Definition: PluginBase.h:47
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