PSCF v1.1
fd1d/sweep/SweepParameter.h
1#ifndef FD1D_SWEEP_PARAMETER_H
2#define FD1D_SWEEP_PARAMETER_H
3
4/*
5* PSCF - Polymer Self-Consistent Field Theory
6*
7* Copyright 2016 - 2022, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <util/containers/DArray.h>
12#include <iostream>
13
14using namespace Util;
15
16namespace Pscf {
17namespace Fd1d {
18
19 class System;
20
83 {
84
85 public:
86
91
97 SweepParameter(System& system);
98
107 void setSystem(System& system)
108 { systemPtr_ = &system;}
109
113 void getInitial();
114
120 void update(double newVal);
121
125 std::string type() const;
126
132 void writeParamType(std::ostream& out) const;
133
145 int id(int i) const
146 { return id_[i];}
147
151 double current()
152 { return get_(); }
153
157 double initial() const
158 { return initial_; }
159
163 double change() const
164 { return change_; }
165
172 template <class Archive>
173 void serialize(Archive ar, const unsigned int version);
174
175 private:
176
178 enum ParamType { Block, Chi, Kuhn, Phi_Polymer, Phi_Solvent,
179 Mu_Polymer, Mu_Solvent, Solvent, Cell_Param, Null};
180
182 ParamType type_;
183
185 int nID_;
186
188 DArray<int> id_;
189
191 double initial_;
192
194 double change_;
195
197 System* systemPtr_;
198
204 void readParamType(std::istream& in);
205
209 double get_();
210
216 void set_(double newVal);
217
218 // friends:
219
220 friend
221 std::istream& operator >> (std::istream&, SweepParameter&);
222
223 friend
224 std::ostream&
225 operator << (std::ostream&, SweepParameter const &);
226
227 };
228
229 template <class Archive>
230 void SweepParameter::serialize(Archive ar, const unsigned int version)
231 {
232 serializeEnum(ar, type_, version);
233 ar & nID_;
234 for (int i = 0; i < nID_; ++i) {
235 ar & id_[i];
236 }
237 ar & initial_;
238 ar & change_;
239 }
240
241}
242}
243#endif
Block within a branched polymer.
Solver and descriptor for a solvent species.
Class for storing data about an individual sweep parameter.
double initial() const
Return the initial system parameter value.
void getInitial()
Store the pre-sweep value of the corresponding parameter.
std::string type() const
Return a string representation of the parameter type.
double current()
Return the current system parameter value.
int id(int i) const
Get a id for a sub-object or element to which this is applied.
void setSystem(System &system)
Set the system associated with this object.
void serialize(Archive ar, const unsigned int version)
Serialize to or from an archive.
void writeParamType(std::ostream &out) const
Write the parameter type to an output stream.
SweepParameter()
Default constructor.
void update(double newVal)
Update the corresponding parameter value in the system.
double change() const
Return the total change planned for this parameter during sweep.
friend std::ostream & operator<<(std::ostream &, SweepParameter const &)
Extractor for writing a SweepParameter to ostream.
friend std::istream & operator>>(std::istream &, SweepParameter &)
Inserter for reading a SweepParameter from an istream.
Main class in SCFT simulation of one system.
Definition: fd1d/System.h:63
Dynamically allocatable contiguous array template.
Definition: DArray.h:32
void serializeEnum(Archive &ar, T &data, const unsigned int version=0)
Serialize an enumeration value.
Definition: serialize.h:42
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1