open-ideas / IDEAS

Modelica library allowing simultaneous transient simulation of thermal and electrical systems at both building and feeder level.
131 stars 58 forks source link

Error in AHU example model simulation in Open Modelica #1225

Closed Kanchan-Aggarwal closed 2 years ago

Kanchan-Aggarwal commented 3 years ago

As discussed on the issue for Openmodelica with #7705, I am creating an issue here.

I am trying to simulate the AHU example model (Adsolair58) available in IDEAS.AIRFLOW.AHU package of the IDEAS library. When I am trying to simulate the example it is giving the following errors “Illegal access of protected element XiSat.” and “Variable wetBulOut.XiSat not found in scope IndirectEvaporativeHex.”

@Mathadon , kindly look into it and help me resolve the issue.

Thanks

YashwanthVellala commented 3 years ago

@Kanchn12345 Thanks for raising this ticket. I am facing this error too.

Mathadon commented 3 years ago

@Kanchn12345 can you verify whether https://github.com/open-ideas/IDEAS/tree/1225_XiSat resolves your issue?

YashwanthVellala commented 3 years ago

@Mathadon I tried using the above fix, its giving a different error now. Copied the error message below. Please take a look

[2] 14:23:01 Translation Error [IDEAS.Templates.Interfaces.BaseClasses.Structure: 50:3-52:73]: Non-array modification ‘"ThermodynamicTemperature"‘ for array component ‘quantity‘, possibly due to missing ‘each‘.

Error

Kanchan-Aggarwal commented 3 years ago

@Mathadon , Thank you fixing it.

I tried running the model and I am also getting the same error as @YashwanthVellala

Mathadon commented 3 years ago

@Kanchn12345 @YashwanthVellala can you try again?

YashwanthVellala commented 3 years ago

@Mathadon Getting a different error now, below is the error message

YashwanthVellala commented 3 years ago

[2] 14:52:16 Translation Error [IDEAS.Buildings.Components.Interfaces.PartialZone: 254:3-255:43]: Non-array modification ‘false‘ for array component ‘fixed‘, possibly due to missing ‘each‘.

Kanchan-Aggarwal commented 3 years ago

@Mathadon, I am also facing the same error.

YashwanthVellala commented 3 years ago

@Mathadon Can you please try to fix this as soon as possible

Mathadon commented 3 years ago

done!

Mathadon commented 3 years ago

There may be quite a bit more of these missing 'each'. Feel free to add them yourself and report back on where I should add them!

YashwanthVellala commented 3 years ago

@Mathadon Thanks for the fix, but it isnt working yet. its giving a different error, shown below.

[8] 18:01:35 Translation Error [IDEAS.Buildings.Components.Shading.Overhang: 11:3-13:52]: Type mismatch in binding ‘wLeft = {0.5, 4.5}‘, expected array dimensions [], got [2].

Earlier, we had fixed the errors related to using 'each' ourselves, we can note and report to you on those errors. Please help to fix these ones.

Also, do you use a different platform or another version of openmodelica ? just to understand, these errors are not due to compatibility problems.

Mathadon commented 3 years ago

I use dymola for our development and do not use OM.

The error that you report is something that looks less straight forward to fix. Today is the national holiday in Belgium so that will be for later. I can only recommend removing the shading from the building envelope model for now if you want to progress.

Mathadon commented 3 years ago

@casella the error

[8] 18:01:35 Translation Error
[IDEAS.Buildings.Components.Shading.Overhang: 11:3-13:52]: Type mismatch in binding ‘wLeft = {0.5, 4.5}‘, expected array dimensions [], got [2].

Seems to be caused by the code

  extends IDEAS.Buildings.Validation.BaseClasses.Structure.Bui600(win(
        redeclare replaceable IDEAS.Buildings.Components.Shading.Overhang
        shaType(
        each hWin=2.0,
        each wWin=3.0,
        each dep=1.0,
        each gap=0.35,
        wLeft={0.5,4.5},
        wRight={4.5,0.5})));

where win is declared as an array of components

  IDEAS.Buildings.Components.Window[2] win(
    final A={6,6},
    redeclare final parameter IDEAS.Buildings.Validation.Data.Glazing.GlaBesTest glazing,
    final inc={IDEAS.Types.Tilt.Wall,IDEAS.Types.Tilt.Wall},
    azi={aO+IDEAS.Types.Azimuth.S,aO+IDEAS.Types.Azimuth.S},
    redeclare replaceable IDEAS.Buildings.Components.Shading.None shaType,
    redeclare final parameter IDEAS.Buildings.Data.Frames.None fraType,
    each frac=0)

The purpose of wLeft={0.5,4.5}, is to assign a different value of wLeft to each instance of win. As far as I can tell, the syntax is correct (edit: except for missing 'each', solved in 9293da0). But perhaps the standard does not permit such assignments for a replaceable?

Mathadon commented 3 years ago

The issue may be solved through commit 9293da0 but I doubt that.

YashwanthVellala commented 3 years ago

@Mathadon I'll try with this commit and let you know. Thanks

YashwanthVellala commented 3 years ago

@Mathadon Doesn't resolve it. Still the same error.

[4] 12:24:35 Translation Error [IDEAS.Buildings.Components.Shading.Overhang: 11:3-13:52]: Type mismatch in binding ‘wLeft = {0.5, 4.5}‘, expected array dimensions [], got [2].

YashwanthVellala commented 3 years ago

@Mathadon On a different note, need your help on FMU in OpenModelica. I am trying to export \IDEAS\Fluid\Examples\SimpleHouse.mo as an FMU to matlab to try few things. I used the below commands as mentioned in the OMtutorials https://openmodelica.org/doc/OpenModelicaUsersGuide/v1.11.0/fmi.html

  1. loadFile("C:\Users\Exxxxxx\Downloads\IDEAS-1225_XiSat\IDEAS-1225_XiSat\IDEAS\Fluid\Examples\SimpleHouse.mo") true / seems ok/
  2. then I use translateModelFMU(SimpleHouse) /doesnt work/

I also tried with another command translateModelFMU(SimpleHouse, version="2.0"); mentioned here https://build.openmodelica.org/Documentation/OpenModelica.Scripting.translateModelFMU.html /doesnt work as well/

any suggestions ?

Mathadon commented 3 years ago

Can you simulate SimpleHouse using OM (without using FMU)? If that results in an error then that's probably the cause for the FMU too since the same code is used. In any case the translateModelFMU function likely generates an error message that should clarify what the problem is.

YashwanthVellala commented 3 years ago

I can simulate the SimpleHouse in OpenModelica. Looks like the translate function is throwing some error.

[76] 13:49:43 Scripting Notification

Nonlinear iteration variables with predefined start attribute in NLSJac130. (1) ======================================== 1: weaBus.TWetBul:VARIABLE(min = 0.0 start = 291.15 ) "virtual variable in expandable connector" type: Real

Info: Only non-linear iteration variables in non-linear eqation systems require start values. All other start values have no influence on convergence and are ignored. Use "-d=dumpLoops" to show all loops. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("-d=dumpLoops")

Nonlinear iteration variables with predefined start attribute in NLSJac133. (1) ======================================== 1: weaBus.TWetBul:VARIABLE(min = 0.0 start = 291.15 ) "virtual variable in expandable connector" type: Real

Info: Only non-linear iteration variables in non-linear eqation systems require start values. All other start values have no influence on convergence and are ignored. Use "-d=dumpLoops" to show all loops. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("-d=dumpLoops")

[77] 13:49:43 Syntax Warning Lexer treating \ as \, since \U is not a valid Modelica escape sequence.

[78] 13:49:43 Syntax Warning Lexer treating \ as \, since \E is not a valid Modelica escape sequence.

[79] 13:49:43 Syntax Warning Lexer treating \ as \, since \D is not a valid Modelica escape sequence.

[80] 13:49:43 Syntax Warning Lexer treating \ as \, since \I is not a valid Modelica escape sequence.

[81] 13:49:43 Syntax Warning Lexer treating \ as \, since \I is not a valid Modelica escape sequence.

[82] 13:49:43 Syntax Warning Lexer treating \ as \, since \I is not a valid Modelica escape sequence.

[83] 13:49:43 Syntax Warning Lexer treating \ as \, since \F is not a valid Modelica escape sequence.

[84] 13:49:43 Syntax Warning Lexer treating \ as \, since \E is not a valid Modelica escape sequence.

[85] 13:49:43 Syntax Warning Lexer treating \ as \, since \S is not a valid Modelica escape sequence.

[86] 13:49:43 Translation Error Class translateModelFMU not found in scope (looking for a function or record).

[87] 13:49:43 Syntax Warning Lexer treating \ as \, since \U is not a valid Modelica escape sequence.

[88] 13:49:43 Syntax Warning Lexer treating \ as \, since \E is not a valid Modelica escape sequence.

[89] 13:49:43 Syntax Warning Lexer treating \ as \, since \D is not a valid Modelica escape sequence.

[90] 13:49:43 Syntax Warning Lexer treating \ as \, since \I is not a valid Modelica escape sequence.

[91] 13:49:43 Syntax Warning Lexer treating \ as \, since \I is not a valid Modelica escape sequence.

[92] 13:49:43 Syntax Warning Lexer treating \ as \, since \I is not a valid Modelica escape sequence.

[93] 13:49:43 Syntax Warning Lexer treating \ as \, since \F is not a valid Modelica escape sequence.

[94] 13:49:43 Syntax Warning Lexer treating \ as \, since \E is not a valid Modelica escape sequence.

[95] 13:49:43 Syntax Warning Lexer treating \ as \, since \S is not a valid Modelica escape sequence.

[96] 13:49:43 Scripting Error [C:/Users/E485898/AppData/Roaming/.openmodelica/libraries/index.json: 0:0-0:0]: The package index C:/Users/E485898/AppData/Roaming/.openmodelica/libraries/index.json could not be parsed.

[97] 13:49:43 Scripting Error Failed to load package SimpleHouse (default) using MODELICAPATH C:/Program Files/OpenModelica1.17.0-64bit/lib/omlibrary;C:/Users/E485898/AppData/Roaming/.openmodelica/libraries/.

[98] 13:49:43 Translation Error Class SimpleHouse not found in scope .

[99] 13:49:43 Translation Error Class SimpleHouse not found in scope .

