10#include <fd1d/System.h>
11#include <fd1d/domain/Domain.h>
12#include <fd1d/solvers/Mixture.h>
13#include <fd1d/iterator/Iterator.h>
14#include <util/misc/ioUtil.h>
15#include <util/format/Int.h>
16#include <util/format/Dbl.h>
25 #define FD1D_HISTORY_CAPACITY 3
31 :
Base(FD1D_HISTORY_CAPACITY),
72 for (
int j = 0; j < nm; ++j) {
73 if (
state[j].isAllocated()) {
106 UTIL_THROW(
"Called un-implemented Fd1d::Sweep::setParameters");
128 for (i = 0; i < nm; ++i) {
130 for (j = 0; j < nx; ++j) {
135 for (j = 0; j < nx; ++j) {
189 std::string outFileName;
192 outFileName = fileName;
193 outFileName +=
".stt";
205 outFileName = fileName;
210 outFileName = fileName;
219 out <<
Int(i,5) <<
Dbl(sNew)
232 out <<
Dbl(dOmega, 16);
240 { logFile_.close(); }
252 for (i = 0; i < nm; ++i) {
257 for (j = 0; j < nx; ++j) {
258 lhs[i][j] = rhs[i][j];
int nx() const
Get number of spatial grid points, including both endpoints.
double volume() const
Get generalized volume of domain.
void associate(Domain const &domain, FileMaster const &fileMaster)
Get and store addresses of associated objects.
void writeFields(DArray< Field > const &fields, std::ostream &out, bool writeHeader=true)
Write a set of fields, one per monomer type, to an output stream.
void compute(int mode)
Compute properties of a homogeneous reference system.
void output(int mode, std::ostream &out)
Output comparison to a homogeneous reference system.
virtual void outputSolution(std::string const &stateFileName)
Output information after obtaining a converged solution.
virtual void outputSummary(std::ostream &outFile)
Output data to a running summary.
virtual int solve(bool isContinuation)
Call the current iterator to solve one SCFT problem.
virtual void readParameters(std::istream &in)
Read ns and baseFileName parameters.
int homogeneousMode_
Mode for comparison to homogeneous system (none -> -1)
virtual void reset()
Reset system to previous solution after iterature failure.
virtual void cleanup()
Close log file after end of sweep.
virtual void checkAllocation(State &state)
Check allocation of w fields in one state, allocate if needed.
Sweep(System &system)
Constructor.
virtual void setParameters(double s)
Set non-adjustable system parameters to new values.
virtual void extrapolate(double s)
Create initial guess for new w fields by polynomial extrapolation.
virtual void getSolution()
Update state(0) and output data after successful convergence.
virtual void setup()
Setup operation at beginning sweep.
Concise accesss to an associated System.
DArray< System::CField > & cFields()
Get array of all chemical potential fields.
System::WField & wField(int monomerId)
Get chemical potential field for a specific monomer type.
const Domain & domain() const
Get spatial domain (including grid info) by reference.
const System & system() const
Get parent System by reference.
const Mixture & mixture() const
Get Mixture by reference.
FileMaster & fileMaster()
Get FileMaster by reference.
DArray< System::WField > & wFields()
Get array of all chemical potential fields.
Main class in SCFT simulation of one system.
void writeThermo(std::ostream &out)
Write thermodynamic properties to a file.
int iterate(bool isContinuation=false)
Iteratively solve a SCFT problem.
Homogeneous::Mixture & homogeneous()
Get homogeneous mixture (for reference calculations).
Domain & domain()
Get spatial domain (including grid info) by reference.
double fHelmholtz() const
Get precomputed Helmholtz free energy per monomer / kT.
double pressure() const
Get precomputed pressure x monomer volume kT.
FileMaster & fileMaster()
Get FileMaster by reference.
double pressure() const
Return pressure in units of kT / monomer volume.
double fHelmholtz() const
Return Helmholtz free energy per monomer / kT.
int nMonomer() const
Get number of monomer types.
Solve a sequence of problems along a path through parameter space.
int historySize() const
Get the current number of stored previous states.
DArray< System::WField > & state(int i)
Get reference to a stored state, with i=0 being most recent.
std::string baseFileName_
Base name for output files.
double c(int i) const
Get a coefficient of a previous state in a continuation.
void initialize()
Initialize variables that track history of solutions.
int nAccept() const
Get the number of converged solutions accepted thus far.
void setCoefficients(double sNew)
Compute coefficients of previous states for continuation.
virtual void readParameters(std::istream &in)
Read ns and baseFileName parameters.
double s(int i) const
Get the value of s for a stored solution, with i = 0 most recent.
int capacity() const
Return allocated size.
void allocate(int capacity)
Allocate the underlying C array.
bool isAllocated() const
Return true if this DArray has been allocated, false otherwise.
Wrapper for a double precision number, for formatted ostream output.
void openOutputFile(const std::string &filename, std::ofstream &out, std::ios_base::openmode mode=std::ios_base::out) const
Open an output file.
Wrapper for an int, for formatted ostream output.
void setClassName(const char *className)
Set class name string.
virtual void writeParam(std::ostream &out) const
Write all parameters to an output stream.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
std::string toString(int n)
Return string representation of an integer.
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.