TransiEnt-official / transient-lib

official and current version of TransiEnt library
BSD 3-Clause "New" or "Revised" License
9 stars 11 forks source link

feat add the adapter Real_ph_to_Ideal_pT.mo #10

Closed wangzizhe closed 1 year ago

wangzizhe commented 1 year ago

The current gas adapters can only transfer different gas types with the same parameters (p,T,xi,m_flow) or (p,h,xi,m_flow). But there are different cases which need adapters to also transfer different parameters, such as if the the output of a electrolyser (p,h,xi,m_flow) should be coupled to the input of a fuel cell stack (p,T,xi,m_flow), then a new adapter is needed to transfer pressure p to temperature T.

Through modifications (see below), this adapter has been designed to cover this gap. With this adapter, different gas types with different parameters can also be coupled to each other.

The modifications have mainly been done within the following lines.

Line 65 - 79:

protected
  TILMedia.Internals.VLEFluidConfigurations.FullyMixtureCompatible.VLEFluid_ph gasIn(
    vleFluidType=real,
    computeSurfaceTension=false,
    deactivateDensityDerivatives=true,
    h=inStream(gasPortIn.h_outflow),
    p=gasPortIn.p,
    xi=inStream(gasPortIn.xi_outflow),
    deactivateTwoPhaseRegion=true) annotation (Placement(transformation(extent={{-70,-12},{-50,8}})));

  TILMedia.Gas_pT gasOut(
    gasType=ideal,
    T=gasPortOut.T_outflow,
    p=gasPortOut.p,
    xi=gasPortOut.xi_outflow) annotation (Placement(transformation(extent={{50,-12},{70,8}})));

Line 86 - 107:

equation
  // _____________________________________________
  //
  //           Characteristic Equations
  // _____________________________________________

  gasPortIn.p=gasPortOut.p;
  gasPortIn.m_flow+gasPortOut.m_flow=0;

  //if noEvent(gasPortIn.m_flow>0) then
    gasPortIn.h_outflow=gasOut.h;
    gasPortOut.T_outflow=gasIn.T;

  //else
    //gasPortOut.h_outflow=inStream(gasPortIn.h_outflow);
  //end if;

  gasPortIn.xi_outflow=inStream(gasPortOut.xi_outflow);

  gasPortOut.xi_outflow=inStream(gasPortIn.xi_outflow);

 // gasIn.T=gasOut.T;

This modification made an improvement of this issue and also closed it: https://github.com/TransiEnt-official/transient-lib/issues/7