Skip to content

Commit

Permalink
Last fixes before release of 1.3
Browse files Browse the repository at this point in the history
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
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Compiler/DAELow.rml
Expand Up @@ -510,6 +510,15 @@ relation collect_zero_crossings: (Exp.Exp * Exp.Exp list)
axiom collect_zero_crossings( ((e as Exp.RELATION(_,_,_)),zeroCrossings) )=>
((e,e::zeroCrossings))

rule --------------------------------------------------
collect_zero_crossings( ((e as Exp.ARRAY(_,_,[])),zeroCrossings)) => ((e,zeroCrossings))

rule Exp.traverse_exp(e, collect_zero_crossings, zeroCrossings) => ((_,zeroCrossings')) &
collect_zero_crossings( (Exp.ARRAY(tp,scalar,el),zeroCrossings) ) => ((e',zeroCrossings'')) &
list_append(zeroCrossings',zeroCrossings'') => zeroCrossings'''
--------------------------------------------------
collect_zero_crossings( ((Exp.ARRAY(tp,scalar,e::el)),zeroCrossings)) => ((e,zeroCrossings'''))

axiom collect_zero_crossings((e,zeroCrossings)) => ((e,zeroCrossings))
end

Expand Down
20 changes: 20 additions & 0 deletions Examples/BouncingBall.mo
@@ -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;
13 changes: 13 additions & 0 deletions Examples/Circle.mo
@@ -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;
9 changes: 9 additions & 0 deletions Examples/SimpleIntegrator.mo
@@ -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;
10 changes: 10 additions & 0 deletions Examples/VanDerPol.mo
@@ -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;
22 changes: 22 additions & 0 deletions Examples/bubblesort.mo
@@ -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;

15 changes: 15 additions & 0 deletions Examples/dcmotor.mo
@@ -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;
3 changes: 3 additions & 0 deletions Examples/sim_BouncingBall.mos
@@ -0,0 +1,3 @@
loadFile("BouncingBall.mo");
simulate(BouncingBall, stopTime=3.0);
plot({h,flying});
4 changes: 4 additions & 0 deletions Examples/sim_dcmotor.mos
@@ -0,0 +1,4 @@
loadModel(Modelica);
loadFile("dcmotor.mo");
simulate(dcmotor,startTime=0.0,stopTime=10.0);
plot({load.w,load.phi});

0 comments on commit 62b192b

Please sign in to comment.