[100] 13:49:43 Translation Warning [IDEAS.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3: 2:1-105:25]: Pure function ‘IDEAS.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3‘ contains a call to impure function ‘Modelica.Utilities.Streams.readLine‘.

[101] 13:49:43 Translation Warning [IDEAS.BoundaryConditions.WeatherData.BaseClasses.getLongitudeTMY3: 2:1-48:21]: Pure function ‘IDEAS.BoundaryConditions.WeatherData.BaseClasses.getLongitudeTMY3‘ contains a call to impure function ‘IDEAS.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3‘.

[102] 13:49:43 Translation Warning [IDEAS.BoundaryConditions.WeatherData.BaseClasses.getLatitudeTMY3: 2:1-48:20]: Pure function ‘IDEAS.BoundaryConditions.WeatherData.BaseClasses.getLatitudeTMY3‘ contains a call to impure function ‘IDEAS.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3‘.

[103] 13:49:43 Translation Warning [IDEAS.BoundaryConditions.WeatherData.BaseClasses.getTimeZoneTMY3: 2:1-47:20]: Pure function ‘IDEAS.BoundaryConditions.WeatherData.BaseClasses.getTimeZoneTMY3‘ contains a call to impure function ‘IDEAS.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3‘.

[104] 13:49:43 Symbolic Warning The model contains alias variables with redundant start and/or conflicting nominal values. It is recommended to resolve the conflicts, because otherwise the system could be hard to solve. To print the conflicting alias sets and the chosen candidates please use -d=aliasConflicts.

[105] 13:49:43 Translation Error Error building simulator. Build log: clang -Os -falign-functions -mstackrealign -msse2 -mfpmath=sse -I"C:/Program Files/OpenModelica1.17.0-64bit/include/omc/c/fmi" -DOMC_FMI_RUNTIME=1 -DCMINPACK_NO_DLL=1 "-IC:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources" -c -o IDEAS_Fluid_Examples_SimpleHouse.o IDEAS_Fluid_Examples_SimpleHouse.c clang -Os -falign-functions -mstackrealign -msse2 -mfpmath=sse -I"C:/Program Files/OpenModelica1.17.0-64bit/include/omc/c/fmi" -DOMC_FMI_RUNTIME=1 -DCMINPACK_NO_DLL=1 "-IC:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources" -c -o IDEAS_Fluid_Examples_SimpleHouse_functions.o IDEAS_Fluid_Examples_SimpleHouse_functions.c clang -Os -falign-functions -mstackrealign -msse2 -mfpmath=sse -I"C:/Program Files/OpenModelica1.17.0-64bit/include/omc/c/fmi" -DOMC_FMI_RUNTIME=1 -DCMINPACK_NO_DLL=1 "-IC:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources" -c -o IDEAS_Fluid_Examples_SimpleHouse_records.o IDEAS_Fluid_Examples_SimpleHouse_records.c clang -Os -falign-functions -mstackrealign -msse2 -mfpmath=sse -I"C:/Program Files/OpenModelica1.17.0-64bit/include/omc/c/fmi" -DOMC_FMI_RUNTIME=1 -DCMINPACK_NO_DLL=1 "-IC:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources" -c -o IDEAS_Fluid_Examples_SimpleHouse_01exo.o IDEAS_Fluid_Examples_SimpleHouse_01exo.c clang -Os -falign-functions -mstackrealign -msse2 -mfpmath=sse -I"C:/Program Files/OpenModelica1.17.0-64bit/include/omc/c/fmi" -DOMC_FMI_RUNTIME=1 -DCMINPACK_NO_DLL=1 "-IC:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources" -c -o IDEAS_Fluid_Examples_SimpleHouse_02nls.o IDEAS_Fluid_Examples_SimpleHouse_02nls.c clang -Os -falign-functions -mstackrealign -msse2 -mfpmath=sse -I"C:/Program Files/OpenModelica1.17.0-64bit/include/omc/c/fmi" -DOMC_FMI_RUNTIME=1 -DCMINPACK_NO_DLL=1 "-IC:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources" -c -o IDEAS_Fluid_Examples_SimpleHouse_03lsy.o IDEAS_Fluid_Examples_SimpleHouse_03lsy.c clang -Os -falign-functions -mstackrealign -msse2 -mfpmath=sse -I"C:/Program Files/OpenModelica1.17.0-64bit/include/omc/c/fmi" -DOMC_FMI_RUNTIME=1 -DCMINPACK_NO_DLL=1 "-IC:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources" -c -o IDEAS_Fluid_Examples_SimpleHouse_04set.o IDEAS_Fluid_Examples_SimpleHouse_04set.c clang -Os -falign-functions -mstackrealign -msse2 -mfpmath=sse -I"C:/Program Files/OpenModelica1.17.0-64bit/include/omc/c/fmi" -DOMC_FMI_RUNTIME=1 -DCMINPACK_NO_DLL=1 "-IC:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources" -c -o IDEAS_Fluid_Examples_SimpleHouse_05evt.o IDEAS_Fluid_Examples_SimpleHouse_05evt.c clang -Os -falign-functions -mstackrealign -msse2 -mfpmath=sse -I"C:/Program Files/OpenModelica1.17.0-64bit/include/omc/c/fmi" -DOMC_FMI_RUNTIME=1 -DCMINPACK_NO_DLL=1 "-IC:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources" -c -o IDEAS_Fluid_Examples_SimpleHouse_06inz.o IDEAS_Fluid_Examples_SimpleHouse_06inz.c clang -Os -falign-functions -mstackrealign -msse2 -mfpmath=sse -I"C:/Program Files/OpenModelica1.17.0-64bit/include/omc/c/fmi" -DOMC_FMI_RUNTIME=1 -DCMINPACK_NO_DLL=1 "-IC:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources" -c -o IDEAS_Fluid_Examples_SimpleHouse_07dly.o IDEAS_Fluid_Examples_SimpleHouse_07dly.c clang -Os -falign-functions -mstackrealign -msse2 -mfpmath=sse -I"C:/Program Files/OpenModelica1.17.0-64bit/include/omc/c/fmi" -DOMC_FMI_RUNTIME=1 -DCMINPACK_NO_DLL=1 "-IC:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources" -c -o IDEAS_Fluid_Examples_SimpleHouse_08bnd.o IDEAS_Fluid_Examples_SimpleHouse_08bnd.c clang -Os -falign-functions -mstackrealign -msse2 -mfpmath=sse -I"C:/Program Files/OpenModelica1.17.0-64bit/include/omc/c/fmi" -DOMC_FMI_RUNTIME=1 -DCMINPACK_NO_DLL=1 "-IC:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources" -c -o IDEAS_Fluid_Examples_SimpleHouse_09alg.o IDEAS_Fluid_Examples_SimpleHouse_09alg.c In file included from IDEAS_Fluid_Examples_SimpleHouse_functions.c:2: In file included from ./IDEAS_Fluid_Examples_SimpleHouse_functions.h:3: In file included from ./meta/meta_modelica.h:49: ./gc/omc_gc.h:218:28: warning: expression result unused [-Wunused-value] GC_register_displacement(0); ^ ./gc/omc_gc.h:222:34: warning: expression result unused [-Wunused-value] GC_set_force_unmap_on_gcollect(1); ^ In file included from IDEAS_Fluid_Examples_SimpleHouse_records.c:4: In file included from ./meta/meta_modelica.h:49: ./gc/omc_gc.h:218:28: warning: expression result unused [-Wunused-value] GC_register_displacement(0); ^ ./gc/omc_gc.h:222:34: warning: expression result unused [-Wunused-value] GC_set_force_unmap_on_gcollect(1); ^ In file included from IDEAS_Fluid_Examples_SimpleHouse_functions.c:7: In file included from ./IDEAS_Fluid_Examples_SimpleHouse_includes.h:4: In file included from C:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources\getTimeSpan.c:12: C:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources/getTimeSpan.h:11:10: fatal error: 'ModelicaUtilities.h' file not found

include

     ^~~~~~~~~~~~~~~~~~~~~ 

2 warnings and 1 error generated. In file included from IDEAS_Fluid_Examples_SimpleHouse_02nls.c:2: In file included from ./IDEAS_Fluid_Examples_SimpleHouse_model.h:5: In file included from ./openmodelica.h:71: In file included from ./gc/../openmodelica_types.h:149: ./gc/omc_gc.h:218:28: warning: expression result unused [-Wunused-value] GC_register_displacement(0); ^ ./gc/omc_gc.h:222:34: warning: expression result unused [-Wunused-value] GC_set_force_unmap_on_gcollect(1); ^ make: [: IDEAS_Fluid_Examples_SimpleHouse_functions.o] Error 1 make: Waiting for unfinished jobs.... In file included from IDEAS_Fluid_Examples_SimpleHouse_01exo.c:2: In file included from ./IDEAS_Fluid_Examples_SimpleHouse_model.h:5: In file included from ./openmodelica.h:71: In file included from ./gc/../openmodelica_types.h:149: ./gc/omc_gc.h:218:28: warning: expression result unused [-Wunused-value] GC_register_displacement(0); ^ ./gc/omc_gc.h:222:34: warning: expression result unused [-Wunused-value] GC_set_force_unmap_on_gcollect(1); ^ 2 warnings generated. In file included from IDEAS_Fluid_Examples_SimpleHouse_03lsy.c:2: In file included from ./IDEAS_Fluid_Examples_SimpleHouse_model.h:5: In file included from ./openmodelica.h:71: In file included from ./gc/../openmodelica_types.h:149: ./gc/omc_gc.h:218:28: warning: expression result unused [-Wunused-value] GC_register_displacement(0); ^ ./gc/omc_gc.h:222:34: warning: expression result unused [-Wunused-value] GC_set_force_unmap_on_gcollect(1); ^ 2 warnings generated. In file included from IDEAS_Fluid_Examples_SimpleHouse.c:7: In file included from ./IDEAS_Fluid_Examples_SimpleHouse_model.h:5: In file included from ./openmodelica.h:71: In file included from ./gc/../openmodelica_types.h:149: ./gc/omc_gc.h:218:28: warning: expression result unused [-Wunused-value] GC_register_displacement(0); ^ ./gc/omc_gc.h:222:34: warning: expression result unused [-Wunused-value] GC_set_force_unmap_on_gcollect(1); ^ In file included from IDEAS_Fluid_Examples_SimpleHouse_04set.c:2: In file included from ./IDEAS_Fluid_Examples_SimpleHouse_model.h:5: In file included from ./openmodelica.h:71: In file included from ./gc/../openmodelica_types.h:149: ./gc/omc_gc.h:218:28: warning: expression result unused [-Wunused-value] GC_register_displacement(0); ^ ./gc/omc_gc.h:222:34: warning: expression result unused [-Wunused-value] GC_set_force_unmap_on_gcollect(1); ^ In file included from IDEAS_Fluid_Examples_SimpleHouse_05evt.c:2: In file included from ./IDEAS_Fluid_Examples_SimpleHouse_model.h:5: In file included from ./openmodelica.h:71: In file included from ./gc/../openmodelica_types.h:149: ./gc/omc_gc.h:218:28: warning: expression result unused [-Wunused-value] GC_register_displacement(0); ^ ./gc/omc_gc.h:222:34: warning: expression result unused [-Wunused-value] GC_set_force_unmap_on_gcollect(1); ^ 2 warnings generated. 2 warnings generated. 2 warnings generated. In file included from IDEAS_Fluid_Examples_SimpleHouse_06inz.c:2: In file included from ./IDEAS_Fluid_Examples_SimpleHouse_model.h:5: In file included from ./openmodelica.h:71: In file included from ./gc/../openmodelica_types.h:149: ./gc/omc_gc.h:218:28: warning: expression result unused [-Wunused-value] GC_register_displacement(0); ^ ./gc/omc_gc.h:222:34: warning: expression result unused [-Wunused-value] GC_set_force_unmap_on_gcollect(1); ^ 2 warnings generated. In file included from IDEAS_Fluid_Examples_SimpleHouse_07dly.c:2: In file included from ./IDEAS_Fluid_Examples_SimpleHouse_model.h:5: In file included from ./openmodelica.h:71: In file included from ./gc/../openmodelica_types.h:149: ./gc/omc_gc.h:218:28: warning: expression result unused [-Wunused-value] GC_register_displacement(0); ^ ./gc/omc_gc.h:222:34: warning: expression result unused [-Wunused-value] GC_set_force_unmap_on_gcollect(1); ^ In file included from IDEAS_Fluid_Examples_SimpleHouse_08bnd.c:2: In file included from ./IDEAS_Fluid_Examples_SimpleHouse_model.h:5: In file included from ./openmodelica.h:71: In file included from ./gc/../openmodelica_types.h:149: ./gc/omc_gc.h:218:28: warning: expression result unused [-Wunused-value] GC_register_displacement(0); ^ ./gc/omc_gc.h:222:34: warning: expression result unused [-Wunused-value] GC_set_force_unmap_on_gcollect(1); ^ 2 warnings generated. In file included from IDEAS_Fluid_Examples_SimpleHouse_09alg.c:2: In file included from ./IDEAS_Fluid_Examples_SimpleHouse_model.h:5: In file included from ./openmodelica.h:71: In file included from ./gc/../openmodelica_types.h:149: ./gc/omc_gc.h:218:28: warning: expression result unused [-Wunused-value] GC_register_displacement(0); ^ ./gc/omc_gc.h:222:34: warning: expression result unused [-Wunused-value] GC_set_force_unmap_on_gcollect(1); ^ 2 warnings generated. 2 warnings generated. 2 warnings generated. 2 warnings generated.

