1#ifndef RPC_RAMP_PARAMETER_TPP
2#define RPC_RAMP_PARAMETER_TPP
11#include <rpc/system/System.h>
12#include <rpc/fts/simulator/Simulator.h>
13#include <rpc/fts/perturbation/Perturbation.h>
14#include <rpc/solvers/Mixture.h>
15#include <rpc/solvers/MixtureModifier.h>
16#include <rpc/solvers/Polymer.h>
17#include <rpc/solvers/Solvent.h>
18#include <rpc/solvers/Block.h>
19#include <rpc/field/Domain.h>
20#include <prdc/crystal/UnitCell.h>
21#include <pscf/chem/Monomer.h>
22#include <pscf/inter/Interaction.h>
23#include <util/containers/FSArray.h>
58 simulatorPtr_(&simulator),
59 systemPtr_(&(simulator.system()))
69 simulatorPtr_ = &simulator;
70 systemPtr_ = &(simulator.
system());
77 void RampParameter<D>::readParamType(std::istream& in)
81 std::transform(buffer.begin(), buffer.end(),
82 buffer.begin(), ::tolower);
84 if (buffer ==
"block" || buffer ==
"block_length") {
88 }
else if (buffer ==
"chi") {
91 }
else if (buffer ==
"kuhn") {
94 }
else if (buffer ==
"phi_polymer") {
97 }
else if (buffer ==
"phi_solvent") {
100 }
else if (buffer ==
"mu_polymer") {
103 }
else if (buffer ==
"mu_solvent") {
106 }
else if (buffer ==
"solvent" || buffer ==
"solvent_size") {
109 }
else if (buffer ==
"cell_param") {
112 }
else if (buffer ==
"lambda_pert") {
115 }
else if (buffer ==
"v_monomer") {
119 UTIL_THROW(
"Invalid RampParameter::ParamType value");
122 if (id_.isAllocated()) id_.deallocate();
141 { initial_ = get_(); }
156 if (type_ == Block) {
159 }
else if (type_ == Chi) {
161 }
else if (type_ == Kuhn) {
163 }
else if (type_ == Phi_Polymer) {
164 return "phi_polymer";
165 }
else if (type_ == Phi_Solvent) {
166 return "phi_solvent";
167 }
else if (type_ == Mu_Polymer) {
169 }
else if (type_ == Mu_Solvent) {
171 }
else if (type_ == Solvent) {
172 return "solvent_size";
173 }
else if (type_ == Cell_Param) {
175 }
else if (type_ == Lambda_Pert) {
176 return "lambda_pert";
177 }
else if (type_ == Vmonomer) {
185 double RampParameter<D>::get_()
187 if (type_ ==
Block) {
189 return systemPtr_->mixture().polymer(
id(0)).block(
id(1)).length();
190 }
else if (type_ == Chi) {
191 return systemPtr_->interaction().chi(
id(0),
id(1));
192 }
else if (type_ == Kuhn) {
193 return systemPtr_->mixture().monomer(
id(0)).kuhn();
194 }
else if (type_ == Phi_Polymer) {
195 return systemPtr_->mixture().polymer(
id(0)).phi();
196 }
else if (type_ == Phi_Solvent) {
197 return systemPtr_->mixture().solvent(
id(0)).phi();
198 }
else if (type_ == Mu_Polymer) {
199 return systemPtr_->mixture().polymer(
id(0)).mu();
200 }
else if (type_ == Mu_Solvent) {
201 return systemPtr_->mixture().solvent(
id(0)).mu();
203 return systemPtr_->mixture().solvent(
id(0)).size();
204 }
else if (type_ == Cell_Param) {
205 return systemPtr_->domain().unitCell().parameter(
id(0));
206 }
else if (type_ == Lambda_Pert) {
208 return simulatorPtr_->perturbation().lambda();
209 }
else if (type_ == Vmonomer) {
210 return systemPtr_->mixture().vMonomer();
217 void RampParameter<D>::set_(
double newVal)
220 systemPtr_->interaction().setChi(
id(0),
id(1), newVal);
221 }
else if (type_ == Kuhn) {
223 systemPtr_->mixtureModifier().setKuhn(
id(0), newVal);
224 }
else if (type_ == Phi_Polymer) {
226 systemPtr_->mixtureModifier().setPhiPolymer(
id(0), newVal);
227 }
else if (type_ == Mu_Polymer) {
229 systemPtr_->mixtureModifier().setMuPolymer(
id(0), newVal);
230 }
else if (type_ ==
Block) {
233 systemPtr_->mixtureModifier().setBlockLength(
id(0),
id(1), newVal);
234 }
else if (type_ == Phi_Solvent) {
236 systemPtr_->mixtureModifier().setPhiSolvent(
id(0), newVal);
237 }
else if (type_ == Mu_Solvent) {
239 systemPtr_->mixtureModifier().setMuSolvent(
id(0), newVal);
242 systemPtr_->mixtureModifier().setSolventSize(
id(0), newVal);
243 }
else if (type_ == Cell_Param) {
245 = systemPtr_->domain().unitCell().parameters();
247 params[id(0)] = newVal;
248 systemPtr_->setUnitCell(params);
249 }
else if (type_ == Lambda_Pert) {
251 return simulatorPtr_->perturbation().setLambda(newVal);
252 }
else if (type_ == Vmonomer) {
253 systemPtr_->mixtureModifier().setVMonomer(newVal);
260 template <
class Archive>
266 for (
int i = 0; i < nId_; ++i) {
284 param.readParamType(in);
287 if (param.nId_ > 0) {
288 for (
int i = 0; i < param.nId_; ++i) {
308 if (param.nId_ > 0) {
309 for (
int i = 0; i < param.nId_; ++i) {
314 out << param.change_;
Block within a linear or branched block polymer.
Class for storing data about an individual ramp parameter.
RampParameter()
Default constructor.
void getInitial()
Get and store initial value this parameters.
int id(int i) const
Get id for a sub-object or element to which this is applied.
void serialize(Archive ar, const unsigned int version)
Serialize to or from an archive.
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 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.
int size() const
Return logical size of this array (i.e., number of elements).
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.
bool isThread()
Is the thread model in use ?
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.