-
Notifications
You must be signed in to change notification settings - Fork 16
Modelica wrapper: index reduction #61
Comments
To fix this, this is how to use BaseProperties (using density as example):
While introducing the intermediate function density_ph_state might look strange, this is the key to a) properly define the derivatives and b) avoid multiple calls to setState_ph. |
PS: Should issues regarding the Modelica wrapper be filed here at coolprop? If I wanted to fix this myself, I guess I have to fork the CoolProp2Modelica-library, right? And then send a Pull request to @jowr ? |
Hi Matthis, @ibell tries to merge CoolProp and ExternalMedia on a C++ level. I am not sure, but he might be finished already. For now, I think it is fine to report things here. As soon as we have better integration with ExternalMedia (mid November?), the best way is to follow your second suggestion and directly contact the Modelica people via Trac: https://trac.modelica.org/Modelica/query?component=_ExternalMedia . Sorry for the confusion, but I am not completely sure how to handle future bug reports myself. |
It's a work in progress. The limitation is that I don't know the Modelica On Sun, Oct 27, 2013 at 9:52 AM, jowr notifications@github.com wrote:
|
Hi, I just tried to implement @thorade's suggestions and failed... |
I forked the CoolProp2Modelica-library and did some changes, index reduction does then work as it should. You had all the tricky stuff correct, all I had to do was revert the BaseProperties back to how they were implemented in ExternalMedia: BaseProperties needs to call density_ph and so on, otherwise Dymola won't find all the annotations. You only added the derivative annotation for density_ph and specificEntropy_ph, that should be enough if ph is used as input. I also added the annotation to temperature_ph, but I don't remember wether it was really necessary. It might happen that pT is used as input, then you would have to do the same for density_pT and specificEnthalpy_pT. There was a comment about avoiding unnecessary computations, this should be handled by the Inlining annotations. So if it works as it should, you get index reduction without any disadvantages. |
Of course, the baseproperties. I forgot to change them, thanks. Regarding the rest, we have to be a little careful because CoolProp does not support as many derivatives and inverse functions as HelmholtzMedia does. Thanks again for the comments, I really appreciate that you can explain all the advanced Modelica concepts in a a nutshell. Jorrit Jorrit Wronski Technical University of Denmark phone: +45 45 25 41 83 Matthis Thorade notifications@github.com wrote: I forked the CoolProp2Modelica-library and did some changes, index reduction does then work as it should. You had all the tricky stuff correct, all I had to do was revert the BaseProperties back to how they were implemented in ExternalMedia: BaseProperties needs to call density_ph and so on, otherwise Dymola won't find all the annotations. You only added the derivative annotation for density_ph and specificEntropy_ph, that should be enough if ph is used as input. I also added the annotation to temperature_ph, but I don't remember wether it was really necessary. It might happen that pT is used as input, then you would have to do the same for density_pT and specificEnthalpy_pT. There was a comment about avoiding unnecessary computations, this should be handled by the Inlining annotations. So if it works as it should, you get index reduction without any disadvantages. — |
for a discussion see ibell/coolprop#61
I think it's done. We only have to keep our eyes open when adding new functions... |
If you set
Hidden.PrintFailureToDifferentiate=true
then you will see that simple test models like this onehave numerical Jacobians, but they still simulate. Heavier models like this one
will fail with error message
Failed to reduce the DAE index.
. This will only happen when using BaseProperties, but most models in Modelica.Fluid use them.The text was updated successfully, but these errors were encountered: