teaching modelica for mathematicians and engineers · • analysis and linear algebra topics •...

23
Teaching Modelica for Mathematicians and Engineers Bernhard Bachmann University of Applied Sciences Bielefeld Modelica Educational Workshop Berlin

Upload: others

Post on 07-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

Teaching Modelica forMathematicians and Engineers

Bernhard BachmannUniversity of Applied Sciences

Bielefeld

Modelica Educational WorkshopBerlin

Page 2: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

2B. Bachmann, FH Bielefeld

Outline

Past Teaching Experience– Mathematicians

• precognition, course objectives

– Course Details• theoretical content, tools, exercises

0.0 2.5 5.0 7.5 10.0

-0.3

-0.2

-0.1

0.0

0.1

0.2

0.3

0.4

[A]

I1.i I2.i I3.i

0.0 2.5 5.0 7.5 10.0-0.3

-0.2

-0.1

0.0

0.1

0.2

0.3

[A]

I1.i I2.i I3.i

Discussion on Future Teaching Options– Mathematicians and Engineers

• master students having less mathematical background

– Tools and concepts• adaptation of previous course

Page 3: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

3B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)Course attendees (diploma-study in mathematics) [ca. 15]

– good mathematical background• analysis and linear algebra topics• optimization (linear, nonlinear problems)• numerical methods (no ODEs)• theory on ordinary differential equations• familiar tools:Maple, Matlab (no Simulink) • basic programming knowledge (C/C++)

– basic engineering background• simple mathematical modeling of physical components

mechanics, electrical systems (static)

Course objectives– engineering aspects

• component and library development in Modelica – mathematical aspects

• understand symbolic transformations and numerical issues

Page 4: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

4B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)

Course details– 4 semester periods per week (13 weeks)

• theory and practical exercises– learning by doing (small projects)– tools

• Matlab-Simulink (1st project)• Dymola (Modelica projects)

– exam• practical

projects (development and explanation)• theory

mathematical and modeling aspects

Page 5: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

5B. Bachmann, FH Bielefeld

i

i1

i2

uu1

u2

u3

u4

Past Teaching (1999 – 2008)

1st course:Basic understanding of the principlesusing a simple electrical system– modeling

• develop the DAE representationabstract mathematical view

• understand numerical integration (Euler method)• sort the equation system (find causality)

– simulation and implementation• using Matlab• using Simulink• using Dymola (flat representation)

42

12

223111

21

4321

,

, ,

,) 2sin(

udtdiLi

dtduC

iRuiRuiii

uuuuuutfAu

==

==+=

+=+=+⋅= ϕπ

Page 6: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

6B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)

1st course project– basic understanding of the principles

using a simple mechanical system– modeling

• develop the DAE representation• understand numerical integration (Euler method)• sort the equation system (find causality)

– simulation and implementation• using Matlab• using Simulink• using Dymola

input: u(t)z.B. sin(t)

c

J1 J2c

1 2 3 4

ϕ1, τ1 ϕ1, τ2 ϕ2, τ3 ϕ2, τ4= 0

322

2232

122

2111

111

,0)(

,

τωϕωττ

ϕϕτττωϕωτ

=⋅=+=

−⋅=+=⋅==

J

cJ

u

Page 7: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

7B. Bachmann, FH Bielefeld

i

i1

i2

uu1

u2

u3

u4

Past Teaching (1999 – 2008)

2nd course:Benefit of using ModelicaGetting started with Dymola– examples from 1st course continued– modeling

• drag and drop• library structure• find components

– simulation• compile model• experiment setup• view and compare results

input: u(t)z.B. sin(t)

c

J1 J2c

1 2 3 4

ϕ1, τ1 ϕ1, τ2 ϕ2, τ3 ϕ2, τ4= 0

Page 8: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

8B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)

2nd course project– build up and simulate different physical systems

• examples from 1st course• drive train• triple pendulum• …

height = 200

Page 9: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

9B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)

3rd course:Getting started with Modelica– flat Modelica

• basic keywordsmodel, parameter, equation, basic types, der, …

• type attributesmin, max, units, …

• type classeslibrary SIunits

– hierarchical Modelica• model and connector classes• connect statement

basic principles of flow and potential variables

Page 10: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

10B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)

3rd course project– implement and simulate a Pendulum model

• flat representationusing predifined types (SIunits)

• hierarchical representation (using Multibody library)animation

• build up a simple controller to adjust the angle

τϕϕϕ +⋅−⋅⋅⋅−=⋅ dLgmJ )cos(

Page 11: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

11B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)

4th course:Introduction to basic control techniques– examples

• with/without feedback– Laplace-transformation– different mathematical formulations

• functional description• block diagram• Step function response

– standard controller• P-, D-, I-, PD-, PI-, PID-controller

4th course project– example from 3rd course continued– try different controller and compare results

Page 12: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

12B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)

5th course:Build Libraries in Modelica– package concept

• example using simple electrical component– modifier concept – build libraries in Dymola

• icon layer, diagram layer• coordinate system• connector view• parameter settings

5th course project– build up a library

• motor (including control scheme)• gear box (including friction elements)

– adjust control parameter for suitable test cases

