FUNCTION FLOAT UAHX (Cap1,In1,Cap2,In2,Q,ConfigHX,ErrStat) /*********************************************************************/ /* Copyright ASHRAE. Toolkit for HVAC System Energy Calculations */ /*********************************************************************/ /* */ /* FUNCTION: UAHX */ /* LANGUAGE: FORTRAN 77 */ /* PURPOSE: Calculate the UA of a heat exchanger using */ /* the effectiveness-Ntu relationships given */ /* the entering capacity rate and temperature of each */ /* flow stream, the heat transfer rate under these */ /* conditions and the heat exchanger configuration. */ /* CODE IS TAKEN FROM ASHRAE HVAC 2 TOOLKIT */ /* */ /*********************************************************************/ /* INPUT VARIABLES */ /* Cap1 Capacity rate of stream 1 (W/C) */ /* In1 Inlet state of stream 1 (C) */ /* Cap2 Capacity rate of stream 2 (W/C) */ /* In2 Inlet state of stream 2 (C) */ /* Q Heat transfer rate (W) */ /* ConfigHX Heat exchanger configuration (-) */ /* 1 - Counterflow */ /* 2 - Parallel flow */ /* 3 - Cross flow, both streams unmixed */ /* 4 - Cross flow, both streams mixed */ /* 5 - Cross flow, stream 1 unmixed */ /* 6 - Cross flow, stream 2 unmixed */ /* */ /* OUTPUT VARIABLES */ /* UAHX Overall heat transfer coefficient (W/C) */ /* ErrStat Error status indicator, 0 = ok, 1 = error (-) */ /* */ /*********************************************************************/ /* MAJOR RESTRICTIONS: Models coil using effectiveness Ntu model */ /* */ /* WRITTEN: Michael J. Brandemuehl */ /* */ /* ADDAPTED TO NMF BY: Jari Hyttinen */ /* */ /* */ /* DATE: January 1, 1992 */ /* April 10, 1997 rev 1.0 */ /* */ /* INCLUDE FILES: None */ /* FUNCTIONS CALLED: XITERATE */ /* */ /* REFERENCE: ASHRAE HVAC 2 TOOLKIT */ /* Pages 4-9 - 4-12 */ /*********************************************************************/ /* INTERNAL VARIABLES */ /* qMax Maximum heat transfer from inlet conditions (W) */ /* qEstimate Estimated heat transfer in iteration (W) */ /* ua Estimated heat transfer coefficient (W/C) */ /* error Deviation of dependent variable in iteration */ /* icvg Iteration convergence flag */ /* iter Iteration index */ /* itmax Maximum number of iterations */ /* F1,F2 Previous values of error in iteration */ /* X1,X2 Previous values of independent variable in iteration */ /*********************************************************************/ LANGUAGE F77 INPUT FLOAT Cap1,In1,Cap2,In2,Q,ConfigHX; OUTPUT FLOAT ErrStat; CODE DOUBLE PRECISION FUNCTION UAHX (Cap1,In1,Cap2,In2,Q,ConfigHX, & ErrStat) DOUBLE PRECISION XITERATE DOUBLE PRECISION Cap1,In1,Cap2,In2,Q,ConfigHX,ErrStat DOUBLE PRECISION qMax,qEstimate,ua,error DOUBLE PRECISION F1,X1,F2,X2,small,large DOUBLE PRECISION ntu,out1 DOUBLE PRECISION cmin,cmax,cratio,effectiveness,e,eta INTEGER icvg,iter,itmax, mode DATA itmax/20/,small/1.E-9/,large/1.E9/ ErrStat = 0 C1*** Check for Q out of range (effectiveness > 1) qMax = ABS(MIN(Cap1,Cap2)*(In1-In2)) IF((ABS(Q)-qMax)/MAX(qMax,small) .GT. small) THEN WRITE(*,1001) 1001 FORMAT(/1X,'*** ERROR IN SUBROUTINE UAHX ***'/ & 1X,' Given Q is impossible for given inlet states'/ & 1x,' Proceeding with UA = 1.0E+9'/) ErrStat = 1 ENDIF C1*** Check for limiting case of effectiveness = 1 IF((ABS(Q)-qMax)/MAX(qMax,small) .GT. -small) THEN UAHX = large GO TO 999 ENDIF C1*** Estimate UAHX ua = ABS(Q/(In1-In2)) C1*** Cmin/Cmax (cRatio) calculations cMin = MIN(Cap1,Cap2) cMax = MAX(Cap1,Cap2) IF( cMax .EQ. 0.) THEN cRatio = 1. ELSE cRatio = cMin/cMax ENDIF C1*** BEGIN LOOP to iteratively calculate UAHX DO 100 iter = 1,itmax C1*** Calculate heat transfer rate for estimated UAHX C2*** Next lines are from subroutine HEATEX.FOR C1*** Ntu calculation IF( cMin .EQ. 0.) THEN ntu = large ELSE ntu = ua/cMin ENDIF C1*** Calculate effectiveness for special limiting cases mode = NINT(ConfigHX) IF(ntu .LE. 0) THEN effectiveness = 0. ELSE IF(cRatio .LT. small) THEN C2*** Cmin/Cmax = 0 and effectiveness is independent of configuration effectiveness = 1 - EXP(-ntu) C1*** Calculate effectiveness depending on heat exchanger configuration ELSE IF (mode .EQ. 1) THEN IF (ABS(cRatio-1.) .LT. small) THEN effectiveness = ntu/(ntu+1.) ELSE e=EXP(-ntu*(1-cRatio)) effectiveness = (1-e)/(1-cRatio*e) ENDIF ELSE IF (mode .EQ. 2) THEN effectiveness = (1-EXP(-ntu*(1+cRatio)))/(1+cRatio) ELSE IF (mode .EQ. 3) THEN eta = ntu**(-0.22) effectiveness = 1 - EXP((EXP(-ntu*cRatio*eta)-1)/(cRatio*eta)) ELSE IF (mode .EQ. 4) THEN effectiveness = ((1/(1-EXP(-ntu)))+ & (cRatio/(1-EXP(-ntu*cRatio)))-(1/(-ntu)))**(-1) ELSE C2*** One stream is mixed and one is unmixed. Determine whether the C2*** minimum or maximum capacity rate stream is mixed. IF ( (ABS(Cap1-cMin).LT.small .AND. mode.EQ.5) .OR. & (ABS(Cap2-cMin).LT.small .AND. mode.EQ.6) ) THEN effectiveness = (1-EXP(-cRatio*(1-EXP(-ntu))))/cRatio ELSE effectiveness = 1-EXP(-(1-EXP(-ntu*cRatio))/cRatio) ENDIF ENDIF C1*** Determine leaving conditions for the two streams qMax = MAX(cMin,small)*(In1-In2) Out1 = In1 - effectiveness*qMax/MAX(Cap1,small) C2*** End of HEATEX.FOR, back to original code qEstimate = Cap1*(In1-Out1) C1*** Calculate new estimate for UAHX error = ABS(qEstimate) - ABS(Q) ua = XITERATE(ua,error,X1,F1,X2,F2,iter,icvg) C1*** If converged, leave loop IF (icvg .EQ. 1) GO TO 110 100 CONTINUE C1*** If not converged after itmax iterations, return error code WRITE(*,1005) itmax 1005 FORMAT(/1X,'*** ERROR IN SUBROUTINE UAHX ***'/ & 1X,' UA has not converged after',I2, & ' iterations'/) ErrStat = 1 110 CONTINUE UAHX = ua 999 RETURN END END_CODE END_FUNCTION