1#ifndef PSPC_MIXTURE_TPP
2#define PSPC_MIXTURE_TPP
12#include <pscf/mesh/Mesh.h>
56 for (i = 0; i < nPolymer(); ++i) {
57 for (j = 0; j < polymer(i).nBlock(); ++j) {
58 polymer(i).block(j).setDiscretization(ds_, mesh);
65 for (
int i = 0; i < nSolvent(); ++i) {
66 solvent(i).setDiscretization(mesh);
77 unitCellPtr_ = &unitCell;
81 for (
int i = 0; i < nPolymer(); ++i) {
82 polymer(i).setupUnitCell(unitCell);
97 monomer(monomerId).setKuhn(kuhn);
100 for (
int i = 0; i < nPolymer(); ++i) {
101 for (
int j = 0; j < polymer(i).nBlock(); ++j) {
102 if (monomerId == polymer(i).block(j).monomerId()) {
103 polymer(i).block(j).setKuhn(kuhn);
125 int nMesh = mesh().size();
130 for (i = 0; i < nm; ++i) {
133 for (j = 0; j < nMesh; ++j) {
140 for (i = 0; i < nPolymer(); ++i) {
141 polymer(i).compute(wFields, phiTot);
146 for (i = 0; i < nPolymer(); ++i) {
147 for (j = 0; j < polymer(i).nBlock(); ++j) {
148 monomerId = polymer(i).block(j).monomerId();
151 RField<D>& monomerField = cFields[monomerId];
152 RField<D> const & blockField = polymer(i).block(j).cField();
154 for (k = 0; k < nMesh; ++k) {
155 monomerField[k] += blockField[k];
162 for (i = 0; i < nSolvent(); ++i) {
163 monomerId = solvent(i).monomerId();
168 solvent(i).compute(wFields[monomerId], phiTot);
171 RField<D>& monomerField = cFields[monomerId];
172 RField<D> const & solventField = solvent(i).cField();
174 for (k = 0; k < nMesh; ++k) {
175 monomerField[k] += solventField[k];
192 for (i = 0; i < 6; ++i) {
196 if (nPolymer() > 0) {
199 for (i = 0; i < nPolymer(); ++i) {
200 polymer(i).computeStress();
204 for (i = 0; i < unitCellPtr_->nParameter(); ++i) {
205 for (j = 0; j < nPolymer(); ++j) {
206 stress_[i] += polymer(j).stress(i);
222 for (
int i = 0; i < nPolymer(); ++i) {
223 if (polymer(i).ensemble() == Species::Open) {
228 for (
int i = 0; i < nSolvent(); ++i) {
229 if (solvent(i).ensemble() == Species::Open) {
248 int np = nSolvent() + nBlock();
249 int nx = mesh().size();
252 UTIL_CHECK(blockCFields.capacity() == nBlock() + nSolvent());
255 for (i = 0; i < np; ++i) {
257 for (j = 0; j < nx; ++j) {
258 blockCFields[i][j] = 0.0;
265 if (nPolymer() > 0) {
268 for (i = 0; i < nPolymer(); ++i) {
269 for (j = 0; j < polymer(i).nBlock(); ++j) {
274 UTIL_CHECK(blockCFields[sectionId].capacity() == nx);
276 blockCFields[sectionId] = polymer(i).block(j).cField();
282 if (nSolvent() > 0) {
285 for (i = 0; i < nSolvent(); ++i) {
290 UTIL_CHECK(blockCFields[sectionId].capacity() == nx);
292 blockCFields[sectionId] = solvent(i).cField();
Description of a regular grid of points in a periodic domain.
A mixture of polymer and solvent species.
Solvent< D > Solvent
Solvent species solver typename.
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...
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.
Base template for UnitCell<D> classes, D=1, 2 or 3.
int capacity() const
Return allocated size.
Dynamically allocatable contiguous array template.
void setClassName(const char *className)
Set class name string.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
C++ namespace for polymer self-consistent field theory (PSCF).