💻 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.

Anisotropic Thermal Conduction

Core Numerical Engine in Fortran 90 • 28 total downloads

anisotropic_cond.f90
! =========================================================================
! Source File: anisotropic_cond.f90
! =========================================================================

program anisotropic_cond
  implicit none
  integer :: i
  double precision :: kx,ky,kz,Lx,Ly,Lz,Th,Tc,Ac,theta
  double precision :: dT,qx,qy,qz,Qx_rate,Qy_rate,Qz_rate,Rx,Ry,Rz
  double precision :: keff,th_rad,ths,keffs,pi
  pi=3.14159265358979d0
  read(*,*) kx; read(*,*) ky; read(*,*) kz
  read(*,*) Lx; read(*,*) Ly; read(*,*) Lz
  read(*,*) Th; read(*,*) Tc; read(*,*) Ac; read(*,*) theta
  dT=abs(Th-Tc)
  th_rad=theta*pi/180d0
  qx=kx*dT/Lx; qy=ky*dT/Ly; qz=kz*dT/Lz
  Qx_rate=qx*Ac; Qy_rate=qy*Ac; Qz_rate=qz*Ac
  Rx=Lx/(kx*Ac); Ry=Ly/(ky*Ac); Rz=Lz/(kz*Ac)
  keff=kx*cos(th_rad)**2+ky*sin(th_rad)**2
  write(*,'(A)') '============================================'
  write(*,'(A)') '  ANISOTROPIC THERMAL CONDUCTION'
  write(*,'(A)') '============================================'
  write(*,'(A)') ''
  write(*,'(A)') '--- INPUTS ---'
  write(*,'(A,F12.4,A)') '  k_x                     = ',kx,' W/mK'
  write(*,'(A,F12.4,A)') '  k_y                     = ',ky,' W/mK'
  write(*,'(A,F12.4,A)') '  k_z                     = ',kz,' W/mK'
  write(*,'(A,F10.4,A)') '  L_x                     = ',Lx,' m'
  write(*,'(A,F10.4,A)') '  L_y                     = ',Ly,' m'
  write(*,'(A,F10.4,A)') '  L_z                     = ',Lz,' m'
  write(*,'(A,F10.2,A)') '  T_hot                   = ',Th,' C'
  write(*,'(A,F10.2,A)') '  T_cold                  = ',Tc,' C'
  write(*,'(A,F10.4,A)') '  Cross Section A         = ',Ac,' m2'
  write(*,'(A,F10.2,A)') '  Rotation theta          = ',theta,' deg'
  write(*,'(A)') ''
  write(*,'(A)') '--- DIRECTIONAL PROPERTIES ---'
  write(*,'(A,F12.4,A)') '  Heat flux q_x           = ',qx,' W/m2'
  write(*,'(A,F12.4,A)') '  Heat flux q_y           = ',qy,' W/m2'
  write(*,'(A,F12.4,A)') '  Heat flux q_z           = ',qz,' W/m2'
  write(*,'(A,F12.4,A)') '  Heat rate Q_x           = ',Qx_rate,' W'
  write(*,'(A,F12.4,A)') '  Heat rate Q_y           = ',Qy_rate,' W'
  write(*,'(A,F12.4,A)') '  Heat rate Q_z           = ',Qz_rate,' W'
  write(*,'(A,F12.6,A)') '  Resistance R_x          = ',Rx,' K/W'
  write(*,'(A,F12.6,A)') '  Resistance R_y          = ',Ry,' K/W'
  write(*,'(A,F12.6,A)') '  Resistance R_z          = ',Rz,' K/W'
  write(*,'(A)') ''
  write(*,'(A)') '--- ANISOTROPY RATIOS ---'
  write(*,'(A,F10.4)')    '  k_x / k_y               = ',kx/ky
  write(*,'(A,F10.4)')    '  k_x / k_z               = ',kx/kz
  write(*,'(A,F10.4)')    '  k_y / k_z               = ',ky/kz
  write(*,'(A,F12.4,A)') '  k_eff(theta) in x-y     = ',keff,' W/mK'
  write(*,'(A)') ''
  write(*,'(A)') '--- ROTATED k_eff (x-y PLANE) ---'
  write(*,'(A)') '  Tensor rotation: k_eff = kx*cos^2(theta) + ky*sin^2(theta)'
  write(*,'(A)') ''
  write(*,'(A)') '--- ANGLE SWEEP ---'
  write(*,'(A)') '  theta[deg]  k_eff[W/mK]   q[W/m2]     Q[W]'
  write(*,'(A)') '  -----------------------------------------------'
  do i=1,19
    ths=dble(i-1)*5d0
    keffs=kx*cos(ths*pi/180d0)**2+ky*sin(ths*pi/180d0)**2
    write(*,'(2X,F8.1,4X,F10.4,4X,F10.4,4X,F10.4)') ths,keffs,keffs*dT/Lx,keffs*dT/Lx*Ac
  enddo
  write(*,'(A)') ''
  write(*,'(A)') '--- CORRELATIONS ---'
  write(*,'(A)') '  k_eff(theta) = kx*cos^2(theta) + ky*sin^2(theta)'
  write(*,'(A)') '  Off-diagonal: k_xy = (kx-ky)*sin(theta)*cos(theta)'
  write(*,'(A)') '  3D rotation requires full tensor transformation'
  write(*,'(A)') '  Ref: Incropera Appendix A, Ozisik Ch.1'
  write(*,'(A)') '       Chung, Thermal Conductivity of Composites'
end program anisotropic_cond


Solver Description

Calculates directional thermal fluxes and rotated effective thermal conductivities for anisotropic materials (e.g., carbon-fiber reinforced composites, wood, and layered PCBs) using 2D tensor rotation formulations: $k(\theta) = k_x \cos^2(\theta) + k_y \sin^2(\theta)$.

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 anisotropic_cond.f90 -o anisotropic_cond

Execution Command:

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

anisotropic_cond < input.txt

📥 Downloads & Local Files

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

! Conductivity k_x [W/mK]
7.0
! Conductivity k_y [W/mK]
0.8
! Conductivity k_z [W/mK]
0.8
! Thickness L_x [m]
0.01
! Thickness L_y [m]
0.01
! Thickness L_z [m]
0.01
! Hot surface temperature T_hot [C]
100.0
! Cold surface temperature T_cold [C]
25.0
! Cross-section area A [m2]
0.001
! Rotation angle theta [deg]
0.0