9#include <pscf/math/arithmetic.h>
10#include <util/misc/Log.h>
21 template <
typename WT>
35 template <
typename WT>
42 bool hasPhi =
readOptional(in,
"phi", phiMu_).isActive();
44 if (!(std::real(phiMu_) >= 0.0 && std::real(phiMu_) <= 1.0)) {
45 Log::file() <<
"phi = " << phiMu_ <<
"\n";
46 UTIL_THROW(
"Volume fraction phi must lie in [0, 1]");
48 ensemble_ = Ensemble::Closed;
51 read(in,
"mu", phiMu_);
53 ensemble_ = Ensemble::Open;
64 template <
typename WT>
81 template <
typename WT>
96 template <
typename WT>
100 if (
ensemble() == Ensemble::Closed) {
102 div(ratio, phi_, q_);
109 mul(phi_, lambda, q_);
WT q() const
Get the molecular partition function for this species.
void setMu(double mu)
Set value of mu (chemical potential), if ensemble is closed.
Ensemble ensemble() const
Get the statistical ensemble for this species.
virtual void readParameters(std::istream &in)
Read phi or mu (but not both) and set ensemble accordingly.
WT mu() const
Get the chemical potential for this species (units kT=1).
void setQ(WT q)
Set q and compute phi or mu (depending on the ensemble).
WT phi() const
Get the overall volume fraction for this species.
void setPhi(double phi)
Set value of phi (volume fraction), if ensemble is closed.
static std::ostream & file()
Get log ostream by reference.
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.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Ensemble
Statistical ensemble for the number of molecules of one species.
void div(fftw_complex &z, fftw_complex const &a, fftw_complex const &b)
Division of fftw_complex numbers, z = a / b .
void assignExp(fftw_complex &z, fftw_complex const &a)
Exponentation of a ffts_complex variable, z = exp(a).
void assign(fftw_complex &z, double const &a, double const &b)
Create an fftw_complex from real and imaginary parts, z = a + ib.
void mul(fftw_complex &z, fftw_complex const &a, fftw_complex const &b)
Multiplication of fftw_complex numbers, z = a * b.
void assignLog(fftw_complex &z, fftw_complex const &a)
Logarithm of an fftw_complex variable, z = log(a).
PSCF package top-level namespace.