1#ifndef PSCF_MIXTURE_TMPL_TPP
2#define PSCF_MIXTURE_TMPL_TPP
11#include "MixtureTmpl.h"
12#include <util/misc/Log.h>
23 template <
class PT,
class ST,
typename WT>
34 template <
class PT,
class ST,
typename WT>
45 template <
class PT,
class ST,
typename WT>
56 template <
class PT,
class ST,
typename WT>
65 readDArray< Monomer >(in,
"monomers", monomers_, nMonomer_);
75 read<int>(in,
"nPolymer", nPolymer_);
80 readOptional<int>(in,
"nSolvent", nSolvent_);
86 polymers_.allocate(nPolymer_);
87 for (
int i = 0; i < nPolymer_; ++i) {
95 for (
int i = 0; i < nPolymer_; ++i) {
96 for (
int j = 0; j < polymer(i).nBlock(); ++j) {
97 monomerId = polymer(i).block(j).monomerId();
98 if (monomerId < 0 || monomerId >= nMonomer_) {
99 Log::file() <<
"Polymer " << i <<
", block " << j
100 <<
": monomerId = " << monomerId
101 <<
", nMonomer = " << nMonomer_ <<
"\n";
105 polymer(i).block(j).setKuhn(kuhn);
117 int monomerId =
solvent(i).monomerId();
118 if (monomerId < 0 || monomerId >=
nMonomer_) {
119 Log::file() <<
"Solvent " << i <<
": monomerId = "
130 readOptional(in,
"vMonomer", vMonomer_);
131 if (!(vMonomer_ > 0.0)) {
132 Log::file() <<
"vMonomer = " << vMonomer_ <<
"\n";
142 for (
int i = 0; i < nPolymer_; ++i) {
143 sum += polymer(i).phi();
145 for (
int i = 0; i < nSolvent_; ++i) {
146 sum += solvent(i).phi();
148 if (std::abs(sum - 1.0) > 1.0E-10) {
149 std::ostringstream message;
150 message << std::setprecision(16)
151 <<
"Volume fractions of the closed species add up "
152 <<
"to " <<
sum <<
", but must add up to 1 within "
bool isCanonical() const
Is this mixture being treated in a canonical (closed) ensemble?
Monomer const & monomer(int id) const
Get a Monomer type descriptor by const reference.
DArray< Monomer > monomers_
SolventSpecies< WT > const & solventSpecies(int id) const final
Set a SolventSpecies descriptor object by const reference.
MixtureTmpl()
Constructor.
void readParameters(std::istream &in) override
Read parameters from file and initialize.
PolymerT & polymer(int id)
PolymerSpecies< WT > const & polymerSpecies(int id) const final
Get a PolymerSpecies descriptor by const reference.
SolventT & solvent(int id)
double kuhn() const
Statistical segment length (random walk step size).
Descriptor for a linear or acyclic branched block polymer.
Descriptor for a solvent species.
static std::ostream & file()
Get log ostream by reference.
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
ParamComposite()
Constructor.
void readParamComposite(std::istream &in, ParamComposite &child, bool next=true)
Add and read a required child ParamComposite.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
double sum(Array< double > const &in)
Compute sum of array elements (real).
PSCF package top-level namespace.