10#include <r1d/solvers/Mixture.h>
11#include <pscf/inter/Interaction.h>
12#include <pscf/iterator/NanException.h>
46 const int nMonomer = system().mixture().nMonomer();
47 interaction_.setNMonomer(nMonomer);
58 interaction_.update(system().interaction());
64 int AmIterator::nElements()
66 const int nm = system().mixture().nMonomer();
67 const int nx = domain().nx();
71 bool AmIterator::hasInitialGuess()
80 const int nm = system().mixture().nMonomer();
81 const int nx = domain().nx();
85 for (
int i = 0; i < nm; i++) {
86 for (
int k = 0; k < nx; k++) {
87 curr[i*nx+k] = (*currSys)[i][k];
95 void AmIterator::evaluate()
96 { mixture().compute(system().wFields(), system().cFields()); }
101 bool AmIterator::isCanonical()
106 for (
int i = 0; i < mixture().nPolymer(); ++i) {
107 ensemble = mixture().polymer(i).ensemble();
108 if (ensemble == Species::Open) {
111 if (ensemble == Species::Unknown) {
117 for (
int i = 0; i < mixture().nSolvent(); ++i) {
118 ensemble = mixture().solvent(i).ensemble();
119 if (ensemble == Species::Open) {
122 if (ensemble == Species::Unknown) {
134 const int nm = system().mixture().nMonomer();
135 const int nx = domain().nx();
136 const int nr = nm*nx;
139 const double shift = -1.0/interaction_.sumChiInverse();
140 for (
int i = 0 ; i < nr; ++i) {
147 for (i = 0; i < nm; ++i) {
148 for (j = 0; j < nm; ++j) {
149 DArray<double>& cField = system().cField(j);
150 DArray<double>& wField = system().wField(j);
151 chi = interaction_.chi(i,j);
152 p = interaction_.p(i,j);
153 for (k = 0; k < nx; ++k) {
155 resid[idx] += chi*cField[k] - p*wField[k];
165 const int nm = mixture().nMonomer();
166 const int nx = domain().nx();
170 const double shift = newGuess[nm*nx - 1];
171 for (
int i = 0; i < nm; i++) {
172 DArray<double>& wField = system().wField(i);
174 for (
int k = 0; k < nx; k++) {
175 wField[k] = newGuess[i*nx + k] - shift;
178 for (
int k = 0; k < nx; k++) {
179 wField[k] = newGuess[i*nx + k];
186 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.