1#ifndef RPC_SWEEP_PARAMETER_TPP
2#define RPC_SWEEP_PARAMETER_TPP
11#include <rpc/solvers/Block.h>
12#include <rpc/solvers/Mixture.h>
13#include <rpc/solvers/MixtureModifier.h>
14#include <rpc/solvers/Polymer.h>
15#include <rpc/system/System.h>
16#include <prdc/crystal/UnitCell.h>
17#include <pscf/inter/Interaction.h>
18#include <pscf/sweep/ParameterModifier.h>
20#include <util/containers/FSArray.h>
41 parameterTypesPtr_(nullptr),
56 parameterTypesPtr_(nullptr),
64 void SweepParameter<D>::readParamType(std::istream& in)
68 std::transform(buffer.begin(), buffer.end(),
69 buffer.begin(), ::tolower);
71 if (buffer ==
"block" || buffer ==
"block_length") {
74 }
else if (buffer ==
"chi") {
77 }
else if (buffer ==
"kuhn") {
80 }
else if (buffer ==
"phi_polymer") {
83 }
else if (buffer ==
"phi_solvent") {
86 }
else if (buffer ==
"mu_polymer") {
89 }
else if (buffer ==
"mu_solvent") {
92 }
else if (buffer ==
"solvent" || buffer ==
"solvent_size") {
95 }
else if (buffer ==
"cell_param") {
101 if (parameterTypesPtr_) {
102 for (
int i = 0; i < parameterTypesPtr_->size(); i++) {
104 if (buffer == pType.name) {
107 parameterTypeId_ = i;
115 msg =
"Invalid SweepParameter::ParamType value: " + buffer;
120 if (id_.isAllocated()) id_.deallocate();
140 return (*parameterTypesPtr_)[parameterTypeId_];
148 { initial_ = get_(); }
163 if (type_ == Block) {
165 }
else if (type_ == Chi) {
167 }
else if (type_ == Kuhn) {
169 }
else if (type_ == Phi_Polymer) {
170 return "phi_polymer";
171 }
else if (type_ == Phi_Solvent) {
172 return "phi_solvent";
173 }
else if (type_ == Mu_Polymer) {
175 }
else if (type_ == Mu_Solvent) {
177 }
else if (type_ == Solvent) {
178 return "solvent_size";
179 }
else if (type_ == Cell_Param) {
181 }
else if (type_ == Special) {
189 double SweepParameter<D>::get_()
193 return systemPtr_->interaction().chi(
id(0),
id(1));
194 }
else if (type_ == Kuhn) {
195 return systemPtr_->mixture().monomer(
id(0)).kuhn();
196 }
else if (type_ == Phi_Polymer) {
197 return systemPtr_->mixture().polymer(
id(0)).phi();
198 }
else if (type_ == Mu_Polymer) {
199 return systemPtr_->mixture().polymer(
id(0)).mu();
200 }
else if (type_ ==
Block) {
201 return systemPtr_->mixture().polymer(
id(0)).block(
id(1)).length();
202 }
else if (type_ == Phi_Solvent) {
203 return systemPtr_->mixture().solvent(
id(0)).phi();
204 }
else if (type_ == Mu_Solvent) {
205 return systemPtr_->mixture().solvent(
id(0)).mu();
207 return systemPtr_->mixture().solvent(
id(0)).size();
208 }
else if (type_ == Cell_Param) {
209 return systemPtr_->domain().unitCell().parameter(
id(0));
210 }
else if (type_ == Special) {
212 std::string name = parameterType().name;
220 void SweepParameter<D>::set_(
double newVal)
224 systemPtr_->interaction().setChi(
id(0),
id(1), newVal);
225 }
else if (type_ == Kuhn) {
227 systemPtr_->mixtureModifier().setKuhn(
id(0), newVal);
228 }
else if (type_ == Phi_Polymer) {
230 systemPtr_->mixtureModifier().setPhiPolymer(
id(0), newVal);
231 }
else if (type_ == Mu_Polymer) {
233 systemPtr_->mixtureModifier().setMuPolymer(
id(0), newVal);
234 }
else if (type_ ==
Block) {
236 systemPtr_->mixtureModifier().setBlockLength(
id(0),
id(1), newVal);
237 }
else if (type_ == Phi_Solvent) {
239 systemPtr_->mixtureModifier().setPhiSolvent(
id(0), newVal);
240 }
else if (type_ == Mu_Solvent) {
242 systemPtr_->mixtureModifier().setMuSolvent(
id(0), newVal);
245 systemPtr_->mixtureModifier().setSolventSize(
id(0), newVal);
246 }
else if (type_ == Cell_Param) {
248 = systemPtr_->domain().unitCell().parameters();
249 params[id(0)] = newVal;
250 systemPtr_->setUnitCell(params);
251 }
else if (type_ == Special) {
253 std::string name = parameterType().name;
261 template <
class Archive>
266 for (
int i = 0; i < nId_; ++i) {
283 param.readParamType(in);
286 for (
int i = 0; i < param.nId_; ++i) {
304 for (
int i = 0; i < param.nId_; ++i) {
308 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 linear or branched block polymer.
Solver and descriptor for a solvent species.
Class for storing data about an individual sweep parameter.
bool isSpecialized() const
Is this SweepParameter a specialized parameter type?
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.
void getInitial()
Get and store initial value of this parameter.
std::string type() const
Return a string representation of the parameter type.
SweepParameter()
Default constructor.
void serialize(Archive ar, const unsigned int version)
Serialize to or from an archive.
ParameterType & parameterType() const
Get the ParameterType object for a specialized sweep parameter.
int id(int i) const
Get id for a sub-object or element to which this is applied.
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.
Real periodic fields, SCFT and PS-FTS (CPU).
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.