PSCF v1.3
rpc/scft/iterator/AmIteratorBasis.h
1#ifndef RPC_AM_ITERATOR_BASIS_H
2#define RPC_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 Rpc
19{
20
21 template <int D> class System;
22
23 using namespace Util;
24
32 template <int D>
34 : public AmIteratorTmpl< Iterator<D>, DArray<double> >
35 {
36
37 public:
38
45
50
56 void readParameters(std::istream& in);
57
63 void outputTimers(std::ostream& out) const;
64
65 // Inherited public member functions
68 using Iterator<D>::isFlexible;
69 using Iterator<D>::flexibleParams;
70 using Iterator<D>::setFlexibleParams;
71 using Iterator<D>::nFlexibleParams;
72 using Iterator<D>::stress;
73
74 protected:
75
76 // Inherited protected members
83 using Iterator<D>::system;
84 using Iterator<D>::isSymmetric_;
85 using Iterator<D>::isFlexible_;
86 using Iterator<D>::flexibleParams_;
87
93 void setup(bool isContinuation);
94
95 private:
96
98 AmbdInteraction interaction_;
99
101 double scaleStress_;
102
109 void setEqual(DArray<double>& a, DArray<double> const & b);
110
114 double dotProduct(DArray<double> const & a, DArray<double> const & b);
115
119 double maxAbs(DArray<double> const & hist);
120
127 void updateBasis(RingBuffer<DArray<double> > & basis,
128 RingBuffer<DArray<double> > const & hists);
129
138 void addHistories(DArray<double>& trial,
139 RingBuffer<DArray<double> > const & basis,
140 DArray<double> coeffs,
141 int nHist);
142
150 void addPredictedError(DArray<double>& fieldTrial,
151 DArray<double> const & resTrial,
152 double lambda);
153
157 bool hasInitialGuess();
158
164 int nElements();
165
171 void getCurrent(DArray<double>& curr);
172
179 void evaluate();
180
186 void getResidual(DArray<double>& resid);
187
193 void update(DArray<double>& newGuess);
194
198 void outputToLog();
199
200 };
201
202 #ifndef RPC_AM_ITERATOR_BASIS_TPP
203 // Suppress implicit instantiation
204 extern template class AmIteratorBasis<1>;
205 extern template class AmIteratorBasis<2>;
206 extern template class AmIteratorBasis<3>;
207 #endif
208
209} // namespace Rpc
210} // namespace Pscf
211#endif
Modified interaction to compute residual defn.
Rpc implementation of the Anderson Mixing iterator with symmetry.
void setup(bool isContinuation)
Setup iterator just before entering iteration loop.
void outputTimers(std::ostream &out) const
Output timing results to log file.
AmIteratorBasis(System< D > &system)
Constructor.
void readParameters(std::istream &in)
Read all parameters and initialize.
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
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.
Definition param_pc.dox:1