YashwanthVellala commented 3 years ago

@Mathadon Also, is it likely to have a solution on the AHU model soon ?

casella commented 3 years ago

There may be quite a bit more of these missing 'each'. Feel free to add them yourself and report back on where I should add them!

Pedantic check in Dymola report these issues as errors. Unfortunately it only reports the first one, so you have to kill them one by one.

casella commented 3 years ago

[4] 12:24:35 Translation Error [IDEAS.Buildings.Components.Shading.Overhang: 11:3-13:52]: Type mismatch in binding ‘wLeft = {0.5, 4.5}‘, expected array dimensions [], got [2].

This may be by an OpenModelica bug. I would suggest you to try compiling the model with OpenModelica 1.18.0-beta.1 or with the latest nightly build, if you are still using 1.17.0 it may have been fixed already.

If not, please open a ticket here about that.

YashwanthVellala commented 3 years ago

i'll try this as well @casella thanks !

casella commented 3 years ago

I can simulate the SimpleHouse in OpenModelica. Looks like the translate function is throwing some error.

[76] 13:49:43 Scripting Notification

Nonlinear iteration variables with predefined start attribute in NLSJac130. (1)

1: weaBus.TWetBul:VARIABLE(min = 0.0 start = 291.15 ) "virtual variable in expandable connector" type: Real

Info: Only non-linear iteration variables in non-linear eqation systems require start values. All other start values have no influence on convergence and are ignored. Use "-d=dumpLoops" to show all loops. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("-d=dumpLoops")

Nonlinear iteration variables with predefined start attribute in NLSJac133. (1)

1: weaBus.TWetBul:VARIABLE(min = 0.0 start = 291.15 ) "virtual variable in expandable connector" type: Real

