PSCF v1.2
rpg/fts/perturbation/Perturbation.h
1#ifndef RPG_PERTURBATION_H
2#define RPG_PERTURBATION_H
3
4#include <util/param/ParamComposite.h> // base class
5
6namespace Util {
7 template <typename T> class DArray;
8}
9
10namespace Pscf {
11namespace Prdc{
12namespace Cuda{
13 template <int D> class RField;
14}
15}
16}
17
18namespace Pscf {
19namespace Rpg
20{
21
22 using namespace Util;
23 using namespace Prdc;
24 using namespace Prdc::Cuda;
25
26 template <int D> class System;
27 template <int D> class Simulator;
28
34 template <int D>
35 class Perturbation : public ParamComposite
36 {
37
38 public:
39
43 Perturbation(Simulator<D>& simulator);
44
48 virtual ~Perturbation();
49
57 virtual void readParameters(std::istream& in);
58
69 virtual void setup();
70
78 virtual double hamiltonian(double unperturbedHamiltonian);
79
85 virtual void incrementDc(DArray< RField<D> >& dc);
86
94 virtual void saveState();
95
103 virtual void restoreState();
104
110 virtual double df();
111
115 Simulator<D> const & simulator() const;
116
120 System<D> const & system() const;
121
128 double lambda() const
129 { return lambda_; }
130
136 void setLambda(double lambda);
137
138 protected:
139
144
148 System<D>& system();
149
153 double lambda_;
154
155 private:
156
158 Simulator<D>* simulatorPtr_;
159
161 System<D>* systemPtr_;
162
163 };
164
165 // Inline methods
166
167 // Return parent simulator by const reference.
168 template <int D>
170 {
171 assert(simulatorPtr_);
172 return *simulatorPtr_;
173 }
174
175 // Return parent simulator by non-const reference.
176 template <int D>
178 {
179 assert(simulatorPtr_);
180 return *simulatorPtr_;
181 }
182
183 // Return parent simulator by const reference.
184 template <int D>
185 inline System<D> const & Perturbation<D>::system() const
186 {
187 assert(systemPtr_);
188 return *systemPtr_;
189 }
190
191 // Return parent simulator by non-const reference.
192 template <int D>
194 {
195 assert(systemPtr_);
196 return *systemPtr_;
197 }
198
199 #ifndef RPG_PERTURBATION_TPP
200 // Suppress implicit instantiation
201 extern template class Perturbation<1>;
202 extern template class Perturbation<2>;
203 extern template class Perturbation<3>;
204 #endif
205
206}
207}
208#endif
Field of real double precision values on an FFT mesh.
Base class for additive perturbations of standard FTS Hamiltonian.
virtual void incrementDc(DArray< RField< D > > &dc)
Modify the generalized forces to include perturbation.
void setLambda(double lambda)
Set the perturbation parameter value.
System< D > const & system() const
Get parent System<D> by const reference.
double lambda_
Strength of the perturbation.
double lambda() const
Get the perturbation parameter.
virtual double df()
Compute and return derivative of H w/ respect to parameter lambda.
Simulator< D > const & simulator() const
Get parent Simulator<D> by const reference.
virtual void saveState()
Save any required internal state variables.
virtual void readParameters(std::istream &in)
Read parameters from archive.
virtual double hamiltonian(double unperturbedHamiltonian)
Compute and return the perturbation to the Hamiltonian.
Perturbation(Simulator< D > &simulator)
Constructor.
virtual void setup()
Complete any required initialization.
virtual void restoreState()
Restore any required internal state variables.
Field theoretic simulator (base class).
Definition rpg/System.h:41
Main class for calculations that represent one system.
Definition rpg/System.h:107
Dynamically allocatable contiguous array template.
An object that can read multiple parameters from file.
PSCF package top-level namespace.
Definition param_pc.dox:1
Utility classes for scientific computation.