PSCF v1.1
pspc/solvers/Mixture.h
1#ifndef PSPC_MIXTURE_H
2#define PSPC_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 <pscf/chem/Monomer.h>
16#include <util/containers/DArray.h>
17#include <util/containers/FArray.h>
18
19#include <iostream>
20
21namespace Pscf {
22 template <int D> class Mesh;
23}
24
25namespace Pscf {
26namespace Pspc
27{
28
57 template <int D>
58 class Mixture : public MixtureTmpl< Polymer<D>, Solvent<D> >
59 {
60
61 public:
62
66 Mixture();
67
71 ~Mixture();
72
82 void readParameters(std::istream& in);
83
93 void setMesh(Mesh<D> const & mesh);
94
104 void setupUnitCell(const UnitCell<D>& unitCell);
105
116 void setKuhn(int monomerId, double kuhn);
117
145 void compute(DArray< RField<D> > const & wFields,
146 DArray< RField<D> >& cFields,
147 double phiTot = 1.0);
148
152 void computeStress();
153
161 void createBlockCRGrid(DArray< RField<D> >& blockCFields) const;
162
174 double stress(int n) const;
175
183 bool isCanonical();
184
185 // Inherited public member functions with non-dependent names
193
194 protected:
195
196 // Inherited protected member functions with non-dependent names
200
201 private:
202
204 double ds_;
205
207 FArray<double, 6> stress_;
208
210 Mesh<D> const * meshPtr_;
211
213 UnitCell<D> const * unitCellPtr_;
214
216 Mesh<D> const & mesh() const;
217
219 bool hasStress_;
220
221 };
222
223 // Inline member function
224
225 // Stress with respect to unit cell parameter n.
226 template <int D>
227 inline double Mixture<D>::stress(int n) const
228 {
229 UTIL_CHECK(hasStress_);
230 return stress_[n];
231 }
232
233 // Get Mesh<D> by constant reference (private).
234 template <int D>
235 inline Mesh<D> const & Mixture<D>::mesh() const
236 {
237 UTIL_ASSERT(meshPtr_);
238 return *meshPtr_;
239 }
240
241 #ifndef PSPC_MIXTURE_TPP
242 extern template class Mixture<1>;
243 extern template class Mixture<2>;
244 extern template class Mixture<3>;
245 #endif
246
247} // namespace Pspc
248} // namespace Pscf
249#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
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.
bool isCanonical()
Is this mixture being treated in canonical ensemble?
void createBlockCRGrid(DArray< RField< D > > &blockCFields) const
Combine cFields for each block/solvent into one DArray, which is used in System.tpp to print a more d...
double stress(int n) const
Get derivative of free energy w/ respect to a unit cell parameter.
void setKuhn(int monomerId, double kuhn)
Reset statistical segment length for one monomer type.
void setupUnitCell(const UnitCell< D > &unitCell)
Set unit cell parameters used in solver.
void setMesh(Mesh< D > const &mesh)
Create an association with the mesh and allocate memory.
void compute(DArray< RField< D > > const &wFields, DArray< RField< D > > &cFields, double phiTot=1.0)
Compute partition functions and concentrations.
void readParameters(std::istream &in)
Read all parameters and initialize.
void computeStress()
Compute derivatives of free energy w/ respect to cell parameters.
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 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).