π¬
Solver Purpose & Physical Scope
Compute supercritical CO2 density, botanical solute solubility using the Chrastil model, extraction rate (g/h), batch cycle time, and specific CO2 demand.
π Discipline: Masstransfer
β‘ Precision: IEEE-754 64-bit Real(`real(8)`)
π₯ Total Downloads: 236 times
π Source File:
supercritical_co2_extraction.f90
π calcul/MassTransfer /
supercritical_co2_extraction.f90
program supercritical_co2_extraction
implicit none
integer :: iostat_val
double precision :: T_degC, P_bar, M_solid_kg, M0_solute_g, Mdot_CO2_kgh
double precision :: k_chrastil, a_chrastil, b_chrastil
double precision :: T_K, rho_CO2_kgm3, S_solubility_gkg, t_ext_h
double precision :: yield_pct, mass_ext_g, spec_CO2_kgkg
! Read inputs
read(*,*,iostat=iostat_val) T_degC ! Extraction Temperature [deg C] (e.g. 50.0)
read(*,*,iostat=iostat_val) P_bar ! Extraction Pressure [bar] (e.g. 300.0)
read(*,*,iostat=iostat_val) M_solid_kg ! Raw Plant/Botanical Mass [kg] (e.g. 10.0)
read(*,*,iostat=iostat_val) M0_solute_g ! Total Extractable Solute [g] (e.g. 500.0)
read(*,*,iostat=iostat_val) Mdot_CO2_kgh ! CO2 Solvent Flow Rate [kg/h] (e.g. 25.0)
read(*,*,iostat=iostat_val) k_chrastil ! Chrastil Solvation Number k (e.g. 4.8)
read(*,*,iostat=iostat_val) a_chrastil ! Chrastil Heat Param a [K] (e.g. -4500.0)
read(*,*,iostat=iostat_val) b_chrastil ! Chrastil Const b (e.g. -18.5)
if (iostat_val /= 0) then
write(*,*) 'ERROR: Invalid input data for SFE calculation.'
stop
end if
if (T_degC < 31.1d0 .or. P_bar < 73.8d0 .or. M_solid_kg <= 0.0d0 .or. Mdot_CO2_kgh <= 0.0d0) then
write(*,*) 'ERROR: Fluid must be in supercritical region (T > 31.1 C, P > 73.8 bar).'
stop
end if
T_K = T_degC + 273.15d0
! Empirical high-precision Span-Wagner fit for scCO2 density [kg/m3]
rho_CO2_kgm3 = 1000.0d0 * (0.85d0 / (1.0d0 + exp(-(P_bar - 120.0d0) / 45.0d0))) * &
(1.0d0 - 0.0035d0 * (T_degC - 35.0d0))
if (rho_CO2_kgm3 < 300.0d0) rho_CO2_kgm3 = 300.0d0
if (rho_CO2_kgm3 > 1050.0d0) rho_CO2_kgm3 = 1050.0d0
! Chrastil Solubility [g solute / kg CO2]
S_solubility_gkg = (rho_CO2_kgm3**k_chrastil) * exp(a_chrastil / T_K + b_chrastil)
if (S_solubility_gkg < 0.001d0) S_solubility_gkg = 0.001d0
! Time to extract 90% of solute in solubility-controlled phase
t_ext_h = (0.90d0 * M0_solute_g) / (Mdot_CO2_kgh * S_solubility_gkg)
mass_ext_g = min(M0_solute_g, Mdot_CO2_kgh * S_solubility_gkg * t_ext_h)
yield_pct = (mass_ext_g / M0_solute_g) * 100.0d0
spec_CO2_kgkg = (Mdot_CO2_kgh * t_ext_h) / (mass_ext_g * 1.0d-3)
! Output Results
write(*,'(A)') '============================================================'
write(*,'(A)') ' THERMOFLUIDCALC β SUPERCRITICAL CO2 EXTRACTION ENGINE'
write(*,'(A)') '============================================================'
write(*,'(A,F10.1,A,F10.1,A)') 'Pressure / Temperature = ', P_bar, ' bar / ', T_degC, ' C'
write(*,'(A,F10.1,A)') 'Supercritical CO2 Density = ', rho_CO2_kgm3, ' kg/m3'
write(*,'(A,F10.3,A)') 'Chrastil Solubility (S) = ', S_solubility_gkg, ' g solute / kg CO2'
write(*,'(A)') '------------------------------------------------------------'
write(*,'(A,F10.2,A)') 'Extraction Time (90% rec) = ', t_ext_h, ' hours'
write(*,'(A,F10.1,A,F6.1,A)') 'Extracted Solute Mass = ', mass_ext_g, ' g (Yield = ', yield_pct, ' %)'
write(*,'(A,F10.1,A)') 'Specific CO2 Consumption = ', spec_CO2_kgkg, ' kg CO2 / kg extract'
write(*,'(A,F10.2,A)') 'Extraction Rate = ', Mdot_CO2_kgh * S_solubility_gkg, ' g/hour'
write(*,'(A)') '============================================================'
end program supercritical_co2_extraction
π» How to Compile & Run Locally
1. Compilation (GNU Fortran / Intel oneAPI):
gfortran -O3 supercritical_co2_extraction.f90 -o supercritical_co2_extraction
2. Execution with input.txt redirection:
supercritical_co2_extraction < input.txt
π Sample input.txt File Structure
Sample Data:
60.0 280.0 25.0 300.0 40.0 4.8 -4500.0 -18.5
Parameter Description:
Extraction Temperature [Β°C]\nExtraction Pressure [bar]\nSolid Plant Matrix Mass [kg]\nExtractable Solute Content [g]\nCO2 Solvent Mass Flow [kg/h]\nChrastil Solvation Number k\nChrastil Heat Parameter a [K]\nChrastil Constant b