PSCF v1.4.0
rp/scft/sweep/Sweep.h
1#ifndef RP_SWEEP_H
2#define RP_SWEEP_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 <pscf/sweep/SweepTmpl.h> // base class template
12#include <util/containers/FSArray.h> // member
13#include <util/global.h> // inline functions
14
15#include <fstream>
16
17namespace Pscf {
18namespace Rp {
19
20 using namespace Util;
21
38 template <int D, class T>
39 class Sweep : public SweepTmpl< typename T::BasisFieldState >
40 {
41
42 public:
43
51 void setSystem(typename T::System& system);
52
58 virtual void readParameters(std::istream& in);
59
60 protected:
61
65 Sweep();
66
72 Sweep(typename T::System& system);
73
77 ~Sweep();
78
84 virtual void checkAllocation(typename T::BasisFieldState& state);
85
89 virtual void setup();
90
96 virtual void setParameters(double sNew) = 0;
97
107 virtual void extrapolate(double sNew);
108
115 virtual int solve(bool isContinuation);
116
124 virtual void reset();
125
133 virtual void getSolution();
134
138 virtual void cleanup();
139
144 { return (bool)(systemPtr_); }
145
149 typename T::System& system()
150 {
151 UTIL_CHECK(systemPtr_);
152 return *systemPtr_;
153 }
154
155 // Protected variables writeCGrid_, writeCBasis_, and writeWGrid_
156 // control which converged fields will be written to files after
157 // solution of each SCFT problem within a sweep.
158
163
168
173
174 private:
175
177 typename T::BasisFieldState trial_;
178
180 FSArray<double, 6> unitCellParameters_;
181
183 std::ofstream logFile_;
184
186 typename T::System* systemPtr_;
187
189 void outputSolution();
190
192 void outputSummary(std::ostream&);
193
194 // Private alias for base class.
196
197 };
198
199} // namespace Rp
200} // namespace Pscf
201#endif
bool writeWRGrid_
Should converged w fields be written to file in r-grid format?
Sweep()
Default constructor.
Definition Sweep.tpp:34
virtual void setup()
Setup operation at the beginning of a sweep.
Definition Sweep.tpp:105
bool hasSystem()
Does an association with the parent system exist?
void setSystem(typename T::System &system)
Set association with parent system.
Definition Sweep.tpp:71
virtual void getSolution()
Update state(0) and output data after successful convergence.
Definition Sweep.tpp:260
bool writeCRGrid_
Should concentration fields be written to file in r-grid format?
virtual void cleanup()
Cleanup operation at the beginning of a sweep.
Definition Sweep.tpp:349
virtual int solve(bool isContinuation)
Call current iterator to solve SCFT problem.
Definition Sweep.tpp:236
virtual void setParameters(double sNew)=0
Set system parameters to new values.
Definition Sweep.tpp:124
T::System & system()
Return the parent system by reference.
virtual void readParameters(std::istream &in)
Read parameters from param file.
Definition Sweep.tpp:78
bool writeCBasis_
Should concentration fields be written to file in basis format?
virtual void extrapolate(double sNew)
Create a guess for adjustable variables by continuation.
Definition Sweep.tpp:134
virtual void reset()
Reset system to previous solution after iterature failure.
Definition Sweep.tpp:246
~Sweep()
Destructor.
Definition Sweep.tpp:64
virtual void checkAllocation(typename T::BasisFieldState &state)
Check allocation of fields in one state, allocate if necessary.
Definition Sweep.tpp:93
T::BasisFieldState & state(int i)
Definition SweepTmpl.h:107
A fixed capacity (static) contiguous array with a variable logical size.
Definition FSArray.h:38
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.