PSCF v1.2
rpg/solvers/Mixture.h
1#ifndef RPG_MIXTURE_H
2#define RPG_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 namespace Prdc {
20 namespace Cuda {
21 template <int D> class FFT;
22 }
23 }
24}
25
26namespace Pscf {
27namespace Rpg
28{
29
30 using namespace Pscf::Prdc;
31 using namespace Pscf::Prdc::Cuda;
32
49 template <int D>
50 class Mixture : public MixtureTmpl< Polymer<D>, Solvent<D> >
51 {
52
53 public:
54
58 Mixture();
59
63 ~Mixture();
64
74 void readParameters(std::istream& in);
75
93 void associate(Mesh<D> const & mesh, FFT<D> const & fft,
94 UnitCell<D> const & cell, WaveList<D>& wavelist);
95
101 void allocate();
102
106 void clearUnitCellData();
107
118 void setKuhn(int monomerId, double kuhn);
119
147 void compute(DArray< RField<D> > const & wFields,
148 DArray< RField<D> > & cFields,
149 double phiTot = 1.0);
150
162 void computeStress(double phiTot = 1.0);
163
173 void createBlockCRGrid(DArray< RField<D> >& blockCFields) const;
174
183 double stress(int parameterId) const;
184
185 #if 0
189 double vMonomer() const;
190 #endif
191
198 bool isCanonical();
199
200 // Public members from MixtureTmpl with non-dependent names
208
209 protected:
210
211 // Public members from MixtureTmpl with non-dependent names
215
216 private:
217
219 FArray<double, 6> stress_;
220
222 double ds_;
223
225 Mesh<D> const * meshPtr_;
226
228 int nParams_;
229
231 bool hasStress_;
232
234 bool useBatchedFFT_;
235
236 // Private function
237
239 Mesh<D> const & mesh() const;
240
241 };
242
243 // Inline member function
244
245 /*
246 * Get Mesh<D> by constant reference (private).
247 */
248 template <int D>
249 inline Mesh<D> const & Mixture<D>::mesh() const
250 {
251 UTIL_ASSERT(meshPtr_);
252 return *meshPtr_;
253 }
254
255 /*
256 * Get derivative of free energy w/ respect to cell parameter.
257 */
258 template <int D>
259 inline double Mixture<D>::stress(int parameterId) const
260 {
261 UTIL_CHECK(hasStress_);
262 return stress_[parameterId];
263 }
264
265 #ifndef RPG_MIXTURE_TPP
266 // Suppress implicit instantiation
267 extern template class Mixture<1>;
268 extern template class Mixture<2>;
269 extern template class Mixture<3>;
270 #endif
271
272} // namespace Rpg
273} // namespace Pscf
274//#include "Mixture.tpp"
275#endif
Description of a regular grid of points in a periodic domain.
A mixture of polymer and solvent species.
Definition MixtureTmpl.h:27
Fourier transform wrapper.
Field of real double precision values on an FFT mesh.
Base template for UnitCell<D> classes, D=1, 2 or 3.
Definition rpg/System.h:34
Solver for a mixture of polymers and solvents.
double stress(int parameterId) const
Get derivative of free energy w/ respect to cell parameter.
void compute(DArray< RField< D > > const &wFields, DArray< RField< D > > &cFields, double phiTot=1.0)
Compute partition functions and concentrations.
void allocate()
Allocate internal data containers in all solvers.
void createBlockCRGrid(DArray< RField< D > > &blockCFields) const
Combine cFields for each block/solvent into one DArray.
void computeStress(double phiTot=1.0)
Compute derivatives of free energy w/ respect to cell parameters.
void associate(Mesh< D > const &mesh, FFT< D > const &fft, UnitCell< D > const &cell, WaveList< D > &wavelist)
Create associations with a mesh, FFT, UnitCell, and WaveList object.
void readParameters(std::istream &in)
Read all parameters and initialize.
void clearUnitCellData()
Clear data that depends on lattice parameters in all solvers.
bool isCanonical()
Is the ensemble canonical (i.e, closed for all species)?
void setKuhn(int monomerId, double kuhn)
Reset statistical segment length for one monomer type.
Class to calculate and store properties of wavevectors.
Definition WaveList.h:39
Dynamically allocatable contiguous array template.
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
Fields, FFTs, and utilities for periodic boundary conditions (CUDA)
Definition CField.cu:12
Periodic fields and crystallography.
Definition CField.cpp:11
PSCF package top-level namespace.
Definition param_pc.dox:1