PSCF v1.3.2
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
31 class NrIterator : public Iterator
32 {
33
34 public:
35
40
44 NrIterator();
45
52
56 virtual ~NrIterator();
57
63 void readParameters(std::istream& in);
64
71 int solve(bool isContinuation = false);
72
73 private:
74
76 LuSolver solver_;
77
79 DArray<FieldT> wFieldsNew_;
80
82 DArray<FieldT> cFieldsNew_;
83
85 DArray<double> cArray_;
86
88 DArray<double> wArray_;
89
91 DArray<double> residual_;
92
94 DMatrix<double> jacobian_;
95
97 DArray<double> residualNew_;
98
100 DArray<double> dOmega_;
101
103 double epsilon_;
104
106 int maxItr_;
107
109 bool isAllocated_;
110
112 bool newJacobian_;
113
115 bool needsJacobian_;
116
118 bool isCanonical_;
119
120 // Private member functions
121
125 void setup();
126
134 void computeResidual(Array<FieldT> const & wFields,
135 Array<FieldT> const & cFields,
136 Array<double>& residual);
137
143 double residualNorm(Array<double> const & residual) const;
144
148 void computeJacobian();
149
157 void incrementWFields(Array<FieldT> const & wOld,
158 Array<double> const & dW,
159 Array<FieldT>& wNew);
160
161 };
162
163} // namespace R1d
164} // namespace Pscf
165#endif
Solve Ax=b by LU decomposition of A.
Definition LuSolver.h:31
Iterator()
Default constructor.
Propagator::FieldT FieldT
Field type.
Mixture::FieldT FieldT
Monomer chemical potential field.
Definition NrIterator.h:39
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.