1#ifndef RP_EXPLICIT_BD_STEP_TPP
2#define RP_EXPLICIT_BD_STEP_TPP
11#include "ExplicitBdStep.h"
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>
45 template <
int D,
class T>
51 int nMonomer =
system().mixture().nMonomer();
53 w_.allocate(nMonomer);
54 for (
int i=0; i < nMonomer; ++i) {
55 w_[i].allocate(meshDimensions);
57 dwc_.allocate(meshDimensions);
58 gaussianField_.allocate(meshDimensions);
64 template <
int D,
class T>
69 int meshSize =
system().domain().mesh().size();
70 int nMonomer =
system().mixture().nMonomer();
72 for (
int i = 0; i < nMonomer; ++i) {
74 UTIL_CHECK(w_[i].meshDimensions() == meshDimensions);
77 UTIL_CHECK(dwc_.meshDimensions() == meshDimensions);
78 UTIL_CHECK(gaussianField_.capacity() == meshSize);
79 UTIL_CHECK(gaussianField_.meshDimensions() == meshDimensions);
85 template <
int D,
class T>
89 const int nMonomer =
system().mixture().nMonomer();
90 const int meshSize =
system().domain().mesh().size();
97 for (i = 0; i < nMonomer; ++i) {
102 const double vSystem =
system().domain().unitCell().volume();
103 const double a = -1.0*mobility_;
104 const double b = sqrt(2.0*mobility_*
double(meshSize)/vSystem);
107 const double stddev = 1.0;
108 const double mean = 0.0;
113 for (j = 0; j < nMonomer - 1; ++j) {
116 vecRandom().normal(gaussianField_, stddev, mean);
123 for (i = 0; i < nMonomer; ++i) {
132 system().w().setRGrid(w_);
136 bool isConverged =
false;
137 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.
BdStep(BdSimulator< D, T > &simulator)
Constructor.
BdSimulator< D, T > & simulator()
Get parent BdSimulator object.
System< D, T > & system()
Get parent System object.
VecRandom< T > & vecRandom()
Get vector random number generator of parent simulator.
void setup() override
Setup before simulation.
ExplicitBdStep(BdSimulator< D, T > &simulator)
Constructor.
bool step() override
Take a single Brownian dynamics step.
void readParameters(std::istream &in) override
Read body of parameter file block.
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 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.
void addVcVc(Array< double > &a, Array< double > const &b1, const double c1, Array< double > const &b2, const double c2)
Add two scaled vectors, a[i] = b1[i]*c1 + b2[2]*c2 (real).
PSCF package top-level namespace.