Loading [MathJax]/extensions/TeX/AMSsymbols.js
PSCF v1.2
AmIterator.h
1#ifndef R1D_AM_ITERATOR_H
2#define R1D_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 <r1d/solvers/Mixture.h>
13#include <pscf/iterator/AmbdInteraction.h>
14#include <pscf/iterator/AmIteratorTmpl.h>
15
16namespace Pscf {
17namespace R1d
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 R1d
184} // namespace Pscf
185#endif
Template for Anderson mixing iterator algorithm.
Modified interaction to compute residual defn.
Anderson-Mixing iterator.
Definition AmIterator.h:30
void readParameters(std::istream &in)
Read all parameters and initialize.
void setup(bool isContinuation)
Setup iterator just before entering iteration loop.
AmIterator(System &system)
Constructor.
~AmIterator()
Destructor.
Base class for iterative solvers for SCF equations.
const System & system() const
Get parent System by reference.
Main class in SCFT simulation of one system.
Definition r1d/System.h:65
Dynamically allocatable contiguous array template.
Class for storing history of previous values in an array.
Definition RingBuffer.h:27
PSCF package top-level namespace.
Definition param_pc.dox:1
Utility classes for scientific computation.