22.07.2013 Views

Advanced Modelica Tutorial Exercises Refine MultiBody/Engine

Advanced Modelica Tutorial Exercises Refine MultiBody/Engine

Advanced Modelica Tutorial Exercises Refine MultiBody/Engine

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong><br />

<strong>Exercises</strong><br />

Hilding Elmqvist, Dynasim<br />

Martin Otter, DLR<br />

<strong>Refine</strong> <strong>MultiBody</strong>/<strong>Engine</strong><br />

Make <strong>Engine</strong> example model a reusable<br />

component<br />

1. Manage parameters<br />

2. Allow changing number of cylinders<br />

3. Test rig with replaceable engine<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 2


Use Cylinder from Library <strong>MultiBody</strong><br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 3<br />

Package structuring<br />

First create package Then create models, etc within the package<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 4


Task 1. Handling of parameters<br />

• Now – multiple select<br />

Dependent on<br />

experiment<br />

Common to all<br />

cylinders<br />

Specific for each<br />

cylinder<br />

OK as default<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 5<br />

Parameter record<br />

• Introduce parameter record for common<br />

parameters<br />

– Record gives possible reuse of data in<br />

different engine configurations<br />

– Propagate record elements to individual<br />

parameters<br />

– Introduce tabs and groups<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 6


Create record<br />

cylinderParameters and<br />

insert parameters.<br />

Context<br />

menu<br />

To build record in the GUI<br />

Drag and drop<br />

Change of setting needed<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 7<br />

(after paste)<br />

Copy and paste alternative<br />

Delete this line<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 8


Create model<br />

MyCylinder and insert<br />

a cylinder from the<br />

<strong>MultiBody</strong> library and<br />

a parameter record.<br />

Create MyCylinder<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 9<br />

Propagate each<br />

parameter in the<br />

record to the<br />

corresponding<br />

parameter of the<br />

<strong>MultiBody</strong><br />

cylinder. Point to<br />

the input field<br />

and click the<br />

right mouse<br />

button and<br />

create<br />

”Component<br />

reference”.<br />

Propagate parameters<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 10


Add remaining 3<br />

parameters.<br />

Add remaining parameters<br />

Test MyCylinder by<br />

creating a component in<br />

Unnamed and double<br />

clicking it.<br />

Hierarchical dialogs<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 11<br />

Introduce tabs and groups<br />

Resulting dialog with tabs and groups<br />

Improve dialog by<br />

introducing tabs and<br />

groups.<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 12


Propagate connectors by<br />

drawing connections. At<br />

end point, click right<br />

mouse button and select<br />

”Create connector”<br />

Propagate connectors<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 13<br />

Resulting <strong>Modelica</strong> code<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 14


Introduce<br />

World object<br />

and Revolute<br />

joint<br />

Make My<strong>Engine</strong><br />

• Axis of rotation for Revolute joint is x-axis<br />

• Set initial angular velocity to 1 deg/s<br />

• Simulate for 0.1 second<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 15<br />

Declare a<br />

parameter set<br />

by extending<br />

the parameter<br />

record.<br />

Declare parameter set<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 16


Make parameter set<br />

Give values to the parameter<br />

set by using the Parameter<br />

command of the extended<br />

class.<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 17<br />

Use parameter set<br />

Instead of using the<br />

hierarchical parameter dialog,<br />

use the Select Record<br />

command to create a record<br />

constructor referring to the<br />

predefined parameter set.<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 18


Resulting <strong>Modelica</strong> Code<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 19<br />

Task 2. Array of cylinders<br />

• Make array of cylinders<br />

• Propagate parameter record to each<br />

cylinder<br />

• Introduce arrays of individual angles<br />

• Use for loop to connect them<br />

Duplicate My<strong>Engine</strong>. Call it<br />

My<strong>Engine</strong>N. It will contain n<br />

cylinders.<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 20


MyCylinder parameter dialog<br />

My<strong>Engine</strong>N parameters:<br />

For My<strong>Engine</strong>N introduce a<br />

parameter record, n and the<br />

angle vectors.<br />

Introduce an array of<br />

cylinders [n] and propagate<br />

the parameters. Use the each<br />

keyword to the cylinder<br />

parameters since all the<br />

cylinders have the same set.<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 21<br />

Cylinder array connections<br />

Use <strong>Modelica</strong> Text mode to<br />

generate a for statement and<br />

make the connections.<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 22


Use the GUI to define a V6<br />

engine.<br />

Define V6 engine<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 23<br />

Task 3. Make engine test rig<br />

• For structurally different engines<br />

(with the same interface)<br />

• Easy to replace engines<br />

• Common engine property – one rotational<br />

flange<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 24


Make a partial model<br />

<strong>Engine</strong>Base with just a<br />

rotational flange.<br />

Introduce engine base<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 25<br />

Complement My<strong>Engine</strong> and<br />

My<strong>Engine</strong>N<br />

Drag base engine model to My<strong>Engine</strong><br />

Add the base engine with the<br />

rotational flange to My<strong>Engine</strong><br />

and My<strong>Engine</strong>N and connect<br />

the flange to the Revolute<br />

joint.<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 26


<strong>Modelica</strong> Text<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 27<br />

Use replaceable class<br />

Make test rig model. Make a<br />

replaceable component from<br />

<strong>Engine</strong>Base. Add a load<br />

inertia.<br />

Can be<br />

changed<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 28


Mount a V6 in the rig<br />

Create a V6 test rig. Use<br />

the Select Class<br />

command to replace the<br />

engine base by a V6.<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 29<br />

Task 3b. Use of class parameter<br />

Drag default engine class<br />

Create a class parameter<br />

My<strong>Engine</strong>Choise based<br />

on <strong>Engine</strong>Base.<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 30


Class parameter component<br />

Drag from class parameter<br />

Create an engine<br />

component based on the<br />

engine base.<br />

Can be<br />

changed<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 31<br />

Mount a V6 in the rig 2<br />

Create a new V6 test rig.<br />

Use the Select Class<br />

command to replace the<br />

engine base by a V6.<br />

<strong>Advanced</strong> <strong>Modelica</strong> <strong>Tutorial</strong> - <strong>Exercises</strong>, <strong>Modelica</strong>'2003, Nov. 3-4, 2003 32

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!