1#ifndef RPC_FORCE_BIAS_MOVE_TPP
2#define RPC_FORCE_BIAS_MOVE_TPP
11#include "ForceBiasMove.h"
13#include <rpc/solvers/Mixture.h>
14#include <rpc/field/Domain.h>
15#include <rpc/fts/montecarlo/McSimulator.h>
16#include <rpc/fts/compressor/Compressor.h>
17#include <rpc/system/System.h>
18#include <util/param/ParamComposite.h>
19#include <util/random/Random.h>
55 read(in,
"mobility", mobility_);
58 int nMonomer =
system().mixture().nMonomer();
60 w_.allocate(nMonomer);
61 for (
int i=0; i < nMonomer; ++i) {
62 w_[i].allocate(meshDimensions);
64 dc_.allocate(nMonomer-1);
65 dwc_.allocate(nMonomer-1);
66 for (
int i=0; i < nMonomer - 1; ++i) {
67 dc_[i].allocate(meshDimensions);
68 dwc_[i].allocate(meshDimensions);
77 int meshSize =
system().domain().mesh().size();
78 int nMonomer =
system().mixture().nMonomer();
80 for (
int i=0; i < nMonomer; ++i) {
85 for (
int i=0; i < nMonomer - 1; ++i) {
108 const int nMonomer =
system().mixture().nMonomer();
109 const int meshSize =
system().domain().mesh().size();
113 double oldHamiltonian =
simulator().hamiltonian();
124 for (i = 0; i < nMonomer; ++i) {
125 w_[i] =
system().w().rgrid(i);
129 for (i = 0; i < nMonomer - 1; ++i) {
134 const double vSystem =
system().domain().unitCell().volume();
135 const double vNode = vSystem/double(meshSize);
136 const double a = -1.0*mobility_;
137 const double b = sqrt(2.0*mobility_/vNode);
141 double dwd, dwr, evec;
142 for (j = 0; j < nMonomer - 1; ++j) {
145 for (k = 0; k < meshSize; ++k) {
147 dwr = b*
random().gaussian();
152 for (i = 0; i < nMonomer; ++i) {
156 for (k = 0; k < meshSize; ++k) {
157 wn[k] += evec*dwc[k];
164 system().w().setRGrid(w_);
170 compressorTimer_.start();
171 int compress =
simulator().compressor().compress();
172 compressorTimer_.stop();
174 bool isConverged =
false;
182 componentTimer_.start();
186 componentTimer_.stop();
189 hamiltonianTimer_.start();
191 double newHamiltonian =
simulator().hamiltonian();
192 double dH = newHamiltonian - oldHamiltonian;
197 for (j = 0; j < nMonomer - 1; ++j) {
201 for (k=0; k < meshSize; ++k) {
202 dp = 0.5*(di[k] + df[k]);
203 dm = 0.5*(di[k] - df[k]);
204 bias += dp*( dwc[k] + mobility_*dm );
208 hamiltonianTimer_.stop();
212 decisionTimer_.start();
213 double weight = exp(bias - dH);
214 accept =
random().metropolis(weight);
221 decisionTimer_.stop();
240 out <<
"ForceBiasMove time contributions:\n";
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.
ForceBiasMove(McSimulator< D > &simulator)
Constructor.
void readParameters(std::istream &in)
Read required parameters from file.
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
bool move()
Attempt and accept or reject force bias Monte-Carlo move.
void setClassName(const char *className)
Set class name string.
void outputTimers(std::ostream &out)
Return real move times contributions.
~ForceBiasMove()
Destructor.
void setup()
Setup before the beginning of each simulation run.
void output()
Output statistics for this move (at the end of simulation)
void incrementNAccept()
Increment the number of accepted moves.
Timer attemptMoveTimer_
Timers for McMove.
Random & random()
Get Random number generator of parent System.
McMove(McSimulator< D > &simulator)
Constructor.
System< D > & system()
Get parent System object.
McSimulator< D > & simulator()
Get parent McSimulator object.
void incrementNAttempt()
Increment the number of attempted moves.
virtual void outputTimers(std::ostream &out)
Log output timing results.
void readProbability(std::istream &in)
Read the probability from file.
void incrementNFail()
Increment the number of failed moves.
virtual void setup()
Setup before the beginning of each simulation run.
Monte-Carlo simulation coordinator.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Real periodic fields, SCFT and PS-FTS (CPU).
PSCF package top-level namespace.