Changeset 1018 for trunk

Show
Ignore:
Timestamp:
01/29/08 12:57:27 (7 months ago)
Author:
hubertus
Message:

- Fixed usage of sqrt() to take into account new Dymola semantics
- Added min=0 to a few more units in SIunits in order to guarantee positive argument to some calls to sqrt()

Location:
trunk/Modelica
Files:
4 modified

Legend:

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

    r1016 r1018  
    353353    extends Modelica.Icons.Function; 
    354354  algorithm 
    355     a := sqrt(data.R*state.T*cp_T(data, state.T)/specificHeatCapacityCv(state)); 
     355    a := sqrt(max(0,data.R*state.T*cp_T(data, state.T)/specificHeatCapacityCv(state))); 
    356356  end velocityOfSound; 
    357357 
     
    598598    parameter Real Const2_SI=131.3/1000.0 
    599599      "Constant in formula for mur converted to SI units"; 
    600     parameter Real mur=Const2_SI*mu/sqrt(Vc*Tc) 
     600    Real mur=Const2_SI*mu/sqrt(Vc*Tc) 
    601601      "Dimensionless dipole moment of gas molecule"; 
    602     parameter Real Fc=1 - 0.2756*w + 0.059035*mur^4 + k 
     602    Real Fc=1 - 0.2756*w + 0.059035*mur^4 + k 
    603603      "Factor to account for molecular shape and polarities of gas"; 
    604604    Real Tstar "Dimensionless temperature defined by equation below"; 
     
    10251025    input ThermodynamicState state "properties at upstream location"; 
    10261026  algorithm 
    1027     a := sqrt(gasConstant(state)*state.T*specificHeatCapacityCp(state)/specificHeatCapacityCv(state)); 
     1027    a := sqrt(max(0,gasConstant(state)*state.T*specificHeatCapacityCp(state)/specificHeatCapacityCv(state))); 
    10281028  end velocityOfSound; 
    10291029 
  • trunk/Modelica/Media/Water/IF97_Utilities.mo

    r887 r1018  
    34163416        Real[49] o "vector of auxiliary variables"; 
    34173417      algorithm 
    3418         pi := p*data.IPSTAR; 
     3418        pi := max(Modelica.Constants.small,p*data.IPSTAR); 
    34193419        o[1] := pi^0.75; 
    34203420        o[2] := 1/o[1]; 
     
    68186818  algorithm 
    68196819    // dp/drho at constant s 
    6820     v_sound := if aux.region == 3 then sqrt((aux.pd*aux.rho*aux.rho*aux.cv + aux.pt*aux.pt*aux.T)/(aux.rho*aux.rho*aux.cv)) else  
     6820    v_sound := if aux.region == 3 then sqrt(max(0,(aux.pd*aux.rho*aux.rho*aux.cv + aux.pt*aux.pt*aux.T)/(aux.rho*aux.rho*aux.cv))) else  
    68216821      if aux.region == 4 then  
    6822       sqrt(1/((aux.rho*(aux.rho*aux.cv/aux.dpT + 1.0)/(aux.dpT*aux.T)) - 1/aux.rho*aux.rho*aux.rho/(aux.dpT*aux.T))) else  
    6823            sqrt(-aux.cp/(aux.rho*aux.rho*(aux.vp*aux.cp+aux.vt*aux.vt*aux.T))); 
     6822      sqrt(max(0,1/((aux.rho*(aux.rho*aux.cv/aux.dpT + 1.0)/(aux.dpT*aux.T)) - 1/aux.rho*aux.rho*aux.rho/(aux.dpT*aux.T)))) else  
     6823           sqrt(max(0,-aux.cp/(aux.rho*aux.rho*(aux.vp*aux.cp+aux.vt*aux.vt*aux.T)))); 
    68246824  end velocityOfSound_props_ph; 
    68256825 
     
    72347234  algorithm 
    72357235    // dp/drho at constant s 
    7236     v_sound := if aux.region == 3 then sqrt((aux.pd*aux.rho*aux.rho*aux.cv + aux.pt*aux.pt*aux.T)/(aux.rho*aux.rho*aux.cv)) else  
    7237       sqrt(-aux.cp/(aux.rho*aux.rho*(aux.vp*aux.cp+aux.vt*aux.vt*aux.T))); 
     7236    v_sound := if aux.region == 3 then sqrt(max(0,(aux.pd*aux.rho*aux.rho*aux.cv + aux.pt*aux.pt*aux.T)/(aux.rho*aux.rho*aux.cv))) else  
     7237      sqrt(max(0,-aux.cp/(aux.rho*aux.rho*(aux.vp*aux.cp+aux.vt*aux.vt*aux.T)))); 
    72387238  end velocityOfSound_props_pT; 
    72397239 
     
    76407640  algorithm 
    76417641    // dp/drho at constant s 
    7642     v_sound := if aux.region == 3 then sqrt((aux.pd*aux.rho*aux.rho*aux.cv + aux.pt*aux.pt*aux.T)/(aux.rho*aux.rho*aux.cv)) else  
     7642    v_sound := if aux.region == 3 then sqrt(max(0,((aux.pd*aux.rho*aux.rho*aux.cv + aux.pt*aux.pt*aux.T)/(aux.rho*aux.rho*aux.cv)))) else  
    76437643      if aux.region == 4 then  
    7644       sqrt(1/((aux.rho*(aux.rho*aux.cv/aux.dpT + 1.0)/(aux.dpT*aux.T)) - 1/aux.rho*aux.rho*aux.rho/(aux.dpT*aux.T))) else  
    7645            sqrt(-aux.cp/(aux.rho*aux.rho*(aux.vp*aux.cp+aux.vt*aux.vt*aux.T))); 
     7644      sqrt(max(0,1/((aux.rho*(aux.rho*aux.cv/aux.dpT + 1.0)/(aux.dpT*aux.T)) - 1/aux.rho*aux.rho*aux.rho/(aux.dpT*aux.T)))) else  
     7645           sqrt(max(0,-aux.cp/(aux.rho*aux.rho*(aux.vp*aux.cp+aux.vt*aux.vt*aux.T)))); 
    76467646  end velocityOfSound_props_dT; 
    76477647 
  • trunk/Modelica/Media/package.mo

    r1016 r1018  
    49634963        extends Modelica.Icons.Function; 
    49644964      algorithm 
    4965         a := sqrt(1/(kappa_const*density(state) -beta_const*beta_const*state.T/cp_const)); 
     4965        a := sqrt(max(0,1/(kappa_const*density(state) -beta_const*beta_const*state.T/cp_const))); 
    49664966      end velocityOfSound; 
    49674967 
  • trunk/Modelica/SIunits.mo

    r1004 r1018  
    13811381      final unit="mol", 
    13821382      min=0); 
    1383   type MolarMass = Real (final quantity="MolarMass", final unit="kg/mol"); 
    1384   type MolarVolume = Real (final quantity="MolarVolume", final unit="m3/mol"); 
     1383  type MolarMass = Real (final quantity="MolarMass", final unit="kg/mol",min=0); 
     1384  type MolarVolume = Real (final quantity="MolarVolume", final unit="m3/mol", min=0); 
    13851385  type MolarInternalEnergy = Real (final quantity="MolarInternalEnergy", final unit 
    13861386        =    "J/mol");