💻 Fortran Source Code Library

We currently offer 172 open-source, production-grade Fortran codes for offline testing. Run calculations locally on your own machine, view code structure, read technical explanations, and download compilation packages including sample input files.

Compact Heat Exchanger Sizing

Core Numerical Engine in Fortran 90 • 34 total downloads

compact_hx.f90
! =========================================================================
! Source File: compact_hx.f90
! =========================================================================

program compact_hx
  implicit none
  integer :: i,stype
  double precision :: Re_Dh,Dh,sigma,alpha_d,Atot,Lf
  double precision :: Thi,Tci,Ch,Cc,Pr_h,Pr_c
  double precision :: j,ff,h_air,Nu,Cmin,Cmax,Cr,NTU,eps,Q
  double precision :: Res,js,fs,Nus
  read(*,*) stype; read(*,*) Re_Dh; read(*,*) Dh
  read(*,*) sigma; read(*,*) alpha_d; read(*,*) Atot
  read(*,*) Lf; read(*,*) Thi; read(*,*) Tci
  read(*,*) Ch; read(*,*) Cc; read(*,*) Pr_h; read(*,*) Pr_c
  if(stype==1) then; j=0.233d0*Re_Dh**(-0.48d0); ff=0.292d0*Re_Dh**(-0.25d0); endif
  if(stype==2) then; j=0.249d0*Re_Dh**(-0.42d0); ff=0.583d0*Re_Dh**(-0.28d0); endif
  if(stype==3) then; j=0.652d0*Re_Dh**(-0.54d0); ff=1.12d0*Re_Dh**(-0.36d0); endif
  if(stype==4) then; j=0.394d0*Re_Dh**(-0.49d0); ff=0.564d0*Re_Dh**(-0.29d0); endif
  Nu=j*Re_Dh*Pr_c**(1d0/3d0)
  h_air=Nu*0.026d0/Dh
  if(Ch<Cc) then; Cmin=Ch; Cmax=Cc; else; Cmin=Cc; Cmax=Ch; endif
  Cr=Cmin/Cmax
  NTU=h_air*Atot/Cmin
  eps=1d0-exp(NTU**0.78d0*Cr/(-1d0)*(exp(-Cr*NTU**0.22d0)-1d0))
  if(eps>1d0) eps=1d0; if(eps<0d0) eps=0d0
  Q=eps*Cmin*(Thi-Tci)
  write(*,'(A)') '============================================'
  write(*,'(A)') '  COMPACT HEAT EXCHANGER (KAYS & LONDON)'
  write(*,'(A)') '============================================'
  write(*,'(A)') ''
  write(*,'(A)') '--- INPUTS ---'
  if(stype==1) write(*,'(A)') '  Surface                 = Plain fin'
  if(stype==2) write(*,'(A)') '  Surface                 = Louvered fin'
  if(stype==3) write(*,'(A)') '  Surface                 = Offset strip fin'
  if(stype==4) write(*,'(A)') '  Surface                 = Wavy fin'
  write(*,'(A,F10.1)')    '  Re_Dh                   = ',Re_Dh
  write(*,'(A,F10.6,A)') '  Dh                      = ',Dh,' m'
  write(*,'(A,F10.4)')    '  sigma (Ac/Afr)          = ',sigma
  write(*,'(A,F10.1,A)') '  Surface density alpha   = ',alpha_d,' m2/m3'
  write(*,'(A,F10.2,A)') '  Total surface A         = ',Atot,' m2'
  write(*,'(A,F10.4,A)') '  Flow length L           = ',Lf,' m'
  write(*,'(A,F10.2,A)') '  T_hot_in                = ',Thi,' C'
  write(*,'(A,F10.2,A)') '  T_cold_in               = ',Tci,' C'
  write(*,'(A)') ''
  write(*,'(A)') '--- j AND f FACTORS ---'
  write(*,'(A,ES12.4)')  '  Colburn j-factor        = ',j
  write(*,'(A,ES12.4)')  '  Fanning f-factor        = ',ff
  write(*,'(A,F10.4)')    '  j/f ratio               = ',j/ff
  write(*,'(A,F10.2)')    '  Nusselt Nu              = ',Nu
  write(*,'(A,F10.2,A)') '  h_air                   = ',h_air,' W/m2K'
  write(*,'(A)') ''
  write(*,'(A)') '--- THERMAL RESULTS ---'
  write(*,'(A,F10.4)')    '  Cr                      = ',Cr
  write(*,'(A,F10.4)')    '  NTU                     = ',NTU
  write(*,'(A,F10.4)')    '  Effectiveness           = ',eps
  write(*,'(A,F12.2,A)') '  Heat transfer Q         = ',Q,' W'
  write(*,'(A,F10.2,A)') '  T_hot_out               = ',Thi-Q/Ch,' C'
  write(*,'(A,F10.2,A)') '  T_cold_out              = ',Tci+Q/Cc,' C'
  write(*,'(A)') ''
  write(*,'(A)') '--- Re SWEEP (j & f factors) ---'
  write(*,'(A)') '  Re        j          f          j/f       Nu'
  write(*,'(A)') '  --------------------------------------------------'
  do i=1,25
    Res=100d0*10d0**(2d0*dble(i-1)/24d0)
    if(stype==1) then; js=0.233d0*Res**(-0.48d0); fs=0.292d0*Res**(-0.25d0); endif
    if(stype==2) then; js=0.249d0*Res**(-0.42d0); fs=0.583d0*Res**(-0.28d0); endif
    if(stype==3) then; js=0.652d0*Res**(-0.54d0); fs=1.12d0*Res**(-0.36d0); endif
    if(stype==4) then; js=0.394d0*Res**(-0.49d0); fs=0.564d0*Res**(-0.29d0); endif
    Nus=js*Res*Pr_c**(1d0/3d0)
    write(*,'(2X,F8.0,2X,ES10.3,2X,ES10.3,2X,F8.4,2X,F8.2)') Res,js,fs,js/fs,Nus
  enddo
  write(*,'(A)') ''
  write(*,'(A)') '--- CORRELATIONS ---'
  write(*,'(A)') '  Plain fin:    j=0.233*Re^-0.48  f=0.292*Re^-0.25'
  write(*,'(A)') '  Louvered:     j=0.249*Re^-0.42  f=0.583*Re^-0.28'
  write(*,'(A)') '  Offset strip: j=0.652*Re^-0.54  f=1.12*Re^-0.36 (Manglik-Bergles)'
  write(*,'(A)') '  Wavy fin:     j=0.394*Re^-0.49  f=0.564*Re^-0.29'
  write(*,'(A)') '  Cross-flow unmixed: eps=1-exp((NTU^0.78/Cr)(exp(-Cr*NTU^0.22)-1))'
  write(*,'(A)') '  Ref: Kays & London, Compact Heat Exchangers (1984)'
  write(*,'(A)') '       Manglik & Bergles, J Heat Transf (1995)'