Info: Only non-linear iteration variables in non-linear eqation systems require start values. All other start values have no influence on convergence and are ignored. Use "-d=dumpLoops" to show all loops. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("-d=dumpLoops")

These are not errors, just warnings that there are some iteration variables in nonlinear equations that are using a default value as a first guess. If the solver converges, you can ignore this messsage. If it fails, this may be the cause of the failure.

BTW, we are implementing a very nice tool to help you in this case, based on the theory explained in this paper, it should be available later this autumn, at least as an experimental feature. @Mathadon, this could also be interesting for you.

casella commented 3 years ago

[77] 13:49:43 Syntax Warning Lexer treating \ as \, since \U is not a valid Modelica escape sequence.

[78] 13:49:43 Syntax Warning Lexer treating \ as \, since \E is not a valid Modelica escape sequence.

[79] 13:49:43 Syntax Warning Lexer treating \ as \, since \D is not a valid Modelica escape sequence.

[80] 13:49:43 Syntax Warning Lexer treating \ as \, since \I is not a valid Modelica escape sequence.

[81] 13:49:43 Syntax Warning Lexer treating \ as \, since \I is not a valid Modelica escape sequence.

[82] 13:49:43 Syntax Warning Lexer treating \ as \, since \I is not a valid Modelica escape sequence.

[83] 13:49:43 Syntax Warning Lexer treating \ as \, since \F is not a valid Modelica escape sequence.

[84] 13:49:43 Syntax Warning Lexer treating \ as \, since \E is not a valid Modelica escape sequence.

[85] 13:49:43 Syntax Warning Lexer treating \ as \, since \S is not a valid Modelica escape sequence.

[86] 13:49:43 Translation Error Class translateModelFMU not found in scope (looking for a function or record).

[87] 13:49:43 Syntax Warning Lexer treating \ as \, since \U is not a valid Modelica escape sequence.

[88] 13:49:43 Syntax Warning Lexer treating \ as \, since \E is not a valid Modelica escape sequence.

[89] 13:49:43 Syntax Warning Lexer treating \ as \, since \D is not a valid Modelica escape sequence.

[90] 13:49:43 Syntax Warning Lexer treating \ as \, since \I is not a valid Modelica escape sequence.

[91] 13:49:43 Syntax Warning Lexer treating \ as \, since \I is not a valid Modelica escape sequence.

[92] 13:49:43 Syntax Warning Lexer treating \ as \, since \I is not a valid Modelica escape sequence.

[93] 13:49:43 Syntax Warning Lexer treating \ as \, since \F is not a valid Modelica escape sequence.

[94] 13:49:43 Syntax Warning Lexer treating \ as \, since \E is not a valid Modelica escape sequence.

[95] 13:49:43 Syntax Warning Lexer treating \ as \, since \S is not a valid Modelica escape sequence.

[96] 13:49:43 Scripting Error [C:/Users/E485898/AppData/Roaming/.openmodelica/libraries/index.json: 0:0-0:0]: The package index C:/Users/E485898/AppData/Roaming/.openmodelica/libraries/index.json could not be parsed.

[97] 13:49:43 Scripting Error Failed to load package SimpleHouse (default) using MODELICAPATH C:/Program Files/OpenModelica1.17.0-64bit/lib/omlibrary;C:/Users/E485898/AppData/Roaming/.openmodelica/libraries/.

[98] 13:49:43 Translation Error Class SimpleHouse not found in scope .

[99] 13:49:43 Translation Error Class SimpleHouse not found in scope .

Not sure about these errors, maybe they are not that important.

[100] 13:49:43 Translation Warning [IDEAS.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3: 2:1-105:25]: Pure function ‘IDEAS.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3‘ contains a call to impure function ‘Modelica.Utilities.Streams.readLine‘.

@Mathadon according to the latest rules regarding pure/impure functions I guess you should declare getHeaderElementTMY3 as impure, since it depends on externally loaded data. This ensures the compiler deals with it properly.

Mathadon commented 3 years ago

@YashwanthVellala your code contains

[98] 13:49:43 Translation Error
Class SimpleHouse not found in scope .

[99] 13:49:43 Translation Error
Class SimpleHouse not found in scope .

I think you need to use translateModelFMU(IDEAS.Fluid.Examples.SimpleHouse) or translateModelFMU("IDEAS.Fluid.Examples.SimpleHouse") instead of translateModelFMU(SimpleHouse)

Mathadon commented 3 years ago

BTW, we are implementing a very nice tool to help you in this case, based on the theory explained in this paper, it should be available later this autumn, at least as an experimental feature. @Mathadon, this could also be interesting for you.

@casella thanks for this info! In my experience we don't often have initial guess problems if the equations are well-defined, unless perhaps for highly non-linear systems. E.g. the sudden closing of a value can cause the initial guess for a flow network to be completely off and can result in numerical problems. Would this tool indicate what equation/variable is the one that is causing problems?

YashwanthVellala commented 3 years ago

Thank you for the reference to the paper. I will go through it.

YashwanthVellala commented 3 years ago

@Mathadon I think you need to use translateModelFMU(IDEAS.Fluid.Examples.SimpleHouse) or translateModelFMU("IDEAS.Fluid.Examples.SimpleHouse") instead of translateModelFMU(SimpleHouse) ---> didn't work

