Changeset 350
- Timestamp:
- 02/21/06 09:45:30 (3 years ago)
- Files:
-
- 1 modified
-
Modelica/trunk/Media/package.mo (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Modelica/trunk/Media/package.mo
r349 r350 3352 3352 h2 = Medium.specificEnthalpy_pTX(1e5, T, fill(0.0,0)); 3353 3353 end Inverse_h_T; 3354 3354 3355 3355 model InverseIncompressible_h_T 3356 "inverse computation for incmpressible media"3356 "inverse computation for incmpressible media" 3357 3357 import SI = Modelica.SIunits; 3358 3358 import Cv = Modelica.SIunits.Conversions; 3359 3359 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 3364 3365 parameter SI.Temperature T_min = Medium.T_min; 3365 3366 parameter SI.Temperature T_max = Medium.T_max; … … 3369 3370 SI.SpecificEnthalpy h2 "Specific enthalpy computed from T (= h1 required)"; 3370 3371 SI.Temperature T "Temperature computed from h1"; 3371 annotation ( 3372 experiment, 3372 annotation (experiment, 3373 3373 experimentSetupOutput, 3374 3374 Documentation(info="<html> 3375 3375 3376 3376 </html>")); 3377 3377 3378 3378 equation 3379 3379 // Define specific enthalpy … … 3381 3381 if time > 1 then h_max else 3382 3382 h_min + time*(h_max - h_min); 3383 3383 3384 3384 // Solve for temperature 3385 3385 T = Medium.temperature_phX(1e5, h1, fill(0.0,0)); 3386 3386 3387 3387 // Check (h2 must be identical to h1) 3388 3388 h2 = Medium.specificEnthalpy_pTX(1e5, T, fill(0.0,0)); 3389 3389 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" 3392 3393 import SI = Modelica.SIunits; 3393 3394 extends Modelica.Icons.Example; 3394 3395 3395 replaceable package Medium = Modelica.Media.IdealGases.MixtureGases.FlueGasLambdaOnePlus 3396 replaceable package Medium = 3397 Modelica.Media.IdealGases.MixtureGases.FlueGasLambdaOnePlus 3396 3398 extends Modelica.Media.IdealGases.Common.MixtureGasNasa 3397 3399 "Medium model" annotation (choicesAllMatching=true); … … 3402 3404 SI.SpecificEnthalpy h_max = Medium.h_TX(T_max,X); 3403 3405 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)"; 3405 3408 SI.Temperature T "Temperature computed from h1"; 3406 3409 SI.MassFraction[4] X "mass fraction vector"; … … 3412 3415 </html>")); 3413 3416 3414 equation 3417 equation 3415 3418 X = {0.78, 0.12,0.05,0.05}; 3416 3419 // Define specific enthalpy … … 3425 3428 h2 = Medium.specificEnthalpy_pTX(1e5, T, X); 3426 3429 end Inverse_h_TX; 3427 3428 3429 end SolveOneNonlinearEquation; 3430 3431 end SolveOneNonlinearEquation; 3430 3432 end Examples; 3431 3433 … … 3848 3850 end BaseProperties; 3849 3851 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" 3851 3854 extends Modelica.Icons.Function; 3852 3855 input AbsolutePressure p "Pressure"; … … 3856 3859 end setState_pTX; 3857 3860 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" 3859 3863 extends Modelica.Icons.Function; 3860 3864 input AbsolutePressure p "Pressure"; … … 3864 3868 end setState_phX; 3865 3869 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" 3867 3872 extends Modelica.Icons.Function; 3868 3873 input AbsolutePressure p "Pressure"; … … 3872 3877 end setState_psX; 3873 3878 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" 3875 3881 extends Modelica.Icons.Function; 3876 3882 input Density d "density"; … … 3926 3932 end specificEnthalpy; 3927 3933 3928 replaceable partial function specificInternalEnergy "retuns specific internal energy" 3934 replaceable partial function specificInternalEnergy 3935 "retuns specific internal energy" 3929 3936 extends Modelica.Icons.Function; 3930 3937 input ThermodynamicState state "thermodynamic state record"; … … 3938 3945 end specificEntropy; 3939 3946 3940 replaceable partial function specificGibbsEnergy "computes specific Gibbs energy" 3947 replaceable partial function specificGibbsEnergy 3948 "computes specific Gibbs energy" 3941 3949 extends Modelica.Icons.Function; 3942 3950 input ThermodynamicState state "thermodynamic state record"; … … 3944 3952 end specificGibbsEnergy; 3945 3953 3946 replaceable partial function specificHelmholtzEnergy "computes specific Helmholtz energy" 3954 replaceable partial function specificHelmholtzEnergy 3955 "computes specific Helmholtz energy" 3947 3956 extends Modelica.Icons.Function; 3948 3957 input ThermodynamicState state "thermodynamic state record"; 3949 3958 output SpecificEnergy f "specific Helmholtz energy"; 3950 3959 end specificHelmholtzEnergy; 3951 3960 3952 3961 replaceable partial function specificHeatCapacityCp 3953 3962 "Return specific heat capacity at constant pressure" … … 3957 3966 "Specific heat capacity at constant pressure"; 3958 3967 end specificHeatCapacityCp; 3959 3960 function heatCapacity_cp = specificHeatCapacityCp "alias for deprecated name"; 3968 3969 function heatCapacity_cp = specificHeatCapacityCp 3970 "alias for deprecated name"; 3961 3971 3962 3972 replaceable partial function specificHeatCapacityCv … … 3967 3977 "Specific heat capacity at constant volume"; 3968 3978 end specificHeatCapacityCv; 3969 3970 function heatCapacity_cv = specificHeatCapacityCv "alias for deprecated name"; 3979 3980 function heatCapacity_cv = specificHeatCapacityCv 3981 "alias for deprecated name"; 3971 3982 3972 3983 replaceable partial function isentropicExponent … … 4056 4067 input MassFraction X[nX] "Mass fractions"; 4057 4068 output SpecificEnthalpy h "Specific enthalpy at p, T, X"; 4058 algorithm 4069 algorithm 4059 4070 h := specificEnthalpy(setState_pTX(p,T,X)); 4060 4071 end specificEnthalpy_pTX; … … 4067 4078 input MassFraction X[nX] "Mass fractions"; 4068 4079 output Temperature T "Temperature"; 4069 algorithm 4080 algorithm 4070 4081 T := temperature(setState_phX(p,h,X)); 4071 4082 end temperature_phX; … … 4078 4089 input MassFraction X[nX] "Mass fractions"; 4079 4090 output Density d "density"; 4080 algorithm 4091 algorithm 4081 4092 d := density(setState_phX(p,h,X)); 4082 4093 end density_phX; … … 4089 4100 input MassFraction X[nX] "Mass fractions"; 4090 4101 output Temperature T "Temperature"; 4091 algorithm 4102 algorithm 4092 4103 T := temperature(setState_psX(p,s,X)); 4093 4104 end temperature_psX; … … 4100 4111 input MassFraction X[nX] "Mass fractions"; 4101 4112 output SpecificEnthalpy h "specific enthalpy"; 4102 algorithm 4113 algorithm 4103 4114 h := specificEnthalpy(setState_psX(p,s,X)); 4104 4115 end specificEnthalpy_psX; … … 4629 4640 end setBubbleState; 4630 4641 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; 4648 4661 4649 4662 replaceable function setSat_T … … 4799 4812 end dDewEnthalpy_dPressure; 4800 4813 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; 4801 4878 end PartialTwoPhaseMedium; 4802 4879 … … 4831 4908 4832 4909 // h = cp_const*(T-T0); 4833 h = specificEnthalpy_pTX i(p,T,Xi);4910 h = specificEnthalpy_pTX(p,T,X); 4834 4911 u = cv_const*(T-T0); 4835 4912 d = d_const; … … 4880 4957 end velocityOfSound; 4881 4958 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"; 4884 4966 algorithm 4885 4967 h := cp_const*(T-T0); 4886 4968 end specificEnthalpy_pTX; 4887 4969 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" 4890 4973 extends Modelica.Icons.Function; 4891 4974 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"; 4914 4978 algorithm 4915 4979 T := T0 + h/cp_const; 4916 4980 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"; 4920 4989 algorithm 4921 4990 d := d_const; 4922 4991 end density_phX; 4923 4992 4924 4993 end PartialSimpleMedium; 4925 4994 … … 6447 6516 input Real x "Independent variable of function"; 6448 6517 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"; 6451 6522 output Real y "= f_nonlinear(x)"; 6452 6523 // annotation(derivative(zeroDerivative=y)); // this must hold for all replaced functions … … 6461 6532 input Real x_min "Minimum value of x"; 6462 6533 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)"; 6465 6538 input f_nonlinear_Data f_nonlinear_data 6466 6539 "Additional data for function f_nonlinear";