end program compact_hx


Solver Description

Thermal analysis and sizing of compact heat exchangers using Kays and London performance correlations. Supports plain, louvered, offset strip, and wavy fin geometry configurations. Evaluates Colburn j-factors, friction f-factors, Nusselt numbers, exchanger effectiveness, and total heat transfer duty.

Key Numerical Methods & Architecture

  • Input Redirection: Reads parameters sequentially from standard input (`stdin`) using Fortran sequential read (`read(*,*)`), ensuring modular integration.
  • Modular Design: Formulated using pure mathematical routines, separation of equations from output formatting, and precise numerical solvers (e.g. bisection, Newton-Raphson).
  • Standard Compliant: Written in clean, standards-compliant Fortran 90 to ensure cross-compiler compatibility.

🛠️ Local Compilation

To test this code on your machine, compile the source code file(s) using a standard Fortran compiler (e.g., `gfortran`).

Compilation Command:

gfortran -O3 compact_hx.f90 -o compact_hx

Execution Command:

Execute the program by feeding the sample input file into the program using stdin redirection:

compact_hx < input.txt

📥 Downloads & Local Files

Preview of the required input file (input.txt):

! Surface type (1=Plain fin, 2=Louvered, 3=Offset strip, 4=Wavy)
1
! Reynolds number Re_Dh
800
! Hydraulic diameter Dh [m]
0.003
! Frontal area ratio sigma (Ac/Afr)
0.534
! Surface density alpha [m2/m3]
886
! Total surface area A_tot [m2]
10
! Flow length Lf [m]
0.05
! Inlet hot temperature Thi [°C]
90
! Inlet cold temperature Tci [°C]
25
! Hot fluid capacity rate Ch [W/K]
2000
! Cold fluid capacity rate Cc [W/K]
1500
! Hot fluid Prandtl number Pr_h
0.71
! Cold fluid Prandtl number Pr_c
0.71