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 FunctionalModels.jl results to those online.
These are available in FunctionalModels.Examples.Tiller. Here is an example of use:
using FunctionalModels
m = FunctionalModels.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 FunctionalModels.jl. Because FunctionalModels.jl is functional, the approach is different than Modelica's object-oriented approach. The functional approach is generally cleaner.
FlatSystem
Main.Examples.Tiller.FlatSystem
— FunctionSensor comparison for a rotational example
http://mbe.modelica.university/components/architectures/sensor_comparison/
BasicPlant
Main.Examples.Tiller.BasicPlant
— FunctionBasic plant for the example
IdealSensor
Main.Examples.Tiller.IdealSensor
— FunctionIdeal sensor for angular velocity
SampleHoldSensor
Main.Examples.Tiller.SampleHoldSensor
— FunctionSample-and-hold velocity sensor
IdealActuator
Main.Examples.Tiller.IdealActuator
— FunctionIdeal actuator
LimitedActuator
Main.Examples.Tiller.LimitedActuator
— FunctionActuator with lag and saturation
ProportionalController
Main.Examples.Tiller.ProportionalController
— FunctionProportional controller
PIDController
Main.Examples.Tiller.PIDController
— FunctionPID controller
BaseSystem
Main.Examples.Tiller.BaseSystem
— FunctionBase 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
Main.Examples.Tiller.Variant1
— FunctionBaseSystem variant with sample-hold sensing
Variant2
Main.Examples.Tiller.Variant2
— FunctionBaseSystem variant with PID control along with a realistic actuator
Variant2a
Main.Examples.Tiller.Variant2a
— FunctionBaseSystem 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 Variable variables and Events.
The system is based on the following plant:
SecondOrderSystem
Main.Examples.Tiller.SecondOrderSystem
— FunctionRotational example
http://mbe.modelica.university/behavior/equations/mechanical/
SecondOrderSystemUsingFunctionalModelsLib
Main.Examples.Tiller.SecondOrderSystemUsingFunctionalModelsLib
— FunctionRotational example based on components in FunctionalModels.Lib
http://mbe.modelica.university/behavior/equations/mechanical/
SampleAndHold
Main.Examples.Tiller.SampleAndHold
— FunctionRotational example with sample-and-hold measurement
http://mbe.modelica.university/behavior/discrete/measuring/#sample-and-hold
IntervalMeasure
Main.Examples.Tiller.IntervalMeasure
— FunctionRotational example with interval measurements
http://mbe.modelica.university/behavior/discrete/measuring/#interval-measurement
PulseCounting
Main.Examples.Tiller.PulseCounting
— FunctionRotational example with pulse counting
http://mbe.modelica.university/behavior/discrete/measuring/#pulse-counting