PSCF v1.2
rpc/fts/perturbation/Perturbation.h
1#ifndef RPC_PERTURBATION_H
2#define RPC_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 Cpu{
13 template <int D> class RField;
14}
15}
16}
17
18namespace Pscf {
19namespace Rpc {
20
21 using namespace Util;
22 using namespace Prdc;
23 using namespace Prdc::Cpu;
24
25 template <int D> class System;
26 template <int D> class Simulator;
27
35 template <int D>
36 class Perturbation : public ParamComposite
37 {
38
39 public:
40
44 Perturbation(Simulator<D>& simulator);
45
49 virtual ~Perturbation();
50
58 virtual void readParameters(std::istream& in);
59
70 virtual void setup();
71
79 virtual double hamiltonian(double unperturbedHamiltonian);
80
86 virtual void incrementDc(DArray< RField<D> >& dc);
87
95 virtual void saveState();
96
104 virtual void restoreState();
105
111 virtual double df();
112
116 Simulator<D> const & simulator() const;
117
121 System<D> const & system() const;
122
129 double lambda() const
130 { return lambda_; }
131
137 void setLambda(double lambda);
138
139 protected:
140
145
149 System<D>& system();
150
154 double lambda_;
155
156 private:
157
159 Simulator<D>* simulatorPtr_;
160
162 System<D>* systemPtr_;
163
164 };
165
166 // Inline methods
167
168 // Return parent simulator by const reference.
169 template <int D>
171 {
172 assert(simulatorPtr_);
173 return *simulatorPtr_;
174 }
175
176 // Return parent simulator by non-const reference.
177 template <int D>
179 {
180 assert(simulatorPtr_);
181 return *simulatorPtr_;
182 }
183
184 // Return parent simulator by const reference.
185 template <int D>
186 inline System<D> const & Perturbation<D>::system() const
187 {
188 assert(systemPtr_);
189 return *systemPtr_;
190 }
191
192 // Return parent simulator by non-const reference.
193 template <int D>
195 {
196 assert(systemPtr_);
197 return *systemPtr_;
198 }
199
200 #ifndef RPC_PERTURBATION_TPP
201 // Suppress implicit instantiation
202 extern template class Perturbation<1>;
203 extern template class Perturbation<2>;
204 extern template class Perturbation<3>;
205 #endif
206
207}
208}
209#endif
Base class for additive perturbations of standard FTS Hamiltonian.
Perturbation(Simulator< D > &simulator)
Constructor.
Simulator< D > const & simulator() const
Get parent Simulator<D> by const reference.
virtual void setup()
Complete any required initialization.
void setLambda(double lambda)
Set the perturbation parameter value.
virtual void saveState()
Save any required internal state variables.
virtual double hamiltonian(double unperturbedHamiltonian)
Compute and return the perturbation to the Hamiltonian.
virtual void restoreState()
Restore any required internal state variables.
double lambda() const
Get the perturbation parameter.
double lambda_
Strength of the perturbation.
virtual double df()
Compute and return derivative of H w/ respect to parameter lambda.
virtual void incrementDc(DArray< RField< D > > &dc)
Modify the generalized forces to include perturbation.
virtual void readParameters(std::istream &in)
Read parameters from archive.
System< D > const & system() const
Get parent System<D> by const reference.
Field theoretic simulator (base class).
Definition rpc/System.h:38
Main class for SCFT or PS-FTS simulation of one system.
Definition rpc/System.h:100
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.