1#ifndef RPC_LM_BD_STEP_TPP
2#define RPC_LM_BD_STEP_TPP
13#include <rpc/fts/brownian/BdSimulator.h>
14#include <rpc/fts/compressor/Compressor.h>
15#include <rpc/System.h>
16#include <pscf/math/IntVec.h>
17#include <util/random/Random.h>
23 using namespace Prdc::Cpu;
53 read(in,
"mobility", mobility_);
55 int nMonomer = system().mixture().nMonomer();
56 IntVec<D> meshDimensions = system().domain().mesh().dimensions();
59 w_.allocate(nMonomer);
60 for (
int i=0; i < nMonomer; ++i) {
61 w_[i].allocate(meshDimensions);
63 etaA_.allocate(nMonomer-1);
64 etaB_.allocate(nMonomer-1);
65 for (
int i=0; i < nMonomer - 1; ++i) {
66 etaA_[i].allocate(meshDimensions);
67 etaB_[i].allocate(meshDimensions);
69 dwc_.allocate(meshDimensions);
78 const int nMonomer = system().mixture().nMonomer();
79 const int meshSize = system().domain().mesh().size();
82 const double vSystem = system().domain().unitCell().volume();
83 const double b = sqrt(0.5*mobility_*
double(meshSize)/vSystem);
86 for (j = 0; j < nMonomer - 1; ++j) {
88 for (k = 0; k < meshSize; ++k) {
89 eta[k] = b*random().gaussian();
98 void LMBdStep<D>::exchangeOldNew()
102 etaOldPtr_ = etaNewPtr_;
112 int nMonomer = system().mixture().nMonomer();
113 int meshSize = system().domain().mesh().size();
118 for (
int i=0; i < nMonomer - 1; ++i) {
139 const int nMonomer = system().mixture().nMonomer();
140 const int meshSize = system().domain().mesh().size();
144 simulator().saveState();
147 for (i = 0; i < nMonomer; ++i) {
148 w_[i] = system().w().rgrid(i);
155 const double a = -1.0*mobility_;
158 for (j = 0; j < nMonomer - 1; ++j) {
161 RField<D> const & dc = simulator().dc(j);
162 for (k = 0; k < meshSize; ++k) {
163 dwc_[k] = a*dc[k] + etaN[k] + etaO[k];
166 for (i = 0; i < nMonomer; ++i) {
168 evec = simulator().chiEvecs(j,i);
169 for (k = 0; k < meshSize; ++k) {
170 w[k] += evec*dwc_[k];
176 system().setWRGrid(w_);
179 bool isConverged =
false;
180 int compress = simulator().compressor().compress();
182 simulator().restoreState();
188 simulator().clearState();
189 simulator().clearData();
190 simulator().computeWc();
191 simulator().computeCc();
192 simulator().computeDc();
An IntVec<D, T> is a D-component vector of elements of integer type T.
Field of real double precision values on an FFT mesh.
Brownian dynamics simulator for PS-FTS.
BdStep is an abstract base class for Brownian dynamics steps.
Leimkuhler-Matthews Brownian dynamics stepper.
virtual bool step()
Take a single Brownian dynamics step.
virtual void readParameters(std::istream &in)
Read required parameters from file.
virtual void setup()
Setup before simulation.
LMBdStep(BdSimulator< D > &simulator)
Constructor.
virtual ~LMBdStep()
Destructor.
Dynamically allocatable contiguous array template.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
PSCF package top-level namespace.
Utility classes for scientific computation.