PSCF v1.2
SolventSpecies.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 "SolventSpecies.h"
9
10namespace Pscf {
11
12 /*
13 * Constructor
14 */
16 : Species(),
17 monomerId_(-1),
18 size_(0.0)
19 { setClassName("SolventSpecies"); }
20
21 /*
22 * Destructor
23 */
26
27 /*
28 * Read contents of parameter file block
29 */
30 void SolventSpecies::readParameters(std::istream& in)
31 {
32 read<int>(in, "monomerId", monomerId_);
33 read<double>(in, "size", size_);
34
35 // Read phi or mu (but not both)
36 bool hasPhi = readOptional(in, "phi", phi_).isActive();
37 if (hasPhi) {
38 ensemble_ = Species::Closed;
39 } else {
40 ensemble_ = Species::Open;
41 read(in, "mu", mu_);
42 }
43 }
44
45 /*
46 * Rest phi to a new value, if closed ensemble.
47 */
48 void SolventSpecies::setPhi(double phi)
49 {
50 UTIL_CHECK(ensemble() == Species::Closed);
51 UTIL_CHECK(phi >= 0.0);
52 UTIL_CHECK(phi <= 1.0);
53 phi_ = phi;
54 }
55
56 /*
57 * Rest mu to a new value, if open ensemble.
58 */
59 void SolventSpecies::setMu(double mu)
60 {
61 UTIL_CHECK(ensemble() == Species::Open);
62 mu_ = mu;
63 }
64
65 /*
66 * Set the monomer type id for this solvent species.
67 */
68 void SolventSpecies::setMonomerId(int monomerId)
70
71 /*
72 * Set the size parameter for this solvent.
73 */
74 void SolventSpecies::setSize(double size)
75 { size_ = size; }
76
77}
SolventSpecies()
Constructor.
void setMonomerId(int monomerId)
Set the monomer id for this solvent.
void setMu(double mu)
Set input value of mu (chemical potential), if ensemble is open.
int monomerId_
Identifier for the associated monomer type.
void setSize(double size)
Set the molecular volume of this solvent species.
~SolventSpecies()
Constructor.
void setPhi(double phi)
Set input value of phi (volume fraction), if ensemble is closed.
virtual void readParameters(std::istream &in)
Read and initialize.
int monomerId() const
Get the monomer type id.
double size_
Size of this block = volume / monomer reference volume.
double size() const
Get the size (number of monomers) in this solvent.
Base class for a molecular species (polymer or solvent).
Definition Species.h:30
double phi() const
Get the overall volume fraction for this species.
Definition Species.h:90
Ensemble ensemble_
Statistical ensemble for this species (open or closed).
Definition Species.h:83
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 a compute function.
Definition Species.h:68
double mu_
Chemical potential, set by either setPhi or a compute function.
Definition Species.h:73
double mu() const
Get the chemical potential for this species (units kT=1).
Definition Species.h:96
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
PSCF package top-level namespace.
Definition param_pc.dox:1