PSCF v1.5.0
LrCompressor.h
1#ifndef RP_LR_COMPRESSOR_H
2#define RP_LR_COMPRESSOR_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <rp/fts/compressor/Compressor.h> // base class
12#include <rp/fts/compressor/IntraCorrelation.h> // member
13#include <pscf/field/RField.h> // member
14#include <pscf/field/RFieldDft.h> // member
15#include <pscf/math/IntVec.h> // member
16#include <util/containers/DArray.h> // member
17#include <util/misc/Timer.h> // member
18
19#include <pscf/backend/TmplDeclare.h>
20
21// Forward declarations
22namespace Pscf {
23 template <int D, class T> class FFT;
24 namespace Rp {
25 template <int D, class T> class System;
26 template <int D, class T> class Simulator;
27 }
28}
29
30namespace Pscf {
31namespace Rp {
32
33 using namespace Util;
34
51 template <int D, class T>
52 class LrCompressor : public Compressor<D,T>
53 {
54
55 public:
56
63
67 ~LrCompressor() = default;
68
74 void readParameters(std::istream& in) override;
75
81 int compress() override;
82
86 void clearCache() override;
87
93 void outputTimers(std::ostream& out) const override;
94
98 void clearTimers() override;
99
100 protected:
101
102 // Inherited protected member (for convenience)
103 using Compressor<D,T>::system;
104
105 private:
106
107 // Private member variables
108
109 // Template w Field used in update function
110 DArray< RField<D,T> > wFieldTmp_;
111
112 // Residual in real space
113 RField<D,T> resid_;
114
115 // Residual in Fourier space
116 RFieldDft<D,T> residK_;
117
118 // Intramolecular correlation in Fourier space
119 RField<D,T> intraCorrelationK_;
120
121 // IntraCorrelation object
123
124 // Dimensions of wavevector mesh in real-to-complex transform
125 IntVec<D> kMeshDimensions_;
126
127 // Timers for analyzing performance
128 Timer timerTotal_;
129 Timer timerMDE_;
130
131 // Type of error criterion used to test convergence
132 std::string errorType_;
133
134 // Error tolerance
135 double epsilon_;
136
137 // Current iteration counter
138 int itr_;
139
140 // Maximum number of iterations
141 int maxItr_;
142
143 // Total iteration counter
144 int totalItr_;
145
146 // Verbosity level
147 int verbose_;
148
149 // Has required memory been allocated?
150 bool isAllocated_;
151
152 // Is the IntraCorrelationK_ array up to date?
153 bool hasIntraCorrelationK_;
154
155 // Private member functions
156
164 void setup();
165
169 void computeResidual();
170
174 void updateWFields();
175
182 double computeError(int verbose);
183
187 void outputToLog();
188
189 };
190
191 // Explicit instantiation declaration
192 PSCF_TMPL_DECLARE(LrCompressor)
193
194} // namespace Rp
195} // namespace Pscf
196#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Compressor()
Default constructor.
System< D, T > const & system() const
Return parent system by const reference.
Definition Compressor.h:128
Intramolecular correlation analyzer.
Linear response compressor.
int compress() override
Iterate pressure field to obtain partial saddle point.
void outputTimers(std::ostream &out) const override
Return compressor times contributions.
void readParameters(std::istream &in) override
Read all parameters and initialize.
void clearCache() override
Mark the stored intramolecular correlation function as outdated.
~LrCompressor()=default
Destructor.
void clearTimers() override
Clear all timers.
LrCompressor(System< D, T > &system)
Constructor.
Base class for field theoretic PS-FTS simulator.
Definition Simulator.h:93
Base class template for classes that represent a complete system.
Dynamically allocatable contiguous array template.
Definition DArray.h:32
Wall clock timer.
Definition Timer.h:35
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.