SpECTRE  v2024.02.05
TimescaleTuner< AllowDecrease > Class Template Reference

Manages control system timescales. More...

#include <TimescaleTuner.hpp>

Classes

struct  DecreaseFactor
 
struct  DecreaseThreshold
 
struct  IncreaseFactor
 
struct  IncreaseThreshold
 
struct  InitialTimescales
 
struct  MaxTimescale
 
struct  MinTimescale
 

Public Types

using options = tmpl::append< tmpl::list< InitialTimescales, MaxTimescale, MinTimescale, IncreaseThreshold, IncreaseFactor >, tmpl::conditional_t< AllowDecrease, tmpl::list< DecreaseThreshold, DecreaseFactor >, tmpl::list<> > >
 

Public Member Functions

 TimescaleTuner (const typename InitialTimescales::type &initial_timescale, double max_timescale, double min_timescale, double increase_timescale_threshold, double increase_factor, double decrease_timescale_threshold=std::numeric_limits< double >::max(), double decrease_factor=1.0)
 
 TimescaleTuner (TimescaleTuner &&)=default
 
TimescaleTuneroperator= (TimescaleTuner &&)=default
 
 TimescaleTuner (const TimescaleTuner &)=default
 
TimescaleTuneroperator= (const TimescaleTuner &)=default
 
const DataVectorcurrent_timescale () const
 Returns the current timescale for each component of a FunctionOfTime.
 
void set_timescale_if_in_allowable_range (double suggested_timescale)
 Manually sets all timescales to a specified value, unless the value is outside of the specified minimum and maximum timescale bounds, in which case it is set to the nearest bounded value.
 
void update_timescale (const std::array< DataVector, 2 > &q_and_dtq)
 The update function responsible for modifying the timescale based on the control system errors.
 
bool timescales_have_been_set () const
 Return whether the timescales have been set.
 
void resize_timescales (size_t num_timescales, const std::optional< double > &fill_value=std::nullopt)
 Destructively resize the DataVector of timescales. All previous timescale information will be lost. More...
 
void pup (PUP::er &p)
 

Static Public Attributes

static constexpr Options::String help
 

Friends

template<bool LocalAllowDecrease>
bool operator== (const TimescaleTuner< LocalAllowDecrease > &lhs, const TimescaleTuner< LocalAllowDecrease > &rhs)
 

Detailed Description

template<bool AllowDecrease>
class TimescaleTuner< AllowDecrease >

Manages control system timescales.

The TimescaleTuner adjusts the damping timescale, \(\tau\), of the control system.
The damping timescale is restricted to min_timescale \(\le\tau\le\)max_timescale

The damping time is adjusted according to the following criteria:

Decrease the timescale by a factor of decrease_factor if either

  • the error is too large: \(|Q| >\) decrease_timescale_threshold OR the error is changing quickly: \(|\dot{Q}|\tau >\) decrease_timescale_threshold,
    AND
  • the error is growing: \(\dot{Q}Q > 0\) OR the expected change in \(Q\) is less than half its current value: \(|\dot{Q}|\tau < |Q|/2\)

Increase the timescale by a factor of increase_factor if

  • the error is sufficiently small: \(|Q|<\) increase_timescale_threshold
    AND
  • the expected change in \(Q\) is less than the threshold: \(|\dot{Q}|\tau < \) increase_timescale_threshold

If the template bool AllowDecrease is false, then the check for decreasing the timescale will be ignored. This can be used if something else will be controlling the decrease of the timescale.

Member Function Documentation

◆ resize_timescales()

template<bool AllowDecrease>
void TimescaleTuner< AllowDecrease >::resize_timescales ( size_t  num_timescales,
const std::optional< double > &  fill_value = std::nullopt 
)

Destructively resize the DataVector of timescales. All previous timescale information will be lost.

Parameters
num_timescalesNumber of components to resize to. Can be larger or smaller than the previous size. Must be greater than 0.
fill_valueOptional of what value to use to fill the new timescales. std::nullopt signifies to use the minimum of the initial timescales. Default is std::nullopt.

Member Data Documentation

◆ help

template<bool AllowDecrease>
constexpr Options::String TimescaleTuner< AllowDecrease >::help
staticconstexpr
Initial value:
{
"TimescaleTuner: stores and dynamically updates the timescales for each "
"component of a particular control system."}

The documentation for this class was generated from the following files: