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/Polymer.h>
17#include <rpg/solvers/Solvent.h>
18#include <rpg/solvers/Block.h>
19#include <rpg/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") {
87 }
else if (buffer ==
"chi") {
90 }
else if (buffer ==
"kuhn") {
93 }
else if (buffer ==
"phi_polymer") {
96 }
else if (buffer ==
"phi_solvent") {
99 }
else if (buffer ==
"mu_polymer") {
102 }
else if (buffer ==
"mu_solvent") {
105 }
else if (buffer ==
"solvent" || buffer ==
"solvent_size") {
108 }
else if (buffer ==
"cell_param") {
111 }
else if (buffer ==
"lambda_pert") {
114 }
else if (buffer ==
"v_monomer") {
118 UTIL_THROW(
"Invalid RampParameter::ParamType value");
121 if (id_.isAllocated()) id_.deallocate();
140 { initial_ = get_(); }
155 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) {
186 return systemPtr_->mixture().polymer(
id(0)).block(
id(1)).length();
187 }
else if (type_ == Chi) {
188 return systemPtr_->interaction().chi(
id(0),
id(1));
189 }
else if (type_ == Kuhn) {
190 return systemPtr_->mixture().monomer(
id(0)).kuhn();
191 }
else if (type_ == Phi_Polymer) {
192 return systemPtr_->mixture().polymer(
id(0)).phi();
193 }
else if (type_ == Phi_Solvent) {
194 return systemPtr_->mixture().solvent(
id(0)).phi();
195 }
else if (type_ == Mu_Polymer) {
196 return systemPtr_->mixture().polymer(
id(0)).mu();
197 }
else if (type_ == Mu_Solvent) {
198 return systemPtr_->mixture().solvent(
id(0)).mu();
200 return systemPtr_->mixture().solvent(
id(0)).size();
201 }
else if (type_ == Cell_Param) {
202 return systemPtr_->domain().unitCell().parameter(
id(0));
203 }
else if (type_ == Lambda_Pert) {
205 return simulatorPtr_->perturbation().lambda();
206 }
else if (type_ == Vmonomer) {
207 return systemPtr_->mixture().vMonomer();
214 void RampParameter<D>::set_(
double newVal)
217 systemPtr_->interaction().setChi(
id(0),
id(1), newVal);
218 }
else if (type_ == Kuhn) {
219 systemPtr_->mixtureModifier().setKuhn(
id(0), newVal);
220 }
else if (type_ == Phi_Polymer) {
221 systemPtr_->mixtureModifier().setPhiPolymer(
id(0), newVal);
222 }
else if (type_ == Mu_Polymer) {
223 systemPtr_->mixtureModifier().setMuPolymer(
id(0), newVal);
224 }
else if (type_ ==
Block) {
225 systemPtr_->mixtureModifier().setBlockLength(
id(0),
id(1), newVal);
226 }
else if (type_ == Phi_Solvent) {
227 systemPtr_->mixtureModifier().setPhiSolvent(
id(0), newVal);
228 }
else if (type_ == Mu_Solvent) {
229 systemPtr_->mixtureModifier().setMuSolvent(
id(0), newVal);
231 systemPtr_->mixtureModifier().setSolventSize(
id(0), newVal);
232 }
else if (type_ == Vmonomer) {
233 systemPtr_->mixtureModifier().setVMonomer(newVal);
235 }
else if (type_ == Kuhn) {
236 systemPtr_->mixture().setKuhn(
id(0), newVal);
237 }
else if (type_ == Phi_Polymer) {
238 systemPtr_->mixture().polymer(
id(0)).setPhi(newVal);
239 }
else if (type_ == Phi_Solvent) {
240 systemPtr_->mixture().solvent(
id(0)).setPhi(newVal);
241 }
else if (type_ == Mu_Polymer) {
242 systemPtr_->mixture().polymer(
id(0)).setMu(newVal);
243 }
else if (type_ == Mu_Solvent) {
244 systemPtr_->mixture().solvent(
id(0)).setMu(newVal);
245 }
else if (type_ ==
Block) {
246 systemPtr_->mixture().polymer(
id(0)).block(
id(1)).setLength(newVal);
248 systemPtr_->mixture().solvent(
id(0)).setSize(newVal);
250 }
else if (type_ == Cell_Param) {
252 params = systemPtr_->domain().unitCell().parameters();
253 params[id(0)] = newVal;
254 systemPtr_->setUnitCell(params);
255 }
else if (type_ == Lambda_Pert) {
257 return simulatorPtr_->perturbation().setLambda(newVal);
264 template <
class Archive>
270 for (
int i = 0; i < nId_; ++i) {
288 param.readParamType(in);
291 if (param.nId_ > 0) {
292 for (
int i = 0; i < param.nId_; ++i) {
312 if (param.nId_ > 0) {
313 for (
int i = 0; i < param.nId_; ++i) {
318 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.