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

Sensor comparison for a rotational example

http://book.xogeny.com/components/architectures/sensor_comparison/

diagram

source

BasicPlant

Basic plant for the example

source

IdealSensor

Ideal sensor for angular velocity

source

SampleHoldSensor

Sample-and-hold velocity sensor

source

IdealActuator

Ideal actuator

source

LimitedActuator

Actuator with lag and saturation

source

ProportionalController

Proportional controller

source

PIDController

PID controller

source

BaseSystem

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

BaseSystem variant with sample-hold sensing

source

Variant2

BaseSystem variant with PID control along with a realistic actuator

source

Variant2a

BaseSystem variant with a tuned PID control along with a realistic actuator

source

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:

diagram

SecondOrderSystem

Rotational example

http://book.xogeny.com/behavior/equations/mechanical/

source

SecondOrderSystemUsingSimsLib

Rotational example based on components in Sims.Lib

http://book.xogeny.com/behavior/equations/mechanical/

diagram

source

SampleAndHold

Rotational example with sample-and-hold measurement

http://book.xogeny.com/behavior/discrete/measuring/#sample-and-hold

source

IntervalMeasure

Rotational example with interval measurements

http://book.xogeny.com/behavior/discrete/measuring/#interval-measurement

source

PulseCounting

Rotational example with pulse counting

http://book.xogeny.com/behavior/discrete/measuring/#pulse-counting

source