Skip to content
Plant.md

Plant

Second-order linear system for testing control designs.

A linear dynamic system with second-order behavior that exhibits damped oscillations in response to inputs.

The system is described by the state-space representation:

x˙1=x2x˙2=x10.5x2+uy=0.5x1+x2

where states x1 and x2 represent position and velocity in a mechanical system analogy.

This component extends from SISO

Usage

Plant()

Connectors

  • u - This connector represents a real signal as an input to a component (RealInput)

  • y - This connector represents a real signal as an output from a component (RealOutput)

Variables

NameDescriptionUnits
x1First state variable (position in mechanical analogy)
x2Second state variable (velocity in mechanical analogy)

Behavior

dx1(t)dt=x2(t)dx2(t)dt=u(t)x1(t)0.5x2(t)y(t)=0.5x1(t)+x2(t)

Source

dyad
# Second-order linear system for testing control designs.
#
# A linear dynamic system with second-order behavior that exhibits damped oscillations in response to inputs.
#
# The system is described by the state-space representation:
#
# ```math
# \begin{align}
# \dot{x}_1 &= x_2 \\
# \dot{x}_2 &= -x_1 - 0.5x_2 + u \\
# y &= 0.5x_1 + x_2
# \end{align}
# ```
#
# where states `x1` and `x2` represent position and velocity in a mechanical system analogy.
component Plant
  extends SISO
  # First state variable (position in mechanical analogy)
  variable x1::Real
  # Second state variable (velocity in mechanical analogy)
  variable x2::Real
relations
  der(x1) = x2
  der(x2) = -x1-0.5*x2+u
  y = 0.5*x1+x2
end
Flattened Source
dyad
# Second-order linear system for testing control designs.
#
# A linear dynamic system with second-order behavior that exhibits damped oscillations in response to inputs.
#
# The system is described by the state-space representation:
#
# ```math
# \begin{align}
# \dot{x}_1 &= x_2 \\
# \dot{x}_2 &= -x_1 - 0.5x_2 + u \\
# y &= 0.5x_1 + x_2
# \end{align}
# ```
#
# where states `x1` and `x2` represent position and velocity in a mechanical system analogy.
component Plant
  # Input signal port
  u = RealInput() [{
    "Dyad": {
      "placement": {"icon": {"iconName": "input", "x1": -50, "y1": 450, "x2": 50, "y2": 550}}
    }
  }]
  # Output signal port
  y = RealOutput() [{
    "Dyad": {
      "placement": {"icon": {"iconName": "output", "x1": 950, "y1": 450, "x2": 1050, "y2": 550}}
    }
  }]
  # First state variable (position in mechanical analogy)
  variable x1::Real
  # Second state variable (velocity in mechanical analogy)
  variable x2::Real
relations
  der(x1) = x2
  der(x2) = -x1-0.5*x2+u
  y = 0.5*x1+x2
metadata {}
end


Test Cases

This is setup code, that must be run before each test case.

julia
using BlockComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames

snapshotsdir = joinpath(dirname(dirname(pathof(BlockComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/BlockComponents/77kIK/test/snapshots"