1#ifndef RPG_SWEEP_PARAMETER_TPP
2#define RPG_SWEEP_PARAMETER_TPP
11#include <rpg/system/System.h>
12#include <rpg/solvers/Mixture.h>
13#include <rpg/solvers/MixtureModifier.h>
14#include <rpg/solvers/Polymer.h>
15#include <rpg/solvers/Block.h>
17#include <prdc/crystal/UnitCell.h>
19#include <pscf/inter/Interaction.h>
20#include <pscf/sweep/ParameterModifier.h>
21#include <util/containers/FSArray.h>
44 parameterTypesPtr_(0),
59 parameterTypesPtr_(0),
67 void SweepParameter<D>::readParamType(std::istream& in)
71 std::transform(buffer.begin(), buffer.end(),
72 buffer.begin(), ::tolower);
74 if (buffer ==
"block" || buffer ==
"block_length") {
77 }
else if (buffer ==
"chi") {
80 }
else if (buffer ==
"kuhn") {
83 }
else if (buffer ==
"phi_polymer") {
86 }
else if (buffer ==
"phi_solvent") {
89 }
else if (buffer ==
"mu_polymer") {
92 }
else if (buffer ==
"mu_solvent") {
95 }
else if (buffer ==
"solvent" || buffer ==
"solvent_size") {
98 }
else if (buffer ==
"cell_param") {
104 for (
int i = 0; i < parameterTypesPtr_->size(); i++) {
106 if (buffer == pType.name) {
109 parameterTypeId_ = i;
116 msg =
"Invalid SweepParameter::ParamType value: " + buffer;
121 if (id_.isAllocated()) id_.deallocate();
142 return (*parameterTypesPtr_)[parameterTypeId_];
169 if (type_ == Block) {
171 }
else if (type_ == Chi) {
173 }
else if (type_ == Kuhn) {
175 }
else if (type_ == Phi_Polymer) {
176 return "phi_polymer";
177 }
else if (type_ == Phi_Solvent) {
178 return "phi_solvent";
179 }
else if (type_ == Mu_Polymer) {
181 }
else if (type_ == Mu_Solvent) {
183 }
else if (type_ == Solvent) {
184 return "solvent_size";
185 }
else if (type_ == Cell_Param) {
187 }
else if (type_ == Special) {
195 double SweepParameter<D>::get_()
197 if (type_ ==
Block) {
198 return systemPtr_->mixture().polymer(
id(0)).block(
id(1)).length();
199 }
else if (type_ == Chi) {
200 return systemPtr_->interaction().chi(
id(0),
id(1));
201 }
else if (type_ == Kuhn) {
202 return systemPtr_->mixture().monomer(
id(0)).kuhn();
203 }
else if (type_ == Phi_Polymer) {
204 return systemPtr_->mixture().polymer(
id(0)).phi();
205 }
else if (type_ == Phi_Solvent) {
206 return systemPtr_->mixture().solvent(
id(0)).phi();
207 }
else if (type_ == Mu_Polymer) {
208 return systemPtr_->mixture().polymer(
id(0)).mu();
209 }
else if (type_ == Mu_Solvent) {
210 return systemPtr_->mixture().solvent(
id(0)).mu();
212 return systemPtr_->mixture().solvent(
id(0)).size();
213 }
else if (type_ == Cell_Param) {
214 return systemPtr_->domain().unitCell().parameter(
id(0));
215 }
else if (type_ == Special) {
217 std::string name = parameterType().name;
225 void SweepParameter<D>::set_(
double newVal)
228 systemPtr_->interaction().setChi(
id(0),
id(1), newVal);
229 }
else if (type_ == Kuhn) {
230 systemPtr_->mixtureModifier().setKuhn(
id(0), newVal);
231 }
else if (type_ == Phi_Polymer) {
232 systemPtr_->mixtureModifier().setPhiPolymer(
id(0), newVal);
233 }
else if (type_ == Mu_Polymer) {
234 systemPtr_->mixtureModifier().setMuPolymer(
id(0), newVal);
235 }
else if (type_ ==
Block) {
236 systemPtr_->mixtureModifier().setBlockLength(
id(0),
id(1), newVal);
237 }
else if (type_ == Phi_Solvent) {
238 systemPtr_->mixtureModifier().setPhiSolvent(
id(0), newVal);
239 }
else if (type_ == Mu_Solvent) {
240 systemPtr_->mixtureModifier().setMuSolvent(
id(0), newVal);
242 systemPtr_->mixtureModifier().setSolventSize(
id(0), newVal);
244 }
else if (type_ == Kuhn) {
245 systemPtr_->mixture().setKuhn(
id(0), newVal);
246 }
else if (type_ == Phi_Polymer) {
247 systemPtr_->mixture().polymer(
id(0)).setPhi(newVal);
248 }
else if (type_ == Phi_Solvent) {
249 systemPtr_->mixture().solvent(
id(0)).setPhi(newVal);
250 }
else if (type_ == Mu_Polymer) {
251 systemPtr_->mixture().polymer(
id(0)).setMu(newVal);
252 }
else if (type_ == Mu_Solvent) {
253 systemPtr_->mixture().solvent(
id(0)).setMu(newVal);
254 }
else if (type_ ==
Block) {
255 systemPtr_->mixture().polymer(
id(0)).block(
id(1)).setLength(newVal);
257 systemPtr_->mixture().solvent(
id(0)).setSize(newVal);
259 }
else if (type_ == Cell_Param) {
261 params[id(0)] = newVal;
262 systemPtr_->setUnitCell(params);
263 }
else if (type_ == Special) {
265 std::string name = parameterType().name;
273 template <
class Archive>
278 for (
int i = 0; i < nId_; ++i) {
298 param.readParamType(in);
300 for (
int i = 0; i < param.nId_; ++i) {
321 for (
int i = 0; i < param.nId_; ++i) {
325 out << param.change_;
Base class allowing subclasses to define sweepable parameters.
virtual void setParameter(std::string name, DArray< int > ids, double value, bool &success)
Set the value of a specialized sweep parameter.
virtual double getParameter(std::string name, DArray< int > ids, bool &success) const
Get the value of a specialized sweep parameter.
Block within a branched polymer.
Solver and descriptor for a solvent species.
Class for storing data about an individual sweep parameter.
void getInitial()
Store the pre-sweep value of the corresponding parameter.
void serialize(Archive ar, const unsigned int version)
Serialize to or from an archive.
void writeParamType(std::ostream &out) const
Write the parameter type to an output stream.
int id(int i) const
Get a id for a sub-object or element to which this is applied.
SweepParameter()
Default constructor.
void update(double newVal)
Update the corresponding parameter value in the system.
std::string type() const
Return a string representation of the parameter type.
bool isSpecialized() const
Is this SweepParameter a specialized parameter type?
ParameterType & parameterType() const
Get the ParameterType object for a specialized sweep parameter.
Main class, representing one complete 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.
Periodic fields and crystallography.
SCFT and PS-FTS with real periodic fields (GPU)
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.