1#ifndef RPG_RAMP_PARAMETER_TPP
2#define RPG_RAMP_PARAMETER_TPP
11#include <rpg/system/System.h>
12#include <rpg/fts/simulator/Simulator.h>
13#include <rpg/fts/perturbation/Perturbation.h>
14#include <rpg/solvers/Mixture.h>
15#include <rpg/solvers/MixtureModifier.h>
16#include <rpg/solvers/Block.h>
17#include <rpg/solvers/Polymer.h>
18#include <prdc/crystal/UnitCell.h>
19#include <pscf/inter/Interaction.h>
20#include <util/containers/FSArray.h>
55 simulatorPtr_(&simulator),
56 systemPtr_(&(simulator.system()))
66 simulatorPtr_ = &simulator;
67 systemPtr_ = &(simulator.
system());
74 void RampParameter<D>::readParamType(std::istream& in)
78 std::transform(buffer.begin(), buffer.end(),
79 buffer.begin(), ::tolower);
81 if (buffer ==
"block" || buffer ==
"block_length") {
84 }
else if (buffer ==
"chi") {
87 }
else if (buffer ==
"kuhn") {
90 }
else if (buffer ==
"phi_polymer") {
93 }
else if (buffer ==
"phi_solvent") {
96 }
else if (buffer ==
"mu_polymer") {
99 }
else if (buffer ==
"mu_solvent") {
102 }
else if (buffer ==
"solvent" || buffer ==
"solvent_size") {
105 }
else if (buffer ==
"cell_param") {
108 }
else if (buffer ==
"lambda_pert") {
111 }
else if (buffer ==
"v_monomer") {
115 UTIL_THROW(
"Invalid RampParameter::ParamType value");
118 if (id_.isAllocated()) id_.deallocate();
137 { initial_ = get_(); }
152 if (type_ == Block) {
154 }
else if (type_ == Chi) {
156 }
else if (type_ == Kuhn) {
158 }
else if (type_ == Phi_Polymer) {
159 return "phi_polymer";
160 }
else if (type_ == Phi_Solvent) {
161 return "phi_solvent";
162 }
else if (type_ == Mu_Polymer) {
164 }
else if (type_ == Mu_Solvent) {
166 }
else if (type_ == Solvent) {
167 return "solvent_size";
168 }
else if (type_ == Cell_Param) {
170 }
else if (type_ == Lambda_Pert) {
171 return "lambda_pert";
172 }
else if (type_ == Vmonomer) {
180 double RampParameter<D>::get_()
182 if (type_ ==
Block) {
183 return systemPtr_->mixture().polymer(
id(0)).block(
id(1)).length();
184 }
else if (type_ == Chi) {
185 return systemPtr_->interaction().chi(
id(0),
id(1));
186 }
else if (type_ == Kuhn) {
187 return systemPtr_->mixture().monomer(
id(0)).kuhn();
188 }
else if (type_ == Phi_Polymer) {
189 return systemPtr_->mixture().polymer(
id(0)).phi();
190 }
else if (type_ == Phi_Solvent) {
191 return systemPtr_->mixture().solvent(
id(0)).phi();
192 }
else if (type_ == Mu_Polymer) {
193 return systemPtr_->mixture().polymer(
id(0)).mu();
194 }
else if (type_ == Mu_Solvent) {
195 return systemPtr_->mixture().solvent(
id(0)).mu();
197 return systemPtr_->mixture().solvent(
id(0)).size();
198 }
else if (type_ == Cell_Param) {
199 return systemPtr_->domain().unitCell().parameter(
id(0));
200 }
else if (type_ == Lambda_Pert) {
202 return simulatorPtr_->perturbation().lambda();
203 }
else if (type_ == Vmonomer) {
204 return systemPtr_->mixture().vMonomer();
211 void RampParameter<D>::set_(
double newVal)
214 systemPtr_->interaction().setChi(
id(0),
id(1), newVal);
215 }
else if (type_ == Kuhn) {
216 systemPtr_->mixtureModifier().setKuhn(
id(0), newVal);
217 }
else if (type_ == Phi_Polymer) {
218 systemPtr_->mixtureModifier().setPhiPolymer(
id(0), newVal);
219 }
else if (type_ == Mu_Polymer) {
220 systemPtr_->mixtureModifier().setMuPolymer(
id(0), newVal);
221 }
else if (type_ ==
Block) {
222 systemPtr_->mixtureModifier().setBlockLength(
id(0),
id(1), newVal);
223 }
else if (type_ == Phi_Solvent) {
224 systemPtr_->mixtureModifier().setPhiSolvent(
id(0), newVal);
225 }
else if (type_ == Mu_Solvent) {
226 systemPtr_->mixtureModifier().setMuSolvent(
id(0), newVal);
228 systemPtr_->mixtureModifier().setSolventSize(
id(0), newVal);
229 }
else if (type_ == Vmonomer) {
230 systemPtr_->mixtureModifier().setVMonomer(newVal);
232 }
else if (type_ == Kuhn) {
233 systemPtr_->mixture().setKuhn(
id(0), newVal);
234 }
else if (type_ == Phi_Polymer) {
235 systemPtr_->mixture().polymer(
id(0)).setPhi(newVal);
236 }
else if (type_ == Phi_Solvent) {
237 systemPtr_->mixture().solvent(
id(0)).setPhi(newVal);
238 }
else if (type_ == Mu_Polymer) {
239 systemPtr_->mixture().polymer(
id(0)).setMu(newVal);
240 }
else if (type_ == Mu_Solvent) {
241 systemPtr_->mixture().solvent(
id(0)).setMu(newVal);
242 }
else if (type_ ==
Block) {
243 systemPtr_->mixture().polymer(
id(0)).block(
id(1)).setLength(newVal);
245 systemPtr_->mixture().solvent(
id(0)).setSize(newVal);
247 }
else if (type_ == Cell_Param) {
249 params = systemPtr_->domain().unitCell().parameters();
250 params[id(0)] = newVal;
251 systemPtr_->setUnitCell(params);
252 }
else if (type_ == Lambda_Pert) {
254 return simulatorPtr_->perturbation().setLambda(newVal);
261 template <
class Archive>
267 for (
int i = 0; i < nId_; ++i) {
285 param.readParamType(in);
288 if (param.nId_ > 0) {
289 for (
int i = 0; i < param.nId_; ++i) {
309 if (param.nId_ > 0) {
310 for (
int i = 0; i < param.nId_; ++i) {
315 out << param.change_;
Block within a branched polymer.
Class for storing data about an individual ramp parameter.
int id(int i) const
Get id for a sub-object or element to which this is applied.
RampParameter()
Default constructor.
std::string type() const
Return a string representation of the 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 serialize(Archive ar, const unsigned int version)
Serialize to or from an archive.
void getInitial()
Get and store initial value this parameters.
void setSimulator(Simulator< D > &simulator)
Set the simulator and system associated with this object.
Field theoretic simulator (base class).
System< D > & system()
Get parent system by reference.
Solver and descriptor for a solvent species.
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.