Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » habersmn
  • » Profile

Posts

Posts

Apr-09-14 22:46:05
Simulation of example results in OMC-Error
Category: Programming

I'm just starting to learn Modelica and working through the DrModelica tutorial.
In 'Packages as Abstract Data Types' (PackasADTs.onb),
simulating the following code I'm getting an error I can't figure out.
Has anyone run into this?

Note: I'm using OpenModelica 1.9.1 Beta2 (r19512) (RML version)


Code:

encapsulated package ComplexNumbersA


  function Add = Complex.Add;

  function Multiply = Complex.Multiply;

  function MakeComplex = Complex.MakeComplex;


  class Complex

    protected
      Real re;
      Real im;

    public
      function Add
        input Complex x;
        input Complex y;
        output Complex z;
      algorithm
        z.re:=x.re+y.re;
        z.im:=x.im+y.im;
      end Add;

      function Multiply
        input Complex x;
        input Complex y;
        output Complex z;
      algorithm
        z.re:=x.re*y.re-x.im*y.im;
        z.im:=x.re*y.im+x.im*y.re;
      end Multiply;

      function MakeComplex
        input Real x;
        input Real y;
        output Complex z;
      algorithm
        z.re:=x;
        z.im:=y;
      end MakeComplex;

    end Complex;

end ComplexNumbersA;

{ComplexNumbersA}

Code:

class ComplexUser3

  ComplexNumbersA.Complex  a = ComplexNumbersA.MakeComplex(1.0, 2.0);
  ComplexNumbersA.Complex  b = ComplexNumbersA.MakeComplex(1.0, 2.0);
  ComplexNumbersA.Complex  z, w;
equation
  z = ComplexNumbersA.Multiply(a, b);
  w = ComplexNumbersA.Add(a, b);
end ComplexUser3;

{ComplexUser3}

Code:

simulate(ComplexUser3)

record SimulationResult
    resultFile = "",
    messages = "Failed to build model: ComplexUser3"
end SimulationResult;
OMC-ERROR:
"[<interactive>:13:7-13:14:writable] Error: Variable a.re is not referenced in any equation (possibly after symbolic manipulations).
"

  • Index
  • » Users
  • » habersmn
  • » Profile
You are here: