PSCF v1.1
fd1d/solvers/Polymer.cpp
1/*
2* PSCF - Polymer Self-Consistent Field Theory
3*
4* Copyright 2016 - 2022, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "Polymer.h"
9
10namespace Pscf {
11namespace Fd1d
12{
13
15 { setClassName("Polymer"); }
16
18 {}
19
20 void Polymer::setPhi(double phi)
21 {
22 UTIL_CHECK(ensemble() == Species::Closed);
23 UTIL_CHECK(phi >= 0.0);
24 UTIL_CHECK(phi <= 1.0);
25 phi_ = phi;
26 }
27
28 void Polymer::setMu(double mu)
29 {
30 UTIL_CHECK(ensemble() == Species::Open);
31 mu_ = mu;
32 }
33
34 /*
35 * Compute solution to MDE and concentrations.
36 */
38 {
39
40 // Setup solvers for all blocks
41 int monomerId;
42 for (int j = 0; j < nBlock(); ++j) {
43 monomerId = block(j).monomerId();
44 block(j).setupSolver(wFields[monomerId]);
45 }
46
47 solve();
48 }
49
50}
51}
void setPhi(double phi)
Set volume fraction (if ensemble is closed).
void compute(DArray< Block::WField > const &wFields)
Compute solution to modified diffusion equation.
void setMu(double mu)
Set chemical potential mu (if ensemble is open).
Polymer()
Default constructor.
Block & block(int id)
Get a specified Block.
Definition: PolymerTmpl.h:276
int nBlock() const
Number of blocks.
Definition: PolymerTmpl.h:241
virtual void solve(double phiTot=1.0)
Solve modified diffusion equation.
Definition: PolymerTmpl.h:522
double phi() const
Get the overall volume fraction for this species.
Definition: Species.h:90
Ensemble ensemble()
Get the statistical ensemble for this species (open or closed).
Definition: Species.h:102
double phi_
Volume fraction, set by either setPhi or compute function.
Definition: Species.h:68
double mu_
Chemical potential, set by either setPhi or compute function.
Definition: Species.h:73
double mu() const
Get the chemical potential for this species (units kT=1).
Definition: Species.h:96
Dynamically allocatable contiguous array template.
Definition: DArray.h:32
void setClassName(const char *className)
Set class name string.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition: global.h:68
C++ namespace for polymer self-consistent field theory (PSCF).