PSCF v1.1
fd1d/iterator/AmIterator.h
1#ifndef FD1D_AM_ITERATOR_H
2#define FD1D_AM_ITERATOR_H
3
4/*
5* PSCF - Polymer Self-Consistent Field Theory
6*
7* Copyright 2016 - 2019, 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 <fd1d/solvers/Mixture.h>
13#include <pscf/iterator/AmbdInteraction.h>
14#include <pscf/iterator/AmIteratorTmpl.h>
15
16namespace Pscf {
17namespace Fd1d
18{
19
20 class System;
21
22 using namespace Util;
23
29 class AmIterator : public AmIteratorTmpl<Iterator, DArray<double> >
30 {
31
32 public:
33
39 AmIterator(System& system);
40
45
51 void readParameters(std::istream& in);
52
53 // Inherited public member functions
55 using AmIteratorTmpl<Iterator,DArray<double> >::setClassName;
56
57 protected:
58
59 // Inherited protected members
60 using Iterator::system;
61
67 void setup(bool isContinuation);
68
69 private:
70
71 // Local copy of interaction, adapted for use AMBD residual definition
72 AmbdInteraction interaction_;
73
74 // -- Virtual functions used to implement AM algorithm -- //
75
82 void setEqual(DArray<double>& a, DArray<double> const & b);
83
87 double
88 dotProduct(DArray<double> const & a, DArray<double> const & b);
89
93 double maxAbs(DArray<double> const & hist);
94
101 void updateBasis(RingBuffer<DArray<double> > & basis,
102 RingBuffer<DArray<double> > const & hists);
103
112 void addHistories(DArray<double>& trial,
113 RingBuffer<DArray<double> > const & basis,
114 DArray<double> coeffs,
115 int nHist);
116
124 void addPredictedError(DArray<double>& fieldTrial,
125 DArray<double> const & resTrial,
126 double lambda);
127
128 // -- Virtual funtions to exchange data with parent System -- //
129
133 bool hasInitialGuess();
134
140 int nElements();
141
147 void getCurrent(DArray<double>& curr);
148
155 void evaluate();
156
162 void getResidual(DArray<double>& resid);
163
169 void update(DArray<double>& newGuess);
170
174 void outputToLog();
175
179 bool isCanonical();
180
181 };
182
183} // namespace Fd1d
184} // namespace Pscf
185#endif
Template for Anderson mixing iterator algorithm.
int solve(bool isContinuation=false)
Iterate to a solution.
Modified interaction to compute residual defn.
Anderson-Mixing iterator.
void readParameters(std::istream &in)
Read all parameters and initialize.
void setup(bool isContinuation)
Setup iterator just before entering iteration loop.
Base class for iterative solvers for SCF equations.
const System & system() const
Get parent System by reference.
Definition: SystemAccess.h:158
Main class in SCFT simulation of one system.
Definition: fd1d/System.h:63
Dynamically allocatable contiguous array template.
Definition: DArray.h:32
Class for storing history of previous values in an array.
Definition: RingBuffer.h:27
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1