PSCF v1.1
pspc/solvers/Block.h
1#ifndef PSPC_BLOCK_H
2#define PSPC_BLOCK_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 "Propagator.h" // base class argument
12#include <pscf/solvers/BlockTmpl.h> // base class template
13#include <pscf/mesh/Mesh.h> // member
14#include <pscf/crystal/UnitCell.h> // member
15#include <pspc/field/RField.h> // member
16#include <pspc/field/RFieldDft.h> // member
17#include <pspc/field/FFT.h> // member
18#include <util/containers/FArray.h> // member template
19#include <util/containers/DMatrix.h> // member template
20
21namespace Pscf {
22 template <int D> class Mesh;
23 template <int D> class UnitCell;
24}
25
26namespace Pscf {
27namespace Pspc {
28
29 using namespace Util;
30
40 template <int D>
41 class Block : public BlockTmpl< Propagator<D> >
42 {
43
44 public:
45
49 Block();
50
54 ~Block();
55
70 void setDiscretization(double ds, const Mesh<D>& mesh);
71
86 void setupUnitCell(const UnitCell<D>& unitCell);
87
93 void setLength(double newLength);
94
100 void setKuhn(double kuhn);
101
112 void setupSolver(RField<D> const & w);
113
125 void step(RField<D> const & q, RField<D>& qNew);
126
145 void computeConcentration(double prefactor);
146
156 void computeStress(double prefactor);
157
161 Mesh<D> const & mesh() const;
162
166 double ds() const;
167
171 int ns() const;
172
181 double stress(int n) const;
182
183 // Functions with non-dependent names from BlockTmpl< Propagator<D> >
184 using BlockTmpl< Propagator<D> >::setKuhn;
185 using BlockTmpl< Propagator<D> >::propagator;
186 using BlockTmpl< Propagator<D> >::cField;
187 using BlockTmpl< Propagator<D> >::length;
188 using BlockTmpl< Propagator<D> >::kuhn;
189
190 // Functions with non-dependent names from BlockDescriptor
200
201 private:
202
203 // Matrix to store derivatives of plane waves
204 DMatrix<double> dGsq_;
205
206 // Stress arising from this block
207 FSArray<double, 6> stress_;
208
209 // Fourier transform plan
210 FFT<D> fft_;
211
212 // Array of elements containing exp(-K^2 b^2 ds/6)
213 RField<D> expKsq_;
214
215 // Array of elements containing exp(-W[i] ds/2)
216 RField<D> expW_;
217
218 // Array of elements containing exp(-K^2 b^2 ds/(6*2))
219 RField<D> expKsq2_;
220
221 // Array of elements containing exp(-W[i] (ds/2)*0.5)
222 RField<D> expW2_;
223
224 // Work array for real-space field (step size ds)
225 RField<D> qr_;
226
227 // Work array for real-space field (step size ds/2)
228 RField<D> qr2_;
229
230 // Work array for wavevector space field (step size ds)
231 RFieldDft<D> qk_;
232
233 // Work array for wavevector space field (step size ds/2)
234 RFieldDft<D> qk2_;
235
236 // Pointer to associated Mesh<D> object
237 Mesh<D> const* meshPtr_;
238
239 // Pointer to associated UnitCell<D> object
240 UnitCell<D> const* unitCellPtr_;
241
242 // Dimensions of wavevector mesh in real-to-complex transform
243 IntVec<D> kMeshDimensions_;
244
245 // Contour length step size (actual step size for this block)
246 double ds_;
247
248 // Contour length step size (value input in param file)
249 double dsTarget_;
250
251 // Number of contour grid points = # of contour steps + 1
252 int ns_;
253
254 // Have arrays been allocated in setDiscretization ?
255 bool isAllocated_;
256
257 // Are expKsq_ arrays up to date ? (initialize false)
258 bool hasExpKsq_;
259
263 UnitCell<D> const & unitCell() const
264 { return *unitCellPtr_; }
265
269 void computedGsq();
270
274 void computeExpKsq();
275
276 };
277
278 // Inline member functions
279
281 template <int D>
282 inline int Block<D>::ns() const
283 { return ns_; }
284
286 template <int D>
287 inline double Block<D>::ds() const
288 { return ds_; }
289
291 template <int D>
292 inline double Block<D>::stress(int n) const
293 { return stress_[n]; }
294
296 template <int D>
297 inline Mesh<D> const & Block<D>::mesh() const
298 {
299 UTIL_ASSERT(meshPtr_);
300 return *meshPtr_;
301 }
302
303 #ifndef PSPC_BLOCK_TPP
304 // Suppresse implicit instantiation
305 extern template class Block<1>;
306 extern template class Block<2>;
307 extern template class Block<3>;
308 #endif
309
310}
311}
312#endif
double length() const
Get the length (number of monomers) in this block.
int vertexId(int i) const
Get id of an associated vertex.
void setId(int id)
Set the id for this block.
int monomerId() const
Get the monomer type id.
const Pair< int > & vertexIds() const
Get the pair of associated vertex ids.
virtual void setLength(double length)
Set the length of this block.
void setVertexIds(int vertexAId, int vertexBId)
Set indices of associated vertices.
int id() const
Get the id of this block.
void setMonomerId(int monomerId)
Set the monomer id.
Class template for a block in a block copolymer.
Definition: BlockTmpl.h:89
double kuhn() const
Get monomer statistical segment length.
Definition: BlockTmpl.h:205
Propagator< D > & propagator(int directionId)
Get a Propagator for a specified direction.
Definition: BlockTmpl.h:174
TP::CField & cField()
Get the associated monomer concentration field.
Definition: BlockTmpl.h:190
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition: IntVec.h:27
Description of a regular grid of points in a periodic domain.
Definition: Mesh.h:61
Block within a branched polymer.
void computeStress(double prefactor)
Compute stress contribution for this block.
double length() const
Get the length (number of monomers) in this block.
void step(RField< D > const &q, RField< D > &qNew)
Compute one step of solution of MDE, from step i to i+1.
Mesh< D > const & mesh() const
Get associated spatial Mesh by const reference.
void setDiscretization(double ds, const Mesh< D > &mesh)
Initialize discretization and allocate required memory.
double stress(int n) const
Get derivative of free energy w/ respect to unit cell parameter n.
void computeConcentration(double prefactor)
Compute concentration (volume fraction) for block by integration.
double ds() const
Get contour length step size.
void setLength(double newLength)
Set or reset block length.
void setupUnitCell(const UnitCell< D > &unitCell)
Setup parameters that depend on the unit cell.
void setKuhn(double kuhn)
Set or reset monomer statistical segment length.
int ns() const
Get the number of contour length steps in this block.
void setupSolver(RField< D > const &w)
Set solver for this block.
Fourier transform wrapper for real data.
Fourier transform of a real field on an FFT mesh.
Definition: RFieldDft.h:31
Field of real double precision values on an FFT mesh.
Definition: RField.h:29
Base template for UnitCell<D> classes, D=1, 2 or 3.
Definition: UnitCell.h:44
Dynamically allocated Matrix.
Definition: DMatrix.h:25
A fixed capacity (static) contiguous array with a variable logical size.
Definition: FSArray.h:38
#define UTIL_ASSERT(condition)
Assertion macro suitable for debugging serial or parallel code.
Definition: global.h:75
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1