PSCF v1.3
rpg/fts/analyzer/HamiltonianAnalyzer.tpp
1#ifndef RPG_HAMILTONIAN_ANALYZER_TPP
2#define RPG_HAMILTONIAN_ANALYZER_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 "HamiltonianAnalyzer.h"
12#include <rpg/system/System.h>
13#include <rpg/fts/simulator/Simulator.h>
14
15namespace Pscf {
16namespace Rpg
17{
18 using namespace Util;
19
20 /*
21 * Constructor.
22 */
23 template <int D>
28 hasAnalyzeChi_(false),
29 idealId_(-1),
30 fieldId_(-1),
31 totalId_(-1)
32 { setClassName("HamiltonianAnalyzer"); }
33
34 /*
35 * Read interval and outputFileName.
36 */
37 template <int D>
39 {
41
42 idealId_ = 0;
43 fieldId_ = 1;
44 totalId_ = 2;
46
47 setName(idealId_, "ideal");
48 setName(fieldId_, "field");
49 setName(totalId_, "total");
50 }
51
52 /*
53 * Output energy to file
54 */
55 template <int D>
57 {
58 UTIL_CHECK(system().w().hasData());
59 if (!system().c().hasData()) {
60 system().compute();
61 }
62 if (!simulator().hasWc()){
63 simulator().computeWc();
64 }
65
66 #if 0
67 if (!simulator().hasWc()){
68 if (!hasAnalyzeChi_){
69 simulator().analyzeChi();
70 hasAnalyzeChi_ = true;
71 }
72 system().compute();
73 simulator().computeWc();
74 }
75 #endif
76
77 if (!simulator().hasHamiltonian()) {
78 simulator().computeHamiltonian();
79 }
80
81 double ideal = simulator().idealHamiltonian();
82 setValue(idealId_, ideal);
83
84 double field = simulator().fieldHamiltonian();
85 setValue(fieldId_, field);
86
87 double total = simulator().hamiltonian();
88 setValue(totalId_, total);
89 }
90
91}
92}
93#endif
AverageListAnalyzer(System< D > &system)
Constructor.
void setName(int i, std::string name)
Set name of variable.
virtual void readParameters(std::istream &in)
Read interval, outputFileName and (optionally) nSamplePerOutput.
void setValue(int i, double value)
Set current value, used by compute function.
void initializeAccumulators(int nValue)
Instantiate Average accumulators and set nSamplePerOutput set nValue.
Simulator< D > & simulator()
Return reference to parent Simulator.
void compute()
Compute and store values of Hamiltonian components.
void setClassName(const char *className)
Set class name string.
Simulator< D > * simulatorPtr_
Pointer to parent Simulator.
HamiltonianAnalyzer(Simulator< D > &simulator, System< D > &system)
Constructor.
virtual void readParameters(std::istream &in)
Read interval and output file name.
System< D > & system()
Return reference to parent system.
System< D > * systemPtr_
Pointer to the parent system.
Field theoretic simulator (base class).
Main class, representing one complete system.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.
Definition param_pc.dox:1