Module Index

Detailed API

GasChromatographySystems.ModuleColumnType
ModuleColumn(; Tcold_abs=true, sflank=40, tflank=20, alg=Vern9(), abstol=1e-10, reltol=1e-8, dtinit=1e-6, ng=true, Tcontrol="inlet")

Structure describing the module of a gas chromatographic column, the basic buliding block of a gas chromatographic system. These are edges of the graph representation of a GC system.

Arguments

  • name: Name of the module.
  • L: Length of the column in m.
  • d: Internal diameter of the column in m. This can be a function of column position, if a non-uniform diameter is used (not tested yet).
  • a_d: Parameters of the diameter function d. Empty, if d is not a function.
  • df: Film thickness of the column in m. This can be a function of column position, if a non-uniform film thickness is used (not tested yet).
  • a_df: Parameters of the film thickness function df. Empty, if df is not a function.
  • sp: The name of the stationary phase.
  • T: Temperature of the module. This can be a value (in °C) or a temperature program as a TemperatureProgram structure.
  • F: Flow of the mobile phase through the column in mL/min. This can be an number, a fuction or a NaN (if it is not defined yet an should be calculated based on values from other modules or pressure points in the system).
  • opt: Options for this module. This is a structure of the form ModuleColumnOptions.

Four methods to construct this structure exist:

  • ModuleColumn(name, L, d, df, sp, T, opt::ModuleColumnOptions): The flow is not defined, uniform d and df.
  • ModuleColumn(name, L, d, df, sp, T, F, opt::ModuleColumnOptions): The flow is defined by F and uniform d and df.
  • ModuleColumn(name, L, d, df, sp, T; alg=OwrenZen5(), abstol=1e-8, reltol=1e-6, ng=false, Tcontrol="inlet"): The flow is not defined, uniform d and df. Options according to ModuleColumnOptions.
  • ModuleColumn(name, L, d, df, sp, tp, flow; alg=OwrenZen5(), abstol=1e-8, reltol=1e-6, ng=false, Tcontrol="inlet"): The flow is defined by F and uniform d and df. Options according to ModuleColumnOptions.
source
GasChromatographySystems.ModuleColumnOptionsType
ModuleColumnOptions(; alg=OwrenZen5(), abstol=1e-8, reltol=1e-5, ng=false, Tcontrol="inlet")

Structure describing options for column modules.

Arguments

  • alg: The algorithm used for the ODE solver. The algorithms OwrenZen3(), OwrenZen4() and OwrenZen5() are recommended.
  • abstol: The absolute tolerance for the ODE solver. Recommended value 1e-6 to 1e-8.
  • reltol: The relative tolerance for the ODE solver. Recommended value 1e-3 to 1e-5.
  • ng: Option to calculate the simulation without a gradient (ng = true, default) or with a gradient (ng = false).
  • Tcontrol: Option defining at which point of the column the temperature program is calculated. The options are inlet (x=0) and outlet (x=L).
source
GasChromatographySystems.ModuleTMType
ModuleTM(; Tcold_abs=true, sflank=40, tflank=20, alg=Vern9(), abstol=1e-10, reltol=1e-8, dtinit=1e-6, ng=true, Tcontrol="inlet")

Structure describing the module of a thermal modulator, a short section of a column with a periodic repeating temperature modulation between a cold and hot jet. These are edges of the graph representation of a GC system.

Arguments

  • name: Name of the module.
  • L: Length of the column in m.
  • d: Internal diameter of the column in m. This can be a function of column position, if a non-uniform diameter is used (not tested yet).
  • a_d: Parameters of the diameter function d. Empty, if d is not a function.
  • df: Film thickness of the column in m. This can be a function of column position, if a non-uniform film thickness is used (not tested yet).
  • a_df: Parameters of the film thickness function df. Empty, if df is not a function.
  • sp: The name of the stationary phase.
  • T: Basic temperature of the module. On top of this temperature the modulation occurs. This can be a value (in °C) or a temperature program as a TemperatureProgram structure.
  • shift: Time shift in s of the periodic modulation relative to the start of the chromatogram.
  • PM: Modulation period in s.
  • ratio: The ratio of the duration of cold and hot jet.
  • Thot: Temperature in °C, by which T is increased while the hot jet is active.
  • Tcold: Temperature in °C, by which T is decrease while the cold jet is active (if Tcold_abs = false in ModuleColumnOptions) or to which the column is cooled down (if Tcold_abs = true in ModuleTMOptions)
  • F: Flow of the mobile phase through the column in mL/min. This can be an number, a fuction or a NaN (if it is not defined yet an should be calculated based on values from other modules or pressure points in the system).
  • opt: Options for this module. This is a structure of the form ModuleTMOptions.

Four methods to construct this structure exist:

  • ModuleTM(name, L, d, df, sp, T, shift, PM, ratio, Thot, Tcold, opt::ModuleTMOptions): The flow is not defined, uniform d and df.
  • ModuleTM(name, L, d, df, sp, T, shift, PM, ratio, Thot, Tcold, F, opt::ModuleTMOptions): The flow is defined by F and uniform d and df.
  • ModuleTM(name, L, d, df, sp, T, shift, PM, ratio, Thot, Tcold; Tcold_abs=true, sflank=40, tflank=20, alg=Vern9(), abstol=1e-10, reltol=1e-8, dtinit=1e-6, ng=false, Tcontrol="inlet"): The flow is not defined, uniform d and df. Options according to ModuleTMOptions.
  • ModuleTM(name, L, d, df, sp, tp, shift, pm, ratio, Thot, Tcold, F; Tcold_abs=true, sflank=40, tflank=20, alg=Vern9(), abstol=1e-10, reltol=1e-8, dtinit=1e-6, ng=false, Tcontrol="inlet"): The flow is defined by F and uniform d and df. Options according to ModuleTMOptions.
