PSCF v1.5.0
Composition.tpp
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "Composition.h"
9#include "PolymerSpecies.h"
10#include "SolventSpecies.h"
11
12namespace Pscf
13{
14
15 /*
16 * Constructor.
17 */
18 template <typename WT>
20 : monomers_(),
21 nMonomer_(0),
22 nPolymer_(0),
23 nSolvent_(0),
24 nBlock_(0),
25 vMonomer_(1.0),
26 isCanonical_(false),
27 hasIsCanonical_(false)
28 {}
29
30 /*
31 * Set the monomer volume value.
32 */
33 template <typename WT>
39
40 /*
41 * Is the ensemble closed for all species?
42 *
43 * The return value is computed only once, the first time this function
44 * is called.
45 */
46 template <typename WT>
48 {
49 // Compute isCanonical_ , if not computed previously.
50 if (!hasIsCanonical_) {
51 isCanonical_ = true;
52
53 // Check ensemble of all polymer species
54 for (int i = 0; i < nPolymer(); ++i) {
55 UTIL_CHECK(polymerSpecies(i).ensemble() != Ensemble::Unknown);
56 if (polymerSpecies(i).ensemble() == Ensemble::Open) {
57 isCanonical_ = false;
58 }
59 }
60
61 // Check ensemble of all solvent species
62 for (int i = 0; i < nSolvent(); ++i) {
63 UTIL_CHECK(polymerSpecies(i).ensemble() != Ensemble::Unknown);
64 if (solventSpecies(i).ensemble() == Ensemble::Open) {
65 isCanonical_ = false;
66 }
67 }
68
69 hasIsCanonical_ = true;
70 }
71
72 return isCanonical_;
73 }
74
int nPolymer_
Number of polymer species.
bool isCanonical() const
Is this mixture being treated in a canonical (closed) ensemble?
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.
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.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
PSCF package top-level namespace.