modelica-3rdparty / ExternalMedia

The ExternalMedia library provides a framework for interfacing external codes computing fluid properties to Modelica.Media-compatible component models.
53 stars 36 forks source link

Using ExternalMedia to access RefProp via CoolProp #48

Open patrick-fourspring-nnl opened 2 years ago

patrick-fourspring-nnl commented 2 years ago

We welcome any suggestions for the following issue using External Media (v3.3.0) within OpenModelica (runing Modelica v3.2.3):


The following Modelica code works:

model CoolPropTest

package Medium = 
ExternalMedia.Media.CoolPropMedium(
mediumName = "Water");

Medium.AbsolutePressure p1 = 8e6;
Medium.SpecificEnthalpy h1 = 1.0e5;

Medium.Density d;

equation

d = Medium.density_ph(p1, h1, 0);

end CoolPropTest;


Using the same code to access RefProp does not work

model CoolPropTest

package Medium = 
ExternalMedia.Media.CoolPropMedium(
mediumName = "REFPROP::Water");

Medium.AbsolutePressure p1 = 8e6;
Medium.SpecificEnthalpy h1 = 1.0e5;

Medium.Density d;

equation

d = Medium.density_ph(p1, h1, 0);

end CoolPropTest;

error Code:

calc_transport has the value of 1 TTSE is off enable_TTSE has the value of 0 BICUBIC is off enable_BICUBIC has the value of 0 enable_EXTTP has the value of 1 twophase_derivsmoothing_xend has the value of 0.0 rho_smoothing_xend has the value of 0.0 debug has the value of 0

This backend does not implement calc_specify_phasefunction simulation terminated by an assertation at initialization Simulation process failed. Exited with code -1.


Thanks, Patrick

jowr commented 2 years ago

The latest release of ExternalMedia helped with this problem, but there are still a few things that do not work with REFPROP. Sorry.

patrick-fourspring-nnl commented 2 years ago

Thanks, Jorrit. Please excuse my misunderstanding of the source of the problem. Patrick