Page 13: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

13B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)

6th course:Build Libraries in Modelica– general connection concept

• energy flow, domain specificpotential and flow variables

• discuss practical issues (rotational)– multidisciplinary modeling– parameter propagation

• modifications • GUI in Dymola

6th course project– continue 5th course project

Page 14: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

14B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)

7th course:Advanced Modelica– class types

• type, model, block, function,package, connector

– algorithm versus equations– additional keywords

• input, output, protected– matrices

• definition, element access, operations, inline functions – example of general transfer function

7th course project– still continue 5th course project

uab

abab

abab

abab

ababy

uaa

aaa

aa

aa

⋅+⋅⎥⎦

⎤⎢⎣

⎡−−−−=

⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢

+⋅

⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢

⎡ −−−−

=

1

1

1

155

1

144

1

133

1

122

11

5

1

4

1

3

1

2

000

1

010000100001

x

xx

Page 15: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

15B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)

8th course:Symbolic transformation algorithm– mathematical DAE representation– regular (index 1) problems– matching algorithm – sorting (Tarjan algorithm)– BLT representation of

adjacence matrix

8th course project– implement the BLT algorithm

for random matrices

f1

f3

f2

f4

f5

z1

z3

z2

z4

z5

Page 16: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

16B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)

9th course:Higher Index problems– examples (mechanical, electrical)

• mathematical DAE representation• definition of the structural

and differential index– detect singular set of equations

• Pantelides algorithm – dummy derivative method– state selection mechanism– initialization of models

9th course project– continue 8th course project

f1

f3

f2

f4

f5

z1

z3

z2

z4

z5

Page 17: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

17B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)

10th course:Advanced Modelica– arrays of component

• for-loop, variable numberof connect statements

– example• transmission line model

– introduce basic heat flow library10th course project– simulate the temperature distribution of an isolated bar

R=R

R1

C=C

C1

ground

R=R

R2

C=C

C2

R=R

R3C

=C

C3

R=R

R4

p n

n=3

C[1] C[2] C[3]

R0 R[1] R[2] Rn

Page 18: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

18B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)11th course:Model discontinuities – Modelica Standard library

• digital controller• electrical switch or diode (not ideal)• clutch and brake model

– Modelica language elements• if-then-else, when, noEvent,

smooth, reinit, pre, …– symbolic transformation

• synchronous equation

11th course project– implement examples

• hysteresis function• pulse width modulation block

i3

u1i1

i2

u2u0

Page 19: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

19B. Bachmann, FH Bielefeld

0.0 0.2 0.4 0.6 0.8 1.0-1.0

-0.8

-0.6

-0.4

-0.2

0.0

0.2

0.4

0.6

0.8

1.0

1.2Sw itch.v [V] Sw itch.i [A]

Past Teaching (1999 – 2008)12th course:Model Discontinuities – numerical issues

• stiffness (“not ideal” switch) • time versus state events• rounding errors• event iterations

12th course project– implement further examples

• bouncing ball• …

i3

u1i1

i2

u2u0

Page 20: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

20B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)12th course:Model Discontinuities – numerical issues

• stiffness (“not ideal” switch) • time versus state events• rounding errors• event iterations

12th course project– implement further examples

• bouncing ball• …

0.0 0.4 0.8 1.2 1.6 2.0 2.4 2.8-1.0

-0.8

-0.6

-0.4

-0.2

0.0

0.2

0.4

0.6

0.8

1.0

1.2h

h

g

Page 21: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

21B. Bachmann, FH Bielefeld

0.00 0.25 0.50 0.75 1.00

-0.24

-0.20

-0.16

-0.12

-0.08

-0.04

0.00

0.04

0.08

i u2

Past Teaching (1999 – 2008)13th course:Model Discontinuities – varying higher index problems– examples

• mechanical, electrical– symbolic transformation

• analyse singularity• dummy derivative method

13th course project– run and analyse examples

• introduce dummyderivative terms in branches

u2

u0

i u1

Page 22: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

22B. Bachmann, FH Bielefeld

Past Teaching (1999 – 2008)13th course:Model Discontinuities – varying higher index problems– examples

• mechanical, electrical– symbolic transformation

• analyse singularity• dummy derivative method

13th course project– run and analyse examples

• introduce dummyderivative terms in branches

u2

u0

i u1

0.0 0.5 1.0 1.5 2.0-1.2

-0.8

-0.4

0.0

0.4

0.8

1.2i u2

Page 23: Teaching Modelica for Mathematicians and Engineers · • analysis and linear algebra topics • optimization (linear, nonlinear problems) • numerical methods ... min, max, units,

2009-04-02 Teaching Modelica for Mathematicians and Engineers

23B. Bachmann, FH Bielefeld

Discussion on Future Teaching Options

Course attendees– master-study in „Optimization and Simulation“– mathematicians and engineers

• mechanical, electrical, mechatronics,…– heterogeneous background in mathematics and engineering

Course objectives– engineering aspects

• component and library development in Modelica – mathematical aspects

• understand symbolic transformations and numerical issues

Tools– licencing issues

• OpenModelica (SimForge), Dymola, MapleSim, MathModelica

Applications / Projects