source
GasChromatographySystems.ModuleTMOptionsType
ModuleTMOptions(; Tcold_abs=true, sflank=40, tflank=20, alg=Vern9(), abstol=1e-10, reltol=1e-8, dtinit=1e-6, ng=true, Tcontrol="inlet")

Structure describing options for thermal modulator modules.

Arguments

  • Tcold_abs: Calculate the low temperature at the modulator as the absolute value of the defined parameter Tcold (Tcold_abs = true) or as relative temperature difference from the defined oven temperature (Tcold_abs = false).
  • sflank: Flank factor of the smoothed rectangle temperature function in space. A higher factor results in a steeper slope at the edges of the modulator point. Values between 12 and 100, or Inf if ng = true. Recommend sflank = 40. Only relevante, if option ng = false.
  • tflank: Flank factor of the smoothed rectangle temperature function in time. A higher factor results in a steeper slope at the begining and end of the hot jet. Values between 12 and 100. Recommend tflank = 20.
  • alg: The algorithm used for the ODE solver. For the thermal modulator module the algorithm Vern9() is recommend.
  • abstol: The absolute tolerance for the ODE solver. Recommended value 1e-6 to 1e-12.
  • reltol: The relative tolerance for the ODE solver. Recommended value 1e-3 to 1e-10.
  • dtinit: The initial step width for the ODE solver. A value of L*1e-6, with L the length of the modulator module, is recommend.
  • ng: Option to calculate the simulation without a gradient (ng = true, default) or with a gradient (ng = false).
  • Tcontrol: Option defining at which point of the column the temperature program is calculated. The options are inlet (x=0) and outlet (x=L).
source
GasChromatographySystems.OptionsType
Options(; gas="He", odesys=true, vis="Blumberg", control="Pressure", k_th=1e12)

Structure describing general options for the simulation of the system.

Arguments

  • gas: The type of gas used as mobile phase in the gas chromatographic system. Allowed values: He, H2 or N2.
  • odesys: Combine the ODEs for migration and peak-width into a system of ODEs (odesys = true) or solve the two ODEs separately (odesys = false).
  • vis: Used model of viscosity. HP is a second-order polynomial taken from the HP flow calculator. Blumberg is an emperical formula according to the book Temperature-programmed Gas Chromatography by Leonid M. Blumberg (2010, Wiley-VCH).
  • control: Control of the "Flow" or of the "Pressure" (at column inlet) during the program.
  • k_th: Threshold for the maximum of the retention factor. If the calculated retention factor is bigger than k_th than the retention factor is set to the value k_th. This is done to avoid to small step widths in the solver for highly retained soultes at the beginning of a GC program.
source
GasChromatographySystems.PressurePointType
PressurePoint(name, PP)

Structure describing the pressure program at the connection points of the modules. These are the vertices of the graph representation of a GC system.

Arguments

  • name: Name of the PressurePoint.
  • P: Pressure program as structure GasChromatographySystems.PressureProgram or as a number for constant pressure.
source
GasChromatographySystems.PressureProgramType
PressureProgram(time_steps, pressure_steps)

Structure describing the pressure program.

Arguments

  • time_steps: Time steps in s, after which the corresponding pressure in pressure_steps is reached.
  • pressure_steps: Pressure steps in Pa.

A default temperature program is avaliable:

  • default_PP(): Pressure increase from 100.000 Pa to 200.000 in 1800 s (30 min).
source
GasChromatographySystems.SystemType
System(g, pressurepoints, modules, options)

Structure describing a GC system.

Arguments

  • name: Name of the GC system.
  • g: The graph representation of the GC system, using SimpleDiGraph from Graphs.jl.
  • pressurepoints: The vertices of graph g and their pressure programs. These are structures of type PressurePoint.
  • modules: The edges of graph g. These are column segments of type ModuleColumn or thermal modulator points of type ModuleTM.

Examples

Simple GC:

Definition of the graph:

    g = SimpleDiGraph(1)
    add_edge!(g, 1, 2)

Definition of the two pressure points, here column inlet has the default pressure program and the outlet pressure is constant:

    pp = Array{GasChromatographySystems.PressurePoint}(undef, nv(g))
    pp[1] = GasChromatographySystems.PressurePoint("p_in", GasChromatographySystems.default_PP())
    pp[2] = GasChromatographySystems.PressurePoint("p_out", pout)

Definition of the column module with default temperature program default_TP(), flow is unknown and is calculated from the pressures, default module options:

    modules = Array{GasChromatographySystems.AbstractModule}(undef, ne(g))  
    modules[1] = GasChromatographySystems.ModuleColumn("column", 30.0, 0.25*1e-3, 0.25*1e-6, "Rxi5ms", GasChromatographySystems.default_TP())

Combination to construct the System using the function update_system() and default system options:

    sys = GasChromatographySystems.update_system(GasChromatographySystems.System(g, pp, modules, GasChromatographySystems.Options()))

Series of n columns:

Definition of the graph:

    g = SimpleDiGraph(n+1)
	for i=1:n
		add_edge!(g, i, i+1) 
	end

Split of Columns:

GCxGC with thermal modulation and loop:

source
GasChromatographySystems.TemperatureProgramType
TemperatureProgram(time_steps, temp_steps, gf, a_gf)

Structure describing the temperature program.

Arguments

  • time_steps: Time steps in s, after which the corresponding temperature in temp_steps is reached.
  • temp_steps: Temperature steps in °C.
  • gf: Gradient function gf(x, a_gf), describes the thermal gradient.
  • a_gf:Parameters of the gradient function.

Two method to construct this structure exist for a uniform temperatur program (same for all column positions x):

  • TemperatureProgram(time_steps, temp_steps)
  • TemperatureProgram(CP), with CP beeing a conventional notation of a temperature program in the form of an array with the pattern [T1, t1, r1, T2, t2, r2, ..., Tn, tn], with Ti temperature niveaus, ti holding times for the corresponding tempertures, ri the heating ramp between temperatures Ti and Ti+1.

A default temperature program is avaliable:

  • default_TP(): Heating from 40°C to 340°C in 1800 s (30 min).
source
GasChromatographySystems.build_pressure_squared_functionsMethod
build_pressure_squared_functions(sys, solutions; mode="λ")

Construct array of functions of the solutions for the unkown squared pressures of the flow balance equations of the system of capillaries sys.

The arguments for the build functions are arrays of the ordered known squared pressures $p^2$, the ordered known flow permabilities $λ$ resp. flow restrictions $κ$, the ordered known flows $F$ and constant $A = π/256 p_n/T_n$.

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
  • solutions: The solutions of the flow balance equations for the unknown pressures as symbolic expressions.
  • mode: Mode for flow equations to use flow permeabilities λ (mode = λ; default) or flow restrictions κ (mode = κ)
source
GasChromatographySystems.check_expressions_λ_κMethod
check_expressions_λ_κ(sol; mode="λ", n=100)

Checks the expressions of the array sol (solutions to the flow balance equations) if they use the flow permeabilities λ or the flow restrictions κ and substitutes them if needed.

Arguments

  • sol: Symbolic expressions (of the solutions for the flow balance equations)
  • mode: Mode for flow equations to use flow permeabilities λ (mode = λ; default) or flow restrictions κ (mode = κ)
  • n: Maximum of the number of expected symbols λ resp. κ. Could be replaced by the number of edges of the used system n = ne(sys.g).
source
GasChromatographySystems.check_retention_cold_jetMethod
check_retention_cold_jet(T, par, df_A, PM, ratio, shift, Thot, Tcold)

Check if solutes are retained during the cold phase of thermal modulation by calculating their migration distance.

This function analyzes whether solutes will be retained in the column during the cold phase of thermal modulation by calculating their migration distance under cold phase conditions. It determines if solutes will reach the end of the column before the cold phase ends.

Arguments

  • T: Base temperature or temperature program for the column
  • par: Parameters structure containing column, program, and substance information
  • df_A: DataFrame containing peak areas and initial times from slicing
  • PM: Modulation period in seconds
  • ratio: Ratio of cold phase duration to total period (0 < ratio < 1)
  • shift: Time shift of the modulation pattern in seconds
  • Thot: Temperature difference for hot phase in °C
  • Tcold: Temperature difference for cold phase in °C (absolute or relative)

Returns

  • DataFrame containing:
    • Name: Substance names
    • retained: Boolean array indicating if solutes are retained during cold phase
    • x_cold: Calculated migration distance during cold phase
    • k_cold: Retention factors during cold phase
    • tstartcold: Start times of cold phases
    • tstart: Initial start times of peaks

Notes

  • Uses mod_number for consistent modulation period calculations
  • Calculates migration distance based on cold phase duration and retention factors
  • Considers both absolute and relative cold phase temperatures
  • A solute is considered retained if its migration distance is less than column length
  • Useful for predicting breakthrough during cold phase of modulation
source
GasChromatographySystems.check_temperature_gradientMethod
check_temperature_gradient(T)

Check if a temperature program includes a thermal gradient.

This function determines whether a given temperature specification includes a thermal gradient by examining the gradient parameters. It handles both constant temperature values and temperature programs.

Arguments

  • T: Either a constant temperature value (Number) or a TemperatureProgram structure

Returns

  • gradient: Boolean indicating whether a thermal gradient is present
    • false for constant temperature values
    • false for temperature programs with no gradient (all gradient parameters zero)
    • true for temperature programs with non-zero gradient parameters

Notes

  • For temperature programs, the presence of a gradient is determined by checking if the first column of gradient parameters (a_gf[:, 1]) contains any non-zero values
  • This assumes that the first parameter of a_gf is non-zero when a temperature gradient exists
  • usage for the option ng as: ng=!check_temperature_gradient(TPs[i])
source
GasChromatographySystems.flow_balanceMethod
flow_balance(sys)

Constructing the flow balance equations of the capillary system sys in the form of an array of symbolic equations.

For every inner vertice the sum of ingoing flows (positive) and of outgoing flows (negative) are equated to zero.

