Changeset 350

Show
Ignore:
Timestamp:
02/21/06 09:45:30 (3 years ago)
Author:
CRichter
Message:

changed PartialTwoPhaseMedium and PartialSimpleMedium to fit new interface definitions from the 47th Design Meeting

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Modelica/trunk/Media/package.mo

    r349 r350  
    33523352      h2 = Medium.specificEnthalpy_pTX(1e5, T, fill(0.0,0)); 
    33533353   end Inverse_h_T; 
    3354  
     3354     
    33553355   model InverseIncompressible_h_T  
    3356      "inverse computation for incmpressible media"  
     3356      "inverse computation for incmpressible media"  
    33573357     import SI = Modelica.SIunits; 
    33583358     import Cv = Modelica.SIunits.Conversions; 
    33593359     extends Modelica.Icons.Example; 
    3360    
    3361      replaceable package Medium = Modelica.Media.Incompressible.Examples.Glycol47  
    3362        "Medium model"   annotation (choicesAllMatching=true); 
    3363       
     3360       
     3361     replaceable package Medium =  
     3362          Modelica.Media.Incompressible.Examples.Glycol47 "Medium model"  
     3363                        annotation (choicesAllMatching=true); 
     3364       
    33643365     parameter SI.Temperature T_min = Medium.T_min; 
    33653366     parameter SI.Temperature T_max = Medium.T_max; 
     
    33693370     SI.SpecificEnthalpy h2 "Specific enthalpy computed from T (= h1 required)"; 
    33703371     SI.Temperature T "Temperature computed from h1"; 
    3371      annotation ( 
    3372                  experiment, 
     3372     annotation (experiment, 
    33733373                 experimentSetupOutput, 
    33743374                 Documentation(info="<html> 
    33753375                                
    33763376                               </html>")); 
    3377       
     3377       
    33783378   equation  
    33793379     // Define specific enthalpy 
     
    33813381       if time > 1 then h_max else  
    33823382       h_min + time*(h_max - h_min); 
    3383       
     3383       
    33843384     // Solve for temperature 
    33853385     T = Medium.temperature_phX(1e5, h1, fill(0.0,0)); 
    3386    
     3386       
    33873387     // Check (h2 must be identical to h1) 
    33883388     h2 = Medium.specificEnthalpy_pTX(1e5, T, fill(0.0,0)); 
    33893389   end InverseIncompressible_h_T; 
    3390     
    3391    model Inverse_h_TX "Solve h = h_TX(TX) for T, if h is given for ideal gas NASA"  
     3390     
     3391   model Inverse_h_TX  
     3392      "Solve h = h_TX(TX) for T, if h is given for ideal gas NASA"  
    33923393      import SI = Modelica.SIunits; 
    33933394      extends Modelica.Icons.Example; 
    33943395       
    3395       replaceable package Medium = Modelica.Media.IdealGases.MixtureGases.FlueGasLambdaOnePlus 
     3396      replaceable package Medium =  
     3397          Modelica.Media.IdealGases.MixtureGases.FlueGasLambdaOnePlus  
    33963398            extends Modelica.Media.IdealGases.Common.MixtureGasNasa  
    33973399        "Medium model"     annotation (choicesAllMatching=true); 
     
    34023404      SI.SpecificEnthalpy h_max = Medium.h_TX(T_max,X); 
    34033405      SI.SpecificEnthalpy h1 "Pre-defined specific enthalpy"; 
    3404       SI.SpecificEnthalpy h2 "Specific enthalpy computed from T (= h1 required)"; 
     3406      SI.SpecificEnthalpy h2  
     3407        "Specific enthalpy computed from T (= h1 required)"; 
    34053408      SI.Temperature T "Temperature computed from h1"; 
    34063409      SI.MassFraction[4] X "mass fraction vector"; 
     
    34123415</html>")); 
    34133416       
    3414    equation 
     3417   equation  
    34153418     X = {0.78, 0.12,0.05,0.05}; 
    34163419      // Define specific enthalpy 
     
    34253428      h2 = Medium.specificEnthalpy_pTX(1e5, T, X); 
    34263429   end Inverse_h_TX; 
    3427     
    3428  
    3429  end SolveOneNonlinearEquation; 
     3430     
     3431  end SolveOneNonlinearEquation; 
    34303432end Examples; 
    34313433 
     
    38483850    end BaseProperties; 
    38493851     
    3850     replaceable partial function setState_pTX "Return thermodynamic state as function of p, T and composition X"  
     3852    replaceable partial function setState_pTX  
     3853      "Return thermodynamic state as function of p, T and composition X"  
    38513854      extends Modelica.Icons.Function; 
    38523855      input AbsolutePressure p "Pressure"; 
     
    38563859    end setState_pTX; 
    38573860     
    3858     replaceable partial function setState_phX "Return thermodynamic state as function of p, h and composition X"  
     3861    replaceable partial function setState_phX  
     3862      "Return thermodynamic state as function of p, h and composition X"  
    38593863      extends Modelica.Icons.Function; 
    38603864      input AbsolutePressure p "Pressure"; 
     
    38643868    end setState_phX; 
    38653869     
    3866     replaceable partial function setState_psX "Return thermodynamic state as function of p, s and composition X"  
     3870    replaceable partial function setState_psX  
     3871      "Return thermodynamic state as function of p, s and composition X"  
    38673872      extends Modelica.Icons.Function; 
    38683873      input AbsolutePressure p "Pressure"; 
     
    38723877    end setState_psX; 
    38733878     
    3874     replaceable partial function setState_dTX "Return thermodynamic state as function of d, T and composition X"  
     3879    replaceable partial function setState_dTX  
     3880      "Return thermodynamic state as function of d, T and composition X"  
    38753881      extends Modelica.Icons.Function; 
    38763882      input Density d "density"; 
     
    39263932    end specificEnthalpy; 
    39273933     
    3928     replaceable partial function specificInternalEnergy "retuns specific internal energy"  
     3934    replaceable partial function specificInternalEnergy  
     3935      "retuns specific internal energy"  
    39293936      extends Modelica.Icons.Function; 
    39303937      input ThermodynamicState state "thermodynamic state record"; 
     
    39383945    end specificEntropy; 
    39393946     
    3940     replaceable partial function specificGibbsEnergy "computes specific Gibbs energy"  
     3947    replaceable partial function specificGibbsEnergy  
     3948      "computes specific Gibbs energy"  
    39413949      extends Modelica.Icons.Function; 
    39423950      input ThermodynamicState state "thermodynamic state record"; 
     
    39443952    end specificGibbsEnergy; 
    39453953     
    3946     replaceable partial function specificHelmholtzEnergy "computes specific Helmholtz energy"  
     3954    replaceable partial function specificHelmholtzEnergy  
     3955      "computes specific Helmholtz energy"  
    39473956      extends Modelica.Icons.Function; 
    39483957      input ThermodynamicState state "thermodynamic state record"; 
    39493958      output SpecificEnergy f "specific Helmholtz energy"; 
    39503959    end specificHelmholtzEnergy; 
    3951  
     3960     
    39523961    replaceable partial function specificHeatCapacityCp  
    39533962      "Return specific heat capacity at constant pressure"  
     
    39573966        "Specific heat capacity at constant pressure"; 
    39583967    end specificHeatCapacityCp; 
    3959  
    3960     function heatCapacity_cp = specificHeatCapacityCp "alias for deprecated name"; 
     3968     
     3969    function heatCapacity_cp = specificHeatCapacityCp  
     3970      "alias for deprecated name"; 
    39613971     
    39623972    replaceable partial function specificHeatCapacityCv  
     
    39673977        "Specific heat capacity at constant volume"; 
    39683978    end specificHeatCapacityCv; 
    3969  
    3970     function heatCapacity_cv = specificHeatCapacityCv "alias for deprecated name"; 
     3979     
     3980    function heatCapacity_cv = specificHeatCapacityCv  
     3981      "alias for deprecated name"; 
    39713982     
    39723983    replaceable partial function isentropicExponent  
     
    40564067      input MassFraction X[nX] "Mass fractions"; 
    40574068      output SpecificEnthalpy h "Specific enthalpy at p, T, X"; 
    4058     algorithm 
     4069    algorithm  
    40594070      h := specificEnthalpy(setState_pTX(p,T,X)); 
    40604071    end specificEnthalpy_pTX; 
     
    40674078      input MassFraction X[nX] "Mass fractions"; 
    40684079      output Temperature T "Temperature"; 
    4069     algorithm 
     4080    algorithm  
    40704081      T := temperature(setState_phX(p,h,X)); 
    40714082    end temperature_phX; 
     
    40784089      input MassFraction X[nX] "Mass fractions"; 
    40794090      output Density d "density"; 
    4080     algorithm 
     4091    algorithm  
    40814092      d := density(setState_phX(p,h,X)); 
    40824093    end density_phX; 
     
    40894100      input MassFraction X[nX] "Mass fractions"; 
    40904101      output Temperature T "Temperature"; 
    4091     algorithm 
     4102    algorithm  
    40924103      T := temperature(setState_psX(p,s,X)); 
    40934104    end temperature_psX; 
     
    41004111      input MassFraction X[nX] "Mass fractions"; 
    41014112      output SpecificEnthalpy h "specific enthalpy"; 
    4102     algorithm 
     4113    algorithm  
    41034114      h := specificEnthalpy(setState_psX(p,s,X)); 
    41044115    end specificEnthalpy_psX; 
     
    46294640    end setBubbleState; 
    46304641     
    4631     replaceable partial function setState_ph  
    4632       "set thermodynamic state from pressure and specific enthalpy"  
    4633       extends Modelica.Icons.Function; 
    4634       input AbsolutePressure p "pressure"; 
    4635       input SpecificEnthalpy h "enthalpy"; 
    4636       input FixedPhase phase =  1 "phase: default is one phase"; 
    4637       output ThermodynamicState state "complete thermodynamic state info"; 
    4638     end setState_ph; 
    4639      
    4640     replaceable partial function setState_ps  
    4641       "set thermodynamic state from pressure and specific entropy"  
    4642       extends Modelica.Icons.Function; 
    4643       input AbsolutePressure p "pressure"; 
    4644       input SpecificEntropy s "entropy"; 
    4645       input FixedPhase phase =  1 "phase: default is one phase"; 
    4646       output ThermodynamicState state "complete thermodynamic state info"; 
    4647     end setState_ps; 
     4642    redeclare replaceable partial function extends setState_dTX  
     4643      input FixedPhase phase=0  
     4644        "2 for two-phase, 1 for one-phase, 0 if not known"; 
     4645    end setState_dTX; 
     4646     
     4647    redeclare replaceable partial function extends setState_phX  
     4648      input FixedPhase phase=0  
     4649        "2 for two-phase, 1 for one-phase, 0 if not known"; 
     4650    end setState_phX; 
     4651     
     4652    redeclare replaceable partial function extends setState_psX  
     4653      input FixedPhase phase=0  
     4654        "2 for two-phase, 1 for one-phase, 0 if not known"; 
     4655    end setState_psX; 
     4656     
     4657    redeclare replaceable partial function extends setState_pTX  
     4658      input FixedPhase phase=0  
     4659        "2 for two-phase, 1 for one-phase, 0 if not known"; 
     4660    end setState_pTX; 
    46484661     
    46494662    replaceable function setSat_T  
     
    47994812      end dDewEnthalpy_dPressure; 
    48004813     
     4814      redeclare replaceable function specificEnthalpy_pTX  
     4815      "Compute specific enthalpy from pressure, temperature and mass fraction"  
     4816        extends Modelica.Icons.Function; 
     4817        input AbsolutePressure p "Pressure"; 
     4818        input Temperature T "Temperature"; 
     4819        input MassFraction X[nX] "Mass fractions"; 
     4820        input FixedPhase phase=0  
     4821        "2 for two-phase, 1 for one-phase, 0 if not known"; 
     4822        output SpecificEnthalpy h "Specific enthalpy at p, T, X"; 
     4823      algorithm  
     4824        h := specificEnthalpy(setState_pTX(p,T,X,phase)); 
     4825      end specificEnthalpy_pTX; 
     4826     
     4827      redeclare replaceable function temperature_phX  
     4828      "Compute temperature from pressure, specific enthalpy and mass fraction"  
     4829        extends Modelica.Icons.Function; 
     4830        input AbsolutePressure p "Pressure"; 
     4831        input SpecificEnthalpy h "Specific enthalpy"; 
     4832        input MassFraction X[nX] "Mass fractions"; 
     4833        input FixedPhase phase=0  
     4834        "2 for two-phase, 1 for one-phase, 0 if not known"; 
     4835        output Temperature T "Temperature"; 
     4836      algorithm  
     4837        T := temperature(setState_phX(p,h,X,phase)); 
     4838      end temperature_phX; 
     4839     
     4840      redeclare replaceable function density_phX  
     4841      "Compute density from pressure, specific enthalpy and mass fraction"  
     4842        extends Modelica.Icons.Function; 
     4843        input AbsolutePressure p "Pressure"; 
     4844        input SpecificEnthalpy h "Specific enthalpy"; 
     4845        input MassFraction X[nX] "Mass fractions"; 
     4846        input FixedPhase phase=0  
     4847        "2 for two-phase, 1 for one-phase, 0 if not known"; 
     4848        output Density d "density"; 
     4849      algorithm  
     4850        d := density(setState_phX(p,h,X,phase)); 
     4851      end density_phX; 
     4852     
     4853      redeclare replaceable function temperature_psX  
     4854      "Compute temperature from pressure, specific enthalpy and mass fraction"  
     4855        extends Modelica.Icons.Function; 
     4856        input AbsolutePressure p "Pressure"; 
     4857        input SpecificEntropy s "Specific entropy"; 
     4858        input MassFraction X[nX] "Mass fractions"; 
     4859        input FixedPhase phase=0  
     4860        "2 for two-phase, 1 for one-phase, 0 if not known"; 
     4861        output Temperature T "Temperature"; 
     4862      algorithm  
     4863        T := temperature(setState_psX(p,s,X,phase)); 
     4864      end temperature_psX; 
     4865     
     4866      redeclare replaceable function specificEnthalpy_psX  
     4867      "Compute specific enthalpy from pressure, specific entropy and mass fraction"  
     4868        extends Modelica.Icons.Function; 
     4869        input AbsolutePressure p "Pressure"; 
     4870        input SpecificEntropy s "Specific entropy"; 
     4871        input MassFraction X[nX] "Mass fractions"; 
     4872        input FixedPhase phase=0  
     4873        "2 for two-phase, 1 for one-phase, 0 if not known"; 
     4874        output SpecificEnthalpy h "specific enthalpy"; 
     4875      algorithm  
     4876        h := specificEnthalpy(setState_psX(p,s,X,phase)); 
     4877      end specificEnthalpy_psX; 
    48014878  end PartialTwoPhaseMedium; 
    48024879   
     
    48314908       
    48324909      // h = cp_const*(T-T0); 
    4833       h = specificEnthalpy_pTXi(p,T,Xi); 
     4910      h = specificEnthalpy_pTX(p,T,X); 
    48344911      u = cv_const*(T-T0); 
    48354912      d = d_const; 
     
    48804957    end velocityOfSound; 
    48814958     
    4882     redeclare function extends specificEnthalpy_pTX  
    4883       "Return specific enthalpy from pressure, temperature and mass fraction"  
     4959    redeclare function specificEnthalpy_pTX  
     4960      "Compute specific enthalpy from pressure, temperature and mass fraction"  
     4961      extends Modelica.Icons.Function; 
     4962      input AbsolutePressure p "Pressure"; 
     4963      input Temperature T "Temperature"; 
     4964      input MassFraction X[nX] "Mass fractions"; 
     4965      output SpecificEnthalpy h "Specific enthalpy at p, T, X"; 
    48844966    algorithm  
    48854967      h := cp_const*(T-T0); 
    48864968    end specificEnthalpy_pTX; 
    48874969     
    4888     function specificEnthalpy_pTXi  
    4889       "Return specific enthalpy from pressure, temperature and mass fraction"  
     4970     
     4971    redeclare function temperature_phX  
     4972      "Compute temperature from pressure, specific enthalpy and mass fraction"  
    48904973      extends Modelica.Icons.Function; 
    48914974      input AbsolutePressure p "Pressure"; 
    4892       input Temperature T "Temperature"; 
    4893       input MassFraction Xi[nXi] "Independent mass fractions"; 
    4894       output SpecificEnthalpy h "Specific enthalpy at p, T, Xi"; 
    4895       annotation(LateInline=true, Documentation(info="<html> 
    4896 <p> 
    4897 In order that symbolic processing of connection equations is 
    4898 possible, the specific enthalpy in model BaseProperties has to 
    4899 be computed with a <b>function</b>. Additionally, 
    4900 the independent mass fractions Xi have to be 
    4901 an input argument (for details see the discussion in 
    4902 <a href=\"Modelica:Modelica.Media.UsersGuide.MediumDefinition.SpecificEnthalpyAsFunction\">SpecificEnthalpyAsFunction</a>  
    4903 of the Modelica.Media Users Guide). 
    4904 For this reason, function specificEnthalpy_pTXi() is provided. 
    4905 </p>  
    4906   
    4907 </html>")); 
    4908     algorithm  
    4909       h := cp_const*(T-T0); 
    4910     end specificEnthalpy_pTXi; 
    4911      
    4912     redeclare function extends temperature_phX  
    4913       "Compute temperature from pressure, specific enthalpy and mass fraction"  
     4975      input SpecificEnthalpy h "Specific enthalpy"; 
     4976      input MassFraction X[nX] "Mass fractions"; 
     4977      output Temperature T "Temperature"; 
    49144978    algorithm  
    49154979      T := T0 + h/cp_const; 
    49164980    end temperature_phX; 
    4917  
    4918     redeclare function extends density_phX  
    4919       "Compute temperature from pressure, specific enthalpy and mass fraction"  
     4981     
     4982    redeclare function density_phX  
     4983      "Compute density from pressure, specific enthalpy and mass fraction"  
     4984      extends Modelica.Icons.Function; 
     4985      input AbsolutePressure p "Pressure"; 
     4986      input SpecificEnthalpy h "Specific enthalpy"; 
     4987      input MassFraction X[nX] "Mass fractions"; 
     4988      output Density d "density"; 
    49204989    algorithm  
    49214990      d := d_const; 
    49224991    end density_phX; 
    4923  
     4992     
    49244993  end PartialSimpleMedium; 
    49254994   
     
    64476516      input Real x "Independent variable of function"; 
    64486517      input Real p = 0.0 "disregaded variables (here always used for pressure)"; 
    6449       input Real[:] X = fill(0,0) "disregaded variables (her always used for composition)"; 
    6450       input f_nonlinear_Data f_nonlinear_data  "Additional data for the function"; 
     6518      input Real[:] X = fill(0,0)  
     6519        "disregaded variables (her always used for composition)"; 
     6520      input f_nonlinear_Data f_nonlinear_data  
     6521        "Additional data for the function"; 
    64516522      output Real y "= f_nonlinear(x)"; 
    64526523      // annotation(derivative(zeroDerivative=y)); // this must hold for all replaced functions 
     
    64616532      input Real x_min "Minimum value of x"; 
    64626533      input Real x_max "Maximum value of x"; 
    6463       input Real pressure = 0.0 "disregaded variables (here always used for pressure)"; 
    6464       input Real[:] X = fill(0,0) "disregaded variables (here always used for composition)"; 
     6534      input Real pressure = 0.0  
     6535        "disregaded variables (here always used for pressure)"; 
     6536      input Real[:] X = fill(0,0)  
     6537        "disregaded variables (here always used for composition)"; 
    64656538       input f_nonlinear_Data f_nonlinear_data  
    64666539        "Additional data for function f_nonlinear";