#5523 closed defect (fixed)
Complex number issue when compiling PhotoVoltaics example
| Reported by: | Owned by: | Lennart Ochel | |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.17.0 |
| Component: | Code Generation | Version: | v1.14.0-dev-nightly |
| Keywords: | Cc: | Karim Adbdelhak, Andreas Heuermann |
Description
When trying to simulate the model PhotoVoltaics.Examples.SimpleModuleMP3 an error occurs during compilation.
make -j8 -f PhotoVoltaics.Examples.SimpleModuleMP3.makefile
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3.o PhotoVoltaics.Examples.SimpleModuleMP3.c
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_functions.o PhotoVoltaics.Examples.SimpleModuleMP3_functions.c
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_records.o PhotoVoltaics.Examples.SimpleModuleMP3_records.c
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_01exo.o PhotoVoltaics.Examples.SimpleModuleMP3_01exo.c
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_02nls.o PhotoVoltaics.Examples.SimpleModuleMP3_02nls.c
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_03lsy.o PhotoVoltaics.Examples.SimpleModuleMP3_03lsy.c
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_04set.o PhotoVoltaics.Examples.SimpleModuleMP3_04set.c
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_05evt.o PhotoVoltaics.Examples.SimpleModuleMP3_05evt.c
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_06inz.o PhotoVoltaics.Examples.SimpleModuleMP3_06inz.c
PhotoVoltaics.Examples.SimpleModuleMP3_functions.c:213:11: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
if((_y0 == 0.0))
~~~~^~~~~~
PhotoVoltaics.Examples.SimpleModuleMP3_functions.c:213:11: note: remove extraneous parentheses around the comparison to silence this warning
if((_y0 == 0.0))
~ ^ ~
PhotoVoltaics.Examples.SimpleModuleMP3_functions.c:213:11: note: use '=' to turn this equality comparison into an assignment
if((_y0 == 0.0))
^~
=
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_07dly.o PhotoVoltaics.Examples.SimpleModuleMP3_07dly.c
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_08bnd.o PhotoVoltaics.Examples.SimpleModuleMP3_08bnd.c
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_09alg.o PhotoVoltaics.Examples.SimpleModuleMP3_09alg.c
PhotoVoltaics.Examples.SimpleModuleMP3.c:170:69: error: assigning to 'modelica_real' (aka 'double') from incompatible type 'Modelica_SIunits_ComplexVoltage_array' (aka 'struct base_array_s')
data->localData[0]->realVars[91] /* converter.powerAC variable */ = tmp0;
^ ~~~~
1 warning generated.
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_10asr.o PhotoVoltaics.Examples.SimpleModuleMP3_10asr.c
1 error generated.
clang -Os -fPIC -mfpmath=sse -fno-dollars-in-identifiers -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -DOMC_MODEL_PREFIX=PhotoVoltaics_Examples_SimpleModuleMP3 -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=3 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0 -c -o PhotoVoltaics.Examples.SimpleModuleMP3_11mix.o PhotoVoltaics.Examples.SimpleModuleMP3_11mix.c
<builtin>: recipe for target 'PhotoVoltaics.Examples.SimpleModuleMP3.o' failed
make: *** [PhotoVoltaics.Examples.SimpleModuleMP3.o] Error 1
make: *** Waiting for unfinished jobs....
Compilation process failed. Exited with code 2.
This issue applies to
Connected to OpenModelica 1.14.0~dev-26516-g93a3ce5 Connected to OMSimulator unknown-linux
applying the new instantiation phase.
Note: PhotoVoltaics is a systems library in OpenModelica, so it can directly be opened in OpenModelica without downloading it from https://github.com/christiankral/PhotoVoltaics
Change History (9)
comment:1 by , 6 years ago
| Component: | *unknown* → OMEdit |
|---|---|
| Owner: | changed from to |
| Version: | → v1.14.0-dev-nightly |
comment:2 by , 6 years ago
comment:3 by , 6 years ago
@casella OK, good question:
- I tested the example also with Dymola where the code compiled OK. However, I understand that Dymola is very often too tolerant, so this is very likely no proof.
- The model check both in Dymola (pedantic) and OpenModelica was OK.
- I checked the library with https://www.maplesoft.com/products/maplesim/modelicachecker and it was OK with no errors
- The error message somehow points to the calculation of
powerACwhich is calculated inPhotoVoltaics.Components.Converters.QuasiStaticMultiPhaseConverter, but this looks OK to me:Modelica.SIunits.Power powerAC = Modelica.ComplexMath.real( vAC * Modelica.ComplexMath.conj(iAC));
So vAC and iAC are complex vectors and vAC * Modelica.ComplexMath.conj(iAC) shall be calculating the inner product of the two vectors. The following simulation model breaks down the power calculation of the converter model to a simple example:
model TestComplexSum
parameter Complex a[2] = {Complex(1, 0), Complex(0, 1)};
parameter Real r1 = Modelica.ComplexMath.real(a * a);
parameter Real r2 = Modelica.ComplexMath.real(sum( a[k] * a[k] for k in 1:size(a,1)));
end TestComplexSum;
This example simulates OK in OpenModelica and Dymola. How else could I check whether the Modelica code of the PhotoVoltaics library is wrong or not?
comment:4 by , 6 years ago
I guess what @casella meant was: why do you think the problem lies with the GUI (OMEdit) and not the compiler (component code generation or similar).
comment:5 by , 6 years ago
| Cc: | added |
|---|---|
| Component: | OMEdit → Code Generation |
| Milestone: | 1.14.0 → 2.0.0 |
| Owner: | changed from to |
| Priority: | high → blocker |
| Status: | new → assigned |
Exactly. From what I see, the compilation fails also if I run the model from a script, where OMEdit is hardly involved at all.
As I understand, this is a back-end/code generation problem, related to functions involving arrays of records.
comment:7 by , 4 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
This seems to have been fixed at some point, see simulation output from our library testing.
comment:8 by , 4 years ago
| Milestone: | 2.0.0 → 1.18.0 |
|---|
comment:9 by , 4 years ago
| Milestone: | 1.18.0 → 1.17.0 |
|---|
Apparently, switching to the front end did it.

Christian, why do you think this is an OMEdit issue?