PSCF v1.3.1
ScftThermoTmpl.h
1#ifndef PRDC_SCFT_THERMO_TMPL_H
2#define PRDC_SCFT_THERMO_TMPL_H
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 "SystemConstRefTmpl.h"
12#include <util/global.h>
13#include <iostream>
14
15namespace Pscf {
16namespace Prdc {
17
28 template <int D, class ST>
29 class ScftThermoTmpl : protected SystemConstRefTmpl<ST>
30 {
31
32 public:
33
36
38 using SystemT = typename Base::SystemT;
39
40 // Public member functions
41
48
52 virtual ~ScftThermoTmpl();
53
56
67 void compute();
68
74 void clear();
75
79
83 bool hasData() const;
84
90 double fHelmholtz() const;
91
97 double fIdeal() const;
98
104 double fInter() const;
105
111 double fExt() const;
112
120 double pressure() const;
121
140 void write(std::ostream& out);
141
143
144 protected:
145
146 // Protected inherited type name aliases.
147 using MixtureT = typename Base::MixtureT;
148 using InteractionT = typename Base::InteractionT;
149 using DomainT = typename Base::DomainT;
150 using WFieldsT = typename Base::WFieldsT;
151 using CFieldsT = typename Base::CFieldsT;
152 using MaskT = typename Base::MaskT;
153 using RFieldT = typename Base::RFieldT;
154
155 // Protected inherited member functions
156 using Base::system;
157 using Base::mixture;
158 using Base::interaction;
159 using Base::domain;
160 using Base::c;
161 using Base::w;
162 using Base::h;
163 using Base::mask;
164 using Base::fileMaster;
165
173 virtual
174 double innerProduct(RFieldT const & A, RFieldT const & B) const
175 { return 0.0; };
176
177 private:
178
182 double fHelmholtz_;
183
190 double fIdeal_;
191
195 double fInter_;
196
200 double fExt_;
201
208 double pressure_;
209
216 bool hasData_;
217
218 };
219
220 // Inline member functions
221
222 // Get the Helmholtz free energy per monomer / kT.
223 template <int D, class ST>
225 {
226 UTIL_CHECK(hasData_);
227 return fHelmholtz_;
228 }
229
230 // Get the ideal gas contribution to fHelmholtz.
231 template <int D, class ST>
232 inline double ScftThermoTmpl<D,ST>::fIdeal() const
233 {
234 UTIL_CHECK(hasData_);
235 return fIdeal_;
236 }
237
238 // Get the interaction contribution to fHelmholtz.
239 template <int D, class ST>
240 inline double ScftThermoTmpl<D,ST>::fInter() const
241 {
242 UTIL_CHECK(hasData_);
243 return fInter_;
244 }
245
246 // Get the external field contribution to fHelmholtz.
247 template <int D, class ST>
248 inline double ScftThermoTmpl<D,ST>::fExt() const
249 {
250 UTIL_CHECK(hasData_);
251 return fExt_;
252 }
253
254 // Get the precomputed pressure (units of kT / monomer volume).
255 template <int D, class ST>
256 inline double ScftThermoTmpl<D,ST>::pressure() const
257 {
258 UTIL_CHECK(hasData_);
259 return pressure_;
260 }
261
262 // Have free energies and pressure been computed?
263 template <int D, class ST>
265 { return hasData_; }
266
267} // namespace Prdc
268} // namespace Pscf
269#endif
void write(std::ostream &out)
Write SCFT thermodynamic properties to a file.
double pressure() const
Get the precomputed pressure times monomer volume / kT.
void compute()
Compute SCFT free energy density and pressure for current fields.
virtual double innerProduct(RFieldT const &A, RFieldT const &B) const
Inner product of two fields.
typename Base::SystemT SystemT
Parent System type name alias.
void clear()
Clear all thermodynamic data.
SystemConstRefTmpl< ST > Base
Base class type name alias.
virtual ~ScftThermoTmpl()
Destructor.
double fHelmholtz() const
Get total Helmholtz free energy per monomer / kT.
bool hasData() const
Have free energies and pressure been computed?
double fIdeal() const
Get the ideal gas contribution to fHelmholtz.
double fExt() const
Get the external field contribution to fHelmholtz.
double fInter() const
Get the interaction contribution to fHelmholtz.
ScftThermoTmpl(SystemT const &system)
Constructor.
SystemConstRefTmpl()
Default constructor.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Periodic fields and crystallography.
Definition CField.cpp:11
PSCF package top-level namespace.
Definition param_pc.dox:1