PSCF v1.4.0
PerturbationDerivative.tpp
1#ifndef RP_PERTURBATION_DERIVATIVE_TPP
2#define RP_PERTURBATION_DERIVATIVE_TPP
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2025, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include "PerturbationDerivative.h"
12
13namespace Pscf {
14namespace Rp {
15
16 using namespace Util;
17
18 /*
19 * Constructor.
20 */
21 template <int D, class T>
23 typename T::Simulator& simulator,
24 typename T::System& system)
25 : AverageAnalyzerT(simulator, system)
26 { ParamComposite::setClassName("PerturbationDerivative"); }
27
28 /*
29 * Compute and return derivative df.
30 */
31 template <int D, class T>
33 {
34 UTIL_CHECK(system().w().hasData());
35 UTIL_CHECK(simulator().hasPerturbation());
36
37 if (!system().c().hasData()) {
38 system().compute();
39 }
40 if (!simulator().hasWc()){
41 simulator().computeWc();
42 }
43 if (!simulator().hasHamiltonian()) {
44 simulator().computeHamiltonian();
45 }
46
47 return simulator().perturbation().df();
48 }
49
50} // namespace Rp
51} // namespace Pscf
52#endif
PerturbationDerivative(typename T::Simulator &simulator, typename T::System &system)
Constructor.
double compute() override
Compute and return the derivative of H w/ respect to lambda.
void setClassName(const char *className)
Set class name string.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Class templates for real-valued periodic fields.
PSCF package top-level namespace.