\[\Sum F_{in} + \Sum F_{out} = 0\]

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
source
GasChromatographySystems.flow_functionsMethod
flow_functions(sys, p2fun; mode="λ")

Collects the flow functions as functions of time t for all edges of the system of capillaries sys.

The flow over edge i => j is calculated as

\[F_{i,j} = \frac{A}{κ_{i,j}} \left(p_i^2-p_j^2\right)\]

with flow restriction $κ_{i,j} = \int_0^{L_{i,j}} η(T_{i,j})T_{i,j}/d_{i,j}^4 dx$, pressures $p_i$ resp. $p_j$ at the vertices $i$ resp. $j$, temperature $T_{i,j}$, capillary length $L_{i,j}$ and diameter $d_{i,j}$ of the edge i => j.

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
  • p2fun: Julia function of the solutions of the flow balance equations from build_pressure_squared_functions(sys; mode="λ")
  • mode: Mode for flow equations to use flow permeabilities λ (mode = λ; default) or flow restrictions κ (mode = κ)
source
GasChromatographySystems.flow_permeabilitiesMethod
flow_permeabilities(sys)

Calculates the flow permeabilities λ of all edges (capliaries) of a system of capillaries.

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
source
GasChromatographySystems.flow_restrictionsMethod
flow_restrictions(sys)

Calculates the flow restrictions κ of all edges (capliaries) of a system of capillaries.

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
source
GasChromatographySystems.graph_to_parametersMethod
graph_to_parameters(sys, p2fun, db_dataframe, selected_solutes; interp=true, dt=1, mode="λ")

Convert a gas chromatography system graph into simulation parameters for each module.

This function processes a GC system graph and generates the necessary parameters for simulating solute transport through each module in the system. It handles both column modules and thermal modulators, setting up temperature programs, pressure functions, and substance parameters.

Arguments

  • sys: The GC system structure containing the network of modules
  • p2fun: Pressure functions for the system
  • db_dataframe: Database containing solute properties
  • selected_solutes: List of solutes to include in the simulation

Keyword Arguments

  • interp: Whether to use interpolated pressure functions (default: true)
  • dt: Time step for pressure function interpolation (default: 1)
  • mode: Mode for flow calculations ("λ" for permeability or "κ" for restriction) (default: "λ")

Returns

  • Array of GasChromatographySimulator.Parameters objects, one for each module in the system

Notes

  • Handles both constant and programmed temperature/pressure conditions
  • Sets up column parameters including length, diameter, and stationary phase
  • Configures temperature programs with interpolation functions
  • Loads solute properties from the database for the specified stationary phase
  • Applies module-specific options including numerical solver settings
  • Supports both ModuleColumn and ModuleTM (thermal modulator) types
source
GasChromatographySystems.holdup_time_functionsMethod
holdup_time_functions(sys, p2fun; mode="λ")

Collects the hold-up time functions as functions of time t for all edges of the system of capillaries sys.

The hold-up time over edge i => j is calculated as

\[t_{M_{i,j}} = \frac{128}{3} η(T_{i,j}) \frac{L_{i,j}^2}{d_{i,j}^2} \frac{p_i^3-p_j^3}{\left(p_i^2-p_j^2\right)^2}\]

with flow restriction, pressures $p_i$ resp. $p_j$ at the vertices $i$ resp. $j$, temperature $T_{i,j}$, capillary length $L_{i,j}$ and diameter $d_{i,j}$ of the edge i => j.

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
  • p2fun: Julia function of the solutions of the flow balance equations from build_pressure_squared_functions(sys; mode="λ")
  • mode: Mode for flow equations to use flow permeabilities λ (mode = λ; default) or flow restrictions κ (mode = κ)
source
GasChromatographySystems.holdup_time_pathMethod
holdup_time_path(sys, p2fun, numpaths; mode="λ")

Calculates the hold-up times of the numpaths paths as functions of time t of the system of capillaries sys.

The hold-up time over edge i => j is calculated as

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
  • p2fun: Julia function of the solutions of the flow balance equations from build_pressure_squared_functions(sys; mode="λ")
  • numpaths: Number of the different paths between inlet and outlets of system sys.
  • mode: Mode for flow equations to use flow permeabilities λ (mode = λ; default) or flow restrictions κ (mode = κ)
source
GasChromatographySystems.interpolate_pressure_functionsMethod
interpolate_pressure_functions(sys, p2fun; dt=1, mode="λ")

Interpolates (linearly) all pressure funtions at the vertices of the system of capillaries sys between the time steps dt. For the speed of the simulation these interpolated functions are faster than the pure solution functions of the flow balance equations.

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
  • p2fun: Julia function of the solutions of the flow balance equations from build_pressure_squared_functions(sys; mode="λ")
  • dt: time steps, where the original pressure function is evaluated. Inbetween these time steps the pressure function is linearly interpolated.
  • mode: Mode for flow equations to use flow permeabilities λ (mode = λ; default) or flow restrictions κ (mode = κ)
source
GasChromatographySystems.match_programsMethod
match_programs(sys)

Synchronize and match temperature and pressure programs across all modules in a gas chromatography system.

This function ensures that all temperature and pressure programs in the system use the same time steps by interpolating values to common time points. It handles both pressure programs at pressure points and temperature programs in modules, including thermal gradients.

Arguments

  • sys: A System structure containing the gas chromatography system configuration

