Loading [MathJax]/extensions/TeX/AMSsymbols.js
PSCF v1.2
rpc/scft/sweep/LinearSweep.tpp
1#ifndef RPC_LINEAR_SWEEP_TPP
2#define RPC_LINEAR_SWEEP_TPP
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 "LinearSweep.h"
12#include <rpc/System.h>
13
14namespace Pscf {
15namespace Rpc {
16
17 using namespace Util;
18
19 template <int D>
21 : Sweep<D>(system)
22 {}
23
24 template <int D>
25 void LinearSweep<D>::readParameters(std::istream& in)
26 {
27 // Call the base class's readParameters function
29
30 // Read the number of sweep parameters, allocate parameters_ array
31 read(in, "nParameter", nParameter_);
32 parameters_.allocate(nParameter_);
33
34 // Set the pointer to the array of specialized parameter types for
35 // each SweepParameter object
36 for (int i = 0; i < nParameter_; ++i) {
37 parameters_[i].setParameterTypesArray(
38 SweepTmpl< BasisFieldState<D> >::parameterTypes_);
39 }
40
41 // Read array of SweepParameters, calling << operator for each
42 readDArray(in, "parameters", parameters_, nParameter_);
43
44 // Verify net zero change in volume fractions, if these are swept
45 double sum = 0.0;
46 for (int i = 0; i < nParameter_; ++i) {
47 if (parameters_[i].type() == "phi_polymer" ||
48 parameters_[i].type() == "phi_solvent")
49 {
50 sum += parameters_[i].change();
51 }
52 }
53 UTIL_CHECK(sum > -0.000001);
54 UTIL_CHECK(sum < 0.000001);
55 }
56
57 template <int D>
59 {
60 // Verify that the LinearSweep has a pointer to parent System
61 UTIL_CHECK(hasSystem());
62
63 // Call base class setup function
65
66 // Set system pointer and initial value for each parameter object
67 for (int i = 0; i < nParameter_; ++i) {
68 parameters_[i].setSystem(system());
69 parameters_[i].getInitial();
70 }
71 }
72
73 template <int D>
75 {
76 // Update the system parameter values
77 double newVal;
78 for (int i = 0; i < nParameter_; ++i) {
79 newVal = parameters_[i].initial() + s*parameters_[i].change();
80 parameters_[i].update(newVal);
81 }
82 }
83
84 template <int D>
85 void LinearSweep<D>::outputSummary(std::ostream& out)
86 {}
87
88}
89}
90
91#endif
FieldState for fields in symmetry-adapted basis format.
void readParameters(std::istream &in)
Read parameters from param file.
void setup()
Setup operation at the beginning of a sweep.
void outputSummary(std::ostream &out)
Output data to a running summary.
void setParameters(double s)
Set state parameters before solving an SCFT problem.
LinearSweep(System< D > &system)
Constructor.
Solve a sequence of SCFT problems along a line in parameter space.
Definition rpc/System.h:36
virtual void readParameters(std::istream &in)
Read parameters from param file.
virtual void setup()
Setup operation at the beginning of a sweep.
Main class for SCFT or PS-FTS simulation of one system.
Definition rpc/System.h:100
Solve a sequence of problems along a path through parameter space.
Definition SweepTmpl.h:28
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
PSCF package top-level namespace.
Definition param_pc.dox:1
Utility classes for scientific computation.