Module Index
Detailed API
GasChromatographySystems.ModuleColumn
— TypeModuleColumn(; 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 functiond
. Empty, ifd
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 functiondf
. Empty, ifdf
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 aTemperatureProgram
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 formModuleColumnOptions
.
Four methods to construct this structure exist:
ModuleColumn(name, L, d, df, sp, T, opt::ModuleColumnOptions)
: The flow is not defined, uniformd
anddf
.ModuleColumn(name, L, d, df, sp, T, F, opt::ModuleColumnOptions)
: The flow is defined byF
and uniformd
anddf
.ModuleColumn(name, L, d, df, sp, T; alg=OwrenZen5(), abstol=1e-8, reltol=1e-6, ng=false, Tcontrol="inlet")
: The flow is not defined, uniformd
anddf
. Options according toModuleColumnOptions
.ModuleColumn(name, L, d, df, sp, tp, flow; alg=OwrenZen5(), abstol=1e-8, reltol=1e-6, ng=false, Tcontrol="inlet")
: The flow is defined byF
and uniformd
anddf
. Options according toModuleColumnOptions
.
GasChromatographySystems.ModuleColumnOptions
— TypeModuleColumnOptions(; 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 algorithmsOwrenZen3()
,OwrenZen4()
andOwrenZen5()
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 areinlet
(x=0) andoutlet
(x=L).
GasChromatographySystems.ModuleTM
— TypeModuleTM(; 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 functiond
. Empty, ifd
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 functiondf
. Empty, ifdf
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 aTemperatureProgram
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 whichT
is increased while the hot jet is active.Tcold
: Temperature in °C, by whichT
is decrease while the cold jet is active (ifTcold_abs = false
inModuleColumnOptions
) or to which the column is cooled down (ifTcold_abs = true
inModuleTMOptions
)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 formModuleTMOptions
.
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, uniformd
anddf
.ModuleTM(name, L, d, df, sp, T, shift, PM, ratio, Thot, Tcold, F, opt::ModuleTMOptions)
: The flow is defined byF
and uniformd
anddf
.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, uniformd
anddf
. Options according toModuleTMOptions
.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 byF
and uniformd
anddf
. Options according toModuleTMOptions
.
GasChromatographySystems.ModuleTMOptions
— TypeModuleTMOptions(; 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 parameterTcold
(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 ifng = true
. Recommendsflank = 40
. Only relevante, if optionng = 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. Recommendtflank = 20
.alg
: The algorithm used for the ODE solver. For the thermal modulator module the algorithmVern9()
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 ofL*1e-6
, withL
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 areinlet
(x=0) andoutlet
(x=L).
GasChromatographySystems.Options
— TypeOptions(; 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 bookTemperature-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 thank_th
than the retention factor is set to the valuek_th
. This is done to avoid to small step widths in the solver for highly retained soultes at the beginning of a GC program.
GasChromatographySystems.PressurePoint
— TypePressurePoint(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 thePressurePoint
.P
: Pressure program as structureGasChromatographySystems.PressureProgram
or as a number for constant pressure.
GasChromatographySystems.PressureProgram
— TypePressureProgram(time_steps, pressure_steps)
Structure describing the pressure program.
Arguments
time_steps
: Time steps in s, after which the corresponding pressure inpressure_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).
GasChromatographySystems.System
— TypeSystem(g, pressurepoints, modules, options)
Structure describing a GC system.
Arguments
name
: Name of the GC system.g
: The graph representation of the GC system, usingSimpleDiGraph
fromGraphs.jl
.pressurepoints
: The vertices of graphg
and their pressure programs. These are structures of typePressurePoint
.modules
: The edges of graphg
. These are column segments of typeModuleColumn
or thermal modulator points of typeModuleTM
.
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:
GasChromatographySystems.TemperatureProgram
— TypeTemperatureProgram(time_steps, temp_steps, gf, a_gf)
Structure describing the temperature program.
Arguments
time_steps
: Time steps in s, after which the corresponding temperature intemp_steps
is reached.temp_steps
: Temperature steps in °C.gf
: Gradient functiongf(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)
, withCP
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]
, withTi
temperature niveaus,ti
holding times for the corresponding tempertures,ri
the heating ramp between temperaturesTi
andTi+1
.
A default temperature program is avaliable:
default_TP()
: Heating from 40°C to 340°C in 1800 s (30 min).
GasChromatographySystems.build_pressure_squared_functions
— Methodbuild_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 = κ
)
GasChromatographySystems.check_expressions_λ_κ
— Methodcheck_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 systemn = ne(sys.g)
.
GasChromatographySystems.check_retention_cold_jet
— Methodcheck_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 columnpar
: Parameters structure containing column, program, and substance informationdf_A
: DataFrame containing peak areas and initial times from slicingPM
: Modulation period in secondsratio
: Ratio of cold phase duration to total period (0 < ratio < 1)shift
: Time shift of the modulation pattern in secondsThot
: Temperature difference for hot phase in °CTcold
: 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
GasChromatographySystems.check_temperature_gradient
— Methodcheck_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 presentfalse
for constant temperature valuesfalse
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])
GasChromatographySystems.flow_balance
— Methodflow_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.
GasChromatographySystems.flow_functions
— Methodflow_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 frombuild_pressure_squared_functions(sys; mode="λ")
mode
: Mode for flow equations to use flow permeabilities λ (mode = λ
; default) or flow restrictions κ (mode = κ
)
GasChromatographySystems.flow_permeabilities
— Methodflow_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.
GasChromatographySystems.flow_restrictions
— Methodflow_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.
GasChromatographySystems.graph_to_parameters
— Methodgraph_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 modulesp2fun
: Pressure functions for the systemdb_dataframe
: Database containing solute propertiesselected_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
GasChromatographySystems.holdup_time_functions
— Methodholdup_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 frombuild_pressure_squared_functions(sys; mode="λ")
mode
: Mode for flow equations to use flow permeabilities λ (mode = λ
; default) or flow restrictions κ (mode = κ
)
GasChromatographySystems.holdup_time_path
— Methodholdup_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 frombuild_pressure_squared_functions(sys; mode="λ")
numpaths
: Number of the different paths between inlet and outlets of systemsys
.mode
: Mode for flow equations to use flow permeabilities λ (mode = λ
; default) or flow restrictions κ (mode = κ
)
GasChromatographySystems.interpolate_pressure_functions
— Methodinterpolate_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 frombuild_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 = κ
)
GasChromatographySystems.match_programs
— Methodmatch_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
: ASystem
structure containing the gas chromatography system configuration
Returns
com_times
: Array of common time steps for all programsnew_press_steps
: Array of interpolated pressure values for each pressure point with a pressure programnew_temp_steps
: Array of interpolated temperature values for each module with a temperature programnew_a_gf
: Array of interpolated gradient parameters for each module with a temperature programi_pressprog
: Indices of pressure points that have pressure programsi_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
GasChromatographySystems.mod_number
— Methodmod_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 numbershift
: 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
GasChromatographySystems.modulator_phase
— Methodmodulator_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 peakt_next_hot
: Time of the start of the next hot jettcold
: Duration of the cold jet
Returns
t₀
: initial time of the peakphase
: Phase of the modulation ('cold' or 'hot')
GasChromatographySystems.module_temperature
— Methodmodule_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 parameterssys
: The GC system structure containing the network of modules
Returns
time_steps
: Array of time points for the temperature programtemp_steps
: Array of temperature values at each time pointgf
: Gradient function for temperature programa_gf
: Gradient coefficientsT_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
GasChromatographySystems.module_temperature
— Methodmodule_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 parameterssys
: The GC system structure containing the network of modules
Returns
time_steps
: Array of time points for the temperature programtemp_steps
: Array of temperature values at each time pointgf
: Gradient function for temperature programa_gf
: Gradient coefficientsspot
: 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
GasChromatographySystems.pressure_functions
— Methodpressure_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 frombuild_pressure_squared_functions(sys; mode="λ")
mode
: Mode for flow equations to use flow permeabilities λ (mode = λ
; default) or flow restrictions κ (mode = κ
)
GasChromatographySystems.save_build_pressure_squared_functions
— Methodsave_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. Defaultpwd()*"/p2fun_"*sys.name
attached with"_λ.jl"
or"_κ.jl"
, depending onmode
.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$.
GasChromatographySystems.simplifiedTM
— MethodsimplifiedTM(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 valuepar
: Simulation parameters for the systemdf_A
: DataFrame containing sliced peak information (from slicing function)PM
: Modulation period in secondsratio
: Ratio of cold phase duration to total period (0 < ratio < 1)shift
: Time shift of the modulation pattern in secondsThot
: Temperature difference for the hot phase in °C
Returns
- Tuple containing:
- 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
- Array of solution tuples containing:
- t: column position [0, column length]
- u: Tuples of (time, variance) at start and end points
- DataFrame with chromatographic parameters:
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'
GasChromatographySystems.simplifiedTM_mod2
— MethodsimplifiedTM_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:
- Determining the cold phase temperature (Tmin) based on whether Tcold is absolute or relative
- Creating separate temperature interpolation functions for cold and hot phases
- Calculating retention factors and holdup times for both phases
- Estimating the migration distance during cold phase
- Computing final retention times based on hot phase conditions
Arguments
T
: Base temperature or temperature program for the columnpar
: Parameters structure containing column, program, and substance informationdf_A
: DataFrame containing peak areas and initial timesPM
: Modulation period in secondsratio
: Ratio of cold phase duration to total period (0 < ratio < 1)shift
: Time shift of the modulation pattern in secondsThot
: Temperature difference for hot phase in °CTcold
: Temperature difference for cold phase in °C (absolute or relative)
Returns
peaklist
: DataFrame containing retention times and peak parameterssolutions
: Solutions from the simulationT_itp_cold
: Temperature interpolation function for cold phaseT_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
GasChromatographySystems.simplifiedTM_mod3
— MethodsimplifiedTM_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:
- Determines whether peaks arrive during cold or hot phase
- Adjusts initial conditions based on arrival phase
- Uses a simplified temperature profile using hot phase conditions
- Performs a full simulation to calculate retention times and peak widths
Arguments
T
: Base temperature or temperature program for the columnpar
: Parameters structure containing column, program, and substance informationdf_A
: DataFrame containing peak areas and initial times from slicingPM
: Modulation period in secondsratio
: Ratio of cold phase duration to total period (0 < ratio < 1)shift
: Time shift of the modulation pattern in secondsThot
: Temperature difference for hot phase in °C
Returns
peaklist
: DataFrame containing retention times and peak parameterssolutions
: 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
GasChromatographySystems.simulate_ModuleColumn
— Methodsimulate_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 modulet₀
: Initial time points (first variant)τ₀
: Initial peak widths (first variant)prev_peaklist
: Peak list from previous module (second variant)
Returns
- Tuple containing:
- Updated simulation parameters
- Peak list with chromatographic parameters
- 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
GasChromatographySystems.simulate_ModuleTM
— Methodsimulate_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 modulatorsegment_module
: Thermal modulator module configurationprev_peaklist
: Peak list from previous module
Keyword Arguments
nτ
: 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:
- Updated simulation parameters
- Peak list with chromatographic parameters
- 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
GasChromatographySystems.simulate_along_paths
— Methodsimulate_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 modulesp2fun
: Pressure functions for the systempaths
: Array of paths to simulate, where each path is a sequence of edges in the system graphpar_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)nτ
: 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 encounteredpeaklists
: Array of peak lists for each path, containing retention times and peak widthssolutions
: Array of solutions for each path, containing detailed simulation resultsnew_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
GasChromatographySystems.slicing
— Methodslicing(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 areasPM
: Modulation period in secondsratio
: Ratio of cold phase duration to total period (0 < ratio < 1)shift
: Time shift of the modulation pattern in secondspar
: Original simulation parameters
Keyword Arguments
nτ
: 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 substancesdf_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
GasChromatographySystems.solve_balance
— Methodsolve_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 = κ
)
GasChromatographySystems.substitute_pressure_squared_functions
— Methodsubstitute_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 frombuild_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 = κ
)
GasChromatographySystems.substitute_unknown_flows
— Methodsubstitute_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 ì
and
j
with 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 toflow_balance(sys)
GasChromatographySystems.therm_mod
— Methodtherm_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 temperatureshift
: 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. UseInf
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
GasChromatographySystems.unknown_F
— Methodunknown_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.
GasChromatographySystems.unknown_p
— Methodunknown_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.
GasChromatographySystems.unknown_λ
— Methodunknown_λ(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.
GasChromatographySystems.update_system
— Methodupdate_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:
- Finding common time steps across all programs
- Interpolating pressure and temperature values to these common time points
- Creating new pressure points and modules with synchronized programs
- Preserving constant temperature/pressure values where applicable
Arguments
sys
: ASystem
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
- With gradient (
- The function maintains all other module properties (length, diameter, etc.)
- The graph structure and system options remain unchanged