PSCF
v1.3
src
r1d
solvers
r1d/solvers/Solvent.cpp
1
/*
2
* PSCF - Polymer Self-Consistent Field
3
*
4
* Copyright 2015 - 2025, The Regents of the University of Minnesota
5
* Distributed under the terms of the GNU General Public License.
6
*/
7
8
#include "Solvent.h"
9
#include <r1d/domain/Domain.h>
10
11
namespace
Pscf
{
12
namespace
R1d
{
13
14
/*
15
* Constructor.
16
*/
17
Solvent::Solvent
()
18
:
SolventSpecies
()
19
{
setClassName
(
"Solvent"
); }
20
21
/*
22
* Destructor.
23
*/
24
Solvent::~Solvent
()
25
{}
26
27
/*
28
* Set association with Domain and allocate concentration field.
29
*/
30
void
Solvent::setDiscretization
(
Domain
const
&
domain
)
31
{
32
domainPtr_ = &
domain
;
33
int
nx =
domain
.nx();
34
if
(nx > 0) {
35
cField_.allocate(nx);
36
}
37
}
38
39
/*
40
* Compute concentration, q, and phi or mu.
41
*/
42
void
Solvent::compute
(
FieldT
const
& wField)
43
{
44
UTIL_CHECK
(cField_.isAllocated());
45
46
// Evaluate unnormalized concentration, Boltzmann weight
47
int
nx =
domain
().
nx
();
48
double
s =
size
();
49
for
(
int
i = 0; i < nx; ++i) {
50
cField_[i] = exp(-s*wField[i]);
51
}
52
53
// Compute spatial average q
54
double
Q =
domain
().
spatialAverage
(cField_);
55
56
// Set q and compute mu or phi (depending on ensemble)
57
Species::setQ
(Q);
58
59
#if 0
60
double
prefactor;
61
if
(
ensemble
() == Species::Closed) {
62
prefactor = phi_/q_;
63
mu_ = log(prefactor);
64
}
else
{
65
prefactor = exp(mu_);
66
phi_ = prefactor*q_;
67
}
68
#endif
69
70
// Normalize concentration
71
double
prefactor =
phi
()/Q;
72
for
(
int
i = 0; i < nx; ++i) {
73
cField_[i] *= prefactor;
74
}
75
76
}
77
78
}
79
}
Pscf::R1d::Domain
One-dimensional spatial domain and discretization grid.
Definition
r1d/domain/Domain.h:27
Pscf::R1d::Domain::nx
int nx() const
Get number of spatial grid points, including both endpoints.
Definition
r1d/domain/Domain.h:213
Pscf::R1d::Domain::spatialAverage
double spatialAverage(Field const &f) const
Compute spatial average of a field.
Definition
r1d/domain/Domain.cpp:119
Pscf::R1d::Solvent::setDiscretization
void setDiscretization(Domain const &domain)
Set association with Domain and allocate concentration field array.
Definition
r1d/solvers/Solvent.cpp:30
Pscf::R1d::Solvent::FieldT
typename Propagator::FieldT FieldT
Field type.
Definition
r1d/solvers/Solvent.h:36
Pscf::R1d::Solvent::~Solvent
~Solvent()
Constructor.
Definition
r1d/solvers/Solvent.cpp:24
Pscf::R1d::Solvent::compute
void compute(FieldT const &wField)
Compute monomer concentration field, q and phi and/or mu.
Definition
r1d/solvers/Solvent.cpp:42
Pscf::R1d::Solvent::Solvent
Solvent()
Constructor.
Definition
r1d/solvers/Solvent.cpp:17
Pscf::R1d::Solvent::domain
Domain const & domain() const
Return associated domain by reference.
Definition
r1d/solvers/Solvent.h:98
Pscf::SolventSpecies::SolventSpecies
SolventSpecies()
Constructor.
Definition
SolventSpecies.cpp:15
Pscf::SolventSpecies::size
double size() const
Get the size (number of monomers) in this solvent.
Definition
SolventSpecies.h:113
Pscf::Species::phi
double phi() const
Get the overall volume fraction for this species.
Definition
Species.h:149
Pscf::Species::setQ
void setQ(double q)
Set q and compute phi or mu (depending on the ensemble).
Definition
Species.cpp:63
Pscf::Species::ensemble
Ensemble ensemble() const
Get the statistical ensemble for this species (open or closed).
Definition
Species.h:167
Util::ParamComposite::setClassName
void setClassName(const char *className)
Set class name string.
Definition
ParamComposite.cpp:379
UTIL_CHECK
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition
global.h:68
Pscf::R1d
SCFT with real 1D fields.
Definition
r1d/domain/Domain.cpp:13
Pscf
PSCF package top-level namespace.
Definition
param_pc.dox:1
Generated on
for PSCF by
1.14.0