1#ifndef RP_LM_BD_STEP_TPP
2#define RP_LM_BD_STEP_TPP
13#include <pscf/math/IntVec.h>
24 template <
int D,
class T>
39 template <
int D,
class T>
45 int nMonomer = system().mixture().nMonomer();
46 IntVec<D> meshDimensions = system().domain().mesh().dimensions();
47 w_.allocate(nMonomer);
48 for (
int i=0; i < nMonomer; ++i) {
49 w_[i].allocate(meshDimensions);
51 etaA_.allocate(nMonomer-1);
52 etaB_.allocate(nMonomer-1);
53 for (
int i=0; i < nMonomer - 1; ++i) {
54 etaA_[i].allocate(meshDimensions);
55 etaB_[i].allocate(meshDimensions);
57 dwc_.allocate(meshDimensions);
63 template <
int D,
class T>
64 void LMBdStep<D,T>::generateEtaNew()
67 const int nMonomer = system().mixture().nMonomer();
68 const int meshSize = system().domain().mesh().size();
69 const double vSystem = system().domain().unitCell().volume();
70 const double stddev = sqrt(0.5*mobility_*
double(meshSize)/vSystem);
71 const double mean = 0.0;
73 for (
int j = 0; j < nMonomer - 1; ++j) {
74 vecRandom().normal(etaNew(j), stddev, mean);
81 template <
int D,
class T>
82 void LMBdStep<D,T>::exchangeOldNew()
86 etaOldPtr_ = etaNewPtr_;
93 template <
int D,
class T>
96 int nMonomer = system().mixture().nMonomer();
97 int meshSize = system().domain().mesh().size();
102 for (
int i=0; i < nMonomer - 1; ++i) {
119 template <
int D,
class T>
123 simulator().saveState();
126 const int nMonomer = system().mixture().nMonomer();
127 for (
int i = 0; i < nMonomer; ++i) {
135 const double a = -1.0*mobility_;
138 for (
int j = 0; j < nMonomer - 1; ++j) {
139 RFieldT
const & etaN = etaNew(j);
140 RFieldT
const & etaO = etaOld(j);
141 RFieldT
const & dc = simulator().dc(j);
145 for (
int i = 0; i < nMonomer; ++i) {
146 evec = simulator().chiEvecs(j,i);
152 system().w().setRGrid(w_);
155 bool isConverged =
false;
156 int compress = simulator().compressor().compress();
158 simulator().restoreState();
164 simulator().clearState();
165 simulator().clearData();
166 simulator().computeWc();
167 simulator().computeCc();
168 simulator().computeDc();
An IntVec<D, T> is a D-component vector of elements of integer type T.
void readParameters(std::istream &in) override
Read body of parameter file block.
bool step() override
Take a single Brownian dynamics step.
void setup() override
Setup before simulation loop.
LMBdStep(typename T::BdSimulator &simulator)
Constructor.
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
void setClassName(const char *className)
Set class name string.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
void eqV(Array< double > &a, Array< double > const &b, const int beginIdA, const int beginIdB, const int n)
Vector assignment, a[i] = b[i] (real, slice).
void addVV(Array< double > &a, Array< double > const &b, Array< double > const &c)
Vector-vector addition, a[i] = b[i] + c[i] (real)
void addEqVc(Array< double > &a, Array< double > const &b, const double c)
Add scaled vector in-place, a[i] += b[i]*c (real).
Periodic fields and crystallography.
Class templates for real-valued periodic fields.
PSCF package top-level namespace.