Skip to content

Steady State Analysis

The SteadyStateAnalysis is used to give the solution of the model at steady state.

Method Overview

The Dyad compiler uses the physical description of the system to generate a system of differential-algebraic equations:

x=f(x,y,p,t)0=g(x,y,p,t)

where x are the differential variables, y are the algebraic variables, p are the parameters, and t is the independent variable (time). The steady state is defined as the value when the final time is taken to be infinity, i.e. (x(),y()). If the system is stable, non-oscillatory, and non-chaotic, then this is equivalent to point where x=0, or the values (x,y) s.t.

0=f(x,y,p,t)0=g(x,y,p,t)

Example Definition

For this example we will run a steady state analysis on the basic Hello World Newton's Law of Cooling Thermal model from the Getting Started tutorial:

dyad
# A simple lumped thermal model
component Hello
  # Ambient temperature
  parameter T_inf::Temperature = 300
  # Initial temperature
  parameter T0::Temperature = 320
  # Convective heat transfer coefficient
  parameter h::CoefficientOfHeatTransfer = 0.7
  # Surface area
  parameter A::Area = 1.0
  # Mass of thermal capacitance
  parameter m::Mass = 0.1
  # Specific Heat
  parameter c_p::SpecificHeatCapacity = 1.2
  variable T::Temperature
relations
  # Specify initial conditions
  initial T = T0
  # Newton's law of cooling/heating
  m*c_p*der(T) = h*A*(T_inf-T)
metadata {"Dyad": {"tests": {"case1": {"stop": 10, "expect": {"initial": {"T": 320}}}}}}
end

We can set a few run-specific parameters as follows:

dyad
analysis ThermalSteadyState
  extends DyadInterface.SteadyStateAnalysis(abstol=1e-8, reltol=1e-8)
  model = Hello(T_inf=T_inf, h=h)
  parameter T_inf::Temperature = 300
  parameter h::CoefficientOfHeatTransfer = 0.7
metadata {"Dyad": {"using": "DyadInterface: AbstractSteadyStateAnalysisSpec, SteadyStateAnalysisSpec, SteadyStateAnalysis"}}
end

Then in the Julia REPL, we can run the generated analysis via:

julia
result = ThermalSteadyState()
Steady State Analysis Solutiuon for SteadyStateAnalysis
retcode: Success
u: 1-element Vector{Float64}:
 299.99999999999994

We can get the steady state values by examining the SimulationSolutionTable artifact which gives us a Julia DataFrame of the solution values:

julia
using DyadInterface: artifacts
artifacts(result, :SimulationSolutionTable)
1×1 DataFrame
RowT(t)
Float64
1300.0

Analysis Arguments

The following arguments define a SteadyStateAnalysis:

Required Arguments

  • model: the Dyad model that the analysis is being applied to.

Optional Arguments

  • alg::String: chooses the solver algorithm for the solution process. The default is "auto". The choices are:

    • "auto" - uses the NonlinearSolve.jl automated polyalgorithm.
  • abstol::Real: chooses the absolute tolerance for the solver. Defaults to 1e-8.

  • reltol::Real: chooses the relative tolerance for the solver. Defaults to 1e-8.

Experimental Arguments

  • IfLifting::Boolean: sets the iflifting compiler pass in the ModelingToolkit code generation. Currently defaults to false, but will default to true after the feature is made non-experimental.

Artifacts

A SteadyStateAnalysis returns the following artifacts:

Customizable Plot

No customizable plot is given.

Standard Plots

  • SimulationSolutionTable: Returns a DataFrame of the solution values at the steady state.

Further Reading