Returns

  • com_times: Array of common time steps for all programs
  • new_press_steps: Array of interpolated pressure values for each pressure point with a pressure program
  • new_temp_steps: Array of interpolated temperature values for each module with a temperature program
  • new_a_gf: Array of interpolated gradient parameters for each module with a temperature program
  • i_pressprog: Indices of pressure points that have pressure programs
  • i_tempprog: Indices of modules that have temperature programs

Notes

  • For modules with thermal gradients (ng=false), the function interpolates all gradient parameters (ΔT, x0, L0, α)
  • For modules without thermal gradients (ng=true), the gradient parameters are set to default values
  • All programs are synchronized to common time steps to ensure consistent simulation
source
GasChromatographySystems.mod_numberMethod
mod_number(t, shift, PM, ratio)

Calculate the modulation number for a given time point using the same timing logic as therm_mod.

Arguments

  • t: Time point at which to calculate the modulation number
  • shift: Time shift of the modulation pattern (in seconds)
  • PM: Modulation period (in seconds)
  • ratio: Ratio of cold phase duration to total period (0 < ratio < 1)

Returns

  • Integer modulation number (1-based)

Notes

  • Uses the same timing logic as therm_mod
  • Returns 1 for the first modulation period
  • Uses 4 digits precision to avoid rounding issues
  • Calculates modulation number directly from time value
source
GasChromatographySystems.modulator_phaseMethod
modulator_phase(tstart, t_next_hot, tcold)

Determine the phase of the modulation and initial timesfor each peak based on the start time and the time of the start of the next hot jet.

Arguments

  • tstart: Start time of the peak
  • t_next_hot: Time of the start of the next hot jet
  • tcold: Duration of the cold jet

Returns

  • t₀: initial time of the peak
  • phase: Phase of the modulation ('cold' or 'hot')
source
GasChromatographySystems.module_temperatureMethod
module_temperature(module_::ModuleColumn, sys)

Calculate temperature parameters for a column module in a gas chromatography system.

This function handles temperature calculations for a standard column module, supporting both constant temperature and temperature programs. It returns the necessary parameters for temperature interpolation along the column.

Arguments

  • module_: A ModuleColumn instance containing column parameters
  • sys: The GC system structure containing the network of modules

Returns

  • time_steps: Array of time points for the temperature program
  • temp_steps: Array of temperature values at each time point
  • gf: Gradient function for temperature program
  • a_gf: Gradient coefficients
  • T_itp: Temperature interpolation function that takes position and time as arguments

Notes

  • For constant temperature, uses system's common timesteps or default [0.0, 36000.0]
  • Handles NaN column length by defaulting to 1.0
  • Supports both constant temperature and temperature program modes
source
GasChromatographySystems.module_temperatureMethod
module_temperature(module_::ModuleTM, sys)

Calculate temperature parameters for a thermal modulator module in a gas chromatography system.

This function handles temperature calculations for a thermal modulator, combining a base temperature program with periodic modulation between hot and cold phases. It supports both absolute and relative temperature modes for the cold jet.

Arguments

  • module_: A ModuleTM instance containing thermal modulator parameters
  • sys: The GC system structure containing the network of modules

Returns

  • time_steps: Array of time points for the temperature program
  • temp_steps: Array of temperature values at each time point
  • gf: Gradient function for temperature program
  • a_gf: Gradient coefficients
  • spot: Temperature function that combines base temperature with modulation

Notes

  • Supports both constant temperature and temperature program modes
  • Cold jet temperature can be either absolute (Tcold_abs=true) or relative to base temperature
  • Includes spatial temperature distribution (spot function) when ng=false
  • Temperature values are converted between °C and K as needed
source
GasChromatographySystems.pressure_functionsMethod
pressure_functions(sys, p2fun; mode="λ")

Collect all pressure functions as functions of time t at the vertices of the capillary system sys, either from defined input values or from the solutions of the flow balance equations.

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
  • p2fun: Julia function of the solutions of the flow balance equations from build_pressure_squared_functions(sys; mode="λ")
  • mode: Mode for flow equations to use flow permeabilities λ (mode = λ; default) or flow restrictions κ (mode = κ)
source
GasChromatographySystems.save_build_pressure_squared_functionsMethod
save_build_pressure_squared_functions(sys, solution; filename=pwd()*"/p2fun_"*sys.name, mode="λ")

Constructs and saves the array of functions of the solutions solution for the unkown squared pressures of the flow balance equations of the system of capillaries sys.

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
  • filename: Filename, where the solution functions are saved. Default pwd()*"/p2fun_"*sys.name attached with "_λ.jl" or "_κ.jl", depending on mode.
  • mode: Mode for flow equations to use flow permeabilities λ (mode = λ; default) or flow restrictions κ (mode = κ)

Output

A dictionary with the folowing keys is saved in a .jl file:

  • "p2fun": the build function of the solutions
  • "i_known_p": the indices of the known pressures.
  • "i_known_λ": the indices of the known flow permeabilities.
  • "i_known_F": the indices of the known flows.
  • "mode": mode of the functions using flow permeabilities λ or flow restrictions κ.

Loading

The saved dictionary can easily be loaded into Julia by

p2fun_load = include("p2fun_saved.jl")

The build functions have to be evaluated by eval.(p2fun_load["p2fun"]) before usage. The arguments for the squared pressure functions are the ordered known squared pressures $p^2$, the ordered known flow permabilities $λ$ resp. flow restrictions $κ$, the ordered known flows $F$ and constant $A = π/256 p_n/T_n$.

