PSCF v1.5.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 - 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/scft/sweep/BasisFieldState.h> // member
12#include <pscf/sweep/SweepTmpl.h> // base class template
13#include <util/containers/FSArray.h> // member
14
15#include <pscf/backend/TmplDeclare.h> // declaration macros
16#include <util/global.h> // inline functions
17
18#include <fstream>
19
20// Forward declarations
21namespace Pscf {
22 namespace Rp {
23 template <int D, class T> class System;
24 template <int D, class T> class BasisFieldState;
25 }
26}
27
28namespace Pscf {
29namespace Rp {
30
31 using namespace Util;
32
44 template <int D, class T>
45 class Sweep : public SweepTmpl< BasisFieldState<D,T> >
46 {
47
48 public:
49
53 Sweep();
54
61
65 ~Sweep();
66
75
81 virtual void readParameters(std::istream& in);
82
83 protected:
84
91
95 virtual void setup();
96
102 virtual void setParameters(double sNew) = 0;
103
113 virtual void extrapolate(double sNew);
114
121 virtual int solve(bool isContinuation);
122
130 virtual void reset();
131
139 virtual void getSolution();
140
144 virtual void cleanup();
145
150 { return (bool)(systemPtr_); }
151
156 {
157 UTIL_CHECK(systemPtr_);
158 return *systemPtr_;
159 }
160
161 // Protected variables writeCGrid_, writeCBasis_, and writeWGrid_
162 // control which converged fields will be written to files after
163 // solution of each SCFT problem within a sweep.
164
169
174
179
180 private:
181
184
186 FSArray<double, 6> unitCellParameters_;
187
189 std::ofstream logFile_;
190
192 System<D,T>* systemPtr_;
193
195 void outputSolution();
196
198 void outputSummary(std::ostream&);
199
200 // Private alias for base class.
201 using SweepTmplT = SweepTmpl< BasisFieldState<D,T> >;
202
203 };
204
205 // Explicit instantation declarations
206 PSCF_TMPL_DECLARE(Sweep)
207
208} // namespace Rp
209} // namespace Pscf
210#endif
FieldState for fields in symmetry-adapted basis format.
Solve a sequence of SCFT problems along a line in parameter space.
bool writeWRGrid_
Should converged w fields be written to file in r-grid format?
Sweep()
Default constructor.
Definition Sweep.tpp:44
virtual void setup()
Setup operation at the beginning of a sweep.
Definition Sweep.tpp:115
bool hasSystem()
Does an association with the parent system exist?
virtual void getSolution()
Update state(0) and output data after successful convergence.
Definition Sweep.tpp:276
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:365
virtual int solve(bool isContinuation)
Call current iterator to solve SCFT problem.
Definition Sweep.tpp:252
virtual void setParameters(double sNew)=0
Set system parameters to new values.
Definition Sweep.tpp:138
void setSystem(System< D, T > &system)
Set association with parent system.
Definition Sweep.tpp:81
virtual void checkAllocation(BasisFieldState< D, T > &state)
Check allocation of fields in one state, allocate if necessary.
Definition Sweep.tpp:103
System< D, T > & system()
Return the parent system by reference.
virtual void readParameters(std::istream &in)
Read parameters from param file.
Definition Sweep.tpp:88
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:148
virtual void reset()
Reset system to previous solution after iterature failure.
Definition Sweep.tpp:262
Base class template for classes that represent a complete system.
BasisFieldState< D, T > & 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
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.