PSCF v1.1
SolventDescriptor.cpp
1#ifndef PSCF_SOLVENT_DESCRIPTOR_TPP
2#define PSCF_SOLVENT_DESCRIPTOR_TPP
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 "SolventDescriptor.h"
12
13namespace Pscf {
14
15 /*
16 * Constructor
17 */
19 { setClassName("SolventDescriptor"); }
20
21 /*
22 * Destructor
23 */
25 {}
26
27 /*
28 * Read contents of parameter file block
29 */
30 void SolventDescriptor::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 */
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 */
60 {
61 UTIL_CHECK(ensemble() == Species::Open);
62 mu_ = mu;
63 }
64
65 /*
66 * Set the id for this solvent.
67 */
70
71 /*
72 * Set the id for this solvent.
73 */
75 { size_ = size; }
76
77}
78#endif
double size_
Size of this block = volume / monomer reference volume.
double size() const
Get the size (number of monomers) in this solvent.
void setPhi(double phi)
Set input value of phi (volume fraction), if ensemble is closed.
void setMu(double mu)
Set input value of mu (chemical potential), if ensemble is open.
void setSize(double size)
Set the size or volume of this solvent species.
int monomerId() const
Get the monomer type id.
virtual void readParameters(std::istream &in)
Read and initialize.
int monomerId_
Identifier for the associated monomer type.
void setMonomerId(int monomerId)
Set the monomer id for this solvent.
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 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
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
C++ namespace for polymer self-consistent field theory (PSCF).