PSCF v1.5.0
Species.h
1#ifndef PSCF_SPECIES_H
2#define PSCF_SPECIES_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <util/param/ParamComposite.h> // base class
12#include <pscf/chem/Ensemble.h> // member
13
14namespace Pscf {
15
16 using namespace Util;
17
33 template <typename WT = double>
34 class Species : public ParamComposite
35 {
36 public:
37
44
48 virtual ~Species() = default;
49
64 virtual void readParameters(std::istream& in);
65
79 void setPhi(double phi);
80
94 void setMu(double mu);
95
99 WT phi() const;
100
104 WT mu() const;
105
109 WT q() const;
110
115
116 protected:
117
129 void setQ(WT q);
130
131 private:
132
136 WT phi_;
137
141 WT mu_;
142
146 WT q_;
147
154 double phiMu_;
155
159 Ensemble ensemble_;
160
161 };
162
163 /*
164 * Get the species volume fraction.
165 */
166 template <typename WT> inline
168 { return phi_; }
169
170 /*
171 * Get the species chemical potential.
172 */
173 template <typename WT> inline
175 { return mu_; }
176
177 /*
178 * Get the species partition function q.
179 */
180 template <typename WT> inline
181 WT Species<WT>::q() const
182 { return q_; }
183
184 /*
185 * Get statistical ensemble for this species (open or closed).
186 */
187 template <typename WT> inline
189 { return ensemble_; }
190
191 // Explicit instantiation declaration
192 extern template class Species<double>;
193
194}
195#endif
Base class for a molecular species (polymer or solvent).
Definition Species.h:35
virtual ~Species()=default
Destructor.
WT q() const
Get the molecular partition function for this species.
Definition Species.h:181
void setMu(double mu)
Set value of mu (chemical potential), if ensemble is closed.
Definition Species.tpp:82
Ensemble ensemble() const
Get the statistical ensemble for this species.
Definition Species.h:188
Species()
Constructor.
Definition Species.tpp:22
virtual void readParameters(std::istream &in)
Read phi or mu (but not both) and set ensemble accordingly.
Definition Species.tpp:36
void setQ(WT q)
Set q and compute phi or mu (depending on the ensemble).
Definition Species.tpp:97
void setPhi(double phi)
Set value of phi (volume fraction), if ensemble is closed.
Definition Species.tpp:65
ParamComposite()
Constructor.
Ensemble
Statistical ensemble for the number of molecules of one species.
Definition Ensemble.h:27
PSCF package top-level namespace.