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

Problem with the function setState_phX #4209

Open
congtoantran opened this issue Oct 20, 2023 · 5 comments · Fixed by #4263
Open

Problem with the function setState_phX #4209

congtoantran opened this issue Oct 20, 2023 · 5 comments · Fixed by #4263
Assignees
Labels
bug Critical/severe issue L: Media Issue addresses Modelica.Media V: 4.0.0 Issue originates in MSL v4.0.0 (and is not present in earlier releases) V: 4.1.0-dev Issue originates in MSL v4.1.0-dev (and is not present in earlier releases)
Milestone

Comments

@congtoantran
Copy link

congtoantran commented Oct 20, 2023

I have a library which works well on Modelica 3.3.2, but when converted to Modelica 4.0.0, it doesn't work anymore, and the message error is "Non-real equation in continuous time are not legal:".

I'm trying to understand the problem by using a very simple example (see below):

model model1a
  replaceable package Medium = Modelica.Media.R134a.R134a_ph "Medium model" 
    annotation (choicesAllMatching=true);
  Medium.ThermodynamicState state_a ;
  Modelica.Units.SI.AbsolutePressure p=Medium.p_default;
  Modelica.Units.SI.SpecificEnthalpy h=Medium.h_default;

equation 
  state_a = Medium.setState_phX(Medium.p_default, Medium.h_default);
  //     state_a = Medium.setState_phX(p, h);
end model1a;

The above model runs sucessfully. But when I redefine the variable state_a by using the second line in the equation part, the model does not work and the error is :

  Non-real equation in continuous time are not legal:
  state_a.phase = Modelica.Media.R134a.R134a_ph.getPhase_ph(p, h);

Any help to understand the error? Many thanks. I use Dymola 2021, Modelica 4.0.0

@beutlich
Copy link
Member

beutlich commented Jan 13, 2024

@HansOlsson I can reproduce in Dymola 2024x, but not in SimulationX 4.4. Is it a tool-issue (of one of the tools)?

It works though (in both tools) if the variability is changed to parameter.

model Model1b
  replaceable package Medium = Modelica.Media.R134a.R134a_ph "Medium model"
    annotation (choicesAllMatching=true);
  Medium.ThermodynamicState state_a;
  parameter Modelica.Units.SI.AbsolutePressure p=Medium.p_default;
  parameter Modelica.Units.SI.SpecificEnthalpy h=Medium.h_default;

equation 
  //state_a = Medium.setState_phX(Medium.p_default, Medium.h_default);
  state_a = Medium.setState_phX(p, h);
end Model1b;

@beutlich beutlich added tool-issue Issue targets a specific Modelica tool only L: Media Issue addresses Modelica.Media labels Jan 13, 2024
@HansOlsson
Copy link
Contributor

I would say it is a library issue that can be corrected.

The issue is that this record has a Boolean member (phase), and a Boolean equation requires that both sides are discrete-time valued, section 3.8.4.

The correction would be that the phase-functions get inlined with events.

HansOlsson added a commit to HansOlsson/Modelica that referenced this issue Jan 15, 2024
@HansOlsson HansOlsson removed the tool-issue Issue targets a specific Modelica tool only label Jan 15, 2024
beutlich pushed a commit to HansOlsson/Modelica that referenced this issue Jan 18, 2024
HansOlsson added a commit to HansOlsson/Modelica that referenced this issue Jul 2, 2024
@casella casella closed this as completed in 54f4a7a Jul 2, 2024
@casella casella added the bug Critical/severe issue label Jul 2, 2024
@casella casella added this to the MSL4.1.0 milestone Jul 2, 2024
@casella
Copy link
Contributor

casella commented Jul 2, 2024

I checked @HansOlsson's pull request PR #4263 and it looks good to me.

@arunkumar-narasimhan please back-port this to maint/4.1.0

@casella casella reopened this Jul 2, 2024
@casella casella added V: 4.1.0-dev Issue originates in MSL v4.1.0-dev (and is not present in earlier releases) V: 4.0.0 Issue originates in MSL v4.0.0 (and is not present in earlier releases) and removed V: 4.0.0 Issue originates in MSL v4.0.0 (and is not present in earlier releases) labels Jul 2, 2024
@casella
Copy link
Contributor

casella commented Jul 2, 2024

This issue is actually a regression from v.4.0.0 but I also marked it with the 4.1.0-dev label so we don't forget about it

@casella
Copy link
Contributor

casella commented Sep 10, 2024

@Esther-Devakirubai please back-port this to maint/4.1.x, then you can close this ticket. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Critical/severe issue L: Media Issue addresses Modelica.Media V: 4.0.0 Issue originates in MSL v4.0.0 (and is not present in earlier releases) V: 4.1.0-dev Issue originates in MSL v4.1.0-dev (and is not present in earlier releases)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants