Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1914 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Håkan Lundvall
committed
Oct 6, 2005
1 parent
5ae2eff
commit 62b192b
Showing
9 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
model BouncingBall | ||
parameter Real e=0.7 "coefficient of restitution"; | ||
parameter Real g=9.81 "gravity acceleration"; | ||
Real h(start=1) "height of ball"; | ||
Real v "velocity of ball"; | ||
Boolean flying(start=true) "true, if ball is flying"; | ||
Boolean impact; | ||
Real v_new; | ||
equation | ||
impact = h <= 0.0; | ||
der(v) = if flying then -g else 0; | ||
der(h) = v; | ||
|
||
when {h <= 0.0 and v <= 0.0,impact} then | ||
v_new = if edge(impact) then -e*pre(v) else 0; | ||
flying = v_new > 0; | ||
reinit(v, v_new); | ||
end when; | ||
|
||
end BouncingBall; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Circle model | ||
|
||
model Circle | ||
Real x_out; | ||
Real y_out; | ||
Real x(start=0.1); | ||
Real y(start=0.1); | ||
equation | ||
der(x) = y; | ||
der(y) = x; | ||
x_out = x; | ||
y_out = y; | ||
end Circle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// A simple integrator example. | ||
// | ||
|
||
model SimpleIntegrator | ||
Real u = 1.0; | ||
Real x(start = 2.0); | ||
equation | ||
der(x) = u; | ||
end SimpleIntegrator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Van der Pol model | ||
|
||
model VanDerPol "Van der Pol oscillator model" | ||
Real x(start = 1); | ||
Real y(start = 1); | ||
parameter Real lambda = 0.3; | ||
equation | ||
der(x) = y; | ||
der(y) = - x + lambda*(1 - x*x)*y; | ||
end VanDerPol; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function bubblesort | ||
input Real[:] x; | ||
output Real[size(x,1)] y; | ||
protected | ||
Real t; | ||
algorithm | ||
|
||
y := x; | ||
|
||
for i in 1:size(x,1) loop | ||
for j in 1:size(x,1) loop | ||
|
||
if y[i] > y[j] then | ||
t := y[i]; | ||
y[i] := y[j]; | ||
y[j] := t; | ||
end if; | ||
end for; | ||
end for; | ||
|
||
end bubblesort; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
model dcmotor | ||
Modelica.Electrical.Analog.Basic.Resistor r1(R=10); | ||
Modelica.Electrical.Analog.Basic.Inductor i1; | ||
Modelica.Electrical.Analog.Basic.EMF emf1; | ||
Modelica.Mechanics.Rotational.Inertia load; | ||
Modelica.Electrical.Analog.Basic.Ground g; | ||
Modelica.Electrical.Analog.Sources.ConstantVoltage v; | ||
equation | ||
connect(v.p, r1.p); | ||
connect(v.n, g.p); | ||
connect(r1.n, i1.p); | ||
connect(i1.n, emf1.p); | ||
connect(emf1.n, g.p); | ||
connect(emf1.flange_b, load.flange_a); | ||
end dcmotor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
loadFile("BouncingBall.mo"); | ||
simulate(BouncingBall, stopTime=3.0); | ||
plot({h,flying}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
loadModel(Modelica); | ||
loadFile("dcmotor.mo"); | ||
simulate(dcmotor,startTime=0.0,stopTime=10.0); | ||
plot({load.w,load.phi}); |