Open jelemer opened 7 years ago
Hi Jelmer,
The first family of error of missing viscosity models is, as the error says, because a viscosity model does not exist. What fluid(s) do you get this error for? As you can see in http://www.coolprop.org/fluid_properties/PurePseudoPure.html#list-of-fluids there are quite a few fluids for which no viscosity model is available. In some cases we have just not implemented it yet, in others, there is no model in the literature.
Stupid question: are the units all the same? Enthalpies in molar or mass basis?
Hi @jelemer ,
So there is not viscosity model for D4, hence the error.
To go around this, you should add the option calc_transport=false
which will disable the computation of viscosity.
The other issue seems to be related to the flash routine, I'll have to investigate what's happening here. As Ian said, better check in which units Modelica is working.
@ibell @jowr Should calc_transport=true
be the default option? Should we have a more clever choice automatically checking if a viscosity model is available? For instance outputting a warning that calc_transport
has automatically been set to false if the model is set without any specification from the user on calc_transport
?
Thank you for the quick feedback, I added the calc_transport=0 to the substanceNames and this worked. I was a bit confused about this error I must say, since I only use thermodynamic properties in my model and no transport properties.
Regarding the other part, I am not sure how to set the units in ExternalMedia, but I checked the result for Ethanol, which is working, and the temperature was the same both for the Python script and the Modelica model, indicating that the input has the same units. Are there any other things I can do to test this issue?
@jelemer I understand that it can be confusing, that's why I asked to Ian and Jorrit if this may be a good idea to set to disable by default.
For the methanol case, I'll have to investigate more.
Thanks for the feedback and I will wait for the Methanol case. If there is anything I can do to assist in the investigation, please let me know.
Hello again,
I have encountered some issues by setting the calc_transport=0. Since ExternalMedia returns a NaN when this option is turned off, I get the following error in Modelica:
cycle.evaporator.side1.medium_out.staterec2.1.lambda >= 0.0 The following error was detected at time: 0 Value is: -1.#IND Non-linear solver will attempt to handle this problem.
I did a quick fix by changing the following code in coolpropsolver.cpp:
properties->eta = NAN;
properties->lambda = NAN;
to
properties->eta = 0.0;
properties->lambda = 0.0;
Your error message indicates that you use the transport properties for a calculation. If not, your Modelica code should ignore the NAN values.
Well, I do not do any calculations using transport properties in my code. It might be that they are initialized somewhere and I have not properly switched them off. What I do now is to set calc_transport=0 in the substanceNames when I initialize my CoolPropMedium. Are there any other options I have to set to make sure that Modelica does not include any transport properties?
@jowr Based on your previous comment, I investigated the problem a bit more. I am running Dymola using the Python interface. One of the options I added when I run the model is
Advanced.AssertAllInsideMinMax=true
Setting this option to false, solved this problem. Thanks for the help.
Great, I am happy to hear that it worked. I hope our comments helped a little, but you basically solved this yourself :-)
Sorry for the confusion, but although my issues with the transport properties are now solved, I still have the issue regarding the flash routine. This issue unfortunately does not only occur for Methanol, but also for other fluids. Do you have any suggestion how to fix or even debug this?
You are using p and T as state variables, but you call with p and h - the solver internally tries to find the correct T to match your provided h and maybe changing ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.pT
to something like ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph
helps?
Unfortunately that did not help, I do use that declaration in my original model, but I left it out for the simple model I presented here. I also tried giving p and T as input with ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.pT
, but this also did not work.
Maybe you can enable the debug output and post the logs here? There is an example in ExternalMedia...
@jowr I have been trying to figure out which example you were referring to, but I am not sure what you mean. The logs in Dymola show no more than the error I previously presented: options.T is not valid in saturation_P_pure_1D_T
.
I have also seen that you can set the debug level for the CoolPropMedium with the flag debug=x
and the flag works, however, there is no information written to std::cout when I run the model, probably due to how Dymola handles this. Could you be a bit more specific about how to enable the debug output or which example you are referring to?
The simplified model that I am currently using is given below.
model TestEM
constant String s = ExternalMedia.Common.CheckCoolPropOptions("Methanol|calc_transport=0|debug=100", debug=false);
package Medium = ExternalMedia.Media.CoolPropMedium (
substanceNames = {s},
ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
AbsolutePressure(start=1e5),
SpecificEnthalpy(start=1e5));
Medium.BaseProperties props;
equation
props.p = 1e5;
props.h = 1e5;
end TestEM;
Oh by the way, when I add the option to use tabulated values (enable_TTSE=1
) the code above works as well as my own simulations.
After translating the model, you get a file called dymosim.exe
. This file can be called from the command line and for your example, I get the following output:
dymosim.exe started
Runtime license not available, trying to check out the Dymola Standard license instead.
... "dsin.txt" loading (dymosim input file)
calc_transport has the value of 0
debug has the value of 1000
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
Check passed, reducing Methanol|calc_transport=0|debug=1000|enable_TTSE=0|enable_BICUBIC=0|enable_EXTTP=1|twophase_derivsmoothing_xend=0.0|rho_smoothing_xend=0.0 to fluid Methanol, with HEOS backend.
Setting constants for fluid Methanol
Setting near-critical saturation conditions for fluid Methanol
setSat_p(8.2076341500000004e+006)
options.T is not valid in saturation_P_pure_1D_T
Press the Stop button in Dymola to end the simulation!
The code obviously gets stuck during initialization and I tried to change your example to exclude the BaseProperties, which are known to give problems under certain circumstances, but also this code fails:
model TestEM
constant String s = ExternalMedia.Common.CheckCoolPropOptions("Methanol|calc_transport=0|debug=100", debug=false);
package Medium = ExternalMedia.Media.CoolPropMedium (substanceNames = {s});
Medium.ThermodynamicState state;
Medium.AbsolutePressure p(start=1e5);
Medium.SpecificEnthalpy h(start=1e5);
Medium.Density d;
equation
p = 1e5+1e5*time;
h = 1e5+1e5*time;
state = Medium.setState_ph(p,h);
d = Medium.density(state);
end TestEM;
It looks like the near critical state causes some problems...
Ah yes, when I run the dymosim.exe I get the same output. So is there any way to get around this? As for now I can use the workaround using the tabulated values.
I just wanted to express my appreciation for all the help so far, this helped me a lot and although the issue is not completely solved yet, I now have a way to run my models.
Hello,
Let me start by saying that I appreciate the work done by you on the ExternalMedia library. I am a PhD student at Chalmers University and I am using ExternalMedia to couple my Modelica models to the CoolProp database, with purpose of calculating properties in organic Rankine cycles and similar power cycles for waste heat recovery in automotive applications. For some fluids this works perfectly, but for other fluids there are some issues that I am not able to solve, so maybe you can help me here.
Basically there are two main errors I get depending on the fluid, I will give two examples here. First example is the fluid D4, which gives the following error: _The following error was detected at time: 0 Viscosity model is not available for this fluid The stack of functions is: setState_ph_Unique6 setState_phUnique6(100000.0, 100000.0, 0) Error: Failed to start model.
Another example is Methanol, which gives: _The following error was detected at time: 0 options.T is not valid in saturation_P_pure_1D_T The stack of functions is: getMolarMass_Unique2 getMolarMassUnique2() Error: Failed to start model.
I reproduced these errors in a very simple model:
The weird thing is, that these fluids work in a Python script if I call CoolProp directly with the same input:
I downloaded the latest version of ExternalMedia from github and compiled it using one of the bat files available. Do you have any suggestion what is going wrong here? If you need any more info regarding this or if something is unclear, please let me know.
Kind regards,
Jelmer Rijpkema
System info: ExternalMedia version: 3.2.1 CoolProp version: 6.1.1dev Environment: Dymola OS: Windows 7