PSCF v1.3
NrIterator.h
1#ifndef R1D_NR_ITERATOR_H
2#define R1D_NR_ITERATOR_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 "Iterator.h"
12#include <r1d/solvers/Mixture.h>
13#include <pscf/math/LuSolver.h>
14#include <util/containers/Array.h>
15#include <util/containers/DArray.h>
16#include <util/containers/DMatrix.h>
17
18namespace Pscf {
19namespace R1d
20{
21
22 using namespace Util;
23
29 class NrIterator : public Iterator
30 {
31
32 public:
33
38
42 NrIterator();
43
50
54 virtual ~NrIterator();
55
61 void readParameters(std::istream& in);
62
69 int solve(bool isContinuation = false);
70
71 private:
72
74 LuSolver solver_;
75
77 DArray<FieldT> wFieldsNew_;
78
80 DArray<FieldT> cFieldsNew_;
81
83 DArray<double> cArray_;
84
86 DArray<double> wArray_;
87
89 DArray<double> residual_;
90
92 DMatrix<double> jacobian_;
93
95 DArray<double> residualNew_;
96
98 DArray<double> dOmega_;
99
101 double epsilon_;
102
104 int maxItr_;
105
107 bool isAllocated_;
108
110 bool newJacobian_;
111
113 bool needsJacobian_;
114
116 bool isCanonical_;
117
118 // Private member functions
119
123 void setup();
124
132 void computeResidual(Array<FieldT> const & wFields,
133 Array<FieldT> const & cFields,
134 Array<double>& residual);
135
141 double residualNorm(Array<double> const & residual) const;
142
146 void computeJacobian();
147
155 void incrementWFields(Array<FieldT> const & wOld,
156 Array<double> const & dW,
157 Array<FieldT>& wNew);
158
159 };
160
161} // namespace R1d
162} // namespace Pscf
163#endif
Solve Ax=b by LU decomposition of A.
Definition LuSolver.h:31
Iterator()
Default constructor.
Definition Iterator.cpp:19
Propagator::FieldT FieldT
Field type.
Mixture::FieldT FieldT
Monomer chemical potential field.
Definition NrIterator.h:37
int solve(bool isContinuation=false)
Iterate self-consistent field equations to solution.
void readParameters(std::istream &in)
Read all parameters and initialize.
virtual ~NrIterator()
Destructor.
NrIterator()
Default constructor.
DArray< System::CField > & cFields()
Get array of all chemical potential fields.
DArray< System::WField > & wFields()
Get array of all chemical potential fields.
const System & system() const
Get parent System by reference.
Main class in SCFT simulation of one system.
Definition r1d/System.h:65
Array container class template.
Definition Array.h:34
Dynamically allocatable contiguous array template.
Definition DArray.h:32
Dynamically allocated Matrix.
Definition DMatrix.h:25
SCFT with real 1D fields.
PSCF package top-level namespace.
Definition param_pc.dox:1