💻 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.
Steady Conduction — Plane Walls
Core Numerical Engine in Fortran 90 • 51 total downloads
! =========================================================================
! Source File: steady_heat_conduction_plane_walls.f90
! =========================================================================
program steady_heat_conduction_plane_walls
implicit none
integer :: n_layers, i
real(8) :: T_inner, T_outer, Q, R_total, area, heat_flux
real(8), allocatable :: thickness(:), k(:), R(:), T(:)
! Read number of layers
read *, n_layers
! Allocate arrays
allocate(thickness(n_layers))
allocate(k(n_layers))
allocate(R(n_layers))
allocate(T(0:n_layers))
! Read layer properties (thickness, conductivity)
do i = 1, n_layers
read *, thickness(i)
read *, k(i)
end do
! Read boundary temperatures and area
read *, T_inner
read *, T_outer
read *, area
! Calculate thermal resistances in K/W
R_total = 0.0d0
do i = 1, n_layers
! R_i = L_i / (k_i * A)
R(i) = thickness(i) / (k(i) * area)
R_total = R_total + R(i)
end do
! Calculate heat transfer rate Q (W)
Q = (T_inner - T_outer) / R_total
heat_flux = Q / area
! Calculate interface temperatures
T(0) = T_inner
T(n_layers) = T_outer
do i = 1, n_layers - 1
T(i) = T_inner - (T_inner - T_outer) * sum(R(1:i)) / R_total
end do
! Display results
print *, '========================================='
print *, 'STEADY STATE THERMAL CONDUCTION'
print *, 'GEOMETRY: PLANE WALLS'
print *, '========================================='
print *, ''
print *, 'INPUT PARAMETERS:'
print *, '----------------------------------------'
print '(A,F10.4,A)', ' Wall Area: ', area, ' m2'
print '(A,F10.2,A)', ' Inner Temperature: ', T_inner, ' deg-C'
print '(A,F10.2,A)', ' Outer Temperature: ', T_outer, ' deg-C'
print '(A,F10.2,A)', ' Temperature Difference: ', (T_inner - T_outer), ' deg-C'
print '(A,I3)', ' Number of Layers: ', n_layers
print *, ''
print *, '========================================='
print *, 'MAIN RESULTS'
print *, '========================================='
print *, ''
print '(A,F12.6,A)', ' Total Thermal Resistance: ', R_total, ' K/W'
print '(A,F12.2,A)', ' Total Heat Flux (Q): ', Q, ' W'
print '(A,F12.2,A)', ' Heat Flux Per Area (q): ', heat_flux, ' W/m2'
print *, ''
print *, '========================================='
print *, 'LAYER ANALYSIS'
print *, '========================================='
print *, ''
do i = 1, n_layers
print '(A,I2,A)', ' === Layer ', i, ' ==='
print '(A,F10.4,A)', ' Thickness (L): ', thickness(i), ' m'
print '(A,F10.4,A)', ' ', thickness(i)*1000.0d0, ' mm'
print '(A,F10.4,A)', ' Conductivity (k): ', k(i), ' W/m.K'
print '(A,F10.6,A)', ' Resistance (R): ', R(i), ' K/W'
print '(A,F8.2,A)', ' % of Total Resistance: ', (R(i)/R_total)*100.0d0, ' %'
print '(A,F10.2,A)', ' Inner Temperature: ', T(i-1), ' deg-C'
print '(A,F10.2,A)', ' Outer Temperature: ', T(i), ' deg-C'
print '(A,F10.2,A)', ' Temperature Drop: ', (T(i-1) - T(i)), ' deg-C'
print *, ''
end do
print *, '========================================='
print *, 'INTERFACE TEMPERATURES'
print *, '========================================='
print *, ''
print '(A,F10.2,A)', ' Inner Surface (T0): ', T(0), ' deg-C'
do i = 1, n_layers - 1
print '(A,I2,A,I2,A,F10.2,A)', ' Interface layer ', i, '-', i+1, ': ', T(i), ' deg-C'
end do
print '(A,F10.2,A)', ' Outer Surface (Tn): ', T(n_layers), ' deg-C'
print *, ''
print *, '========================================='
print *, 'PERFORMANCE METRICS'
print *, '========================================='
print *, ''
! Energy loss calculations
print *, 'ENERGY LOSSES (estimates):'
print '(A,F12.2,A)', ' Per hour: ', Q * 3600.0d0 / 1000.0d0, ' kJ/h'
print '(A,F12.2,A)', ' Per day: ', Q * 86400.0d0 / 1000.0d0, ' kJ/day'
print '(A,F12.2,A)', ' ', Q * 24.0d0 / 1000.0d0, ' kWh/day'
print '(A,F12.2,A)', ' Per year: ', Q * 8760.0d0 / 1000.0d0, ' kWh/year'
print *, ''
print *, '========================================='
print *, 'END OF CALCULATION'
print *, '========================================='
deallocate(thickness, k, R, T)
end program steady_heat_conduction_plane_walls
Solver Description
Conduction through a plane wall is governed by Fourier's Law of Heat Conduction. For steady-state 1D heat flow with no heat generation, the heat transfer rate is constant and defined as:
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):
3
! Thickness layer 1 [m]
0.1
! Conductivity layer 1 [W/m-K]
0.8
! Thickness layer 2 [m]
0.05
! Conductivity layer 2 [W/m-K]
0.04
! Thickness layer 3 [m]
0.2
! Conductivity layer 3 [W/m-K]
1.2
! Inner surface temperature [°C]
100.0
! Outer surface temperature [°C]
20.0
! Wall Area [m2]
1.0