Tiller examples
From Modelica by Example
These examples are from the online book Modelica by Example by Michael M. Tiller. Michael explains modeling and simulations very well, and it's easy to compare Sims.jl results to those online.
These are available in Sims.Examples.Tiller. Here is an example of use:
using Sims
m = Sims.Examples.Tiller.SecondOrderSystem()
y = dasslsim(m, tstop = 5.0)
plot(y)
Architectures
These examples from the following sections from the Architectures chapter:
In Modelica by Example, Tiller shows how components can be connected together in a reusable fashion. This is also possible in Sims.jl. Because Sims.jl is functional, the approach is different than Modelica's object-oriented approach. The functional approach is generally cleaner.
FlatSystem
Sims.Examples.Tiller.FlatSystem
— Function.Sensor comparison for a rotational example
http://book.xogeny.com/components/architectures/sensor_comparison/
BasicPlant
Sims.Examples.Tiller.BasicPlant
— Function.Basic plant for the example
IdealSensor
Sims.Examples.Tiller.IdealSensor
— Function.Ideal sensor for angular velocity
SampleHoldSensor
Sims.Examples.Tiller.SampleHoldSensor
— Function.Sample-and-hold velocity sensor
IdealActuator
Sims.Examples.Tiller.IdealActuator
— Function.Ideal actuator
LimitedActuator
Sims.Examples.Tiller.LimitedActuator
— Function.Actuator with lag and saturation
ProportionalController
Sims.Examples.Tiller.ProportionalController
— Function.Proportional controller
PIDController
Sims.Examples.Tiller.PIDController
— Function.PID controller
BaseSystem
Sims.Examples.Tiller.BaseSystem
— Function.Base system with replaceable components
This is the same example as FlatSystem, but Plant
, Sensor
, Actuator
, and Controller
can all be changed by passing in optional keyword arguments.
Here is an example where several components are modified. The replacement components like SampleHoldSensor
are based on closures (functions that return functions).
Variant2 = BaseSystem(Sensor = SampleHoldSensor(sampletime = 0.01),
Controller = PIDController(yMax=15, Td=0.1, k=20, Ti=0.1),
Actuator = LimitedActuator(delayTime=0.005, uMax=10));
Variant1
Sims.Examples.Tiller.Variant1
— Function.BaseSystem variant with sample-hold sensing
Variant2
Sims.Examples.Tiller.Variant2
— Function.BaseSystem variant with PID control along with a realistic actuator
Variant2a
Sims.Examples.Tiller.Variant2a
— Function.BaseSystem variant with a tuned PID control along with a realistic actuator
Examples of speed measurement
These examples show several ways of measuring speed on a rotational system. They are based on Michael's section on Speed Measurement. These examples include use of Discrete variables and Events.
The system is based on the following plant:
SecondOrderSystem
Sims.Examples.Tiller.SecondOrderSystem
— Function.Rotational example
http://book.xogeny.com/behavior/equations/mechanical/
SecondOrderSystemUsingSimsLib
Rotational example based on components in Sims.Lib
http://book.xogeny.com/behavior/equations/mechanical/
SampleAndHold
Sims.Examples.Tiller.SampleAndHold
— Function.Rotational example with sample-and-hold measurement
http://book.xogeny.com/behavior/discrete/measuring/#sample-and-hold
IntervalMeasure
Sims.Examples.Tiller.IntervalMeasure
— Function.Rotational example with interval measurements
http://book.xogeny.com/behavior/discrete/measuring/#interval-measurement
PulseCounting
Sims.Examples.Tiller.PulseCounting
— Function.Rotational example with pulse counting
http://book.xogeny.com/behavior/discrete/measuring/#pulse-counting