PSCF v1.5.0
BdMove.h
1#ifndef RP_BD_MOVE_H
2#define RP_BD_MOVE_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <rp/fts/montecarlo/McMove.h> // base class
12#include <pscf/field/RField.h> // member
13#include <util/containers/DArray.h> // member
14
15#include <pscf/backend/TmplDeclare.h>
16#include <iostream>
17
18namespace Pscf {
19namespace Rp {
20
21 using namespace Util;
22
38 template <int D, class T>
39 class BdMove : public McMove<D,T>
40 {
41
42 public:
43
50
54 ~BdMove() = default;
55
56
62 void readParameters(std::istream &in) override;
63
67 bool move() override;
68
76 bool needsDc() override
77 { return true; }
78
79 protected:
80
84 void bdSetup();
85
91 bool bdStep();
92
93 using McMoveT = McMove<D,T>;
94
95 // Inherited protected member functions
96 using McMoveT::system;
98 using McMoveT::random;
100
101 private:
102
103 using RFieldT = RField<D,T>;
104
105 // Private data members
106
107 // New field values
109
110 // Random displacements (A)
111 DArray< RFieldT > etaA_;
112
113 // Random displacements (B)
114 DArray< RFieldT > etaB_;
115
116 // Change in one field component
117 RFieldT dwc_;
118
119 // Pointer to new random displacements
120 DArray< RFieldT >* etaNewPtr_;
121
122 // Pointer to old random displacements
123 DArray< RFieldT >* etaOldPtr_;
124
125 // Prefactor of -dc_ in deterministic drift term
126 double mobility_;
127
128 // Number of BD steps per MC move.
129 int nStep_;
130
131 // Private member functions
132
133 RFieldT& etaNew(int i)
134 { return (*etaNewPtr_)[i]; }
135
136 RFieldT& etaOld(int i)
137 { return (*etaOldPtr_)[i]; }
138
140 void generateEtaNew();
141
143 void exchangeOldNew();
144
145 };
146
147 // Explicit instantiation declarations
148 PSCF_TMPL_DECLARE(BdMove)
149
150}
151}
152#endif
Brownian dynamics Monte-Carlo move.
Definition BdMove.h:40
McSimulator< D, T > & simulator()
Get parent McSimulator object (non-const ref).
Definition McMove.h:342
void bdSetup()
Setup before simulation loop.
Definition BdMove.tpp:124
void readParameters(std::istream &in) override
Read body of parameter file block.
Definition BdMove.tpp:51
bool needsDc() override
Do dc derivative components need to be saved before a step?
Definition BdMove.h:76
bool bdStep()
Take a single Brownian dynamics step.
Definition BdMove.tpp:168
BdMove(McSimulator< D, T > &simulator)
Constructor.
Definition BdMove.tpp:35
~BdMove()=default
Destructor.
bool move() override
Generate a short BD simulation.
Definition BdMove.tpp:75
McMove is an abstract base class for Monte Carlo moves.
Definition McMove.h:50
Random & random()
Get the scalar random number generator.
Definition McMove.h:356
McSimulator< D, T > & simulator()
Get parent McSimulator object (non-const ref).
Definition McMove.h:342
VecRandom< T > & vecRandom()
Get the vector random number generator.
Definition McMove.h:363
System< D, T > & system()
Get parent System object (non-const ref).
Definition McMove.h:328
McMove(McSimulator< D, T > &simulator)
Constructor.
Definition McMove.tpp:32
Monte-Carlo simulation coordinator.
Definition McSimulator.h:55
Dynamically allocatable contiguous array template.
Definition DArray.h:32
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.