Adding Custom Fuels

This tutorial explains how to add custom fuels to FuelLib. Custom fuels allow you to use your own fuel composition and property data with the FuelLib calculations and plotting tools.

Directory Structure

Create a fuel data directory with this structure:

custom_fuels/
├── gc_data/
│   └── your_fuel_name.csv
├── properties_data/          (optional)
│   └── your_fuel_name.csv
├── ref_compounds.csv        (optional)
├── ref_gani.csv             (optional)
├── ref_nannoolal.csv        (optional)
├── ref_unifac.csv           (optional)
└── fuel_metadata.yaml       (optional)

Required:

  • gc_data/{fuel_name}.csv: GC×GC composition data (one file per fuel).

Optional:

  • properties_data/{fuel_name}.csv: measured property data (one file per fuel) loaded into Fuel.prop_data.

  • ref_compounds.csv, ref_gani.csv, ref_nannoolal.csv, and ref_unifac.csv: custom reference compound and group decomposition tables. When present, each table supplements FuelLib’s built-in table; it does not replace it. If a file is absent, FuelLib uses the built-in table in fuellib/data.

  • fuel_metadata.yaml: display name, source, and other documentation for each fuel, keyed by fuel name under a top-level fuels entry. The entry for a fuel is loaded into Fuel.metadata (None if the file or entry is absent).

Fuel variants with identical compounds but different weight percentages simply use separate gc_data files that refer to the same reference compounds.

GCxGC Composition Data

Create a file named {fuel_name}.csv in the gc_data/ directory with fuel composition data.

Required columns:

  • Weight %: Weight percentage of each component (normalized automatically).

  • Reference Compound and/or SMILES: Identifies the compound. Each row is matched to ref_compounds.csv by Reference Compound name (case-insensitive) first, then by the InChI derived from SMILES.

Optional columns:

  • GC-Bin: Name of the GCxGC bin, used as the compound name by the exporters when PelePhysics keys are not used.

  • PelePhysics Key: Species name of the compound in a PelePhysics mechanism.

Example:

GC-Bin,SMILES,PelePhysics Key,Weight %
n-C10,CCCCCCCCCC,NC10H22,60
n-C12,CCCCCCCCCCCC,NC12H26,40

A ValueError is raised if a row cannot be matched to a reference compound.

Reference Compounds and Group Decompositions

Every compound in a fuel must appear in all of the effective reference tables. To add a new compound, add a row to each custom table:

  • ref_compounds.csv: Family, Carbon Number, Reference Compound, and SMILES are required. Family must be one of n-alkane, isoalkane, alkene, monocycloalkane, dicycloalkane, tricycloalkane, alkylbenzene, cycloaromatic, or diaromatic. Measured properties are optional; see Reference Property Data. A custom row replaces a built-in row when the two SMILES values resolve to the same InChI, so use this to override built-in properties even when the valid SMILES representation differs.

  • ref_gani.csv: the functional group decomposition of the compound, with a Reference Compound column matching ref_compounds.csv. A custom row with the same Reference Compound replaces the built-in decomposition. Groups that are omitted or blank are treated as zero.

  • ref_nannoolal.csv: the Nannoolal group decomposition of the compound, in the same format as ref_gani.csv but with the groups defined in nannoolal.csv.

  • ref_unifac.csv: the UNIFAC subgroup decomposition of the compound, in the same format as ref_gani.csv but with the subgroups defined in unifac.csv.

Decompositions can be generated from SMILES with fl decompose (--method gani, --method nannoolal, or --method unifac; see Command-Line Interface (CLI) Tools), but should be verified before use.

See the Basic Usage tutorial for detailed information on group decompositions.

Using Custom Fuels

Once your custom fuel directory is set up, you can use it like any built-in fuel by specifying the data_dir when creating a fuel object. Custom reference tables are only read from data_dir, so they must follow the directory structure above:

import fuellib as fl

# Load a custom fuel
fuel = fl.Fuel("new-saf", data_dir="/path/to/customFuels")

# Calculate the vapor pressure at 320 K
T = fl.Units.Quantity(320, "K") # Temperature as a pint.Quantity
pvap_i = fuel.comps.pvap(T)
pvap_mix = fuel.mix.pvap(fuel.y0, T)

Tips and Best Practices

  1. Composition Normalization: Weight percentages don’t need to sum to exactly 100% - FuelLib normalizes them automatically.

  2. Group Decomposition Accuracy: Predictions depend heavily on decomposition quality. When possible you should validate individual compound properties against measured properties or NIST WebBook.

  3. Fuel Variants: Create one gc_data file per variant. Variants that share compounds also share the same reference table rows, so no additional decomposition data is needed.