Additional features

Differentiability

The solutions of the ODEs, the retention times and the peak width, can be differentiated for different parameters of the system, e.g., the length $L$ or retention parameters $T_{\text{char}}$, using automatic differentiation (ForwardDiff.jl).

Attention!

The functionality of differentiability at the moment is intended only for non-gradient cases (no spatial thermal gradient, no variation of column diameter or film thickness along the column). Therefore, the option ng should be set to ng = true, see GasChromatographySimulator.Options.

Example code:

Using the solution of the ODE-system, see GasChromatographySimulator.solving_odesystem_r for a substance, the resulting retention time tR and peak variance τR² can be differentiated for selected parameters, e.g. the three retention parameters Tchar, θchar and ΔCp. A new function depending on these parameter (x = [Tchar, θchar, ΔCp]) is created.

using GasChromatographySimulator
using ForwardDiff
L = 30.0; d = 0.25e-3; df = 0.25e-6; gas = "He";
prog = GasChromatographySimulator.Program([40.0, 3.0, 10.0, 300.0, 5.0], [300000.0, 3.0, (450000.0-300000.0)/(300.0-40.0)*10.0, 450000.0, 5.0], L);
φ₀ = 1e-3; Cag = 1e-6; t₀ = 0.0; τ₀ = 0.0;
opt = GasChromatographySimulator.Options(ng=true);
tR_τR2_RP(x) = GasChromatographySimulator.solving_odesystem_r(L, d, df, gas, prog.T_itp, prog.Fpin_itp, prog.pout_itp, x[1], x[2], x[3], φ₀, Cag, t₀, τ₀, opt).u[end];
tR_τR2_RP([400.0, 30.0, 100.0])
2-element Vector{Float64}:
 544.0668637619017
  28.56351882889502

This function can be differentiated for these parameters using an automatic differentiation, like ForwardDiff.jl.

∂_tR_τR2_RP(x) = ForwardDiff.jacobian(tR_τR2_RP, x)

This function calculated the derivative for the selected value:

∂_tR_τR2_RP([400.0, 30.0, 100.0])
2×3 Matrix{Float64}:
 6.1556    -8.31033   0.169421
 0.640745  -0.347507  0.00783324

This functionality can be used for sensitivity analysis and can be helpful for the use of optimization methods.