Open ferrucci-franco opened 1 year ago
Info: I think the error I showed before is thrown by line 650 of coolpropsolver.cpp
(function CoolPropSolver::makeDerivString
):
long iOutput = CoolProp::get_parameter_index(derivTerm.c_str());
Going into CoolProp code, the exception shown in Modelica comes from CoolProp function get_parameter_index()
(see here).
The exception is thrown since function is_valid_parameter()
(see is_valid_parameter) returns 0.
Apparently, is_valid_parameter()
cannot handle an input like dpdT|h
.
In any case, in order to compute the partial derivative, coolpropsolver.cpp
then uses the function double CoolProp::AbstractState::keyed_output(...)
(see line 624 of coolpropsolver.cpp
), which, I think, cannot handle partial derivatives parameters as inputs (see function here).
Would it be possible for coolpropsolver.cpp
to implement TwoPhaseMedium_partialDeriv_state_C_impl()
in the following way?:
CoolPropSolver::partialDeriv_state()
, call Coolprop function CoolProp::get_parameter_index()
for parameters of
, wrt
and cst
to get the corresponding valid parameters (listed in CoolProp::parameters
, such as iT
, iP
, iHmass
, etc.).CoolProp::AbstractState::first_partial_deriv()
(see here).Thanks again,
Franco
@ferrucci-franco I won't have time to look into this until September. If you want to experiment and find a working solution, please open a pull request. Thanks!
Hi there,
I'm trying to use the function
partialDeriv_state
to compute an arbitrary partial derivative. For that, I have created the following test model:In this code, if I uncomment the variable
my_der
as well as the linemy_der = Medium.partialDeriv_state(of="d", wrt="T", cst="p", state=state);
, OpenModelica creates the corresponing EXE file but the simulation stops with the following error:I tried to look inside the C++ files
TestPartialDeriv.c
andTestPartialDeriv_functions.c
to track the error. It looks like there is a problem when calling the functionTwoPhaseMedium_partialDeriv_state_C_impl
from the ExternalMediaDLL
file (maybe the argument is wrong?).Thanks in advance,
Franco