Bring Your Engineering Course Alive with SystemModeler

Johan Rhodin, Wolfram Research

Join the Conversation #WolframTechConf

Introduction

Why

Students can process (much) more materials with SystemModeler than with traditional hand calculations.

Improves intuition & builds confidence.

SystemModeler is multi-domain, meaning a student can use it not only for mechanical simulations, electrical simulations, etc, but also combine these and many more areas.

Models constructed in SystemModeler have an acausal structure.

Easy to see real world resemblance

Helps ease transition from Academia to Industry.

Strong industry demand for modeling and simulation engineers, over a broad range of industrial domains.

Strong integration with the Wolfram Language.

Easy to evaluate performance measures of different designs

Fast access to transform theory, control theory, signal processing, plotting, and post processing of many kinds.

Where

Where is SystemModeler Applicable?

Most major engineering branches:

Electrical Engineering

Mechanical Engineering

Aerospace Engineering

Chemical & Process Engineering

Bioengineering

Industrial Engineering

Agricultural Engineering

Controls Engineering

Examples in this presentation

Example 1–OpAmp & Filter

Example 2–Mass and Spring

Example 3–Magnus Effect

Example 4–Control Systems & Robotics

Example 1–OpAmp & Filter, Virtual Lab

WSMModelData["WSMEducation.Examples.NonInvertingAmplifier"]

Remember that each component defined by equation, such as Ohm’s law: V=R I, etc.

Let’s build this circuit!

\[WolframLanguageLogoCircle]Document Model Use

Simulate the circuit

simAmplifier=WSMSimulate[]

Plot the results:

WSMPlot[simAmplifier,{"out.v","idealOpAmp3Pin.in_p.v"}]

Sample data:

data=Table[simAmplifier[{"out.v"},t][[1]],{t,0,10,0.01}];

Find peaks:

peaks=FindPeaks[data]

ListLinePlot[
data, 
Epilog-> {Red,PointSize[0.02],Point[peaks]}
]

Real-Time Lab

conn=WSMRealTimeSimulate["WSMEducation.Examples.AmplifierTest",200]

Set up a control signal:

AngularGauge[Dynamic[cR],{1,10}]

Set the input to the model:

WSMLink`Simulate`SetInputs[conn,"R"->(cR&)]

WSMRealTimePlot[conn,{"signalVoltage.v","out.v","R"},10]

Add Complexity–Saturation

conn=WSMRealTimeSimulate["WSMEducation.Examples.AmplifierTest",200]

AngularGauge[Dynamic[cR],{1,10}]

WSMLink`Simulate`SetInputs[conn,"R"->(cR&)]

WSMRealTimePlot[conn,{"signalVoltage.v","out.v","R"},10]

\[WolframLanguageLogoCircle]Linearize

ssm=WSMLinearize["WSMEducation.Examples.LowpassFilter",Method->{"SymbolicDerivative","SymbolicParameters"->{"R1","R2","C1","C2","f1"}}]

Main points of this example

it's easy to construct models

easy to change models

easy to add complexity and interact with models

Example 2–Mass, Spring, Damper... and more!

Let’s say we want to model this system:

Traditional approach

Set up equations, use laws & theorems to derive differential equations, ...

SystemModeler Approach

Encapsulate knowledge in components, let the student compose/use the system

Button[,WSMModelCenter["WSMEducation.Examples.MassSpringDamper"],Appearance->"Frameless"]

Start from small system, make it bigger.

Main points of this example

it's easy to construct models

easy to add complexity and interact with models

Example 3–Control Systems & Robotics

WSMModelData["SimplePendulum.Components.Plant"]

Find a linearized version of this plant model:

linearizedModel=WSMLinearize["SimplePendulum.Components.Plant"]

Write it as a transfer function:

tf=TransferFunctionModel@linearizedModel

Get a transfer function for a PID controller:

pidTf=TransferFunctionModel[kp (1+1/(τi \[FormalS])+τd \[FormalS]),\[FormalS]]

Connect the controller and the plant:

cltf=SystemsModelFeedbackConnect[SystemsModelSeriesConnect[pidTf,tf]]

Use built in control theory to pick suitable values for P, I & D:

{pars,parVals}={{"PID.k","PID.Ti","PID.Td"},{108,0.85,0.06}};

Simulate with these values:

sim=WSMSimulate["SimplePendulum.SimpleExample",{0,10},WSMParameterValues->Join[Thread[pars->parVals],{"PID.yMax"->100,"PID.wd"->1}]];

Plot the result

Plot[{Evaluate@sim[{"plant1.y"},t][[1]],π/2},{t,0,2},GridLines->Automatic,PlotRange->{-1,2}]

Watch the animation

Button["Simulation Center",WSMSimulationCenter["SimplePendulum.SimpleExample"]]

Main points of this example

Models have more than one use: model to understand, use model to design controller

Wolfram Language integration brings full suite of capabilities for optimization, control theory, signal processing, etc.

Example 4–Magnus Effect

300 Corner Kicks at Once

Run 300 simulations of a corner kick.

Main points of this example

Models can be connected to user input.

Models can be fun to interact with!

Wolfram Language integration brings full suite of capabilities for optimization, control theory, signal processing, etc.

Resources for Educators

Modelica by Example book, integrated into SystemModeler.

ModelPlug, free library for connecting Arduino boards to SystemModeler

Available from wolfram.com/system-modeler

More than 50 examples on the SystemModeler website

Big upgrade is coming to the website with exercises and lesson suggestions

Free training videos

Paid courses WSM101, WSM201

Wolfram Community group for SystemModeler

Documentation Center has a very useful feature: “Used in Examples” [Demo]

Thanks for listening!

Questions?

johanr@wolfram.com

Extra Points

Why SystemModeler + Mathematica in the classroom

Easy to document models.

Helps remembering what you did last semester/year/course.

Students can keep models throughout the whole education, from Year 1 to graduation.

Initialization

Needs["WSMLink`"]

Import[NotebookDirectory[]<>"WSMEducation.mo",{"ModelicaModel"}]