💻 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.
Regenerative Heat Exchanger Analysis
Core Numerical Engine in Fortran 90 • 31 total downloads
! =========================================================================
! Source File: regenerator.f90
! =========================================================================
program regenerator
implicit none
integer :: i,rtype
double precision :: Ch,Cc,Thi,Tci,NTU,Cr_star,rpm,m_mat,cp_mat
double precision :: Cmin,Cmax,Cr,eps,Q,Tho,Tco,eps_cf
double precision :: leak,NTUs,epss,Qs
read(*,*) rtype; read(*,*) Ch; read(*,*) Cc
read(*,*) Thi; read(*,*) Tci; read(*,*) NTU; read(*,*) Cr_star
read(*,*) rpm; read(*,*) m_mat; read(*,*) cp_mat
if(Ch<Cc) then; Cmin=Ch; Cmax=Cc; else; Cmin=Cc; Cmax=Ch; endif
Cr=Cmin/Cmax
if(abs(Cr-1d0)<1d-6) then
eps_cf=NTU/(1d0+NTU)
else
eps_cf=(1d0-exp(-NTU*(1d0-Cr)))/(1d0-Cr*exp(-NTU*(1d0-Cr)))
endif
if(rtype==1.and.Cr_star>0d0) then
eps=eps_cf*(1d0-1d0/(9d0*Cr_star**1.93d0))
if(eps<0d0) eps=0d0
else
eps=eps_cf
endif
Q=eps*Cmin*(Thi-Tci)
Tho=Thi-Q/Ch
Tco=Tci+Q/Cc
if(rtype==1) then; leak=0.03d0; else; leak=0d0; endif
write(*,'(A)') '============================================'
write(*,'(A)') ' REGENERATIVE HEAT EXCHANGER'
write(*,'(A)') '============================================'
write(*,'(A)') ''
write(*,'(A)') '--- INPUTS ---'
if(rtype==1) write(*,'(A)') ' Type = Rotary (wheel)'
if(rtype==2) write(*,'(A)') ' Type = Fixed matrix'
write(*,'(A,F10.2,A)') ' C_hot = ',Ch,' W/K'
write(*,'(A,F10.2,A)') ' C_cold = ',Cc,' W/K'
write(*,'(A,F10.2,A)') ' T_hot_in = ',Thi,' C'
write(*,'(A,F10.2,A)') ' T_cold_in = ',Tci,' C'
write(*,'(A,F10.4)') ' NTU = ',NTU
write(*,'(A,F10.4)') ' Cr* (matrix cap ratio) = ',Cr_star
if(rtype==1) write(*,'(A,F10.2,A)') ' Rotation speed = ',rpm,' rpm'
write(*,'(A,F10.2,A)') ' Matrix mass = ',m_mat,' kg'
write(*,'(A,F10.1,A)') ' Matrix cp = ',cp_mat,' J/kgK'
write(*,'(A)') ''
write(*,'(A)') '--- RESULTS ---'
write(*,'(A,F10.4)') ' C_min = ',Cmin
write(*,'(A,F10.4)') ' C_max = ',Cmax
write(*,'(A,F10.4)') ' C_r = Cmin/Cmax = ',Cr
write(*,'(A,F10.4)') ' eps_counterflow = ',eps_cf
write(*,'(A,F10.4)') ' eps (with Cr* corr) = ',eps
write(*,'(A,F12.2,A)') ' Heat transfer Q = ',Q,' W'
write(*,'(A,F10.2,A)') ' T_hot_out = ',Tho,' C'
write(*,'(A,F10.2,A)') ' T_cold_out = ',Tco,' C'
if(rtype==1) write(*,'(A,F8.2,A)') ' Carryover leakage est = ',leak*100d0,' %'
write(*,'(A)') ''
write(*,'(A)') '--- NTU SWEEP ---'
write(*,'(A)') ' NTU eps_cf eps Q[W] Tho[C] Tco[C]'
write(*,'(A)') ' ---------------------------------------------------------------'
do i=1,25
NTUs=0.5d0+9.5d0*dble(i-1)/24d0
if(abs(Cr-1d0)<1d-6) then
epss=NTUs/(1d0+NTUs)
else
epss=(1d0-exp(-NTUs*(1d0-Cr)))/(1d0-Cr*exp(-NTUs*(1d0-Cr)))
endif
if(rtype==1.and.Cr_star>0d0) epss=epss*(1d0-1d0/(9d0*Cr_star**1.93d0))
if(epss<0d0) epss=0d0
Qs=epss*Cmin*(Thi-Tci)
write(*,'(2X,F6.2,2X,F8.4,2X,F8.4,2X,F12.2,2X,F8.2,2X,F8.2)') NTUs,NTUs/(1d0+NTUs),epss,Qs,Thi-Qs/Ch,Tci+Qs/Cc
enddo
write(*,'(A)') ''
write(*,'(A)') '--- CORRELATIONS ---'
write(*,'(A)') ' Counterflow: eps=(1-exp(-NTU(1-Cr)))/(1-Cr*exp(-NTU(1-Cr)))'
write(*,'(A)') ' Rotary Cr* correction: eps=eps_cf*(1-1/(9*Cr*^1.93))'
write(*,'(A)') ' Valid for Cr* > 2, NTU up to ~10'
write(*,'(A)') ' Ref: Kays & London, Compact Heat Exchangers (1984)'
write(*,'(A)') ' Shah & Sekulic, Fundamentals of HX Design (2003)'
end program regenerator
Solver Description
Analyzes regenerative heat exchangers, supporting both rotary (Ljungstrom wheel) and fixed-matrix configurations. Uses effectiveness-NTU methods corrected for matrix heat storage capacity ratio (^*$) and rotational speed. Computes overall thermal effectiveness, heat transfer rate, outlet temperatures, and rotational speed/matrix mass dependencies.
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:
Execution Command:
Execute the program by feeding the sample input file into the program using stdin redirection:
📥 Downloads & Local Files
Preview of the required input file (input.txt):
1
! Hot fluid heat capacity rate Ch [W/K]
500
! Cold fluid heat capacity rate Cc [W/K]
450
! Inlet hot temperature Thi [°C]
35
! Inlet cold temperature Tci [°C]
5
! Number of Transfer Units NTU
3
! Matrix-to-minimum fluid capacity ratio Cr*
5
! Rotation speed [rpm] (Rotary only)
10
! Matrix mass m_mat [kg]
200
! Matrix specific heat cp_mat [J/kg-K]
900