PSCF v1.4.0
scft/ScftThermo.h
1#ifndef RP_SCFT_THERMO_H
2#define RP_SCFT_THERMO_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 <rp/system/SystemConstRef.h>
12#include <util/global.h>
13#include <iostream>
14
15namespace Pscf {
16namespace Rp {
17
18 using namespace Util;
19
36 template <int D, class T>
37 class ScftThermo : protected T::SystemConstRef
38 {
39
40 public:
41
44
55 void compute();
56
62 void clear();
63
67
71 bool hasData() const;
72
78 double fHelmholtz() const;
79
85 double fIdeal() const;
86
92 double fInter() const;
93
99 double fExt() const;
100
108 double pressure() const;
109
128 void write(std::ostream& out);
129
131
132 protected:
133
135 using SystemConstRefT = typename T::SystemConstRef;
136
138 using SystemT = typename T::System;
139
140 // Protected inherited type name aliases.
141 using MixtureT = typename T::Mixture;
142 using InteractionT = typename T::Interaction;
143 using DomainT = typename T::Domain;
144 using WFieldsT = typename T::WFields;
145 using CFieldsT = typename T::CFields;
146 using MaskT = typename T::Mask;
147 using RFieldT = typename T::RField;
148
154 ScftThermo(SystemT const & system);
155
159 ~ScftThermo();
160
161 // Protected inherited member functions
162 using SystemConstRefT::system;
163 using SystemConstRefT::mixture;
164 using SystemConstRefT::interaction;
165 using SystemConstRefT::domain;
166 using SystemConstRefT::c;
167 using SystemConstRefT::w;
168 using SystemConstRefT::h;
169 using SystemConstRefT::mask;
170 using SystemConstRefT::fileMaster;
171
172 private:
173
177 double fHelmholtz_;
178
185 double fIdeal_;
186
190 double fInter_;
191
195 double fExt_;
196
203 double pressure_;
204
211 bool hasData_;
212
213 };
214
215 // Inline member functions
216
217 // Get the Helmholtz free energy per monomer / kT.
218 template <int D, class T>
219 inline double ScftThermo<D,T>::fHelmholtz() const
220 {
221 UTIL_CHECK(hasData_);
222 return fHelmholtz_;
223 }
224
225 // Get the ideal gas contribution to fHelmholtz.
226 template <int D, class T>
227 inline double ScftThermo<D,T>::fIdeal() const
228 {
229 UTIL_CHECK(hasData_);
230 return fIdeal_;
231 }
232
233 // Get the interaction contribution to fHelmholtz.
234 template <int D, class T>
235 inline double ScftThermo<D,T>::fInter() const
236 {
237 UTIL_CHECK(hasData_);
238 return fInter_;
239 }
240
241 // Get the external field contribution to fHelmholtz.
242 template <int D, class T>
243 inline double ScftThermo<D,T>::fExt() const
244 {
245 UTIL_CHECK(hasData_);
246 return fExt_;
247 }
248
249 // Get the precomputed pressure (units of kT / monomer volume).
250 template <int D, class T>
251 inline double ScftThermo<D,T>::pressure() const
252 {
253 UTIL_CHECK(hasData_);
254 return pressure_;
255 }
256
257 // Have free energies and pressure been computed?
258 template <int D, class T>
259 inline bool ScftThermo<D,T>::hasData() const
260 { return hasData_; }
261
262} // namespace Rp
263} // namespace Pscf
264#endif
double fInter() const
Get the interaction contribution to fHelmholtz.
~ScftThermo()
Destructor.
bool hasData() const
Have free energies and pressure been computed?
void clear()
Clear all thermodynamic data.
void write(std::ostream &out)
Write SCFT thermodynamic properties to a file.
void compute()
Compute SCFT free energy density and pressure for current fields.
typename T::System SystemT
Parent System type name alias.
double fIdeal() const
Get the ideal gas contribution to fHelmholtz.
double fHelmholtz() const
Get total Helmholtz free energy per monomer / kT.
double fExt() const
Get the external field contribution to fHelmholtz.
typename T::SystemConstRef SystemConstRefT
Base class type name alias.
double pressure() const
Get the precomputed pressure times monomer volume / kT.
ScftThermo(SystemT const &system)
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
Class templates for real-valued periodic fields.
PSCF package top-level namespace.