PSCF v1.3
rpg/scft/iterator/AmIteratorBasis.h
1#ifndef RPG_AM_ITERATOR_BASIS_H
2#define RPG_AM_ITERATOR_BASIS_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" // base class argument
12#include <pscf/iterator/AmIteratorTmpl.h> // base class template
13#include <pscf/iterator/AmbdInteraction.h> // member variable
14#include <util/containers/DArray.h> // base class argument
15#include <util/containers/RingBuffer.h> // method input variable
16
17namespace Pscf {
18namespace Rpg
19{
20
21 template <int D>
22 class System;
23
24 using namespace Util;
25
31 template <int D>
33 : public AmIteratorTmpl< Iterator<D>, DArray<double> >
34 {
35
36 public:
37
44
49
55 void readParameters(std::istream& in);
56
62 void outputTimers(std::ostream& out) const;
63
64 // Inherited public member functions
67 using Iterator<D>::isFlexible;
68 using Iterator<D>::flexibleParams;
69 using Iterator<D>::setFlexibleParams;
70 using Iterator<D>::nFlexibleParams;
71 using Iterator<D>::stress;
72
73 protected:
74
75 // Inherited protected members
82 using Iterator<D>::system;
83 using Iterator<D>::isSymmetric_;
84 using Iterator<D>::isFlexible_;
85 using Iterator<D>::flexibleParams_;
86
92 void setup(bool isContinuation);
93
94 private:
95
97 AmbdInteraction interaction_;
98
100 double scaleStress_;
101
108 void setEqual(DArray<double>& a, DArray<double> const & b);
109
113 double dotProduct(DArray<double> const & a, DArray<double> const & b);
114
118 double maxAbs(DArray<double> const & hist);
119
126 void updateBasis(RingBuffer< DArray<double> > & basis,
127 RingBuffer< DArray<double> > const & hists);
128
137 void addHistories(DArray<double>& trial,
138 RingBuffer<DArray<double> > const & basis,
139 DArray<double> coeffs, int nHist);
140
148 void addPredictedError(DArray<double>& fieldTrial,
149 DArray<double> const & resTrial,
150 double lambda);
151
153 bool hasInitialGuess();
154
158 int nElements();
159
165 void getCurrent(DArray<double>& curr);
166
170 void evaluate();
171
177 void getResidual(DArray<double>& resid);
178
184 void update(DArray<double>& newGuess);
185
189 void outputToLog();
190
191 };
192
193 #ifndef RPG_AM_ITERATOR_BASIS_TPP
194 // Suppress implicit instantiation
195 extern template class AmIteratorBasis<1>;
196 extern template class AmIteratorBasis<2>;
197 extern template class AmIteratorBasis<3>;
198 #endif
199
200} // namespace Rpg
201} // namespace Pscf
202#endif
Modified interaction to compute residual defn.
Rpg implementation of the Anderson Mixing iterator.
AmIteratorBasis(System< D > &system)
Constructor.
void readParameters(std::istream &in)
Read all parameters and initialize.
void outputTimers(std::ostream &out) const
Output timing results to log file.
void setup(bool isContinuation)
Setup iterator just before entering iteration loop.
Base class for iterative solvers for SCF equations.
Main class, representing one complete system.
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.
void readParamCompositeOptional(std::istream &in, ParamComposite &child, bool next=true)
Add and attempt to read an optional child ParamComposite.
Class for storing history of previous values in an array.
Definition RingBuffer.h:27
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.
Definition param_pc.dox:1