FUNCTION VOID BYPASS(TEnt,WEnt,TLvg,WLvg,TAdp,WAdp,BF,ErrStat) /*********************************************************************/ /* SUBROUTINE: BYPASS */ /* */ /* LANGUAGE: FORTRAN 77 */ /* */ /* PURPOSE: Calculate apparatus dew point and bypass */ /* factor given entering and leaving moist */ /* air conditions of cooling coil. */ /* CODE IS TAKEN FROM ASHRAE HVAC 2 TOOLKIT */ /*********************************************************************/ /* INPUT VARIABLES: */ /* TEnt Entering air temperature (C) */ /* WEnt Entering air humidity ratio (-) */ /* TLvg Leaving air temperature (C) */ /* WLvg Leaving air humidity ratio (-) */ /* */ /* OUTPUT VARIABLES: */ /* TAdp Apparatus dewpoint temperature (C) */ /* WAdp Apparatus dewpoint humidity ratio (-) */ /* BF Bypass factor (-) */ /* ErrStat Error status indicator, 0 = ok, 1 = error (-) */ /*********************************************************************/ /* MAJOR RESTRICTIONS: None */ /* */ /* WRITTEN: Michael J. Brandemuehl */ /* Hugh Henderson & Kannan Rengarajan */ /* */ /* ADDAPTED TO NMF BY: Jari Hyttinen */ /* */ /* */ /* DATE: January 1, 1992 */ /* April 10, 1997 rev 1.0 */ /* */ /* INCLUDE FILES: globfor.inc */ /* SUBROUTINES CALLED: None */ /* FUNCTIONS CALLED: DEWPNT */ /* ENTHAL */ /* HUMRAT */ /* SATPRES */ /* XITERATE */ /* */ /* REVISION HISTORY: None */ /* */ /* REFERENCE: ASHRAE HVAC 2 TOOLKIT */ /* Pages 4-33 - 4-36 */ /*********************************************************************/ /* INTERNAL VARIABLES: */ /* small Small number in place of zero */ /* hEnt Entering air enthalpy */ /* hLvg Leaving air enthalpy */ /* hAdp Air enthalpy at apparatus dew point */ /* slope Ratio temperature difference to humidity difference */ /* between entering and leaving air states */ /* tAdpEst Estimate of TAdp from slope */ /* error Deviation of dependent variable in iteration */ /* iter Iteration counter */ /* icvg Iteration convergence flag */ /* F1,F2 Previous values of dependent variable in XITERATE */ /* X1,X2 Previous values of independent variable in XITERATE */ /*********************************************************************/ LANGUAGE F77 INPUT FLOAT TEnt,WEnt,TLvg,WLvg; OUTPUT FLOAT TAdp,WAdp,BF,ErrStat; CODE SUBROUTINE BYPASS(TEnt,WEnt,TLvg,WLvg, & TAdp,WAdp,BF,ErrStat) DOUBLE PRECISION DEWPNT,ENTHAL,HUMRAT,SATPRES,XITERATE DOUBLE PRECISION TEnt,WEnt,TLvg,WLvg,TAdp,WAdp,BF,ErrStat DOUBLE PRECISION small,hEnt,hLvg,Hadp,slope,tAdpEst,error DOUBLE PRECISION F1,X1,F2,X2 INTEGER iter,icvg,itmax INCLUDE 'globfor.inc' DATA itmax/20/,small/1.E-9/ ErrStat = 0. C1*** Iterate to determine apparatus dewpoint at which the ADP C1*** equals the temperature calculated by extending the line between C1*** entering and leaving conditions to the saturation curve C1*** Calculate "slope" of temperature vs. humidity ratio between C1*** entering and leaving states slope = (TEnt-TLvg)/MAX((WEnt-WLvg),small) C1*** Initialize iteration parameters TAdp = DEWPNT(WLvg) DO 100 iter=1,itmax C1*** Calculate apparatus dewpoint and compare with predicted value C1*** using entering conditions and slope WAdp = HUMRAT(Patm,SATPRES(TAdp)) TAdpEst = TEnt - slope*(WEnt-WAdp) error = TAdp-TAdpEst TAdp = XITERATE(TAdp,error,X1,F1,X2,F2,iter,icvg) C1*** If converged, exit loop IF (icvg .EQ. 1) GO TO 110 100 CONTINUE C1*** Apparatus dewpoint has not converged after maximum iterations. C1*** Print error message, set return error flag, and RETURN WRITE(*,1001) itmax 1001 FORMAT(/1X,'*** ERROR IN SUBOUTINE BYPASS ***'/ & 1X,' Apparatus dewpoint has not ' & 'converged after ',I2,' iterations'/) ErrStat = 1 110 CONTINUE C1*** Calculate bypass factor from enthalpies hLvg = ENTHAL(TLvg,WLvg) hEnt = ENTHAL(TEnt,WEnt) hAdp = ENTHAL(TAdp,WAdp) BF = (hLvg-hAdp)/(hEnt-hAdp) 999 RETURN END END_CODE END_FUNCTION