source
GasChromatographySystems.simplifiedTMMethod
simplifiedTM(T, par, df_A, PM, ratio, shift, Thot)

Simulate thermal modulation using a simplified model that assumes rectangular temperature modulation.

This function simulates the behavior of solutes in a thermal modulator using a simplified approach that assumes instantaneous temperature changes between hot and cold phases. It calculates retention times, peak widths, and other chromatographic parameters for each modulated peak.

Arguments

  • T: Temperature program or constant temperature value
  • par: Simulation parameters for the system
  • df_A: DataFrame containing sliced peak information (from slicing function)
  • PM: Modulation period in seconds
  • ratio: Ratio of cold phase duration to total period (0 < ratio < 1)
  • shift: Time shift of the modulation pattern in seconds
  • Thot: Temperature difference for the hot phase in °C

Returns

  • Tuple containing:
    1. DataFrame with chromatographic parameters:
      • No: Modulation number
      • Name: Substance names
      • CAS: CAS numbers
      • tR: Retention times
      • τR: Peak widths
      • TR: Temperatures at retention
      • σR: Peak standard deviations
      • uR: Linear velocities
      • kR: Retention factors
      • Res: Resolution between adjacent peaks
      • Δs: Separation measure
      • Annotations: Peak annotations
      • A: Peak areas
    2. Array of solution tuples containing:
      • t: column position [0, column length]
      • u: Tuples of (time, variance) at start and end points

Notes

  • Assumes rectangular temperature modulation (instantaneous temperature changes)
  • Calculates retention times based on the start of the next hot phase with added peak width (time to flush out the peak)
  • Calculates peak widths from band width equal to the length of the modulator segment
  • using simulation results in similar values, but takes longer to calculate, see 'simplifiedTMmod2' and 'simplifiedTMmod3'
source
GasChromatographySystems.simplifiedTM_mod2Method
simplifiedTM_mod2(T, par, df_A, PM, ratio, shift, Thot, Tcold)

Estimate retention times and peak widths for thermal modulation by assuming isothermal conditions during cold and hot phases.

This function uses a simplified approach that treats the cold and hot phases as separate isothermal conditions. It calculates retention times by:

  1. Determining the cold phase temperature (Tmin) based on whether Tcold is absolute or relative
  2. Creating separate temperature interpolation functions for cold and hot phases
  3. Calculating retention factors and holdup times for both phases
  4. Estimating the migration distance during cold phase
  5. Computing final retention times based on hot phase conditions

Arguments

  • T: Base temperature or temperature program for the column
  • par: Parameters structure containing column, program, and substance information
  • df_A: DataFrame containing peak areas and initial times
  • PM: Modulation period in seconds
  • ratio: Ratio of cold phase duration to total period (0 < ratio < 1)
  • shift: Time shift of the modulation pattern in seconds
  • Thot: Temperature difference for hot phase in °C
  • Tcold: Temperature difference for cold phase in °C (absolute or relative)

Returns

  • peaklist: DataFrame containing retention times and peak parameters
  • solutions: Solutions from the simulation
  • T_itp_cold: Temperature interpolation function for cold phase
  • T_itp_hot: Temperature interpolation function for hot phase

Notes

  • Assumes isothermal conditions during both cold and hot phases
  • Uses a simplified approach that may not capture all temperature transition effects
  • Calculates migration distance during cold phase to estimate peak positions
  • Performs a final simulation using cold phase conditions to verify results
source
GasChromatographySystems.simplifiedTM_mod3Method
simplifiedTM_mod3(T, par, df_A, PM, ratio, shift, Thot)

Estimate retention times and peak widths for thermal modulation by simulating from the hot phase start.

This function uses a more detailed approach that:

  1. Determines whether peaks arrive during cold or hot phase
  2. Adjusts initial conditions based on arrival phase
  3. Uses a simplified temperature profile using hot phase conditions
  4. Performs a full simulation to calculate retention times and peak widths

Arguments

  • T: Base temperature or temperature program for the column
  • par: Parameters structure containing column, program, and substance information
  • df_A: DataFrame containing peak areas and initial times from slicing
  • PM: Modulation period in seconds
  • ratio: Ratio of cold phase duration to total period (0 < ratio < 1)
  • shift: Time shift of the modulation pattern in seconds
  • Thot: Temperature difference for hot phase in °C

Returns

  • peaklist: DataFrame containing retention times and peak parameters
  • solutions: Solutions from the simulation

Notes

  • Assumes rectangular temperature modulation pattern
  • Adjusts initial conditions based on whether peaks arrive during cold or hot phase
  • Uses a simplified temperature profile to avoid ODE solver issues
  • Provides more accurate results than simplifiedTM_mod2 but takes longer to compute
  • Issues warnings for peaks that arrive during hot phase
source
GasChromatographySystems.simulate_ModuleColumnMethod
simulate_ModuleColumn(segment_par, t₀, τ₀)
simulate_ModuleColumn(segment_par, prev_peaklist)

Simulate solute transport through a column module in a gas chromatography system.

This function simulates the behavior of solutes in a column module, either starting from initial conditions or continuing from a previous module's results. It calculates retention times, peak widths, and other chromatographic parameters.

