Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestState fails with assertion error on state.phase #39

Closed
bilderbuchi opened this issue Jun 25, 2021 · 6 comments
Closed

TestState fails with assertion error on state.phase #39

bilderbuchi opened this issue Jun 25, 2021 · 6 comments

Comments

@bilderbuchi
Copy link
Collaborator

bilderbuchi commented Jun 25, 2021

With ExternalMedia 3.3.0 and OM nightly (i.e. >1.17), running ExternalMedia.Test.TestMedium.TestState fails with

The following assertion has been violated at time 0.002000
state.phase >= 0 and state.phase <= 2
Variable violating min/max constraint: 0 <= state.phase <= 2, has value: 1

Note that the printed value actually complies with the required assertion range! Maybe the passed value is a string or somesuch type that fails the assertion but looks identical when printed?

I suspect that this compilation warning (also reported in #10) could be connected:

TestState_functions.c:52:65: warning: incompatible pointer types passing 'ExternalMedia_Test_TestMedium_TestState_Medium_ThermodynamicState *' to parameter of type 'ExternalThermodynamicState *' (aka 'struct ExternalThermodynamicState *') [-Wincompatible-pointer-types]
  TwoPhaseMedium_setState_ph_C_impl(_p_ext, _h_ext, _phase_ext, &_state_ext, MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp1)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp2)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp3)));
                                                                ^~~~~~~~~~~
<...>/Modelica/ExternalMedia 3.3.0/Resources/Include\externalmedialib.h:170:121: note: passing argument to parameter 'state' here
        EXTERNALMEDIA_EXPORT void TwoPhaseMedium_setState_ph_C_impl(double p, double h, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
                                                                                                                               ^
@bilderbuchi
Copy link
Collaborator Author

An equivalent problem occurs in function TwoPhaseMedium_setState_pT_C_impl (see also #10).

@bilderbuchi
Copy link
Collaborator Author

Btw, I don't know if runtests.mos is actually used, but it's missing the tests TestMedium.TestConstants, TestMedium.TestState, TestMedium.TestSat.

@bilderbuchi
Copy link
Collaborator Author

A quick re-check with OM 1.18.1 and the new ExternalMedia 3.3.1 shows that this still occurs.

@casella
Copy link
Collaborator

casella commented May 20, 2022

Probably related to OpenModelica/OpenModelica#8591.

@bilderbuchi
Copy link
Collaborator Author

bilderbuchi commented Mar 20, 2023

I checked with a recent OM nightly (1.21.0-dev-318) and current master (db55653) with binaries from the CI job, and the assertion does not print anymore.

The compilation warning still occurs:

TestState_functions.c:50:70: warning: incompatible pointer types passing 'ExternalMedia_Test_TestMedium_TestState_Medium_ThermodynamicState_external *' to parameter of type 'ExternalThermodynamicState *' (aka 'struct ExternalThermodynamicState *') [-Wincompatible-pointer-types]
  TwoPhaseMedium_setState_ph_C_impl_wrap(_p_ext, _h_ext, _phase_ext, &_state_ext, MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp1)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp2)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp3)));
                                                                     ^~~~~~~~~~~
./TestState_includes.h:13:108: note: passing argument to parameter 'state' here
    void TwoPhaseMedium_setState_ph_C_impl_wrap(double p, double h, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName)

The runtests.mos files seems heavily outdated/old, but that's probably easy to fix/not that relevant anymore.

@casella
Copy link
Collaborator

casella commented Apr 12, 2023

This should be fixed with ExternalMedia 3.3.2, if used with OMC 1.21.0 or later

@casella casella closed this as completed Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants