13#include <rp/fts/montecarlo/McSimulator.h>
14#include <rp/fts/simulator/Simulator.h>
15#include <rp/fts/compressor/Compressor.h>
16#include <rp/system/System.h>
17#include <rp/solvers/Mixture.h>
18#include <rp/field/Domain.h>
19#include <rp/field/CFields.h>
20#include <rp/field/WFields.h>
22#include <pscf/backend/VecRandom.h>
23#include <pscf/backend/VecOp.h>
24#include <pscf/math/IntVec.h>
34 template <
int D,
class T>
50 template <
int D,
class T>
59 int nMonomer =
system().mixture().nMonomer();
61 w_.allocate(nMonomer);
62 for (
int i=0; i < nMonomer; ++i) {
63 w_[i].allocate(meshDimensions);
65 etaA_.allocate(nMonomer-1);
66 etaB_.allocate(nMonomer-1);
67 for (
int i=0; i < nMonomer - 1; ++i) {
68 etaA_[i].allocate(meshDimensions);
69 etaB_[i].allocate(meshDimensions);
71 dwc_.allocate(meshDimensions);
74 template <
int D,
class T>
78 McMoveT::totalTimer_.start();
90 for (
int i=0; i < nStep_; ++i) {
99 if (!
system().c().hasData()) {
115 McMoveT::totalTimer_.stop();
123 template <
int D,
class T>
129 if (!
system().c().hasData()){
146 int nMonomer =
system().mixture().nMonomer();
147 int meshSize =
system().domain().mesh().size();
150 for (
int i=0; i < nMonomer - 1; ++i) {
167 template <
int D,
class T>
178 const int nMonomer =
system().mixture().nMonomer();
179 for (
int i = 0; i < nMonomer; ++i) {
187 const double a = -1.0*mobility_;
190 for (
int j = 0; j < nMonomer - 1; ++j) {
191 RFieldT
const & etaN = etaNew(j);
192 RFieldT
const & etaO = etaOld(j);
197 for (
int i = 0; i < nMonomer; ++i) {
204 system().w().setRGrid(w_);
207 int compress =
simulator().compressor().compress();
247 template <
int D,
class T>
248 void BdMove<D,T>::generateEtaNew()
251 const int nMonomer = system().mixture().nMonomer();
252 const int meshSize = system().domain().mesh().size();
253 const double vSystem = system().domain().unitCell().volume();
254 const double stddev = sqrt(0.5*mobility_*
double(meshSize)/vSystem);
255 const double mean = 0.0;
257 for (
int j = 0; j < nMonomer - 1; ++j) {
258 vecRandom().normal(etaNew(j), stddev, mean);
265 template <
int D,
class T>
266 void BdMove<D,T>::exchangeOldNew()
270 etaOldPtr_ = etaNewPtr_;
An IntVec<D, T> is a D-component vector of elements of integer type T.
McSimulator< D, T > & simulator()
Get parent McSimulator object (non-const ref).
void bdSetup()
Setup before simulation loop.
void readParameters(std::istream &in) override
Read body of parameter file block.
bool needsDc() override
Do dc derivative components need to be saved before a step?
bool bdStep()
Take a single Brownian dynamics step.
BdMove(McSimulator< D, T > &simulator)
Constructor.
System< D, T > & system()
Get parent System object (non-const ref).
bool move() override
Generate a short BD simulation.
void readProbability(std::istream &in)
Read the probability from file.
void incrementNAccept()
Increment the number of accepted moves.
virtual bool needsCc()
Decide whether cc fields need to be saved for move.
Timer attemptMoveTimer_
Timers for McMove.
void incrementNAttempt()
Increment the number of attempted moves.
Monte-Carlo simulation coordinator.
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.