Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#2900 closed defect (duplicate)

Assign Value to A Complex Parameter

Reported by: mengjia@… Owned by: MJ
Priority: high Milestone: never
Component: Frontend Version: trunk
Keywords: Complex Cc: Willi Braun

Description

Hi,

Does anyone know why the complex math operator doesn't work in the parameter declaration ?
I want to compute C as a product of two complex parameters. The code is following :

parameter Complex A(re = 1, im = 2) ;
parameter Complex B(re = 1, im = 2) ;
parameter Complex C= A * B ;

But the value for C wouldn't be A*B in this case.

There are warning shows up as following:

Warning: Parameter C.im has no value, and is fixed during initialization (fixed=true), using available start value (start=0.0) as default value.

Warning: Parameter C.re has no value, and is fixed during initialization (fixed=true), using available start value (start=0.0) as default value.

I have tried to build the operator as math function inside the model like ComplexDivide. But still it didn't work. The warning was still there.

parameter Complex C= ComplexDivide(A, B);

Change History (4)

comment:1 by Martin Sjölund, 10 years ago

Which version of OpenModelica are you running? I get:

class M
  parameter Real A.re = 1.0 "Real part of complex number";
  parameter Real A.im = 2.0 "Imaginary part of complex number";
  parameter Real B.re = 1.0 "Real part of complex number";
  parameter Real B.im = 2.0 "Imaginary part of complex number";
  parameter Real C.re = -3.0 "Real part of complex number";
  parameter Real C.im = 4.0 "Imaginary part of complex number";
end M;

comment:2 by Lennart Ochel, 10 years ago

It's also working fine for me. (1.9.1+dev (r22778) (Bootstrapping version))

I just run the following script:

loadModel(Complex); getErrorString();
loadString("
model foo
  parameter Complex A(re = 1, im = 2);
  parameter Complex B(re = 1, im = 2);
  parameter Complex C= A * B;
end foo;
"); getErrorString();

instantiateModel(foo); getErrorString();
simulate(foo); getErrorString();
Last edited 10 years ago by Lennart Ochel (previous) (diff)

comment:3 by Willi Braun, 10 years ago

Cc: Willi Braun added; wbraun@… removed
Resolution: duplicate
Status: newclosed

Is related to #2902, so duplicate.

comment:4 by Dietmar Winkler, 9 years ago

Milestone: Futurenever

Sorting away the closed as invalid, won't fix and duplicate tickets from Future.

Note: See TracTickets for help on using tickets.