Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to differentiate the equation ExternalMedia.Media.CoolPropMedium.setState_ph_ #13

Closed
slamer59 opened this issue Jul 6, 2018 · 3 comments

Comments

@slamer59
Copy link

slamer59 commented Jul 6, 2018

Hello,
I have a simple model using ExternalMedia which I'm not able to debug.

It maybe a pure modelica issue but I have no idea how to solve it.

It might be a duplicate of modelica/ModelicaStandardLibrary#1575 and ibell/coolprop#61

model CO2InternalCycleSimple1
  //   package Medium = Modelica.Media.IdealGases.SingleGases.CO2 "Medium model";
  //   package Medium = Modelica.Media.R134a "Medium model";
  //  package Medium = ExternalMedia.Examples.CO2CoolProp "Medium model";
  package Medium = Media.CO2 "Medium model";
  parameter Modelica.SIunits.AbsolutePressure p_sink=6000000;

  inner Modelica.Fluid.System system(
    p_ambient=p_sink,
    T_ambient=873.15,
    m_flow_start=1e-5,
    p_start=p_sink,
    T_start=573.15)
    annotation (Placement(visible=true, transformation(extent={{56,-6},{76,14}}, rotation=0)));
  Modelica.Fluid.Machines.SweptVolume cylinder1(
    redeclare package Medium = Medium,
    T_start=system.T_start,
    p_start=system.p_start,
    use_HeatTransfer=true,
    use_portsData=false,
    use_T_start=true,
    nPorts=1,
    pistonCrossArea=Modelica.Constants.pi,
    clearance=1e-4)
              annotation (smoothOrder=20, Placement(visible=true, transformation(extent={{-34,64},{-6,36}},
          rotation=0)));

  Modelica.Thermal.HeatTransfer.Components.HeatCapacitor heatCapacitor1(C=500*25, T(start=773.15))
    annotation (Placement(visible=true, transformation(extent={{-54,50},{-34,70}}, rotation=0)));

  Modelica.Fluid.Sources.Boundary_ph  sink(
    p=p_sink,
    redeclare package Medium = Medium,
    nPorts=1)
    annotation (Placement(visible=true, transformation(extent={{98,-58},{78,-38}}, rotation=0)));
  Modelica.Mechanics.Translational.Components.Fixed
                                 fixed2(s0=1) annotation (Placement(
        transformation(extent={{-26,-10},{-6,10}})));
    annotation (Placement(transformation(extent={{-58,-74},{-38,-54}})));
initial equation 

equation 
  connect(heatCapacitor1.port, cylinder1.heatPort)
    annotation (Line(points={{-44,50},{-34,50}}, color={191,0,0}));
  // Ajout
  connect(sink.ports[1], cylinder1.ports[1])
    annotation (Line(points={{78,-48},{32,-48},{32,64},{-20,64}}, color={0,127,255}));
  connect(fixed2.flange, cylinder1.flange)
    annotation (Line(points={{-16,0},{-18,0},{-18,36},{-20,36}}, color={0,127,0}));
  annotation (
    smoothOrder=20,
    Diagram(coordinateSystem(extent={{-100,-100},{100,100}}, preserveAspectRatio=false)),
    Icon(coordinateSystem(extent={{-100,-100},{100,100}})),
    experiment(
      Interval=0.0001,
      Tolerance=1e-05,
      __Dymola_Algorithm="Radau"));
end CO2InternalCycleSimple1;

CO2 media is defined as:

package CO2 "Model for CO2"
  extends ExternalMedia.Media.CoolPropMedium(
    mediumName="CarbonDioxide",
    substanceNames={"CO2"},
    ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
    SpecificEnthalpy(start=1e5),
    AbsolutePressure(start=1e5));
  annotation (Documentation(info="<html>
http://www.coolprop.org/coolprop/Tabular.html
</html>"));
end CO2;
@jowr
Copy link
Collaborator

jowr commented Aug 4, 2021

Maybe you could tell us what the problem is? Do you get an error message? Does it crash?

If the title of this post is the error message, you can tell from it that you are using incompatible state variables. I seem to remember that the Modelica.Fluid.Machines.SweptVolume model is built around a mass and energy balance that uses density and internal energy as state variables. However, you explicitly selected pressure and enthalpy which forces the Modelica compiler to try and rearrange equations leading to the missing derivative problem...

@casella
Copy link
Collaborator

casella commented May 20, 2022

@slamer59 what about @jowr's comments? Are you still interested in this issue?

Thanks

@casella
Copy link
Collaborator

casella commented Apr 12, 2023

Didn't get any feedback. @slamer59 please reopen if you are still interested.

@casella casella closed this as completed Apr 12, 2023
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

No branches or pull requests

3 participants