PSCF v1.5.0
Composition.h
1#ifndef PSCF_MIXTURE_BASE_H
2#define PSCF_MIXTURE_BASE_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 <pscf/chem/Monomer.h>
12#include <util/containers/DArray.h>
13
14namespace Pscf
15{
16
17 template <typename WT> class PolymerSpecies;
18 template <typename WT> class SolventSpecies;
19
20 using namespace Util;
21
66 template <typename WT>
68 {
69
70 public:
71
76
80 virtual ~Composition() = default;
81
87 void setVmonomer(double vMonomer);
88
91
95 int nMonomer() const;
96
100 int nPolymer() const;
101
105 int nSolvent() const;
106
110 int nBlock() const;
111
115 double vMonomer() const;
116
133 bool isCanonical() const;
134
138
144 Monomer const & monomer(int id) const;
145
155 virtual
156 PolymerSpecies<WT> const & polymerSpecies(int id) const = 0;
157
168 virtual
169 SolventSpecies<WT> const & solventSpecies(int id) const = 0;
170
172
173 protected:
174
180 Monomer& monomer(int id);
181
186
191
196
201
206
210 double vMonomer_;
211
212 private:
213
221 mutable bool isCanonical_;
222
226 mutable bool hasIsCanonical_;
227
228 };
229
230 // Inline public member functions
231
232 template <typename WT> inline
234 { return nMonomer_; }
235
236 template <typename WT> inline
238 { return nPolymer_; }
239
240 template <typename WT> inline
242 { return nSolvent_; }
243
244 template <typename WT> inline
246 { return nBlock_; }
247
248 template <typename WT> inline
250 { return vMonomer_; }
251
252 template <typename WT> inline
253 Monomer const & Composition<WT>::monomer(int id) const
254 {
255 UTIL_CHECK(id < nMonomer_);
256 return monomers_[id];
257 }
258
259 // Inline protected member function
260
261 template <typename WT> inline
263 {
264 UTIL_CHECK(id < nMonomer_);
265 return monomers_[id];
266 }
267
268 // Explicit instantiation declaration
269 extern template class Composition<double>;
270
271}
272#endif
Descriptor for a mixture of polymer and solvent species.
Definition Composition.h:68
int nPolymer_
Number of polymer species.
virtual ~Composition()=default
Destructor.
int nMonomer() const
Get number of monomer types.
void setVmonomer(double vMonomer)
Set new vMonomer value.
int nMonomer_
Number of monomer types.
virtual PolymerSpecies< WT > const & polymerSpecies(int id) const =0
Get a PolymerSpecies by const reference.
virtual SolventSpecies< WT > const & solventSpecies(int id) const =0
Set a solvent solver object by const reference.
double vMonomer() const
Get monomer reference volume (set to 1.0 by default).
double vMonomer_
Monomer reference volume (set to 1.0 by default).
int nPolymer() const
Get number of polymer species.
int nSolvent() const
Get number of solvent (point particle) species.
Monomer const & monomer(int id) const
Get a Monomer type descriptor by const reference.
DArray< Monomer > monomers_
Array of monomer type descriptors.
int nSolvent_
Number of solvent species.
Composition()
Constructor.
int nBlock_
Number of blocks total, across all polymers.
int nBlock() const
Get total number blocks among all polymer species.
Descriptor for a monomer type.
Definition Monomer.h:39
Descriptor for a linear or acyclic branched block polymer.
Descriptor for a solvent species.
Dynamically allocatable contiguous array template.
Definition DArray.h:32
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
PSCF package top-level namespace.