From 3d94fa2a883c5535210ec954543414e17e7ea455 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Mon, 19 Dec 2016 00:16:01 -0800 Subject: parser: more models (not working) --- .../examples/modelica_other/breaking_pendulum.mo | 29 ++++++++++++++++++++++ .../modelica_other/polynomial_evaluator.mo | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 modelica-parser-lalrpop/examples/modelica_other/breaking_pendulum.mo diff --git a/modelica-parser-lalrpop/examples/modelica_other/breaking_pendulum.mo b/modelica-parser-lalrpop/examples/modelica_other/breaking_pendulum.mo new file mode 100644 index 0000000..f719a04 --- /dev/null +++ b/modelica-parser-lalrpop/examples/modelica_other/breaking_pendulum.mo @@ -0,0 +1,29 @@ +record PendulumData + parameter Real m, g, L; +end PendulumData; + +partial model BasePendulum + PendulumData p; + input + Real u; + output Real pos[2], vel[2]; +end BasePendulum; + +block Pendulum + extends BasePendulum; + constant Real PI=3.141592653589793; + output + Real phi(start=PI/4), phid; +equation + phid = der(phi); + p.m*p.L*p.L*der(phid) + p.m*p.g*p.L*sin(phi) = u; + pos = [p.L*sin(phi); -p.L*cos(phi)]; + vel = der(pos); +end Pendulum; + +block BrokenPendulum + extends BasePendulum; +equation + vel = der(pos); + p.m*der(vel) = p.m*[0; -p.g]; +end BrokenPendulum; diff --git a/modelica-parser-lalrpop/examples/modelica_other/polynomial_evaluator.mo b/modelica-parser-lalrpop/examples/modelica_other/polynomial_evaluator.mo index f11d375..632fbc7 100644 --- a/modelica-parser-lalrpop/examples/modelica_other/polynomial_evaluator.mo +++ b/modelica-parser-lalrpop/examples/modelica_other/polynomial_evaluator.mo @@ -3,7 +3,7 @@ block PolynomialEvaluator input Real x; output Real y; protected - constant n = size(a, 1)-1; + constant Real n = size(a, 1)-1; Real xpowers[n+1]; equation xpowers[1] = 1; -- cgit v1.2.3