Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
78 views

Exercise01 Classes Simple Textual

The document provides instructions for simple textual modeling exercises in Modelica, including: 1) Running and modifying the VanDerPol model in DrModelica 2) Creating a simple differential equation model in Modelica called HelloWorld, simulating and plotting it, and checking variable values at specific times 3) Creating a Modelica model to solve a system of equations with initial conditions 4) Defining a Modelica class that calculates the product of two parameter variables 5) Instantiating the Dog class by declaring variables and giving one instance the name "Tim"

Uploaded by

verbicar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Exercise01 Classes Simple Textual

The document provides instructions for simple textual modeling exercises in Modelica, including: 1) Running and modifying the VanDerPol model in DrModelica 2) Creating a simple differential equation model in Modelica called HelloWorld, simulating and plotting it, and checking variable values at specific times 3) Creating a Modelica model to solve a system of equations with initial conditions 4) Defining a Modelica class that calculates the product of two parameter variables 5) Instantiating the Dog class by declaring variables and giving one instance the name "Tim"

Uploaded by

verbicar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercises - Simple Textual

1 Simple Textual Modeling Exercises


1.1Try DrModelica with VanDerPol
Locate

the VanDerPol model in DrModelica (link from Section 2.1), run it, change it slightly, and re-run it.

1.2HelloWorld
Simulate and plot the following example with one differential equation and one initial condition. Do a slight change in the model, re-simulate and re-plot
model HelloWorld "A simple equation" Real x(start=1); equation der(x)= -x; end HelloWorld;

Push shift-tab for command completion, fill in the name HelloWorld, and simulate it!
simul

Push shift-tab for command completion, fill in a variable name (x), and plot it!
plo

Take a look at the intepolated value of the variable x at time=0.5 using the val(variableName,time) function:
val(x,0.5)

Also take a look at the value at time=0.0:


val(x,0.)

1.3A Simple Systems of Equations


Make a Modelica model that solves the equation system below with initial conditions. Hint: initial conditions are often specified using the start attribute.

model ...

1.4Creating a Class
Create a class, Multiply, that calculates the product of two parameter variables, which are equal to Real numbers with given values.

1.5Creating Instances
class Dog constant Real legs = 4; parameter String name = "Dummy"; end Dog;

Create an instance of the class Dog by declaring a variable. Create another dog instance and give this dog the name "Tim".

2 Creating a Function and Making a Function Call


Write a function, addTen, that returns the input number plus the Integer 10. Make a function call to addTen with the input 3.5. Also do that inside a class, and simulate the class.

You might also like