PSCF v1.1
fd1d/sweep/LinearSweep.cpp
1/*
2* PSCF - Polymer Self-Consistent Field Theory
3*
4* Copyright 2016 - 2022, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "LinearSweep.h"
9#include <fd1d/System.h>
10#include <cstdio>
11
12namespace Pscf {
13namespace Fd1d {
14
15 using namespace Util;
16
18 : Sweep(system)
19 {}
20
21 void LinearSweep::readParameters(std::istream& in)
22 {
23 // Call the base class's readParameters function.
25
26 // Read in the number of sweep parameters and allocate.
27 read(in, "nParameter", nParameter_);
28 parameters_.allocate(nParameter_);
29
30 // Read in array of SweepParameters, calling << for each
31 readDArray< SweepParameter >(in, "parameters",
32 parameters_, nParameter_);
33
34 // Verify net zero change in volume fractions if being swept
35 double sum = 0.0;
36 for (int i = 0; i < nParameter_; ++i) {
37 if (parameters_[i].type() == "phi_polymer"
38 || parameters_[i].type() == "phi_solvent")
39 {
40 sum += parameters_[i].change();
41 }
42 }
43 UTIL_CHECK(sum > -0.000001);
44 UTIL_CHECK(sum < 0.000001);
45 }
46
48 {
49 // Call base class's setup function
51
52 // Set system pointer and initial value for each parameter object
53 for (int i = 0; i < nParameter_; ++i) {
54 parameters_[i].setSystem(system());
55 parameters_[i].getInitial();
56 }
57 }
58
60 {
61 // Update the system parameter values
62 double newVal;
63 for (int i = 0; i < nParameter_; ++i) {
64 newVal = parameters_[i].initial() + s*parameters_[i].change();
65 parameters_[i].update(newVal);
66 }
67 }
68
69 void LinearSweep::outputSummary(std::ostream& out)
70 {}
71
72}
73}
74
void setParameters(double s)
Set the state before an iteration.
LinearSweep(System &system)
Constructor.
void outputSummary(std::ostream &out)
Output data to a running summary.
void readParameters(std::istream &in)
Read parameters from param file.
void setup()
Setup operation at the beginning of a sweep.
Solve a sequence of problems along a line in parameter space.
virtual void readParameters(std::istream &in)
Read ns and baseFileName parameters.
virtual void setup()
Setup operation at beginning sweep.
const System & system() const
Get parent System by reference.
Definition: SystemAccess.h:158
Main class in SCFT simulation of one system.
Definition: fd1d/System.h:63
double s(int i) const
Get the value of s for a stored solution, with i = 0 most recent.
Definition: SweepTmpl.h:90
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition: global.h:68
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1