Skip to content

Fixed PartialSimpleIdealGasMedium.setState_psX#294

Merged
CorentinLepais merged 2 commits into
DLR-SR:mainfrom
RaphaelGebhart:291_PartialSimpelIdealGasMedium
Apr 28, 2026
Merged

Fixed PartialSimpleIdealGasMedium.setState_psX#294
CorentinLepais merged 2 commits into
DLR-SR:mainfrom
RaphaelGebhart:291_PartialSimpelIdealGasMedium

Conversation

@RaphaelGebhart
Copy link
Copy Markdown
Collaborator

@RaphaelGebhart RaphaelGebhart commented Feb 27, 2026

Regression test passed.

CorentinLepais
CorentinLepais previously approved these changes Mar 10, 2026
Copy link
Copy Markdown
Contributor

@CorentinLepais CorentinLepais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was indeed a small error in the formula, even if the results do not change. From a physics point of view, I would have written it like below to keep the exponential without unit and to make more obvious that it calculates a temperature :
reference_T*exp(s/cp_const +R_gas/cp_const*Modelica.Math.log(p/reference_p))

Since this error is also in the MSL, should an issue be created in the MSL repository?

@RaphaelGebhart RaphaelGebhart linked an issue Mar 10, 2026 that may be closed by this pull request
@RaphaelGebhart
Copy link
Copy Markdown
Collaborator Author

RaphaelGebhart commented Mar 10, 2026

Yes i already created one: modelica/ModelicaStandardLibrary#4749

And yes Im also in favor of the version you suggested. Lets chose this one. I will run a regression test with the new version.

@RaphaelGebhart
Copy link
Copy Markdown
Collaborator Author

RaphaelGebhart commented Apr 28, 2026

Regression test passed.

@CorentinLepais could you briefly check out the branch and confirm everything looks good (e.g, with the example below)?

model PartialSimleIdealGasMediumTest "Checks Modelica.Media.Air.SimpleAir.setState_psX"

  replaceable package Medium = ThermofluidStream.Media.myMedia.Air.SimpleAir;
  Medium.AbsolutePressure p=pressureSawTooth.y;
  Medium.Temperature T=temperatureSawTooth.y;
  Medium.SpecificEntropy s = Modelica.Media.Air.SimpleAir.specificEntropy_pTX(p,T, Medium.X_default);
  Medium.ThermodynamicState state = Medium.setState_psX(p,s); // This requires modification
  Medium.Temperature T1 = Medium.temperature_ps(p,s);

  Boolean check = abs(T-T1) < Modelica.Constants.eps; // Check passed

  Modelica.Blocks.Sources.SawTooth pressureSawTooth(
    amplitude=2e5,
    period=0.5,
    offset=0.5e5,
    startTime=0.1) annotation (Placement(transformation(extent={{-10,12},{10,32}})));
  Modelica.Blocks.Sources.SawTooth temperatureSawTooth(
    amplitude=200,
    period=0.5,
    offset=273.15,
    startTime=0.2) annotation (Placement(transformation(extent={{-10,-30},{10,-10}})));

end PartialSimleIdealGasMediumTest;

If you approve, we can proceed with the merge.

I also created a pull request for the MSL: modelica/ModelicaStandardLibrary#4782

@CorentinLepais CorentinLepais merged commit 39cf33a into DLR-SR:main Apr 28, 2026
4 checks passed
@RaphaelGebhart RaphaelGebhart deleted the 291_PartialSimpelIdealGasMedium branch April 29, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ThermofluidStream.Media.myMedia.Interfaces.PartialSimpleIdealGasMedium.setState_psX

2 participants