PSCF v1.3
rpc/fts/analyzer/PerturbationDerivative.tpp
1#ifndef RPC_PERTURBATION_DERIVATIVE_TPP
2#define RPC_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
13#include <rpc/system/System.h>
14#include <rpc/fts/simulator/Simulator.h>
15#include <rpc/fts/perturbation/Perturbation.h>
16
17namespace Pscf {
18namespace Rpc {
19
20 using namespace Util;
21
22 /*
23 * Constructor.
24 */
25 template <int D>
30
31 /*
32 * Destructor.
33 */
34 template <int D>
37
38 template <int D>
40 {
41 UTIL_CHECK(system().w().hasData());
42 UTIL_CHECK(simulator().hasPerturbation());
43
44 if (!system().c().hasData()) {
45 system().compute();
46 }
47 if (!simulator().hasWc()){
48 simulator().computeWc();
49 }
50 if (!simulator().hasHamiltonian()) {
51 simulator().computeHamiltonian();
52 }
53
54 return simulator().perturbation().df();
55 }
56
57 template <int D>
58 void PerturbationDerivative<D>::outputValue(int step, double value)
59 {
60 if (simulator().hasRamp() && nSamplePerOutput() == 1) {
61 double lambda = simulator().perturbation().lambda();
62
63 UTIL_CHECK(outputFile_.is_open());
64 outputFile_ << Int(step);
65 outputFile_ << Dbl(lambda);
66 outputFile_ << Dbl(value);
67 outputFile_ << "\n";
68 } else {
70 }
71 }
72
73}
74}
75#endif
AverageAnalyzer(Simulator< D > &simulator, System< D > &system)
Constructor.
int nSamplePerOutput() const
Get value of nSamplePerOutput.
virtual void outputValue(int step, double value)
Output a sampled or block average value.
Simulator< D > & simulator()
Return reference to parent simulator.
System< D > & system()
Return reference to parent system.
virtual void outputValue(int step, double value)
Output a sampled or block average value.
void setClassName(const char *className)
Set class name string.
PerturbationDerivative(Simulator< D > &simulator, System< D > &system)
Constructor.
virtual double compute()
Compute and return the derivative of H w/ respect to lambda.
Field theoretic simulator (base class).
Main class, representing one complete system.
Wrapper for a double precision number, for formatted ostream output.
Definition Dbl.h:40
Wrapper for an int, for formatted ostream output.
Definition Int.h:37
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.
Definition param_pc.dox:1