PSCF v1.4.0
Perturbation.tpp
1#ifndef RP_PERTURBATION_TPP
2#define RP_PERTURBATION_TPP
3
4//Headers to be included in derived class implementation
5// T::Simulator
6// T::RField
7
8#include "Perturbation.h"
9#include <util/containers/DArray.h>
10#include <util/global.h>
11
12namespace Pscf {
13namespace Rp {
14
15 using namespace Util;
16
17 /*
18 * Constructor.
19 */
20 template <int D, class T>
23 lambda_(1.0),
24 simulatorPtr_(&simulator),
25 systemPtr_(&(simulator.system()))
26 {}
27
28 /*
29 * Read parameters from stream, empty default implementation.
30 */
31 template <int D, class T>
32 void Perturbation<D,T>::readParameters(std::istream& in)
33 {}
34
35 /*
36 * Setup before simulation, empty default implementation.
37 */
38 template <int D, class T>
41
42 /*
43 * Compute and return Hamiltonian perturbation, default implementation.
44 */
45 template <int D, class T>
46 double Perturbation<D,T>::hamiltonian(double unperturbedHamiltonian)
47 { return 0.0; }
48
49 /*
50 * Modify functional derivatives, empty default implementation.
51 */
52 template <int D, class T>
55
56 /*
57 * Save any internal state variables.
58 */
59 template <int D, class T>
62
63 /*
64 * Restore any saved internal variables.
65 */
66 template <int D, class T>
69
70 /*
71 * Compute and return derivative of free energy.
72 */
73 template <int D, class T>
75 { return 0.0; }
76
77 /*
78 * Set a new value for the lambda_ parameter.
79 */
80 template <int D, class T>
83
84}
85}
86#endif
double lambda() const
Get the perturbation parameter.
T::System const & system() const
Get parent typename T::System by const reference.
virtual double df()
Compute and return derivative of H w/ respect to parameter lambda.
double lambda_
Strength of the perturbation.
virtual void restoreState()
Restore any required internal state variables.
virtual double hamiltonian(double unperturbedHamiltonian)
Compute and return the perturbation to the Hamiltonian.
void setLambda(double lambda)
Set the perturbation parameter value.
Perturbation(typename T::Simulator &simulator)
Constructor.
T::Simulator const & simulator() const
Get parent typename T::Simulator by const reference.
virtual void incrementDc(DArray< typename T::RField > &dc)
Modify the generalized forces to include perturbation.
virtual void setup()
Complete any required initialization.
virtual void saveState()
Save any required internal state variables.
virtual void readParameters(std::istream &in)
Read parameters from archive.
ParamComposite()
Constructor.
File containing preprocessor macros for error handling.
Class templates for real-valued periodic fields.
PSCF package top-level namespace.