PSCF v1.3
ScftReal.h
1#ifndef PRDC_SCFT_REAL_H
2#define PRDC_SCFT_REAL_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 "SystemConstRefReal.h"
12#include <util/global.h>
13#include <iostream>
14
15namespace Pscf {
16namespace Prdc {
17
23 template <int D, class ST>
24 class ScftReal : protected SystemConstRefReal<ST>
25 {
26
27 public:
28
31
33 using SystemT = typename Base::SystemT;
34
35 // Public member functions
36
43
47 virtual ~ScftReal();
48
51
62 void compute();
63
69 void clear();
70
74
78 bool hasData() const;
79
85 double fHelmholtz() const;
86
92 double fIdeal() const;
93
99 double fInter() const;
100
106 double fExt() const;
107
115 double pressure() const;
116
135 void write(std::ostream& out);
136
138
139 protected:
140
141 // Protected inherited type name aliases.
142 using MixtureT = typename Base::MixtureT;
143 using InteractionT = typename Base::InteractionT;
144 using DomainT = typename Base::DomainT;
145 using WFieldContainerT = typename Base::WFieldContainerT;
146 using CFieldContainerT = typename Base::CFieldContainerT;
147 using MaskT = typename Base::MaskT;
148 using FieldT = typename Base::FieldT;
149
150 // Protected inherited member functions
151 using Base::system;
152 using Base::mixture;
153 using Base::interaction;
154 using Base::domain;
155 using Base::c;
156 using Base::w;
157 using Base::h;
158 using Base::mask;
159 using Base::fileMaster;
160
168 virtual
169 double innerProduct(FieldT const & A, FieldT const & B) const
170 { return 0.0; };
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 ST>
219 inline double ScftReal<D,ST>::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 ST>
227 inline double ScftReal<D,ST>::fIdeal() const
228 {
229 UTIL_CHECK(hasData_);
230 return fIdeal_;
231 }
232
233 // Get the interaction contribution to fHelmholtz.
234 template <int D, class ST>
235 inline double ScftReal<D,ST>::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 ST>
243 inline double ScftReal<D,ST>::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 ST>
251 inline double ScftReal<D,ST>::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 ST>
259 inline bool ScftReal<D,ST>::hasData() const
260 { return hasData_; }
261
262} // namespace Prdc
263} // namespace Pscf
264#endif
virtual ~ScftReal()
Destructor.
Definition ScftReal.tpp:44
typename Base::SystemT SystemT
Parent System type name alias.
Definition ScftReal.h:33
virtual double innerProduct(FieldT const &A, FieldT const &B) const
Inner product of two fields.
Definition ScftReal.h:169
double fHelmholtz() const
Get total Helmholtz free energy per monomer / kT.
Definition ScftReal.h:219
double fIdeal() const
Get the ideal gas contribution to fHelmholtz.
Definition ScftReal.h:227
void clear()
Clear all thermodynamic data.
Definition ScftReal.tpp:269
bool hasData() const
Have free energies and pressure been computed?
Definition ScftReal.h:259
SystemConstRefReal< ST > Base
Base class type name alias.
Definition ScftReal.h:30
ScftReal(SystemT const &system)
Constructor.
Definition ScftReal.tpp:30
void write(std::ostream &out)
Write SCFT thermodynamic properties to a file.
Definition ScftReal.tpp:276
double fInter() const
Get the interaction contribution to fHelmholtz.
Definition ScftReal.h:235
double pressure() const
Get the precomputed pressure times monomer volume / kT.
Definition ScftReal.h:251
double fExt() const
Get the external field contribution to fHelmholtz.
Definition ScftReal.h:243
void compute()
Compute SCFT free energy density and pressure for current fields.
Definition ScftReal.tpp:51
SystemConstRefReal()
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