11#include "../PluginBase.h"
12#include "molecules/Molecule.h"
14#include "utils/CommVar.h"
30template <
typename T >
void shuffle( std::list<T>& lst );
32void create_rand_vec_ones(
const uint64_t& nCount,
const double& percent, std::vector<int>& v);
33void update_velocity_vectors(std::unique_ptr<Random>& rnd,
const uint64_t& numSamples,
const double&T,
const double&D,
const double&v_neg,
const double&e_neg,
34 std::vector<double>& vxi, std::vector<double>& vyi, std::vector<double>& vzi);
36#define FORMAT_SCI_MAX_DIGITS std::setw(24) << std::scientific << std::setprecision(std::numeric_limits<double>::digits10)
38enum ReadReservoirMethods : uint8_t
41 RRM_READ_FROM_FILE = 1,
42 RRM_READ_FROM_FILE_BINARY = 2,
43 RRM_READ_FROM_MEMORY = 3,
48enum MovingDirections : uint8_t
55enum FeedRateMethod : uint8_t
58 FRM_DELETED_MOLECULES = 1,
59 FRM_CHANGED_MOLECULES = 2,
65enum Zone2Method : uint8_t
69 Z2M_RESET_YPOS_ONLY = 2,
72enum ReleaseVelocityMethod : uint32_t
77 RVM_ADD_FIX_VALUE = 3,
79 RVM_NORM_DISTR_GENERATOR = 5
82enum MoleculeFormat : uint32_t {
94 double temperature, drift;
95 double a_neg, a_pos, v_neg, v_pos, e_neg, e_pos;
118 std::vector<double> vx;
119 std::vector<double> vy;
120 std::vector<double> vz;
133 std::vector<int> vec_rand_ins;
204 uint64_t getnNumMoleculesDeleted(
DomainDecompBase* domainDecomposition){
return _nNumMoleculesDeletedGlobalAlltime;}
206 uint8_t getMovingDirection() {
return _nMovingDirection;}
207 double getTransitionPlanePosY() {
return _dTransitionPlanePosY;}
215 uint32_t getFeedRateTargetComponentID() {
return _feedrate.cid_target;}
216 void IncrementInsertedMoleculesLocal() {_feedrate.numMolecules.inserted.local++;}
217 void IncrementDeletedMoleculesLocal() {_feedrate.numMolecules.deleted.local++;}
218 void IncrementChangedToMoleculesLocal() {_feedrate.numMolecules.changed_to.local++;}
219 void IncrementChangedFromMoleculesLocal() {_feedrate.numMolecules.changed_from.local++;}
220 void StoreDensity(
const double& dVal) {_vecDensityValues.push_back(dVal);}
221 void StoreValuesCV(
const double& dDensity,
const double& dVolume) {_dDensityTarget = dDensity; _dVolumeCV = dVolume;}
224 void setActualFeedrate(
const double& feed_actual) {
225 _feedrate.feed.actual = feed_actual;
226 global_log->info() <<
"[MettDeamon]: Set new feedrate by MDFRD to vf= " << _feedrate.feed.actual << std::endl;
228 void setInitFeedrate(
const double& feed_init) {
229 _feedrate.feed.init = feed_init;
230 global_log->info() <<
"[MettDeamon]: Set init feedrate by MDFRD to vf= " << _feedrate.feed.init << std::endl;
232 double getInvDensityArea() {
return _dInvDensityArea;}
236 void writeRestartfile();
239 void logReleasedVelocities();
241 void calcDeltaYbyDensity();
243 bool IsTrappedMolecule(
const uint8_t& cid) {
return cid != _vecChangeCompIDsUnfreeze.at(cid);}
244 bool IsBehindTransitionPlane(
const double& dPosY) {
245 bool bRet = ( MD_LEFT_TO_RIGHT == _nMovingDirection && dPosY > _dTransitionPlanePosY ) ||
246 ( MD_RIGHT_TO_LEFT == _nMovingDirection && dPosY < _dTransitionPlanePosY );
249 bool IsInsideOuterReservoirSlab(
const double& dPosY,
const double& dBoxY);
250 void releaseTrappedMolecule(
Molecule* mol,
bool& bDeleteParticle);
251 void resetPositionAndOrientation(
Molecule* mol,
const double& dBoxY);
254 void InitTransitionPlane(
Domain* domain);
262 void readNormDistr();
265 void updateRandVecTrappedIns();
268 std::unique_ptr<Reservoir> _reservoir;
270 bool _bInitFeedrateLog;
271 bool _bInitRestartLog;
273 double _dInvDensityArea;
274 double _dDeletedMolsPerTimestep;
275 double _dInvNumTimestepsSummation;
276 double _dTransitionPlanePosY;
277 double _dDensityTarget;
279 uint64_t _nUpdateFreq;
280 uint64_t _nWriteFreqRestart;
282 uint64_t _nMaxReservoirMoleculeID;
283 uint64_t _nNumMoleculesDeletedGlobalAlltime;
285 uint8_t _nMovingDirection;
286 uint8_t _nFeedRateMethod;
287 uint8_t _nZone2Method;
288 uint32_t _nNumValsSummation;
289 int64_t _numDeletedMolsSum;
290 uint64_t _nDeleteNonVolatile;
291 std::map<uint64_t, std::array<double,10> > _storePosition;
292 std::list<uint64_t> _listDeletedMolecules;
294 std::vector<uint32_t> _vecChangeCompIDsFreeze;
295 std::vector<uint32_t> _vecChangeCompIDsUnfreeze;
297 std::vector<double> _vecDensityValues;
328 std::list<double> vxz;
329 std::list<double> vy;
336 uint64_t log_freq_vel;
339 std::vector<std::array<double,3> > log_v;
342 std::unique_ptr<Random> _rnd;
354 std::array<double,3> length;
380 void readFromFileBinaryHeader();
385 double getDensity(
const uint32_t& cid) {
return _density.at(cid).density;}
386 void setDensity(
const uint32_t& cid,
const double& dVal) {_density.at(cid).density = dVal;}
387 double getBoxLength(
const uint32_t& nDim) {
return _box.length.at(nDim);}
388 void setBoxLength(
const uint32_t& nDim,
const double& dVal) {_box.length.at(nDim)=dVal;}
389 double getVolume() {
return _box.volume;}
390 void setVolume(
const double& dVal) {_box.volume = dVal;}
391 double getBinWidth() {
return _dBinWidth;}
392 double GetInsPercent() {
return _dInsPercent;}
393 void setInsPercent(
const double& dVal) {_dInsPercent = dVal;}
394 uint8_t getReadMethod() {
return _nReadMethod;}
397 uint32_t getActualBinIndex();
398 uint64_t getNumMoleculesLocal();
399 uint32_t getNumBins();
400 std::vector<Molecule>& getParticlesActualBin();
401 bool nextBin(uint64_t& nMaxID);
402 uint64_t getMaxMoleculeID();
403 bool activateBin(uint32_t nBinIndex);
404 void clearBinQueue();
405 void printBinQueueInfo();
409 void changeComponentID(
Molecule& mol,
const uint32_t& cid);
414 std::unique_ptr<MoleculeDataReader> _moleculeDataReader;
415 std::unique_ptr<BinQueue> _binQueue;
416 uint64_t _numMoleculesRead;
417 uint64_t _nMaxMoleculeID;
418 uint32_t _nMoleculeFormat;
419 uint8_t _nReadMethod;
421 double _dBinWidthInit;
424 std::vector<Molecule> _particleVector;
425 std::vector<uint32_t> _vecChangeCompIDs;
426 std::vector<DensityStruct> _density;
429 bool _bUpdateBinQueue;
440 Bin(
const std::vector<Molecule>& vec, uint32_t nIndex) : _next(
nullptr), _nIndex(nIndex)
442 for(
const auto& p:vec)
443 _particles.push_back(p);
445 uint32_t getIndex() {
return _nIndex;}
446 uint64_t getNumParticles() {
return _particles.size();}
449 std::vector<Molecule> _particles;
452 Bin *_first, *_last, *_actual;
454 uint32_t _nRoundCount;
455 uint64_t _numParticles;
471 BinQueue(std::vector<Molecule> vec) :
480 enque(std::move(vec));
486 _last->_next =
nullptr;
491 auto ptr_next = ptr->_next;
498 return _first ==
nullptr;
501 void enque(std::vector<Molecule> vec)
503 Bin* ptr =
new Bin(vec, _numBins);
512 _last->_next = _first;
514 _numParticles += vec.size();
516 if(_numParticles > 0)
518 std::vector<Molecule>::iterator it;
521 else if(vec.size() == 1)
524 it = max_element(vec.begin(), vec.end(), molecule_id_compare);
527 _maxID = ( (*it).getID()>_maxID ? (*it).getID() : _maxID);
538 else if (_first == _last) {
539 _numParticles -= _first->getNumParticles();
541 _first = _last =
nullptr;
546 while(ptr->_next != _last) {
549 _numParticles -= ptr->_next->getNumParticles();
551 ptr->_next =
nullptr;
554 _last->_next = _first;
565 std::vector<Molecule>& head() {
566 return _first->_particles;
569 std::vector<Molecule>& getParticlesActualBin() {
570 return _actual->_particles;
573 void showActualBin() {
574 for(
auto& p:_actual->_particles)
575 std::cout << p <<
", ";
579 void connectTailToHead()
587 _actual = _actual->_next;
588 if(_actual == _first)
590 bool bSuccess =
dynamic_cast<Bin*
>(_actual);
594 bool activateBin(uint32_t nBinIndex)
597 while(ptr !=
nullptr)
599 if(ptr->_nIndex == nBinIndex) {
610 uint32_t getActualBinIndex() {
return _actual->_nIndex;}
611 uint32_t getNumBins() {
return _numBins;}
612 uint32_t getRoundCount() {
return _nRoundCount;}
613 uint64_t getNumParticles() {
return _numParticles;}
614 uint64_t getMaxID() {
return _maxID;}
621 void determineMaxID()
625 while(ptr !=
nullptr)
627 std::vector<Molecule> vec = ptr->_particles;
628 auto it = max_element(vec.begin(), vec.end(), molecule_id_compare);
629 _maxID = ( (*it).getID()>_maxID ? (*it).getID() : _maxID);
Definition: MettDeamon.h:435
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
Base class for ensembles.
Definition: EnsembleBase.h:47
FullMolecule modeled as LJ sphere with point polarities.
Definition: FullMolecule.h:18
unsigned long getID() const override
Definition: FullMolecule.h:41
Definition: MettDeamon.h:144
void finish(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain) override
Method finish will be called at the end of the simulation.
Definition: MettDeamon.h:200
std::string getPluginName() override
return the name of the plugin
Definition: MettDeamon.h:201
void init(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain) override
Method init will be called at the begin of the simulation.
Definition: MettDeamon.cpp:443
void afterForces(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, unsigned long simstep) override
Method afterForces will be called after forcefields have been applied no sitewise Forces can be appli...
Definition: MettDeamon.cpp:457
void siteWiseForces(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, unsigned long simstep) override
Method siteWiseForces will be called before forcefields have been applied alterations to sitewise for...
Definition: MettDeamon.h:197
void readXML(XMLfileUnits &xmlconfig) override
Read in XML configuration for MettDeamon and all its included objects.
Definition: MettDeamon.cpp:266
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: MettDeamon.h:199
void beforeForces(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, unsigned long simstep) override
Method beforeForces will be called before forcefields have been applied no alterations w....
Definition: MettDeamon.cpp:452
void beforeEventNewTimestep(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, unsigned long simstep) override
Method will be called first thing in a new timestep.
Definition: MettDeamon.cpp:448
Definition: ReplicaGenerator.h:84
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
Definition: MettDeamon.h:366
XML file with unit attributes abstraction.
Definition: xmlfileUnits.h:25
Enumeration class corresponding to the type schema type.
Definition: vtk-unstructured.h:1746
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
Definition: vtk-punstructured.h:270
Definition: MettDeamon.h:352
Definition: MettDeamon.h:358
Definition: MettDeamon.h:105
Definition: MettDeamon.h:114
Definition: MettDeamon.h:125
Definition: MettDeamon.h:100
Definition: MettDeamon.h:346
Definition: MettDeamon.h:324
Definition: MettDeamon.h:93
Definition: MettDeamon.h:87
Definition: FakedOptFFT.h:23