https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SecantInversionControl.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11
13
16{
19 "Adjusts a parameter postprocessor each fixed-point iteration using the secant method so "
20 "that a sub-app output postprocessor matches a target function of time.");
21
22 params.addRangeCheckedParam<Real>(
23 "initial_delta",
24 1e-3,
25 "initial_delta>0",
26 "Perturbation applied to the parameter on the first iteration of each fixed-point solve to "
27 "seed the secant method.");
28
29 return params;
30}
31
33 : InversionControlBase(parameters),
34 _initial_delta(getParam<Real>("initial_delta")),
35 _p_prev(0.0),
36 _y_prev(0.0)
37{
38}
39
41SecantInversionControl::computeUpdate(unsigned int it, Real p_used, Real y, Real y_target)
42{
43 Real p_next;
44 if (it == 1)
45 // Only one (p, y) pair known: seed the secant method with a perturbation.
46 p_next = p_used + _initial_delta;
47 else
48 p_next = linearRootUpdate(_p_prev, _y_prev, p_used, y, y_target);
49
50 // _p_prev/_y_prev are plain members, not restartable: they are re-seeded on the first iteration
51 // of every fixed-point solve (it == 1), so a recover at a step boundary loses nothing.
52 _p_prev = p_used;
53 _y_prev = y;
54
55 // Every secant iteration reports the normalized residual and publishes its evaluated parameter.
56 return {p_next, normalizedResidual(y), true};
57}
const std::vector< double > y
registerMooseObject("OptimizationApp", SecantInversionControl)
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
Base class for controls that adjust a single scalar parameter (held in a postprocessor) once per fixe...
Real normalizedResidual(Real y) const
Normalized convergence residual for output value y: |y - targetValue()| / max(absolute_tolerance,...
Real linearRootUpdate(Real p_a, Real y_a, Real p_b, Real y_b, Real y_target)
One guarded linear-model root update from two (parameter, output) samples – a secant step shared by t...
static InputParameters validParams()
Control that adjusts a scalar parameter (held in a postprocessor) once per fixed-point iteration usin...
virtual IterationUpdate computeUpdate(unsigned int it, Real p_used, Real y, Real y_target) override
Compute this iteration's update from the current sample: the 1-based fixed-point iteration it and the...
static InputParameters validParams()
const Real _initial_delta
Perturbation applied on the first iteration of each fixed-point solve to seed the secant method.
Real _y_prev
Previous iteration's output value (secant point); refreshed each fixed-point solve.
Real _p_prev
Previous iteration's parameter value (secant point); refreshed each fixed-point solve.
SecantInversionControl(const InputParameters &parameters)
One iteration's update, produced by the derived scheme and applied by execute().