8#include <r1d/sweep/SweepParameter.h>
9#include <r1d/solvers/Block.h>
10#include <r1d/solvers/Mixture.h>
11#include <r1d/solvers/Polymer.h>
12#include <r1d/System.h>
13#include <pscf/inter/Interaction.h>
14#include <pscf/sweep/ParameterModifier.h>
15#include <util/containers/FSArray.h>
36 parameterTypesPtr_(0),
50 parameterTypesPtr_(0),
57 void SweepParameter::readParamType(std::istream& in)
61 std::transform(buffer.begin(), buffer.end(),
62 buffer.begin(), ::tolower);
64 if (buffer ==
"block" || buffer ==
"block_length") {
67 }
else if (buffer ==
"chi") {
70 }
else if (buffer ==
"kuhn") {
73 }
else if (buffer ==
"phi_polymer") {
76 }
else if (buffer ==
"phi_solvent") {
79 }
else if (buffer ==
"mu_polymer") {
82 }
else if (buffer ==
"mu_solvent") {
85 }
else if (buffer ==
"solvent" || buffer ==
"solvent_size") {
88 }
else if (buffer ==
"cell_param") {
94 for (
int i = 0; i < parameterTypesPtr_->size(); i++) {
95 ParameterType& pType = (*parameterTypesPtr_)[i];
96 if (buffer == pType.name) {
106 msg =
"Invalid SweepParameter::ParamType value: " + buffer;
111 if (id_.isAllocated()) id_.deallocate();
129 return (*parameterTypesPtr_)[parameterTypeId_];
153 if (type_ == Block) {
155 }
else if (type_ == Chi) {
157 }
else if (type_ == Kuhn) {
159 }
else if (type_ == Phi_Polymer) {
160 return "phi_polymer";
161 }
else if (type_ == Phi_Solvent) {
162 return "phi_solvent";
163 }
else if (type_ == Mu_Polymer) {
165 }
else if (type_ == Mu_Solvent) {
167 }
else if (type_ == Solvent) {
168 return "solvent_size";
169 }
else if (type_ == Special) {
172 UTIL_THROW(
"Invalid type_ in accessor SweepParameter::type().");
176 double SweepParameter::get_()
178 if (type_ ==
Block) {
179 return systemPtr_->
mixture().
polymer(
id(0)).block(
id(1)).length();
180 }
else if (type_ == Chi) {
182 }
else if (type_ == Kuhn) {
184 }
else if (type_ == Phi_Polymer) {
185 return systemPtr_->mixture().polymer(
id(0)).phi();
186 }
else if (type_ == Phi_Solvent) {
187 return systemPtr_->mixture().solvent(
id(0)).phi();
188 }
else if (type_ == Mu_Polymer) {
189 return systemPtr_->mixture().polymer(
id(0)).mu();
190 }
else if (type_ == Mu_Solvent) {
191 return systemPtr_->mixture().solvent(
id(0)).mu();
192 }
else if (type_ == Solvent) {
193 return systemPtr_->mixture().solvent(
id(0)).size();
194 }
else if (type_ == Special) {
197 return modifier->getParameter(name,id_);
199 UTIL_THROW(
"Invalid type_ in SweepParameter::get_.");
203 void SweepParameter::set_(
double newVal)
205 if (type_ == Block) {
206 systemPtr_->mixture().polymer(
id(0)).block(
id(1)).setLength(newVal);
207 }
else if (type_ == Chi) {
208 systemPtr_->interaction().setChi(
id(0),
id(1), newVal);
209 }
else if (type_ == Kuhn) {
210 systemPtr_->mixture().setKuhn(
id(0), newVal);
211 }
else if (type_ == Phi_Polymer) {
212 systemPtr_->mixture().polymer(
id(0)).setPhi(newVal);
213 }
else if (type_ == Phi_Solvent) {
214 systemPtr_->mixture().solvent(
id(0)).setPhi(newVal);
215 }
else if (type_ == Mu_Polymer) {
216 systemPtr_->mixture().polymer(
id(0)).setMu(newVal);
217 }
else if (type_ == Mu_Solvent) {
218 systemPtr_->mixture().solvent(
id(0)).setMu(newVal);
219 }
else if (type_ == Solvent) {
220 systemPtr_->mixture().solvent(
id(0)).setSize(newVal);
221 }
else if (type_ == Special) {
224 return modifier->setParameter(name,id_,newVal);
226 UTIL_THROW(
"Invalid type_ in SweepParameter::set_.");
242 param.readParamType(in);
244 for (
int i = 0; i < param.nId_; ++i) {
264 for (
int i = 0; i < param.nId_; ++i) {
268 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 branched 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.