- Index
- » Programming
- » Modelica Language
- » DrModelica - Complex Example...
DrModelica - Complex Example OMC-Error - Variable a.re not referenced
DrModelica - Complex Example OMC-Error - Variable a.re not referenced
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
- » Programming
- » Modelica Language
- » DrModelica - Complex Example...