PSCF v1.4.0
cp/solvers/Mixture.h
1#ifndef PRDC_CL_MIXTURE_H
2#define PRDC_CL_MIXTURE_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 <pscf/solvers/MixtureTmpl.h> // base class template
12#include <iostream>
13
14// Forward declarations
15namespace Util {
16 template <typename T> class DArray;
17}
18namespace Pscf {
19 template <int D> class Mesh;
20 namespace Prdc {
21 template <int D> class UnitCell;
22 }
23}
24
25namespace Pscf {
26namespace Cp {
27
28 using namespace Util;
29 using namespace Prdc;
30
50 template <int D, class PT, class ST, class TT>
51 class Mixture : public MixtureTmpl< PT, ST, std::complex<double> >
52 {
53
54 public:
55
56 // Public type name aliases
57
60
63
65 using typename MixtureTmplT::SolventT;
66
68 using typename MixtureTmplT::PolymerT;
69
71 using BlockT = typename TT::Block;
72
74 using PropagatorT = typename TT::Propagator;
75
77 using FieldT = typename TT::CField;
78
80 using FFTT = typename TT::FFT;
81
83 using WaveListT = typename TT::WaveList;
84
86 using FieldIoT = typename TT::FieldIo;
87
88 // Public member functions
89
92
96 Mixture();
97
101 ~Mixture();
102
112 virtual void readParameters(std::istream& in);
113
134 void associate(Mesh<D> const & mesh,
135 FFTT const & fft,
136 UnitCell<D> const & cell,
137 WaveListT& waveList);
138
147 void setFieldIo(FieldIoT const & fieldIo);
148
155 void allocate();
156
160
182 void compute(DArray<FieldT> const & wFields,
183 DArray<FieldT>& cFields);
184
188
199 void setKuhn(int monomerId, double kuhn);
200
209 void clearUnitCellData();
210
212
213 #if 0 // Delay implementation and testing
216
237 void createBlockCRGrid(DArray<FieldT>& blockCFields) const;
238
252 void writeBlockCRGrid(std::string const & filename) const;
253
255 #endif
256
257 #if 0 // Delay implementation and testing
260
270 void writeQSlice(std::string const & filename,
271 int polymerId, int blockId,
272 int directionId, int segmentId) const;
273
282 void writeQTail(std::string const & filename, int polymerId,
283 int blockId, int directionId) const;
284
293 void writeQ(std::string const & filename, int polymerId,
294 int blockId, int directionId) const;
295
314 void writeQAll(std::string const & basename);
315
317 #endif
318
319 // Inherited public member functions
331
332 protected:
333
335 Mesh<D> const & mesh() const
336 { return *meshPtr_; }
337
339 UnitCell<D> const & unitCell() const
340 { return *unitCellPtr_; }
341
343 FieldIoT const & fieldIo() const
344 { return *fieldIoPtr_; }
345
347 double ds() const
348 { return ds_; }
349
350 // Inherited protected member functions
354
355 private:
356
357 // Private member data
358
360 double ds_;
361
363 Mesh<D> const * meshPtr_;
364
365 // Pointer to associated UnitCell<D> object
366 UnitCell<D> const * unitCellPtr_;
367
368 // Pointer to associated FieldIoT object
369 FieldIoT const * fieldIoPtr_;
370
371 // Private member functions (pure virtual)
372
379 virtual void eqS(FieldT& A, double s) const = 0;
380
387 virtual void addEqV(FieldT& A, FieldT const & B) const = 0;
388
392 virtual void allocateBlocks() = 0;
393
394 };
395
396} // namespace Cp
397} // namespace Pscf
398#endif
typename TT::FFT FFTT
WaveList type.
UnitCell< D > const & unitCell() const
Return associated UnitCell<D> by const reference.
double ds() const
Return target value for the contour step size ds (thread model).
virtual void readParameters(std::istream &in)
Read all parameters and initialize.
typename TT::FieldIo FieldIoT
FieldIo type.
MixtureBase< std::complex< double > > MixtureBaseT
MixtureBase class.
void clearUnitCellData()
Clear all data that depends on the unit cell parameters.
typename TT::WaveList WaveListT
WaveList type.
void setKuhn(int monomerId, double kuhn)
Reset statistical segment length for one monomer type.
typename TT::Propagator PropagatorT
Propagator type, for one direction within a block.
MixtureTmpl< PT, ST, std::complex< double > > MixtureTmplT
MixtureTmpl class.
void compute(DArray< FieldT > const &wFields, DArray< FieldT > &cFields)
Compute partition functions and concentrations.
void associate(Mesh< D > const &mesh, FFTT const &fft, UnitCell< D > const &cell, WaveListT &waveList)
Create associations with Mesh, FFT, UnitCell, and WaveList objects.
void allocate()
Allocate required internal memory for all solvers.
Mesh< D > const & mesh() const
Return associated Mesh<D> by const reference.
FieldIoT const & fieldIo() const
Return associated FieldIoT by const reference.
typename TT::Block BlockT
Block type, for a block in a block polymer.
void setFieldIo(FieldIoT const &fieldIo)
Create an association with a FieldIoT object.
typename TT::CField FieldT
Field type, for data defined on a real-space grid.
Description of a regular grid of points in a periodic domain.
Definition Mesh.h:61
Abstract descriptor for a mixture of polymer and solvent species.
Definition MixtureBase.h:58
Monomer const & monomer(int id) const
SolventSpecies< std::complex< double > > const & solventSpecies(int id) const final
PolymerSpecies< std::complex< double > > const & polymerSpecies(int id) const final
Base template for UnitCell<D> classes, D=1, 2 or 3.
Definition UnitCell.h:56
Dynamically allocatable contiguous array template.
Definition DArray.h:32
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
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.
Complex-valued periodic fields (class templates).
Definition cp.mod:6
Periodic fields and crystallography.
Definition complex.cpp:11
PSCF package top-level namespace.
Utility classes for scientific computation.