8#include "HomogeneousComparison.h"
10#include <r1d/solvers/Mixture.h>
11#include <r1d/solvers/Polymer.h>
12#include <r1d/solvers/Block.h>
13#include <r1d/solvers/Solvent.h>
15#include <pscf/interaction/Interaction.h>
16#include <pscf/floryHuggins/FhInteraction.h>
17#include <pscf/floryHuggins/FhMixture.h>
19#include <util/format/Str.h>
20#include <util/format/Int.h>
21#include <util/format/Dbl.h>
36 fhMixturePtr_(nullptr),
37 fhInteractionPtr_(nullptr),
59 if (fhInteractionPtr_) {
60 delete fhInteractionPtr_;
78 fhMixture().initialize(
mixture());
85 if (!p_.isAllocated()) {
92 for (
int i = 0; i < np; ++i) {
95 fhMixture().setComposition(p_);
97 fhMixture().computeMu( fhInteraction(), xi );
100 if (mode == 1 || mode == 2) {
102 if (!m_.isAllocated()) {
105 UTIL_CHECK(m_.capacity() == fhMixture().nMolecule());
106 for (
int i = 0; i < np; ++i) {
119 for (
int i = 0; i < np; ++i) {
122 for (
int j = 0; j < nb; ++j) {
128 fhMixture().computePhi(fhInteraction(), m_, p_, xi);
131 UTIL_THROW(
"Unknown mode in computeHomogeneous");
135 fhMixture().computeFreeEnergy(fhInteraction());
154 double fHomo = fhMixture().fHelmholtz();
157 out <<
"f (homo) = " <<
Dbl(fHomo, 18, 11)
158 <<
" [per monomer volume]" << std::endl;
159 out <<
"delta f = " <<
Dbl(df, 18, 11)
160 <<
" [per monomer volume]" << std::endl;
164 out <<
"Species:" << std::endl;
169 for (
int i = 0; i < fhMixture().nMolecule(); ++i) {
171 <<
" " <<
Dbl(fhMixture().mu(i), 18, 11)
172 <<
" " <<
Dbl(fhMixture().phi(i), 18, 11)
178 if (mode == 1 || mode == 2) {
181 double fHomo = fhMixture().fHelmholtz();
182 double pHomo = fhMixture().pressure();
186 double PhiExTot = -1.0*pEx*V;
187 double fExTot = fEx*V;
189 out <<
"f (homo) = " <<
Dbl(fHomo, 18, 11)
190 <<
" [per monomer volume]" << std::endl;
191 out <<
"p (homo) = " <<
Dbl(pHomo, 18, 11)
192 <<
" [per monomer volume]" << std::endl;
193 out <<
"delta f = " <<
Dbl(fEx, 18, 11)
194 <<
" [per monomer volume]" << std::endl;
195 out <<
"delta p = " <<
Dbl(pEx, 18, 11)
196 <<
" [per monomer volume]" << std::endl;
197 out <<
"Phi (ex) = " <<
Dbl(PhiExTot, 18, 11)
198 <<
" [total]" << std::endl;
199 out <<
"F (ex) = " <<
Dbl(fExTot, 18, 11)
200 <<
" [total]" << std::endl;
201 out <<
"V(tot)/v = " <<
Dbl(V, 18, 11) << std::endl;
206 out <<
"Species:" << std::endl;
212 for (
int i = 0; i < fhMixture().nMolecule(); ++i) {
216 <<
" " <<
Dbl(fhMixture().mu(i), 18, 11)
217 <<
" " <<
Dbl(fhMixture().phi(i), 18, 11)
218 <<
" " <<
Dbl(dV, 18, 11)
Flory-Huggins interaction model.
A spatially homogeneous mixture.
double vMonomer() const
Get monomer reference volume (set to 1.0 by default).
int nSolvent() const
Get number of solvent (point particle) species.
int nPolymer() const
Get number of polymer species.
PolymerT & polymer(int id)
Get a polymer solver object by non-const reference.
int nx() const
Get number of spatial grid points, including both endpoints.
double volume() const
Get generalized volume of domain.
HomogeneousComparison()
Default constructor.
void output(int mode, std::ostream &out) const
Output comparison to a homogeneous reference system.
void compute(int mode)
Compute properties of a homogeneous reference system.
~HomogeneousComparison()
Destructor.
SystemAccess()
Default constructor.
const Domain & domain() const
Get spatial domain (including grid info) by reference.
const Interaction & interaction() const
Get interaction (i.e., excess free energy model) by reference.
const System & system() const
Get parent System by reference.
const Mixture & mixture() const
Get Mixture by reference.
Main class in SCFT simulation of one system.
double fHelmholtz() const
Get precomputed Helmholtz free energy per monomer / kT.
double pressure() const
Get precomputed pressure x monomer volume kT.
Wrapper for a double precision number, for formatted ostream output.
Wrapper for an int, for formatted ostream output.
#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.
SCFT with real 1D fields.
PSCF package top-level namespace.