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:
where
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:
# 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}}}}}}
endWe can set a few run-specific parameters as follows:
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"}}
endThen in the Julia REPL, we can run the generated analysis via:
result = ThermalSteadyState()Steady State Analysis Solution for SteadyStateAnalysis
retcode: Success
u: 1-element Vector{Float64}:
299.99999999999994We can get the steady state values by examining the SimulationSolutionTable artifact which gives us a Julia DataFrame of the solution values:
using DyadInterface: artifacts
artifacts(result, :SimulationSolutionTable)| Row | T(t) |
|---|---|
| Float64 | |
| 1 | 300.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 to1e-8.reltol::Real: chooses the relative tolerance for the solver. Defaults to1e-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.