---
url: /dyad/stable/analyses/steadystate.md
description: Learn how to find the steady state of a Dyad model.
---

# Steady State Analysis {#SteadyStateAnalysis}

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

## Method Overview {#Method-Overview}

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

$$\begin{align\*}
x' &= f(x,y,p,t)\\
0  &= g(x,y,p,t)
\end{align\*}$$

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(\infty), y(\infty))$. 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.

$$\begin{align\*}
0 &= f(x,y,p,t)\\
0 &= g(x,y,p,t)
\end{align\*}$$

## Example Definition {#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](/tutorials/getting-started#getting_started):

```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 SteadyStateAnalysis()
  model = Hello(T_inf=T_inf, h=h)
  parameter T_inf::Temperature = 300
  parameter h::CoefficientOfHeatTransfer = 0.7
end
```

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

```julia
result = ThermalSteadyState()
```

```ansi
Steady State Analysis Solution for ThermalSteadyState
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](https://dataframes.juliadata.org/stable/) of the solution values:

```julia
using DyadInterface: artifacts
artifacts(result, :SimulationSolutionTable)
```

## Analysis Arguments {#Analysis-Arguments}

The following arguments define a SteadyStateAnalysis:

#### Required Arguments {#Required-Arguments}

* `model`: the Dyad model that the analysis is being applied to.

#### Optional Arguments {#Optional-Arguments}

* `alg::String`: chooses the solver algorithm for the solution process. The default is `"auto"`. The choices are:
  * `"auto"` - uses the [NonlinearSolve.jl](https://docs.sciml.ai/NonlinearSolve/stable/) automated polyalgorithm.

  * `"TrustRegion"` - Trust region method from [NonlinearSolve.jl](https://docs.sciml.ai/NonlinearSolve/stable/).

  * `"LevenbergMarquardt"` - Levenberg-Marquardt method from [NonlinearSolve.jl](https://docs.sciml.ai/NonlinearSolve/stable/).

  * `"NewtonRaphson"` - Newton-Raphson method from [NonlinearSolve.jl](https://docs.sciml.ai/NonlinearSolve/stable/).

* `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`.

* `specialization::SpecializationLevel`: defaults to `SpecializationLevel.Despecialize()`. See [Specialization](/analyses/transient#analysis-specialization) for choices and benchmarking guidance. The current steady-state solver accepts the setting but retains ordinary specialization, so `Despecialize()` provides no compilation-latency benefit on this path.

#### Experimental Arguments {#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 {#Artifacts}

A SteadyStateAnalysis returns the following artifacts:

#### Customizable Plot {#Customizable-Plot}

No customizable plot is given.

#### Tables {#Tables}

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

* `:ObservablesTable`: Returns a DataFrame of all observable values evaluated at the steady state.

#### Julia-Side Artifacts {#Julia-Side-Artifacts}

* `:RawSolution`: Returns the NonlinearSolve.jl solution type from the run.

* `:SimplifiedSystem`: Returns the ModelingToolkit.jl model after structural simplification was performed.

* `:InitialSystem`: Returns the initial ModelingToolkit.jl model that was passed to the analysis.

## Further Reading {#Further-Reading}

* [NonlinearSolve.jl's Documentation](https://docs.sciml.ai/NonlinearSolve/stable/)

* [NonlinearSolve.jl: High-Performance and Robust Solvers for Systems of Nonlinear Equations in Julia](https://arxiv.org/abs/2403.16341)

* [ModelingToolkit's Nonlinear System Tutorial](https://docs.sciml.ai/ModelingToolkit/stable/tutorials/nonlinear/)