Arguments

  • segment_par: Simulation parameters for the column module
  • t₀: Initial time points (first variant)
  • τ₀: Initial peak widths (first variant)
  • prev_peaklist: Peak list from previous module (second variant)

Returns

  • Tuple containing:
    1. Updated simulation parameters
    2. Peak list with chromatographic parameters
    3. Solution trajectories

Notes

  • First variant is used for the initial column segment
  • Second variant is used for subsequent column segments
  • Peak areas are preserved between segments
  • Initial areas are set to 1.0 for the first segment
source
GasChromatographySystems.simulate_ModuleTMMethod
simulate_ModuleTM(segment_par, segment_module, prev_peaklist; nτ=6, τ₀_focus=zeros(length(segment_par.sub)), refocus=false, kwargsTM...)

Simulate solute transport through a thermal modulator module in a gas chromatography system.

This function simulates the behavior of solutes in a thermal modulator, handling both simplified and full simulation approaches. It includes peak slicing, temperature modulation, and optional refocusing of peaks.

Arguments

  • segment_par: Simulation parameters for the thermal modulator
  • segment_module: Thermal modulator module configuration
  • prev_peaklist: Peak list from previous module

Keyword Arguments

  • : Number of peak widths to consider for slicing (default: 6)
  • τ₀_focus: Initial peak widths for refocusing (default: zeros)
  • refocus: Whether to refocus peaks (default: false)
  • kwargsTM: Additional keyword arguments for simulation

Returns

  • Tuple containing:
    1. Updated simulation parameters
    2. Peak list with chromatographic parameters
    3. Solution trajectories

Notes

  • Supports two simulation algorithms:
    • "simplifiedTM": Uses simplified rectangular temperature modulation
    • Full simulation: Uses ODE solving with adaptive time steps (this only works if the segment has a stationary phase)
  • Performs peak slicing based on modulation periods
  • Checks for peak widths exceeding modulation period
  • Handles temperature programs and constant temperatures
  • Preserves peak areas through the modulation process
source
GasChromatographySystems.simulate_along_pathsMethod
simulate_along_paths(sys, p2fun, paths, par_sys; t₀=zeros(length(par_sys[1].sub)), τ₀=zeros(length(par_sys[1].sub)), nτ=6, refocus=falses(ne(sys.g)), τ₀_focus=zeros(length(par_sys[1].sub)), mode="λ", kwargsTM...)

Simulate solute transport along multiple paths in a gas chromatography system.

This function simulates the transport of solutes through a network of GC modules (columns and thermal modulators) along specified paths. It handles both direct simulation of new segments and reuse of previously simulated segments when possible.

Arguments

  • sys: The GC system structure containing the network of modules
  • p2fun: Pressure functions for the system
  • paths: Array of paths to simulate, where each path is a sequence of edges in the system graph
  • par_sys: Array of parameter sets for each module in the system

Keyword Arguments

  • t₀: Initial times for solutes (default: zeros)
  • τ₀: Initial peak widths for solutes (default: zeros)
  • : Number of peak widths to consider for slicing in the thermal modulator (default: 6)
  • refocus: Boolean array indicating which modules should refocus peaks (default: all false)
  • τ₀_focus: Initial peak widths for refocusing (default: zeros)
  • mode: Mode for flow calculations ("λ" for permeability or "κ" for restriction) (default: "λ")
  • kwargsTM: Additional keyword arguments for thermal modulator simulation

Returns

  • path_pos: Array of strings indicating if each path is possible and any issues encountered
  • peaklists: Array of peak lists for each path, containing retention times and peak widths
  • solutions: Array of solutions for each path, containing detailed simulation results
  • new_par_sys: Updated parameter sets for the system

Notes

  • Reuses simulation results from previous paths when possible to improve efficiency
  • Handles both ModuleColumn and ModuleTM (thermal modulator) types
  • Checks for negative flows to determine if paths are possible
  • First segment after injection is assumed to be a ModuleColumn
source
GasChromatographySystems.slicingMethod
slicing(pl, PM, ratio, shift, par; nτ=6, τ₀=zeros(length(pl.τR)), abstol=1e-8, reltol=1e-8, alg=OwrenZen5())

Slice peaks into segments based on thermal modulation periods and calculate their areas.

This function handles the slicing of chromatographic peaks into segments that align with thermal modulation periods. It calculates the areas of these segments and creates new substance parameters for each slice. The function is designed to work with both single-stage and multi-stage modulation systems.

Arguments

  • pl: Peak list containing retention times, peak widths, and areas
  • PM: Modulation period in seconds
  • ratio: Ratio of cold phase duration to total period (0 < ratio < 1)
  • shift: Time shift of the modulation pattern in seconds
  • par: Original simulation parameters

Keyword Arguments

  • : Number of peak widths to consider for slicing (default: 6)
  • τ₀: Initial peak widths for new slices (default: zeros)
  • abstol: Absolute tolerance for numerical integration (default: 1e-8)
  • reltol: Relative tolerance for numerical integration (default: 1e-8)
  • alg: Numerical integration algorithm (default: OwrenZen5())

Returns

  • newpar_focussed: New parameters object containing the sliced substances
  • df_A_foc: DataFrame containing:
    • Name: Substance names
    • CAS: CAS numbers
    • Annotations: Slice annotations (e.g., "s1", "s2", etc.)
    • A: Calculated areas for each slice
    • t0: Start times of each slice

