PSCF v1.1
pspg/solvers/Mixture.h
1#ifndef PSPG_MIXTURE_H
2#define PSPG_MIXTURE_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 "Polymer.h"
12#include "Solvent.h"
13#include <pscf/solvers/MixtureTmpl.h>
14#include <pscf/inter/Interaction.h>
15#include <util/containers/DArray.h>
16
17namespace Pscf {
18 template <int D> class Mesh;
19}
20
21namespace Pscf {
22namespace Pspg
23{
24
25
42 template <int D>
43 class Mixture : public MixtureTmpl< Polymer<D>, Solvent<D> >
44 {
45
46 public:
47
51 Mixture();
52
56 ~Mixture();
57
67 void readParameters(std::istream& in);
68
78 void setMesh(Mesh<D> const & mesh);
79
86 void setupUnitCell(UnitCell<D> const & unitCell,
87 WaveList<D> const & waveList);
88
99 void setKuhn(int monomerId, double kuhn);
100
120 void
121 compute(DArray< RDField<D> > const & wFields,
122 DArray< RDField<D> > & cFields);
123
129 void computeStress(WaveList<D> const & waveList);
130
140 void createBlockCRGrid(DArray< RDField<D> >& blockCFields) const;
141
150 double stress(int parameterId) const;
151
152 #if 0
156 double vMonomer() const;
157 #endif
158
165 bool isCanonical();
166
167 // Public members from MixtureTmpl with non-dependent names
175
176 protected:
177
178 // Public members from MixtureTmpl with non-dependent names
182
183 private:
184
186 FArray<double, 6> stress_;
187
188 #if 0
190 double vMonomer_;
191 #endif
192
194 double ds_;
195
197 int nUnitCellParams_;
198
200 Mesh<D> const * meshPtr_;
201
203 bool hasStress_;
204
206 Mesh<D> const & mesh() const;
207
208 };
209
210 // Inline member function
211
212 #if 0
213 /*
214 * Get monomer reference volume (public).
215 */
216 template <int D>
217 inline double Mixture<D>::vMonomer() const
218 { return vMonomer_; }
219 #endif
220
221 /*
222 * Get Mesh<D> by constant reference (private).
223 */
224 template <int D>
225 inline Mesh<D> const & Mixture<D>::mesh() const
226 {
227 UTIL_ASSERT(meshPtr_);
228 return *meshPtr_;
229 }
230
231 /*
232 * Get derivative of free energy w/ respect to cell parameter.
233 */
234 template <int D>
235 inline double Mixture<D>::stress(int parameterId) const
236 {
237 UTIL_CHECK(hasStress_);
238 return stress_[parameterId];
239 }
240
241 #ifndef PSPG_MIXTURE_TPP
242 // Suppress implicit instantiation
243 extern template class Mixture<1>;
244 extern template class Mixture<2>;
245 extern template class Mixture<3>;
246 #endif
247
248} // namespace Pspg
249} // namespace Pscf
250//#include "Mixture.tpp"
251#endif
Description of a regular grid of points in a periodic domain.
Definition: Mesh.h:61
A mixture of polymer and solvent species.
Definition: MixtureTmpl.h:27
Polymer & polymer(int id)
Get a polymer object.
Definition: MixtureTmpl.h:220
int nBlock() const
Get number of total blocks in the mixture across all polymers.
Definition: MixtureTmpl.h:202
int nSolvent() const
Get number of solvent (point particle) species.
Definition: MixtureTmpl.h:198
double vMonomer() const
Get monomer reference volume (set to 1.0 by default).
Definition: MixtureTmpl.h:248
Polymer< D > Polymer
Polymer species solver typename.
Definition: MixtureTmpl.h:35
int nMonomer() const
Get number of monomer types.
Definition: MixtureTmpl.h:190
Monomer const & monomer(int id) const
Get a Monomer type descriptor (const reference).
Definition: MixtureTmpl.h:206
Solvent & solvent(int id)
Set a solvent solver object.
Definition: MixtureTmpl.h:234
Solvent< D > Solvent
Solvent species solver typename.
Definition: MixtureTmpl.h:40
int nPolymer() const
Get number of polymer species.
Definition: MixtureTmpl.h:194
Solver for a mixture of polymers and solvents.
void setKuhn(int monomerId, double kuhn)
Reset statistical segment length for one monomer type.
bool isCanonical()
Is the ensemble canonical (i.e, closed for all species)?
void readParameters(std::istream &in)
Read all parameters and initialize.
double stress(int parameterId) const
Get derivative of free energy w/ respect to cell parameter.
void setupUnitCell(UnitCell< D > const &unitCell, WaveList< D > const &waveList)
Set unit cell parameters used in solver.
void computeStress(WaveList< D > const &waveList)
Get monomer reference volume.
void compute(DArray< RDField< D > > const &wFields, DArray< RDField< D > > &cFields)
Compute concentrations.
void setMesh(Mesh< D > const &mesh)
Create an association with the mesh and allocate memory.
void createBlockCRGrid(DArray< RDField< D > > &blockCFields) const
Combine cFields for each block/solvent into one DArray.
Field of real single precision values on an FFT mesh on a device.
Definition: RDField.h:34
Container for wavevector data.
Definition: WaveList.h:31
Base template for UnitCell<D> classes, D=1, 2 or 3.
Definition: UnitCell.h:44
Dynamically allocatable contiguous array template.
Definition: DArray.h:32
A fixed size (static) contiguous array template.
Definition: FArray.h:47
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.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition: global.h:68
#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).