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/Block.h>
17#include <rpc/solvers/Mixture.h>
18#include <rpc/solvers/Polymer.h>
19#include <prdc/crystal/UnitCell.h>
20#include <pscf/inter/Interaction.h>
21#include <util/containers/FSArray.h>
56 simulatorPtr_(&simulator),
57 systemPtr_(&(simulator.system()))
67 simulatorPtr_ = &simulator;
68 systemPtr_ = &(simulator.
system());
75 void RampParameter<D>::readParamType(std::istream& in)
79 std::transform(buffer.begin(), buffer.end(),
80 buffer.begin(), ::tolower);
82 if (buffer ==
"block" || buffer ==
"block_length") {
86 }
else if (buffer ==
"chi") {
89 }
else if (buffer ==
"kuhn") {
92 }
else if (buffer ==
"phi_polymer") {
95 }
else if (buffer ==
"phi_solvent") {
98 }
else if (buffer ==
"mu_polymer") {
101 }
else if (buffer ==
"mu_solvent") {
104 }
else if (buffer ==
"solvent" || buffer ==
"solvent_size") {
107 }
else if (buffer ==
"cell_param") {
110 }
else if (buffer ==
"lambda_pert") {
113 }
else if (buffer ==
"v_monomer") {
117 UTIL_THROW(
"Invalid RampParameter::ParamType value");
120 if (id_.isAllocated()) id_.deallocate();
139 { initial_ = get_(); }
154 if (type_ == Block) {
157 }
else if (type_ == Chi) {
159 }
else if (type_ == Kuhn) {
161 }
else if (type_ == Phi_Polymer) {
162 return "phi_polymer";
163 }
else if (type_ == Phi_Solvent) {
164 return "phi_solvent";
165 }
else if (type_ == Mu_Polymer) {
167 }
else if (type_ == Mu_Solvent) {
169 }
else if (type_ == Solvent) {
170 return "solvent_size";
171 }
else if (type_ == Cell_Param) {
173 }
else if (type_ == Lambda_Pert) {
174 return "lambda_pert";
175 }
else if (type_ == Vmonomer) {
183 double RampParameter<D>::get_()
185 if (type_ ==
Block) {
187 return systemPtr_->mixture().polymer(
id(0)).block(
id(1)).length();
188 }
else if (type_ == Chi) {
189 return systemPtr_->interaction().chi(
id(0),
id(1));
190 }
else if (type_ == Kuhn) {
191 return systemPtr_->mixture().monomer(
id(0)).kuhn();
192 }
else if (type_ == Phi_Polymer) {
193 return systemPtr_->mixture().polymer(
id(0)).phi();
194 }
else if (type_ == Phi_Solvent) {
195 return systemPtr_->mixture().solvent(
id(0)).phi();
196 }
else if (type_ == Mu_Polymer) {
197 return systemPtr_->mixture().polymer(
id(0)).mu();
198 }
else if (type_ == Mu_Solvent) {
199 return systemPtr_->mixture().solvent(
id(0)).mu();
201 return systemPtr_->mixture().solvent(
id(0)).size();
202 }
else if (type_ == Cell_Param) {
203 return systemPtr_->domain().unitCell().parameter(
id(0));
204 }
else if (type_ == Lambda_Pert) {
206 return simulatorPtr_->perturbation().lambda();
207 }
else if (type_ == Vmonomer) {
208 return systemPtr_->mixture().vMonomer();
215 void RampParameter<D>::set_(
double newVal)
218 systemPtr_->interaction().setChi(
id(0),
id(1), newVal);
219 }
else if (type_ == Kuhn) {
221 systemPtr_->mixtureModifier().setKuhn(
id(0), newVal);
222 }
else if (type_ == Phi_Polymer) {
224 systemPtr_->mixtureModifier().setPhiPolymer(
id(0), newVal);
225 }
else if (type_ == Mu_Polymer) {
227 systemPtr_->mixtureModifier().setMuPolymer(
id(0), newVal);
228 }
else if (type_ ==
Block) {
231 systemPtr_->mixtureModifier().setBlockLength(
id(0),
id(1), newVal);
232 }
else if (type_ == Phi_Solvent) {
234 systemPtr_->mixtureModifier().setPhiSolvent(
id(0), newVal);
235 }
else if (type_ == Mu_Solvent) {
237 systemPtr_->mixtureModifier().setMuSolvent(
id(0), newVal);
240 systemPtr_->mixtureModifier().setSolventSize(
id(0), newVal);
241 }
else if (type_ == Cell_Param) {
243 = systemPtr_->domain().unitCell().parameters();
245 params[id(0)] = newVal;
246 systemPtr_->setUnitCell(params);
247 }
else if (type_ == Lambda_Pert) {
249 return simulatorPtr_->perturbation().setLambda(newVal);
250 }
else if (type_ == Vmonomer) {
251 systemPtr_->mixtureModifier().setVMonomer(newVal);
258 template <
class Archive>
264 for (
int i = 0; i < nId_; ++i) {
282 param.readParamType(in);
285 if (param.nId_ > 0) {
286 for (
int i = 0; i < param.nId_; ++i) {
306 if (param.nId_ > 0) {
307 for (
int i = 0; i < param.nId_; ++i) {
312 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.