temperature_model

Data-driven model that maps pyrolysis temperature (and optionally feedstock) to biochar composition targets (H/C ratio, O/C ratio, aromaticity) and a set of reference properties. Fit from the UC Davis Biochar Database (https://biochar.ucdavis.edu/) with aromaticity calibrated from NMR data collected by Wood, Mašek & Erastova (2024).

Module-level helpers

biochar.temperature_model.properties(temperature, feedstock=None)[source]

Convenience: all modeled biochar properties at a pyrolysis temperature (°C), optionally for a feedstock (one of VALID_FEEDSTOCKS).

Example:

import biochar
biochar.properties(600, feedstock="softwood")
Return type:

Dict[str, float]

Parameters:
  • temperature (float)

  • feedstock (str | None)

biochar.temperature_model.VALID_FEEDSTOCKS = ('corn_stover', 'grass', 'hardwood', 'manure', 'softwood', 'wood')

First-class feedstocks eligible for per-group H/C and O/C overrides.

TemperatureModel

class biochar.temperature_model.TemperatureModel(model_path=None)[source]

Bases: object

Query the bundled temperature × feedstock property model.

Parameters:

model_path – Path to the JSON artifact (defaults to the bundled file).

Parameters:

model_path (Optional[Path])

predict(temperature, prop, feedstock=None)[source]

Predict prop at temperature (°C). Uses the feedstock-specific curve only for H/C and O/C when that group has one and temperature is within its support; otherwise the pooled curve. Clamped to the grid ends.

Return type:

float

Parameters:
  • temperature (float)

  • prop (str)

  • feedstock (str | None)

aromaticity_from_hc(hc)[source]
Return type:

float

Parameters:

hc (float)

composition(temperature, feedstock=None)[source]

The three generator targets at temperature (and feedstock).

Return type:

Dict[str, float]

Parameters:
  • temperature (float)

  • feedstock (str | None)

predict_all(temperature, feedstock=None)[source]

Every modeled property at temperature (reference query).

Return type:

Dict[str, float]

Parameters:
  • temperature (float)

  • feedstock (str | None)

property feedstocks: Tuple[str, ...]
property provenance: dict

Build helper

biochar.temperature_model.build_model(output_path=None)[source]

Build the temperature-model JSON artifact from the bundled CSVs.

Dev/offline entry point:

python -c "from biochar.temperature_model import build_model; build_model()"

Returns the path written. Prints a short QC report (dedup count, per-property point counts, aromaticity fit R²).

Return type:

Path

Parameters:

output_path (Path | None)

biochar.temperature_model.compare_models(path_a, path_b)[source]

Compare two model artifacts on their shared grid; report per-property mean absolute and max prediction delta. Used to evaluate a refit (e.g. davis-only vs davis+Charchive).

Return type:

Dict[str, dict]

Parameters: