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

BasicPlant

IdealSensor

SampleHoldSensor

IdealActuator

LimitedActuator

ProportionalController

PIDController

BaseSystem

Main.Examples.Tiller.BaseSystemFunction

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));
source

Variant1

Variant2

Variant2a

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:

diagram

SecondOrderSystem

SecondOrderSystemUsingFunctionalModelsLib

SampleAndHold

IntervalMeasure

PulseCounting