From: Jorrit Wronski @.> Sent: Thursday, February 17, 2022 6:37 AM To: modelica-3rdparty/ExternalMedia @.> Cc: Fourspring, Patrick (Contractor) @.>; Author @.> Subject: [EXTERNAL SENDER] Re: [modelica-3rdparty/ExternalMedia] Using ExternalMedia to access RefProp via CoolProp (Issue #48)

The latest release of ExternalMedia helped with this problem, but there are still a few things that do not work with REFPROP. Sorry.

— Reply to this email directly, view it on GitHubhttps://urldefense.us/v3/__https:/github.com/modelica-3rdparty/ExternalMedia/issues/48*issuecomment-1042858230__;Iw!!DpXkFSQVhDe0Sg!fxVwqD5JxvQdispdjnRkDhiRP69gqzGLoODq47OOPV4bGrzMErpQTkblJVtPEdYACg0w1qRCXg$, or unsubscribehttps://urldefense.us/v3/__https:/github.com/notifications/unsubscribe-auth/AUCT66T7WGPAWAMVBXVGLZTU3TMVHANCNFSM5KVEQR3Q__;!!DpXkFSQVhDe0Sg!fxVwqD5JxvQdispdjnRkDhiRP69gqzGLoODq47OOPV4bGrzMErpQTkblJVtPEdYACg2BfjvE9g$. Triage notifications on the go with GitHub Mobile for iOShttps://urldefense.us/v3/__https:/apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!DpXkFSQVhDe0Sg!fxVwqD5JxvQdispdjnRkDhiRP69gqzGLoODq47OOPV4bGrzMErpQTkblJVtPEdYACg0q_icEEQ$ or Androidhttps://urldefense.us/v3/__https:/play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!DpXkFSQVhDe0Sg!fxVwqD5JxvQdispdjnRkDhiRP69gqzGLoODq47OOPV4bGrzMErpQTkblJVtPEdYACg2DQFOv3w$. You are receiving this because you authored the thread.Message ID: @.**@.>>

freundlicherDon commented 2 years ago

I have a similar problem when using Dymola 2022x. I tested both the master branch with Modelica 3.3.1 as well as v4-dev with Modelica 4.0.0 and could run Test.CO2.TestStatesSupercritical sucessfully with a compiled STATIC Library of External Media (made with cmake and VS2019). However, when I change the substance name in Examples.CO2CoolProp to substanceNames = {"REFPROP-CO2"}

I get the following error in both cases: calc_first_saturation_deriv is not implemented for this backend

I have installed RefProp 10 on my computer under C:/program files/REFPROP. (I successfully used this REFPROP installation with older external media version under Dymola 2019).

casella commented 2 years ago

We are currently working to solve several issues with the dynamic/shared library, see #50. As soon as that thing is stabilized, we can get back to this issue.

shjiang commented 1 year ago

I had the same problem.

shjiang commented 1 year ago

I have made some changes on the ExternalMedia library, and it works now for me, with MSL4.0, vs 2019, and dymola 2023. The ThermoCycle library works as well. I have placed the codes with the below link. Hopes it helps. https://github.com/shjiang/ThermoCycle-ExternalMedia I hope that your question is solved @patrick-fourspring-nnl, as I have made several tests.

casella commented 1 year ago

@patrick-fourspring-nnl we have now fixed a lot of issues with ExternalMedia, and we're going to release 3.3.2 and 4.0.0 anytime soon. I'm not sure about the REFPROP interface, because I don't have it installed on my PC so I can't test that.

thorade commented 1 year ago

I tested today, with the release v4.0.0 and RefProp 10, and below code works for me on Windows 11.

  package Medium
    extends ExternalMedia.Media.CoolPropMedium(
      mediumName = "REFPROP::Pentane",
      substanceNames = {"n-Pentane"},
      inputChoice=ExternalMedia.Common.InputChoice.ph);
  end Medium;
patrick-fourspring-nnl commented 1 year ago

Thanks Matthis.

Patrick

From: Matthis Thorade @.> Sent: Thursday, November 2, 2023 4:14 AM To: modelica-3rdparty/ExternalMedia @.> Cc: Fourspring, Patrick (Contractor) @.>; Mention @.> Subject: [EXTERNAL SENDER] Re: [modelica-3rdparty/ExternalMedia] Using ExternalMedia to access RefProp via CoolProp (Issue #48)

I tested today, with the release v4.0.0 and RefProp 10, and below code works for me on Windows 11.

package Medium

extends ExternalMedia.Media.CoolPropMedium(

  mediumName = "REFPROP::Pentane",

  substanceNames = {"n-Pentane"},

  inputChoice=ExternalMedia.Common.InputChoice.ph);

end Medium;

— Reply to this email directly, view it on GitHubhttps://urldefense.us/v3/__https:/github.com/modelica-3rdparty/ExternalMedia/issues/48*issuecomment-1790258634__;Iw!!DpXkFSQVhDe0Sg!PZpnFr93AbPfa0wg5W0swcKUyMj14OgqfhDDg3Ppn22qNNbhx0nCM1HuYHeKcF6HRh9fIBj_Gu5JypN0iNqcdqFFdi3TCt31-_c$, or unsubscribehttps://urldefense.us/v3/__https:/github.com/notifications/unsubscribe-auth/AUCT66UL7C5EDHOSUB7TU4LYCNI57AVCNFSM5KVEQR32U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZZGAZDKOBWGM2A__;!!DpXkFSQVhDe0Sg!PZpnFr93AbPfa0wg5W0swcKUyMj14OgqfhDDg3Ppn22qNNbhx0nCM1HuYHeKcF6HRh9fIBj_Gu5JypN0iNqcdqFFdi3T72KTDIg$. You are receiving this because you were mentioned.Message ID: @.**@.>>

thorade commented 8 months ago

I tested again today, and this is the new model:

  package Medium
    extends ExternalMedia.Media.CoolPropMedium(
      mediumName = "Pentane any string can go here",
      substanceNames = {"REFPROP::Pentane"},
      inputChoice=ExternalMedia.Common.InputChoice.ph);
  end Medium;

in mediumName, you can put whatever descriptive string you like, but substanceName is where you would have to put the REFPROP:: thing, and if you put it there, it gives an error message:

Error: The following error was detected at time: 0
ExternalMedia error: calc_first_saturation_deriv is not implemented for this backend
The stack of functions is:
ExternalMedia.Examples.CO2CoolPropRefProp.setSat_T_Unique32
ExternalMedia.Examples.CO2CoolPropRefProp.setSat_T_Unique32(T2)
thorade commented 8 months ago

That finding has also been reported here: https://github.com/CoolProp/CoolProp/issues/2013