10#include <r1d/solvers/Mixture.h>
11#include <r1d/solvers/Polymer.h>
12#include <r1d/solvers/Solvent.h>
13#include <pscf/inter/Interaction.h>
14#include <pscf/iterator/NanException.h>
48 const int nMonomer = system().mixture().nMonomer();
49 interaction_.setNMonomer(nMonomer);
60 interaction_.update(system().interaction());
66 int AmIterator::nElements()
68 const int nm = system().mixture().nMonomer();
69 const int nx = domain().nx();
73 bool AmIterator::hasInitialGuess()
82 const int nm = system().mixture().nMonomer();
83 const int nx = domain().nx();
87 for (
int i = 0; i < nm; i++) {
88 for (
int k = 0; k < nx; k++) {
89 curr[i*nx+k] = (*currSys)[i][k];
97 void AmIterator::evaluate()
98 { mixture().compute(system().wFields(), system().cFields()); }
103 bool AmIterator::isCanonical()
108 for (
int i = 0; i < mixture().nPolymer(); ++i) {
109 ensemble = mixture().polymer(i).ensemble();
110 if (ensemble == Species::Open) {
113 if (ensemble == Species::Unknown) {
119 for (
int i = 0; i < mixture().nSolvent(); ++i) {
120 ensemble = mixture().solvent(i).ensemble();
121 if (ensemble == Species::Open) {
124 if (ensemble == Species::Unknown) {
136 const int nm = system().mixture().nMonomer();
137 const int nx = domain().nx();
138 const int nr = nm*nx;
141 const double shift = -1.0/interaction_.sumChiInverse();
142 for (
int i = 0 ; i < nr; ++i) {
149 for (i = 0; i < nm; ++i) {
150 for (j = 0; j < nm; ++j) {
151 DArray<double>& cField = system().cField(j);
152 DArray<double>& wField = system().wField(j);
153 chi = interaction_.chi(i,j);
154 p = interaction_.p(i,j);
155 for (k = 0; k < nx; ++k) {
157 resid[idx] += chi*cField[k] - p*wField[k];
167 const int nm = mixture().nMonomer();
168 const int nx = domain().nx();
172 const double shift = newGuess[nm*nx - 1];
173 for (
int i = 0; i < nm; i++) {
174 DArray<double>& wField = system().wField(i);
176 for (
int k = 0; k < nx; k++) {
177 wField[k] = newGuess[i*nx + k] - shift;
180 for (
int k = 0; k < nx; k++) {
181 wField[k] = newGuess[i*nx + k];
188 void AmIterator::outputToLog()
AmIteratorTmpl< Iterator, DArray< double > > AmTmpl
Alias for base class template.
void readMixingParameters(std::istream &in, bool useLambdaRamp=true)
void readErrorType(std::istream &in)
virtual void readParameters(std::istream &in)
void readParameters(std::istream &in) override
Read all parameters and initialize.
AmIterator(System &system)
Constructor.
void setup(bool isContinuation) override
Setup iterator just before entering iteration loop.
Base class for iterative solvers for SCF equations.
Main class in SCFT simulation of one system.
Ensemble
Statistical ensemble for number of molecules.
Dynamically allocatable contiguous array template.
void setClassName(const char *className)
Set class name string.
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
SCFT with real 1D fields.
PSCF package top-level namespace.