1#ifndef PSPC_SWEEP_PARAMETER_TPP
2#define PSPC_SWEEP_PARAMETER_TPP
11#include <pspc/solvers/Block.h>
12#include <pspc/solvers/Mixture.h>
13#include <pspc/solvers/Polymer.h>
14#include <pspc/iterator/AmIterator.h>
15#include <pspc/iterator/FilmIterator.h>
16#include <pspc/System.h>
17#include <pscf/crystal/UnitCell.h>
18#include <pscf/inter/Interaction.h>
20#include <util/containers/FSArray.h>
63 std::transform(buffer.begin(), buffer.end(),
64 buffer.begin(), ::tolower);
66 if (buffer ==
"block" || buffer ==
"block_length") {
69 }
else if (buffer ==
"chi") {
72 }
else if (buffer ==
"kuhn") {
75 }
else if (buffer ==
"phi_polymer") {
78 }
else if (buffer ==
"phi_solvent") {
81 }
else if (buffer ==
"mu_polymer") {
84 }
else if (buffer ==
"mu_solvent") {
87 }
else if (buffer ==
"solvent" || buffer ==
"solvent_size") {
90 }
else if (buffer ==
"cell_param") {
93 }
else if (buffer ==
"chi_bottom") {
97 }
else if (buffer ==
"chi_top") {
102 UTIL_THROW(
"Invalid SweepParameter::ParamType value");
105 if (id_.isAllocated()) id_.deallocate();
143 if (type_ ==
Block) {
145 }
else if (type_ == Chi) {
147 }
else if (type_ == Kuhn) {
149 }
else if (type_ == Phi_Polymer) {
150 return "phi_polymer";
151 }
else if (type_ == Phi_Solvent) {
152 return "phi_solvent";
153 }
else if (type_ == Mu_Polymer) {
155 }
else if (type_ == Mu_Solvent) {
158 return "solvent_size";
159 }
else if (type_ == Cell_Param) {
161 }
else if (type_ == Chi_Bottom) {
163 }
else if (type_ == Chi_Top) {
173 if (type_ ==
Block) {
174 return systemPtr_->mixture().polymer(
id(0)).block(
id(1)).length();
175 }
else if (type_ == Chi) {
176 return systemPtr_->interaction().chi(
id(0),
id(1));
177 }
else if (type_ == Kuhn) {
178 return systemPtr_->mixture().monomer(
id(0)).kuhn();
179 }
else if (type_ == Phi_Polymer) {
180 return systemPtr_->mixture().polymer(
id(0)).phi();
181 }
else if (type_ == Phi_Solvent) {
182 return systemPtr_->mixture().solvent(
id(0)).phi();
183 }
else if (type_ == Mu_Polymer) {
184 return systemPtr_->mixture().polymer(
id(0)).mu();
185 }
else if (type_ == Mu_Solvent) {
186 return systemPtr_->mixture().solvent(
id(0)).mu();
187 }
else if (type_ == Solvent) {
188 return systemPtr_->mixture().solvent(
id(0)).size();
189 }
else if (type_ == Cell_Param) {
190 return systemPtr_->unitCell().parameter(
id(0));
191 }
else if (type_ == Chi_Bottom) {
194 if (systemPtr_->iterator().className() ==
"AmIteratorFilm") {
195 FilmIterator<D, AmIterator<D> >* itrPtr_(0);
196 itrPtr_ =
static_cast<FilmIterator<D, AmIterator<D>
>* >(&(systemPtr_->iterator()));
197 return itrPtr_->chiBottom(
id(0));
199 UTIL_THROW(
"Iterator type is not compatible with this sweep parameter.");
201 }
else if (type_ == Chi_Top) {
204 if (systemPtr_->iterator().className() ==
"AmIteratorFilm") {
205 FilmIterator<D, AmIterator<D> >* itrPtr_(0);
206 itrPtr_ =
static_cast<FilmIterator<D, AmIterator<D>
>* >(&(systemPtr_->iterator()));
207 return itrPtr_->chiTop(
id(0));
209 UTIL_THROW(
"Iterator type is not compatible with this sweep parameter.");
217 void SweepParameter<D>::set_(
double newVal)
219 if (type_ == Block) {
220 systemPtr_->mixture().polymer(
id(0)).block(
id(1)).setLength(newVal);
221 }
else if (type_ == Chi) {
222 systemPtr_->interaction().setChi(
id(0),
id(1), newVal);
223 }
else if (type_ == Kuhn) {
224 systemPtr_->mixture().setKuhn(
id(0), newVal);
225 }
else if (type_ == Phi_Polymer) {
226 systemPtr_->mixture().polymer(
id(0)).setPhi(newVal);
227 }
else if (type_ == Phi_Solvent) {
228 systemPtr_->mixture().solvent(
id(0)).setPhi(newVal);
229 }
else if (type_ == Mu_Polymer) {
230 systemPtr_->mixture().polymer(
id(0)).setMu(newVal);
231 }
else if (type_ == Mu_Solvent) {
232 systemPtr_->mixture().solvent(
id(0)).setMu(newVal);
233 }
else if (type_ == Solvent) {
234 systemPtr_->mixture().solvent(
id(0)).setSize(newVal);
235 }
else if (type_ == Cell_Param) {
237 params[id(0)] = newVal;
238 systemPtr_->setUnitCell(params);
239 }
else if (type_ == Chi_Bottom) {
242 if (systemPtr_->iterator().className() ==
"AmIteratorFilm") {
243 FilmIterator<D, AmIterator<D> >* itrPtr_(0);
244 itrPtr_ =
static_cast<FilmIterator<D, AmIterator<D>
>* >(&(systemPtr_->iterator()));
245 itrPtr_->setChiBottom(
id(0), newVal);
247 UTIL_THROW(
"Iterator type is not compatible with this sweep parameter.");
249 }
else if (type_ == Chi_Top) {
252 if (systemPtr_->iterator().className() ==
"AmIteratorFilm") {
253 FilmIterator<D, AmIterator<D> >* itrPtr_(0);
254 itrPtr_ =
static_cast<FilmIterator<D, AmIterator<D>
>* >(&(systemPtr_->iterator()));
255 itrPtr_->setChiTop(
id(0), newVal);
257 UTIL_THROW(
"Iterator type is not compatible with this sweep parameter.");
268 bool SweepParameter<D>::isFilmIterator()
const
270 std::string name = systemPtr_->iterator().className();
271 if (name.size() < 4) {
274 return (name.substr(name.size() - 4) ==
"Film");
279 template <
class Archive>
284 for (
int i = 0; i < nID_; ++i) {
301 param.readParamType(in);
303 for (
int i = 0; i < param.nID_; ++i) {
321 for (
int i = 0; i < param.nID_; ++i) {
325 out << param.change_;
Block within a branched polymer.
Solver and descriptor for a solvent species.
Class for storing data about an individual sweep parameter.
std::string type() const
Return a string representation of the parameter type.
void getInitial()
Store the pre-sweep value of the corresponding parameter.
SweepParameter()
Default constructor.
void serialize(Archive ar, const unsigned int version)
Serialize to or from an archive.
int id(int i) const
Get a id for a sub-object or element to which this is applied.
void update(double newVal)
Update the corresponding parameter value in the system.
void writeParamType(std::ostream &out) const
Write the parameter type to an output stream.
Main class for SCFT simulation of one system.
A fixed capacity (static) contiguous array with a variable logical size.
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.
void serializeEnum(Archive &ar, T &data, const unsigned int version=0)
Serialize an enumeration value.
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
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.