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

Questions about function calls #82

Open
yaosssSY opened this issue Apr 25, 2023 · 0 comments
Open

Questions about function calls #82

yaosssSY opened this issue Apr 25, 2023 · 0 comments

Comments

@yaosssSY
Copy link

yaosssSY commented Apr 25, 2023

I just learned the modelica language recently, and I am currently building a mathematical model, using the externalmedia physical property library, and customizing many functions, but the following problems occurred during the running process, how to solve this situation.

Failed to differentiate the equation
T = Water.ph.T_ph(Ps, Hs*1000, 0);

in order to reduce the DAE index.

Cannot find differentiation function:
Water.ph.T_ph(Ps, Hs*1000, 0)
with respect to time

Failed to reduce the DAE index.

Here are the relevant partial functions, and what I'm guessing is the offending code.

  V1*der(Ps)=Rs*T*(Ge+Gaux+Geved-Gvo-Gn)/3600;
  rou2=Water.pT.d_pT(Ps,T,0);
  der(rou2*V1*Hs)=(Ge*He+Gaux*Haux+Geved*h1-Gvo*Hs-Gn*Hs)/3600;
function T_ph
  "Return thermodynamic state as function of p, h and phase"
    extends Modelica.Icons.Function;
    input Water.total.Medium.AbsolutePressure p "Pressure";
    input Water.total.Medium.SpecificEnthalpy h "Enthalpy";
    input Water.total.Medium.FixedPhase phase=0
    "2 for two-phase, 1 for one-phase, 0 if not known";
    output Water.total.Medium.Temperature T;
protected 
       Water.total.Medium.ThermodynamicState state;
algorithm 
  state := Water.total.Medium.setState_ph(
        p,
        h,
        phase);
     T:=state.T;
end T_ph;
function total

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

end total;

Because I used the differentiation of time, I guess that the custom function may not be able to perform related processing, and I don't know how to solve it.
Thanks in advance for your reply.

@yaosssSY yaosssSY closed this as completed May 5, 2023
@yaosssSY yaosssSY reopened this May 5, 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

1 participant