Mathadon commented 3 years ago

I’m pretty sure you’d get different errors though since the error message seemed quite clear about what the problem is?

casella commented 3 years ago

On a more general note, there are already at least a dozen differente issues in this ticket, which makes it a bit unmanageable if they are not solved overnight.

I would suggest to open separate ones for each issue with a clear title that refers to that.

Thanks!

casella commented 3 years ago

@casella thanks for this info! In my experience we don't often have initial guess problems if the equations are well-defined,

I guess that's because you don't need to initialize your models in steady-state. In the field of power plant modelling, you normally do, and it's quite a pain.

unless perhaps for highly non-linear systems. E.g. the sudden closing of a value can cause the initial guess for a flow network to be completely off and can result in numerical problems. Would this tool indicate what equation/variable is the one that is causing problems?

Absolutely 😃

YashwanthVellala commented 3 years ago

@Mathadon can you see the original issue @Kanchn12345 reported earlier is fixed at the earliest ?

casella commented 3 years ago

@casella the error

[8] 18:01:35 Translation Error
[IDEAS.Buildings.Components.Shading.Overhang: 11:3-13:52]: Type mismatch in binding ‘wLeft = {0.5, 4.5}‘, expected array dimensions [], got [2].

Seems to be caused by the code

  extends IDEAS.Buildings.Validation.BaseClasses.Structure.Bui600(win(
        redeclare replaceable IDEAS.Buildings.Components.Shading.Overhang
        shaType(
        each hWin=2.0,
        each wWin=3.0,
        each dep=1.0,
        each gap=0.35,
        wLeft={0.5,4.5},
        wRight={4.5,0.5})));

where win is declared as an array of components

  IDEAS.Buildings.Components.Window[2] win(
    final A={6,6},
    redeclare final parameter IDEAS.Buildings.Validation.Data.Glazing.GlaBesTest glazing,
    final inc={IDEAS.Types.Tilt.Wall,IDEAS.Types.Tilt.Wall},
    azi={aO+IDEAS.Types.Azimuth.S,aO+IDEAS.Types.Azimuth.S},
    redeclare replaceable IDEAS.Buildings.Components.Shading.None shaType,
    redeclare final parameter IDEAS.Buildings.Data.Frames.None fraType,
    each frac=0)

The purpose of wLeft={0.5,4.5}, is to assign a different value of wLeft to each instance of win. As far as I can tell, the syntax is correct (edit: except for missing 'each', solved in 9293da0). But perhaps the standard does not permit such assignments for a replaceable?

I'm not sure. When you instantiate arrays, you can modify individual values of elements (e.g. parameters) by passing arrays of values with the same dimension of the array, or by adding 'each'. However, in this case you are redeclaring a replaceable element; what I understand is that you cannot redeclare individual elements of an array to have different types, they all need to have the same type. So, I would expect that 'each' was not required here, but on the other hand all shaTypes in the array should be the same.

We should ask this question to @perost when he comes back from his vacation mid-August.

Mathadon commented 3 years ago

On a more general note, there are already at least a dozen differente issues in this ticket, which makes it a bit unmanageable if they are not solved overnight.

I would suggest to open separate ones for each issue with a clear title that refers to that.

Thanks!

That's a fair suggestion. Focussing on a quick solution for now :)

Mathadon commented 3 years ago

@Mathadon can you see the original issue @Kanchn12345 reported earlier is fixed at the earliest ?

I pushed a workaround by no longer using the (possibly) incorrect syntax in that example. Can you test the code in the pull request?

Just to be clear. I fix these issue on my spare time, which I'll prioritise myself :)

Mathadon commented 3 years ago

@casella the error

[8] 18:01:35 Translation Error
[IDEAS.Buildings.Components.Shading.Overhang: 11:3-13:52]: Type mismatch in binding ‘wLeft = {0.5, 4.5}‘, expected array dimensions [], got [2].

Seems to be caused by the code

  extends IDEAS.Buildings.Validation.BaseClasses.Structure.Bui600(win(
        redeclare replaceable IDEAS.Buildings.Components.Shading.Overhang
        shaType(
        each hWin=2.0,
        each wWin=3.0,
        each dep=1.0,
        each gap=0.35,
        wLeft={0.5,4.5},
        wRight={4.5,0.5})));

where win is declared as an array of components

  IDEAS.Buildings.Components.Window[2] win(
    final A={6,6},
    redeclare final parameter IDEAS.Buildings.Validation.Data.Glazing.GlaBesTest glazing,
    final inc={IDEAS.Types.Tilt.Wall,IDEAS.Types.Tilt.Wall},
    azi={aO+IDEAS.Types.Azimuth.S,aO+IDEAS.Types.Azimuth.S},
    redeclare replaceable IDEAS.Buildings.Components.Shading.None shaType,
    redeclare final parameter IDEAS.Buildings.Data.Frames.None fraType,
    each frac=0)

The purpose of wLeft={0.5,4.5}, is to assign a different value of wLeft to each instance of win. As far as I can tell, the syntax is correct (edit: except for missing 'each', solved in 9293da0). But perhaps the standard does not permit such assignments for a replaceable?

I'm not sure. When you instantiate arrays, you can modify individual values of elements (e.g. parameters) by passing arrays of values with the same dimension of the array, or by adding 'each'. However, in this case you are redeclaring a replaceable element; what I understand is that you cannot redeclare individual elements of an array to have different types, they all need to have the same type. So, I would expect that 'each' was not required here, but on the other hand all shaTypes in the array should be the same.

We should ask this question to @perost when he comes back from his vacation mid-August.

If that is correct then we indeed made an error against the specification but perhaps this is just a corner case that is not supported yet in OM? It would be great if @perost could clarify this. We can revise the model to avoid this construction if it would be needed. In any case I pushed a workaround for now.

YashwanthVellala commented 3 years ago

@Mathadon Thanks a lot ! this is working now. i could simulate simplehouse example in IDEAS/Fluid.

thanks ! I still havent figured out how to export FMU from OpenModelica, its still giving the same error.

Mathadon commented 3 years ago

Aha, this I did not spot last time:

C:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources/getTimeSpan.h:11:10: fatal error: 'ModelicaUtilities.h' file not found
#include <ModelicaUtilities.h>
^~~~~~~~~~~~~~~~~~~~~

@casella as far as I know this file should be provided by OpenModelica? Any idea why it is not found?

@YashwanthVellala you can try to search the openmodelica directories for this file and manually add the containing directory to your PATH variable..

casella commented 3 years ago

Aha, this I did not spot last time:

C:/Users/E485898/Downloads/IDEAS-1225_XiSat/IDEAS-1225_XiSat/IDEAS/Resources/C-Sources/getTimeSpan.h:11:10: fatal error: 'ModelicaUtilities.h' file not found
#include <ModelicaUtilities.h>
^~~~~~~~~~~~~~~~~~~~~

Yeah, sorry, I indeed spotted it myself yesterday, but then got carried away.

I tried the following MWE

model TestModelicaUtilities
  function f
    input Real x;
    output Real y;
  external "C";
  annotation(Include="
    double f(double x)
    {
      if (x > 0.5)
        ModelicaError(\"Too large x\");
      return 2*x;
    }
  ");
  end f;
  Real x;
equation
  x = f(time);
end TestModelicaUtilities;

which works fine without the need of any # includestatement. I guess the Modelica environment adds it automatically (from the appropriate path) when it is compiling the C source code of external functions.

In fact #include <xxx.h> is reserved for standard system headers defined by the C compiler, but ModelicaError.h is not a standard header like stdio.h or math.h, so obviously the compiler complains it doesn't find it.

As I understand it, you need #include "somepath/ModelicaError.h" in your source code if you want to compile a binary library separately and then have it linked at compile time with the OMC generated code. Otherwise, you don't need the include statement at all.

Mathadon commented 3 years ago

@YashwanthVellala I have pushed a change that removes the include. Can you try again?

Kanchan-Aggarwal commented 3 years ago

@Mathadon I tried simulating the AHU example using the latest changes made by you. I am still getting this error "10:22:47 Translation Error [IDEAS.Buildings.Components.Interfaces.ZoneInterface: 96:5-101:36]: cardinality may only be used in the condition of an if-statement/equation or an assert."

Please look in to the issue.

Thanks

Mathadon commented 3 years ago

This piece of code seems to be the culprit:

  for i in 1:nPorts loop
    assert(cardinality(ports[i])<=2,
      "Each element of ports should have zero or one external connections but " +
      getInstanceName() +".ports[" + String(i) + "] has " + String(cardinality(ports[i]) - 1) + "." +
      " This can cause air to mix at the fluid port, without entering the zone, which is usually unintended.
      Instead, increase nPorts and create a separate connection.",
      level=AssertionLevel.warning);
  end for;

These cardinality operator is used within an assert so I don't see what the problem is but possibly the translator detects String(cardinality(ports[i]) - 1) as being problematic. I revised this term. Can you try again?

casella commented 3 years ago

Section 3.7.4.3 of the specification says:

cardinality should only be used in the condition of assert and if-statements

@Mathadon I guess you should remove any reference to cardinality in the message string with something like "too many".

Mathadon commented 3 years ago

@casella thanks! Upon re-reading the error it is indeed quite specific about what is wrong. I just overlooked the wording. I figured it would be something like that so my fix 44016c6 of before should work.

Mathadon commented 3 years ago

For the record: I'm a big fan of the cardinality() operator and it would be a pity if it were to be removed.

casella commented 3 years ago

For the record: I'm a big fan of the cardinality() operator and it would be a pity if it were to be removed.

You should open a ticket here and explain what are your motivations and why you think it would be difficult to remove.

This operator has been deprecated for like 15 years, which is a bit pointless IMHO. Three years ago there were some clarifications in the spec, see #1409 but it remained deprecated nevertheless, which is even more pointless.

We should probably just face the fact that people use it and keep it there indefinitely. Feel free to open a ticket, if you mention me I can back it up.

YashwanthVellala commented 3 years ago

@Mathadon any new release to check if the model works ? (1) AHU model and (2) the FMU cant be exported.

YashwanthVellala commented 3 years ago

@casella @Mathadon the FMU is a larger issue ? I cant export any example model as an FMU. not with any of the existing commands mentioned in the documentation.