Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r64), | intent(in) | :: | Ti | |||
real(kind=r64), | intent(in) | :: | Tf | |||
real(kind=r64), | intent(in) | :: | Ta | |||
real(kind=r64), | intent(in) | :: | T1 | |||
real(kind=r64), | intent(in) | :: | T2 | |||
real(kind=r64), | intent(in) | :: | m | |||
real(kind=r64), | intent(in) | :: | Cp | |||
real(kind=r64), | intent(in) | :: | m1 | |||
real(kind=r64), | intent(in) | :: | m2 | |||
real(kind=r64), | intent(in) | :: | UA | |||
real(kind=r64), | intent(in) | :: | Q | |||
real(kind=r64), | intent(in) | :: | t |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
REAL(r64) FUNCTION CalcTempIntegral(Ti, Tf, Ta, T1, T2, m, Cp, m1, m2, UA, Q, t)
! SUBROUTINE INFORMATION:
! AUTHOR Peter Graham Ellis
! DATE WRITTEN February 2005
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! Calculates the integral of the tank temperature from Ti to Tf. The integral is added to a sum which is
! later divided by the elapsed time to yield the average tank temperature over the timestep.
! METHODOLOGY EMPLOYED:
! Equations are the mathematical integrals of the governing differential equations.
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
REAL(r64), INTENT(IN) :: Ti ! Initial tank temperature (C)
REAL(r64), INTENT(IN) :: Tf ! Final tank temperature (C)
REAL(r64), INTENT(IN) :: Ta ! Ambient environment temperature (C)
REAL(r64), INTENT(IN) :: T1 ! Temperature of flow 1 (C)
REAL(r64), INTENT(IN) :: T2 ! Temperature of flow 2 (C)
REAL(r64), INTENT(IN) :: m ! Mass of tank fluid (kg)
REAL(r64), INTENT(IN) :: Cp ! Specific heat of fluid (J/kg deltaC)
REAL(r64), INTENT(IN) :: m1 ! Mass flow rate 1 (kg/s)
REAL(r64), INTENT(IN) :: m2 ! Mass flow rate 2 (kg/s)
REAL(r64), INTENT(IN) :: UA ! Heat loss coefficient to ambient environment (W/deltaC)
REAL(r64), INTENT(IN) :: Q ! Net heating rate for non-temp dependent sources, i.e. heater and parasitics (W)
REAL(r64), INTENT(IN) :: t ! Time elapsed from Ti to Tf (s)
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
REAL(r64) :: a ! Intermediate variable
REAL(r64) :: b ! Intermediate variable
REAL(r64) :: dTsum ! Integral of tank temperature (C s)
! FLOW:
IF (t == 0.0d0) THEN
dTsum = 0.0d0
ELSE IF (Tf == Ti) THEN ! Steady-state conditions
dTsum = Tf * t
ELSE IF (UA / Cp + m1 + m2 == 0.0d0) THEN
a = Q / (m * Cp)
! Integral of T(t) = a * t + Ti, evaluated from 0 to t
dTsum = 0.5d0 * a * t * t + Ti * t
ELSE
a = (Q / Cp + UA * Ta / Cp + m1 * T1 + m2 * T2) / m
b = -(UA / Cp + m1 + m2) / m
! Integral of T(t) = (a / b + Ti) * EXP(b * t) - a / b, evaluated from 0 to t
dTsum = (a / b + Ti) * (EXP(b * t) - 1.0d0) / b - a * t / b
END IF
CalcTempIntegral = dTsum
RETURN
END FUNCTION CalcTempIntegral