PSCF v1.5.0
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 - 2026, David Morse (morse012@um.edu) and co-authors
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <rp/system/SystemConstRef.h> // base class
12#include <pscf/backend/TmplDeclare.h> // declaration macros
13#include <util/global.h> // inline functions
14
15#include <iostream>
16
17
18namespace Pscf {
19namespace Rp {
20
21 using namespace Util;
22
37 template <int D, class T>
38 class ScftThermo : protected SystemConstRef<D,T>
39 {
40
41 public:
42
45
52
53 ~ScftThermo() = default;
54
58
69 void compute();
70
76 void clear();
77
81
85 bool hasData() const;
86
92 double fHelmholtz() const;
93
99 double fIdeal() const;
100
106 double fInter() const;
107
113 double fExt() const;
114
122 double pressure() const;
123
142 void write(std::ostream& out);
143
145
146 protected:
147
150
151 // Protected inherited member functions
156 using SystemConstRefT::c;
157 using SystemConstRefT::w;
158 using SystemConstRefT::h;
161
162 private:
163
167 double fHelmholtz_;
168
175 double fIdeal_;
176
180 double fInter_;
181
185 double fExt_;
186
193 double pressure_;
194
201 bool hasData_;
202
203 };
204
205 // Inline member functions
206
207 // Get the Helmholtz free energy per monomer / kT.
208 template <int D, class T>
209 inline double ScftThermo<D,T>::fHelmholtz() const
210 {
211 UTIL_CHECK(hasData_);
212 return fHelmholtz_;
213 }
214
215 // Get the ideal gas contribution to fHelmholtz.
216 template <int D, class T>
217 inline double ScftThermo<D,T>::fIdeal() const
218 {
219 UTIL_CHECK(hasData_);
220 return fIdeal_;
221 }
222
223 // Get the interaction contribution to fHelmholtz.
224 template <int D, class T>
225 inline double ScftThermo<D,T>::fInter() const
226 {
227 UTIL_CHECK(hasData_);
228 return fInter_;
229 }
230
231 // Get the external field contribution to fHelmholtz.
232 template <int D, class T>
233 inline double ScftThermo<D,T>::fExt() const
234 {
235 UTIL_CHECK(hasData_);
236 return fExt_;
237 }
238
239 // Get the precomputed pressure (units of kT / monomer volume).
240 template <int D, class T>
241 inline double ScftThermo<D,T>::pressure() const
242 {
243 UTIL_CHECK(hasData_);
244 return pressure_;
245 }
246
247 // Have free energies and pressure been computed?
248 template <int D, class T>
249 inline bool ScftThermo<D,T>::hasData() const
250 { return hasData_; }
251
252 // Explicit instantation declarations
253 PSCF_TMPL_DECLARE(ScftThermo)
254
255} // namespace Rp
256} // namespace Pscf
257#endif
Base class for SCFT thermodynamic property calculators.
Definition ScftThermo.h:39
double fInter() const
Get the interaction contribution to fHelmholtz.
Definition ScftThermo.h:225
ScftThermo(System< D, T > const &system)
Constructor.
bool hasData() const
Have free energies and pressure been computed?
Definition ScftThermo.h:249
void clear()
Clear all thermodynamic data.
void write(std::ostream &out)
SystemConstRef< D, T > SystemConstRefT
Base class type name alias.
Definition ScftThermo.h:149
void compute()
Compute SCFT free energy density and pressure for current fields.
System< D, T > const & system() const
Get the associated System.
double fIdeal() const
Get the ideal gas contribution to fHelmholtz.
Definition ScftThermo.h:217
double fHelmholtz() const
Get total Helmholtz free energy per monomer / kT.
Definition ScftThermo.h:209
double fExt() const
Get the external field contribution to fHelmholtz.
Definition ScftThermo.h:233
double pressure() const
Get the precomputed pressure times monomer volume / kT.
Definition ScftThermo.h:241
FileMaster const & fileMaster() const
Get the FileMaster.
System< D, T > const & system() const
Get the associated System.
Mask< D, T > const & mask() const
Get the mask (if any).
CFields< D, T > const & c() const
Get the concentration (c) field container.
WFields< D, T > const & h() const
Get the external potential (h) field container (if any).
Mixture< D, T > const & mixture() const
Get the Mixture.
SystemConstRef()
Default constructor.
Interaction const & interaction() const
Get the Interaction.
WFields< D, T > const & w() const
Get the chemical potential (w) field container.
Domain< D, T > const & domain() const
Get the Domain.
Base class template for classes that represent a complete system.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.