PSCF v1.4.0
ForceBiasMove.cpp
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2025, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "ForceBiasMove.h"
9#include "McMove.h"
10#include <rpc/fts/montecarlo/McSimulator.h>
11#include <rpc/fts/compressor/Compressor.h>
12#include <rpc/system/System.h>
13#include <rpc/solvers/Mixture.h>
14#include <rpc/field/Domain.h>
15#include <rpc/field/WFields.h>
16#include <rpc/field/CFields.h>
17
18#include <pscf/cpu/VecOp.h>
19#include <pscf/cpu/Reduce.h>
20#include <pscf/cpu/CpuVecRandom.h>
21
22#include <rp/fts/montecarlo/ForceBiasMove.tpp>
23
24namespace Pscf {
25namespace Rpc {
26
27 using namespace Util;
28 using namespace Prdc;
29 using namespace Prdc::Cpu;
30
31 /*
32 * Constructor.
33 */
34 template <int D>
36 : Rp::ForceBiasMove<D, Types<D> > (simulator)
37 {}
38
39 /*
40 * Compute force bias field for use in Metropolis acceptance test.
41 */
42 template<int D>
43 void ForceBiasMove<D>::computeForceBias(
44 RField<D>& result,
45 RField<D> const & di,
46 RField<D> const & df,
47 RField<D> const & dwc,
48 double mobility)
49 {
50 const int n = McMove<D>::system().domain().mesh().size();
51 UTIL_CHECK(result.capacity() == n);
52 UTIL_CHECK(di.capacity() == n);
53 UTIL_CHECK(df.capacity() == n);
54 UTIL_CHECK(dwc.capacity() == n);
55
56 double dp, dm;
57 for (int k = 0; k < n; ++k) {
58 dp = 0.5*(di[k] + df[k]);
59 dm = 0.5*(di[k] - df[k]);
60 result[k] = dp*( dwc[k] + mobility*dm );
61 }
62 }
63
64
65}
66}
67
68// Explicit instantiation definitions
69namespace Pscf {
70 namespace Rp {
71 template class ForceBiasMove<1, Rpc::Types<1> >;
72 template class ForceBiasMove<2, Rpc::Types<2> >;
73 template class ForceBiasMove<3, Rpc::Types<3> >;
74 }
75 namespace Rpc {
76 template class ForceBiasMove<1>;
77 template class ForceBiasMove<2>;
78 template class ForceBiasMove<3>;
79 }
80}
Field of real double precision values on an FFT mesh.
Definition cpu/RField.h:27
Mesh< D > & mesh()
Get the Mesh by non-const reference.
ForceBiasMove attempts a Brownian dynamics move.
T::Domain const & domain() const
Get the Domain (const).
ForceBiasMove attempts a Brownian dynamics move.
ForceBiasMove(McSimulator< D > &simulator)
Constructor.
Monte Carlo simulator for PS-FTS.
Aliases for types used in the Rpc program-level namespace.
int capacity() const
Return allocated size.
Definition Array.h:144
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Periodic fields and crystallography.
Definition complex.cpp:11
Class templates for real-valued periodic fields.
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.