8#include <r1d/sweep/SweepParameter.h>
10#include <r1d/solvers/Block.h>
11#include <r1d/solvers/Mixture.h>
12#include <r1d/solvers/Polymer.h>
13#include <r1d/solvers/Solvent.h>
14#include <pscf/inter/Interaction.h>
15#include <pscf/sweep/ParameterModifier.h>
16#include <util/containers/FSArray.h>
37 parameterTypesPtr_(0),
51 parameterTypesPtr_(0),
58 void SweepParameter::readParamType(std::istream& in)
62 std::transform(buffer.begin(), buffer.end(),
63 buffer.begin(), ::tolower);
65 if (buffer ==
"block" || buffer ==
"block_length") {
68 }
else if (buffer ==
"chi") {
71 }
else if (buffer ==
"kuhn") {
74 }
else if (buffer ==
"phi_polymer") {
77 }
else if (buffer ==
"phi_solvent") {
80 }
else if (buffer ==
"mu_polymer") {
83 }
else if (buffer ==
"mu_solvent") {
86 }
else if (buffer ==
"solvent" || buffer ==
"solvent_size") {
89 }
else if (buffer ==
"cell_param") {
95 for (
int i = 0; i < parameterTypesPtr_->size(); i++) {
96 ParameterType& pType = (*parameterTypesPtr_)[i];
97 if (buffer == pType.name) {
100 parameterTypeId_ = i;
107 msg =
"Invalid SweepParameter::ParamType value: " + buffer;
112 if (id_.isAllocated()) id_.deallocate();
130 return (*parameterTypesPtr_)[parameterTypeId_];
154 if (type_ == Block) {
156 }
else if (type_ == Chi) {
158 }
else if (type_ == Kuhn) {
160 }
else if (type_ == Phi_Polymer) {
161 return "phi_polymer";
162 }
else if (type_ == Phi_Solvent) {
163 return "phi_solvent";
164 }
else if (type_ == Mu_Polymer) {
166 }
else if (type_ == Mu_Solvent) {
168 }
else if (type_ == Solvent) {
169 return "solvent_size";
170 }
else if (type_ == Special) {
173 UTIL_THROW(
"Invalid type_ in accessor SweepParameter::type().");
177 double SweepParameter::get_()
179 if (type_ ==
Block) {
180 return systemPtr_->
mixture().
polymer(
id(0)).block(
id(1)).length();
181 }
else if (type_ == Chi) {
183 }
else if (type_ == Kuhn) {
185 }
else if (type_ == Phi_Polymer) {
186 return systemPtr_->mixture().polymer(
id(0)).phi();
187 }
else if (type_ == Phi_Solvent) {
188 return systemPtr_->mixture().solvent(
id(0)).phi();
189 }
else if (type_ == Mu_Polymer) {
190 return systemPtr_->mixture().polymer(
id(0)).mu();
191 }
else if (type_ == Mu_Solvent) {
192 return systemPtr_->mixture().solvent(
id(0)).mu();
193 }
else if (type_ == Solvent) {
194 return systemPtr_->mixture().solvent(
id(0)).size();
195 }
else if (type_ == Special) {
198 return modifier->getParameter(name,id_);
200 UTIL_THROW(
"Invalid type_ in SweepParameter::get_.");
204 void SweepParameter::set_(
double newVal)
206 if (type_ == Block) {
207 systemPtr_->mixture().polymer(
id(0)).block(
id(1)).setLength(newVal);
208 }
else if (type_ == Chi) {
209 systemPtr_->interaction().setChi(
id(0),
id(1), newVal);
210 }
else if (type_ == Kuhn) {
211 systemPtr_->mixture().setKuhn(
id(0), newVal);
212 }
else if (type_ == Phi_Polymer) {
213 systemPtr_->mixture().polymer(
id(0)).setPhi(newVal);
214 }
else if (type_ == Phi_Solvent) {
215 systemPtr_->mixture().solvent(
id(0)).setPhi(newVal);
216 }
else if (type_ == Mu_Polymer) {
217 systemPtr_->mixture().polymer(
id(0)).setMu(newVal);
218 }
else if (type_ == Mu_Solvent) {
219 systemPtr_->mixture().solvent(
id(0)).setMu(newVal);
220 }
else if (type_ == Solvent) {
221 systemPtr_->mixture().solvent(
id(0)).setSize(newVal);
222 }
else if (type_ == Special) {
225 return modifier->setParameter(name,id_,newVal);
227 UTIL_THROW(
"Invalid type_ in SweepParameter::set_.");
243 param.readParamType(in);
245 for (
int i = 0; i < param.nId_; ++i) {
265 for (
int i = 0; i < param.nId_; ++i) {
269 out << param.change_;
DMatrix< double > const & chi() const
Return the chi matrix by const reference.
Monomer const & monomer(int id) const
Get a Monomer type descriptor by const reference.
PolymerT & polymer(int id)
Get a polymer solver object by non-const reference.
double kuhn() const
Statistical segment length (random walk step size).
Block within a block polymer.
std::string type() const
Return a string representation of the parameter type.
void writeParamType(std::ostream &out) const
Write the parameter type to an output stream.
SweepParameter()
Default constructor.
bool isSpecialized() const
Is this SweepParameter a specialized parameter type?
void getInitial()
Store the pre-sweep value of the corresponding parameter.
int id(int i) const
Get a id for a sub-object or element to which this is applied.
ParameterType & parameterType() const
Get the ParameterType object for a specialized sweep parameter.
void update(double newVal)
Update the corresponding parameter value in the system.
Main class in SCFT simulation of one system.
Interaction & interaction()
Get interaction (i.e., excess free energy) by reference.
Mixture & mixture()
Get Mixture by reference.
File containing preprocessor macros for error handling.
#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.
std::istream & operator>>(std::istream &in, Pair< Data > &pair)
Input a Pair from an istream.
std::ostream & operator<<(std::ostream &out, const Pair< Data > &pair)
Output a Pair to an ostream, without line breaks.
Declaration of a specialized sweep parameter type.