Notes

  • Uses mod_number for consistent modulation period calculations
  • Handles peaks that span multiple modulation periods
  • Calculates areas using Gaussian peak approximation
  • For peaks within a single modulation period, uses the original area
  • For multi-period peaks, integrates the Gaussian function over each period
  • Appoximation: integration over the whole period, in reality the segment of the peak during the hot-jet is not included. Assuming a second focussing the not focussed segment should be focussed there.
  • Maintains substance properties while creating new slice annotations
source
GasChromatographySystems.solve_balanceMethod
solve_balance(sys; mode="λ", bal_eq = flow_balance(sys))

Solves the substituted flow balance equations of the capillary system sys for the squared pressures of vertices with undefined pressures as an array of symbolic expressions.

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
  • mode: Mode for flow equations to use flow permeabilities λ (mode = λ; default) or flow restrictions κ (mode = κ)
source
GasChromatographySystems.substitute_pressure_squared_functionsMethod
substitute_pressure_squared_functions(p2fun, sys; mode="λ")

Substitutes the the pressure functions (solutions to the flow balance equations) with the known quantities of pressures, flows, flow restictions/permabilities.

This results in an array of pressures $p$ at vertices without defined pressure as function of time $t$.

Arguments

  • p2fun: Julia function of the solutions of the flow balance equations from build_pressure_squared_functions(sys; mode="λ")
  • sys: System structure of the capillary system for which the flow balance is set up.
  • mode: Mode for flow equations to use flow permeabilities λ (mode = λ; default) or flow restrictions κ (mode = κ)
source
GasChromatographySystems.substitute_unknown_flowsMethod
substitute_unknown_flows(sys; mode="λ", bal_eq = flow_balance(sys))

Substitutes flow equations for undefined flows over edges in the capillary system sys in the flow balance equation system.

Flow equation over edge $j,i$ between vertice ìandjwith flow permabilityλ_{i,j}`:

\[F_{i,j} = A λ_{i,j} \left(p_i^2-p_j^2\right)\]

For flow resistance $κ_{i,j}$:

\[F_{i,j} = \frac{A}{κ_{i,j}} \left(p_i^2-p_j^2\right)\]

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
  • mode: Mode for flow equations to use flow permeabilities λ (mode = λ; default) or flow restrictions κ (mode = κ)
  • bal_eq: Array of the symbolic flow balance equations; defaults to flow_balance(sys)
source
GasChromatographySystems.therm_modMethod
therm_mod(t, shift, PM, ratio, Tcold, Thot; flank=20)

Generate a periodic temperature modulation pattern for thermal modulation in gas chromatography.

The function creates a temperature profile that alternates between cold (Tcold) and hot (Thot) phases with a specified period (PM). The pattern can be either a sharp rectangular function or a smoothed version with controlled transition flanks.

Arguments

  • t: Time point(s) at which to evaluate the temperature
  • shift: Time shift of the modulation pattern (in seconds)
  • PM: Modulation period (in seconds)
  • ratio: Ratio of cold phase duration to total period (0 < ratio < 1)
  • Tcold: Temperature during the cold phase (in °C)
  • Thot: Temperature during the hot phase (in °C)

Keyword Arguments

  • flank: Controls the smoothness of temperature transitions. Use Inf for sharp transitions, or a positive number for smoothed transitions (default: 20)

Returns

  • Temperature value(s) at the specified time point(s)

Notes

  • on modulation consists of a cold phase and a hot phase in this order
  • The cold phase duration is ratio * PM
  • The hot phase duration is (1 - ratio) * PM
  • When shift = 0, the pattern starts with the hot phase
  • The flank parameter controls the width of the temperature transition regions
source
GasChromatographySystems.unknown_FMethod

unknown_F(sys)

Extract the index of the edges of the graph of system sys for which the flows F are not defined.

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
source
GasChromatographySystems.unknown_pMethod

unknown_p(sys)

Extract the index of the vertices of the graph of system sys for which the pressure p are not defined.

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
source
GasChromatographySystems.unknown_λMethod

unknown_λ(sys)

Extract the index of the edges of the graph of system sys for which the flow permeabilities λ are not defined.

Arguments

  • sys: System structure of the capillary system for which the flow balance is set up.
source
GasChromatographySystems.update_systemMethod
update_system(sys)

Update and synchronize all temperature and pressure programs in a gas chromatography system to use common time steps.

This function ensures that all modules and pressure points in the system use synchronized time steps by:

  1. Finding common time steps across all programs
  2. Interpolating pressure and temperature values to these common time points
  3. Creating new pressure points and modules with synchronized programs
  4. Preserving constant temperature/pressure values where applicable

Arguments

  • sys: A System structure containing the gas chromatography system configuration

Returns

  • A new System structure with synchronized programs

Notes

  • For pressure points:
    • Constant pressure values are preserved unchanged
    • Pressure programs are interpolated to common time steps
  • For modules:
    • Constant temperature values are preserved unchanged
    • Temperature programs are interpolated to common time steps
    • Thermal gradients are handled differently based on the ng option:
      • With gradient (ng=false): All gradient parameters are interpolated
      • Without gradient (ng=true): Uses default gradient parameters
  • The function maintains all other module properties (length, diameter, etc.)
  • The graph structure and system options remain unchanged
source