PSCF v1.1
pspc/iterator/AmIterator.h
1#ifndef PSPC_AM_ITERATOR_H
2#define PSPC_AM_ITERATOR_H
3
4/*
5* PSCF - Polymer Self-Consistent Field Theory
6*
7* Copyright 2016 - 2022, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include "Iterator.h" // base class
12#include <pscf/iterator/AmIteratorTmpl.h> // base class template
13#include <pscf/iterator/AmbdInteraction.h> // member variable
14
15namespace Pscf {
16namespace Pspc
17{
18
19 template <int D>
20 class System;
21
22 using namespace Util;
23
29 template <int D>
30 class AmIterator : public AmIteratorTmpl<Iterator<D>, DArray<double> >
31 {
32
33 public:
34
40 AmIterator(System<D>& system);
41
46
52 void readParameters(std::istream& in);
53
54 // Inherited public member functions
56 using Iterator<D>::isFlexible;
57 using Iterator<D>::flexibleParams;
58 using Iterator<D>::setFlexibleParams;
59 using Iterator<D>::nFlexibleParams;
60
61 protected:
62
63 // Inherited protected members
68 using Iterator<D>::system;
69 using Iterator<D>::isFlexible_;
70 using Iterator<D>::flexibleParams_;
71
72
78 void setup(bool isContinuation);
79
80 private:
81
82 // Local copy of interaction, adapted for use AMBD residual definition
83 AmbdInteraction interaction_;
84
86 double scaleStress_;
87
94 void setEqual(DArray<double>& a, DArray<double> const & b);
95
99 double dotProduct(DArray<double> const & a, DArray<double> const & b);
100
104 double maxAbs(DArray<double> const & hist);
105
112 void updateBasis(RingBuffer<DArray<double> > & basis,
113 RingBuffer<DArray<double> > const & hists);
114
123 void addHistories(DArray<double>& trial,
124 RingBuffer<DArray<double> > const & basis,
125 DArray<double> coeffs,
126 int nHist);
127
135 void addPredictedError(DArray<double>& fieldTrial,
136 DArray<double> const & resTrial,
137 double lambda);
138
142 bool hasInitialGuess();
143
149 int nElements();
150
156 void getCurrent(DArray<double>& curr);
157
164 void evaluate();
165
171 void getResidual(DArray<double>& resid);
172
178 void update(DArray<double>& newGuess);
179
183 void outputToLog();
184
185 };
186
187} // namespace Pspc
188} // namespace Pscf
189#endif
Template for Anderson mixing iterator algorithm.
int verbose() const
Verbosity level, allowed values 0, 1, or 2.
int solve(bool isContinuation=false)
Iterate to a solution.
Modified interaction to compute residual defn.
Pspc implementation of the Anderson Mixing iterator.
void setup(bool isContinuation)
Setup iterator just before entering iteration loop.
Definition: AmIterator.tpp:82
void readParameters(std::istream &in)
Read all parameters and initialize.
Definition: AmIterator.tpp:36
~AmIterator()
Destructor.
Definition: AmIterator.tpp:31
Base class for iterative solvers for SCF equations.
Main class for SCFT simulation of one system.
Definition: pspc/System.h:76
Dynamically allocatable contiguous array template.
Definition: DArray.h:32
FSArrayParam< Type, N > & readOptionalFSArray(std::istream &in, const char *label, FSArray< Type, N > &array, int size)
Add and read an optional FSArray < Type, N > array parameter.
void setClassName(const char *className)
Set class name string.
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
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