1#ifndef RP_RAMP_PARAMETER_TPP
2#define RP_RAMP_PARAMETER_TPP
11#include "RampParameter.h"
12#include <prdc/crystal/UnitCell.h>
13#include <pscf/chem/Monomer.h>
14#include <pscf/chem/PolymerModel.h>
15#include <pscf/interaction/Interaction.h>
16#include <util/containers/FSArray.h>
29 template <
int D,
class T>
43 template <
int D,
class T>
50 simulatorPtr_(&simulator),
51 systemPtr_(&(simulator.system()))
57 template <
int D,
class T>
60 simulatorPtr_ = &simulator;
61 systemPtr_ = &(simulator.system());
67 template <
int D,
class T>
68 void RampParameter<D,T>::readParamType(std::istream& in)
72 std::transform(buffer.begin(), buffer.end(),
73 buffer.begin(), ::tolower);
75 if (buffer ==
"block" || buffer ==
"block_length") {
79 }
else if (buffer ==
"chi") {
82 }
else if (buffer ==
"kuhn") {
85 }
else if (buffer ==
"phi_polymer") {
88 }
else if (buffer ==
"phi_solvent") {
91 }
else if (buffer ==
"mu_polymer") {
94 }
else if (buffer ==
"mu_solvent") {
97 }
else if (buffer ==
"solvent" || buffer ==
"solvent_size") {
100 }
else if (buffer ==
"cell_param") {
103 }
else if (buffer ==
"lambda_pert") {
106 }
else if (buffer ==
"v_monomer") {
110 UTIL_THROW(
"Invalid RampParameter::ParamType value");
113 if (id_.isAllocated()) id_.deallocate();
123 template <
int D,
class T>
130 template <
int D,
class T>
132 { initial_ = get_(); }
137 template <
int D,
class T>
144 template <
int D,
class T>
147 if (type_ == Block) {
150 }
else if (type_ == Chi) {
152 }
else if (type_ == Kuhn) {
154 }
else if (type_ == Phi_Polymer) {
155 return "phi_polymer";
156 }
else if (type_ == Phi_Solvent) {
157 return "phi_solvent";
158 }
else if (type_ == Mu_Polymer) {
160 }
else if (type_ == Mu_Solvent) {
162 }
else if (type_ == Solvent) {
163 return "solvent_size";
164 }
else if (type_ == Cell_Param) {
166 }
else if (type_ == Lambda_Pert) {
167 return "lambda_pert";
168 }
else if (type_ == Vmonomer) {
178 template <
int D,
class T>
179 double RampParameter<D,T>::get_()
181 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_ == Vmonomer) {
199 return systemPtr_->mixture().vMonomer();
200 }
else if (type_ == Cell_Param) {
201 return systemPtr_->domain().unitCell().parameter(
id(0));
202 }
else if (type_ == Lambda_Pert) {
204 return simulatorPtr_->perturbation().lambda();
213 template <
int D,
class T>
214 void RampParameter<D,T>::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) {
226 systemPtr_->mixtureModifier().setBlockLength(
id(0),
id(1), newVal);
227 }
else if (type_ == Phi_Solvent) {
228 systemPtr_->mixtureModifier().setPhiSolvent(
id(0), newVal);
229 }
else if (type_ == Mu_Solvent) {
230 systemPtr_->mixtureModifier().setMuSolvent(
id(0), newVal);
232 systemPtr_->mixtureModifier().setSolventSize(
id(0), newVal);
233 }
else if (type_ == Vmonomer) {
234 systemPtr_->mixtureModifier().setVMonomer(newVal);
235 }
else if (type_ == Cell_Param) {
237 params = systemPtr_->domain().unitCell().parameters();
239 params[id(0)] = newVal;
240 systemPtr_->setUnitCell(params);
241 }
else if (type_ == Lambda_Pert) {
243 return simulatorPtr_->perturbation().setLambda(newVal);
RampParameter()
Default constructor.
void writeParamType(std::ostream &out) const
Write the parameter type to an output stream.
void getInitial()
Get and store initial value this parameters.
void setSimulator(typename T::Simulator &simulator)
Set the simulator and system associated with this object.
void update(double newVal)
Update the corresponding parameter value in the System.
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).
#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.
bool isThread()
Is the thread model in use ?
Periodic fields and crystallography.
Class templates for real-valued periodic fields.
PSCF package top-level namespace.