Opened 6 years ago

Closed 6 years ago

#4974 closed defect (fixed)

ComplexMath.'abs' is not inlined

Reported by: Francesco Casella Owned by: somebody
Priority: critical Milestone: 1.13.0
Component: Backend Version:
Keywords: Cc: Martin Sjölund, Willi Braun, Vitalij Ruge

Description

Please run this simple model with -d=dumpdaelow

model TestComplexAbs
 Complex z;
 Real x;
equation
 z = Complex(time, 1);
 x = Modelica.ComplexMath.'abs'(z);
end TestComplexAbs;

The output is

1/1 (1): z.re = time   [dynamic |0|0|0|0|] 
2/2 (1): z.im = 1.0   [dynamic |0|0|0|0|] 
3/3 (1): x = Modelica.ComplexMath.'abs'(z)   [dynamic |0|0|0|0|] 

For some reason, the 'abs' function is not inlined as required by the annotation in its definition, otherwise the third line should read

x = (z.re^2 + z.im^2)^0.5

Please make sure inlining works with this function, otherwise the backend cannot generate symbolic Jacobians if the function is involved in a nonlinear algebraic loop

Change History (6)

comment:1 by Francesco Casella, 6 years ago

Cc: Vitalij Ruge added

comment:2 by Vitalij Ruge, 6 years ago

Owner: changed from Lennart Ochel to somebody
Status: newassigned

@casella
Inlining of functions will be done with normalInlineFunction

######################################## 
pre-optimization module normalInlineFunction (simulation) 
######################################## 
Equations (3, 3) 
======================================== 
1/1 (1): z.re = time   [dynamic] 
2/2 (1): z.im = 1.0   [dynamic] 
3/3 (1): x = (z.re ^ 2.0 + z.im ^ 2.0) ^ 0.5   [dynamic] 

I guess we do partitional some inlining for records like constructor in frondend and inlining function in backend in the optdaemodul normalInlineFunction .

Version 0, edited 6 years ago by Vitalij Ruge (next)

comment:3 by Francesco Casella, 6 years ago

@vitalij, there was some issue with the NF that did not pass the Inline annotation to the backend. This should now be fixed, I'll check again tomorrow.

comment:4 by Francesco Casella, 6 years ago

Unfortunately, if I run the model with -d=newInst,dumpdaelow I still get

Equations (3, 3) 
======================================== 
1/1 (1): z.im = 1.0   [dynamic |0|0|0|0|] 
2/2 (1): z.re = time   [dynamic |0|0|0|0|] 
3/3 (1): x = Modelica.ComplexMath.'abs'(z)   [dynamic |0|0|0|0|] 

@vitalij, how did you get the result reported in comment:2?

comment:5 by Vitalij Ruge, 6 years ago

setCommandLineOptions("+d=optdaedump,newInst");
loadModel(Modelica);
getErrorString();
loadString("
model TestComplexAbs
 Complex z;
 Real x;
equation
 z = Complex(time, 1);
 x = Modelica.ComplexMath.'abs'(z);
end TestComplexAbs;
");

getErrorString();
simulate(TestComplexAbs);

comment:6 by Francesco Casella, 6 years ago

Resolution: fixed
Status: assignedclosed

Oops, sorry, I missed the right -d flag.

Thanks @vitalij!

Note: See TracTickets for help on using tickets.