1#ifndef RP_LM_BD_STEP_TPP
2#define RP_LM_BD_STEP_TPP
13#include <rp/fts/brownian/BdSimulator.h>
14#include <rp/fts/compressor/Compressor.h>
15#include <rp/system/System.h>
16#include <rp/solvers/Mixture.h>
17#include <rp/field/Domain.h>
18#include <rp/field/CFields.h>
19#include <rp/field/WFields.h>
21#include <pscf/backend/VecRandom.h>
22#include <pscf/backend/VecOp.h>
23#include <pscf/math/IntVec.h>
33 template <
int D,
class T>
48 template <
int D,
class T>
54 int nMonomer =
system().mixture().nMonomer();
56 w_.allocate(nMonomer);
57 for (
int i=0; i < nMonomer; ++i) {
58 w_[i].allocate(meshDimensions);
60 etaA_.allocate(nMonomer-1);
61 etaB_.allocate(nMonomer-1);
62 for (
int i=0; i < nMonomer - 1; ++i) {
63 etaA_[i].allocate(meshDimensions);
64 etaB_[i].allocate(meshDimensions);
66 dwc_.allocate(meshDimensions);
72 template <
int D,
class T>
73 void LMBdStep<D,T>::generateEtaNew()
76 const int nMonomer = system().mixture().nMonomer();
77 const int meshSize = system().domain().mesh().size();
78 const double vSystem = system().domain().unitCell().volume();
79 const double stddev = sqrt(0.5*mobility_*
double(meshSize)/vSystem);
80 const double mean = 0.0;
82 for (
int j = 0; j < nMonomer - 1; ++j) {
83 vecRandom().normal(etaNew(j), stddev, mean);
90 template <
int D,
class T>
91 void LMBdStep<D,T>::exchangeOldNew()
95 etaOldPtr_ = etaNewPtr_;
102 template <
int D,
class T>
105 int nMonomer =
system().mixture().nMonomer();
106 int meshSize =
system().domain().mesh().
size();
111 for (
int i=0; i < nMonomer - 1; ++i) {
128 template <
int D,
class T>
135 const int nMonomer =
system().mixture().nMonomer();
136 for (
int i = 0; i < nMonomer; ++i) {
144 const double a = -1.0*mobility_;
147 for (
int j = 0; j < nMonomer - 1; ++j) {
148 RFieldT
const & etaN = etaNew(j);
149 RFieldT
const & etaO = etaOld(j);
154 for (
int i = 0; i < nMonomer; ++i) {
161 system().w().setRGrid(w_);
164 bool isConverged =
false;
165 int compress =
simulator().compressor().compress();
An IntVec<D, T> is a D-component vector of elements of integer type T.
Brownian dynamics simulator for PS-FTS.
void readParameters(std::istream &in) override
Read body of parameter file block.
LMBdStep(BdSimulator< D, T > &simulator)
Constructor.
bool step() override
Take a single Brownian dynamics step.
BdSimulator< D, T > & simulator()
Get parent BdSimulator object.
System< D, T > & system()
Get parent System object.
void setup() override
Setup before simulation loop.
int size() const
Return logical size of array.
Dynamically allocatable contiguous array template.
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).
Code for programs that simulate real-valued periodic fields.
PSCF package top-level namespace.