Opened 7 years ago
Last modified 3 years ago
#4835 assigned defect
Get Complex numbers to work without compromises
Reported by: | Francesco Casella | Owned by: | Francesco Casella |
---|---|---|---|
Priority: | blocker | Milestone: | 2.0.0 |
Component: | *unknown* | Version: | |
Keywords: | Cc: | Martin Sjölund, massimo ceraolo, dr.christian.kral@…, belen.goncer-maraver@… |
Description (last modified by )
Complex numbers are increasingly used in Modelica, particularly for power system models. They are used by Modelica.Electrical.QuasiStationary
, and also by other libraries being developed for electro-mechanical modelling of power systems.
OMC supports complex numbers, but there are still some issue that prevents their full, uncompromised use. This ticket collects all of them in the attempt of solving the pending problems soon.
In most, possibly all, cases, the best strategy to solve equations involving Complex variables is to turn them into scalar Real equations and then apply all possible symbolic simplifications. This is particularly important when Complex number that happen to be purely real or imaginary are used.
In simple cases, this already happens. If you compile this model
model TestComplex Complex z1, z2; equation z1+z2 = Complex(0); z2 = Complex(1,2); end TestComplex;
the record equations are turned into scalar equations and solved symbolically, so eventually z1 and z2 are evaluated at initialization, because they are constant.
Unfortunately, in some cases this does not happen, for reasons that need to be investigated. In #4354 and #4808 this issue leads to problems solving otherwise trivial equations, in #4157 it leads to problems with equations in when statements. #4611 is a slightly more involved case, where arrays of Complex constructors are involved. #4973 has a test case for the new front-end, while #4974 shows an issue with the missing inlining of ComplexMath functions.
The code generation for algorithms involving Complex numbers needs to be fixed, see #4055.
There are also some issues with Complex equations and removeSimpleEquations
, see #4793.
Last, but not least, the sum of Complex numbers should be supported, see #4297.
Change History (13)
comment:1 by , 7 years ago
Cc: | added |
---|
comment:2 by , 7 years ago
Description: | modified (diff) |
---|
comment:5 by , 6 years ago
Description: | modified (diff) |
---|
comment:7 by , 6 years ago
Cc: | added |
---|---|
Owner: | changed from | to
Priority: | high → blocker |
Status: | new → assigned |
We are making good progress in supporting Complex numbers with the new front-end. As of today, issues #4055, #4354, #4793, #4808, and #4973 have been solved, while #4157, #4611, and #4297 are still open.
We can tentatively set the goal to resolve all these issues with the new front-end for the 1.14.0 release (see roadmap), where the new front-end use will still be optional, but reliable enough for most models to work.
comment:9 by , 6 years ago
Issues still open as of 10/05/2019:
- #4157 backend issue with
Complex
equations in when statements) - #4297 frontend issue with
sum()
ofComplex
numbers - #4611 backend issue with functions taking
Real
arrays as inputs and returningComplex
arrays as outputs
In fact, #2387, involving array products of Complex
numbers should also be fixed, though apparently nobody needs this feature for applications at the moment.
comment:10 by , 5 years ago
Milestone: | 1.14.0 → 2.0.0 |
---|
Some of the remaining issues require non-trivial work, rescheduling to 2.0.0
Another case of Complex number analysis failure, not covered by the tickets mentioned in this ticket's description:
Checking produces the following error message:
(checked with OpenModelica 1.13.0~dev-1028-g72f3421 for Linux)
I know that a good workaround exists:
but here we are discussing of getting Complex numbers to work "without compromises".