IGL 0.5 · Reference
The reference for version 0.5 of the language: file structure, notation, units, blocks and their statements, computation rules, factor databases, diagnostics and the files produced. Every code example on this page is checked by the reference compiler. The full specification, with the accepted and rejected examples of every block, is at igl-lang.org/spec. For an introduction to the language and what it computes, see The IGL language.
A model is a UTF-8 text file with the . extension. LF and CRLF line endings are equivalent. Two position rules, and only two:
A block ends at the next header or at the end of the file; there is no end marker. A named block carries its name on the header line (RESERVOIR Groundwater). A comment starts with # and runs to the end of the line, on its own or after a statement.
RESERVOIR Groundwater # a named compartment volume 1000 L temperature 12 C Cr(VI) 0.85 umol/kgw delta53Cr -0.2 permil
Headers and keys are case-insensitive (PROCESS, process); identifiers are case-sensitive (Reduction and reduction are two names). By convention, a lower-case initial marks a keyword or an enumerated value (type, first_), an upper-case initial a name chosen by the author or a chemical species (Groundwater, Cr(VI)). A lower-case block name is accepted with the warning IG010.
There are no reserved words: a word is a keyword by its position. Named entities share a single namespace: a reservoir and a process cannot have the same name (IG102). A secondary block carrying the name of an existing entity extends it: FRACTIONATION Reduction attaches to the process Reduction. The order of blocks in the file is free, and forward references are allowed.
Non-ASCII characters are allowed in quoted strings and in comments; the TITLE line is not a string and stays ASCII. Elsewhere, only µ in a unit (read as u) and ‰ as a unit (read as permil) are accepted and normalised; any other non-ASCII character gives IG006.
| Form | Example | Role |
|---|---|---|
| key value [unit] | volume 1000 L | static assignment |
| key reference | location Groundwater | reference to an entity |
| name = expression [unit] | k_ | evaluated expression |
| species value [unit] | Cr(VI) 0.85 umol/kgw | concentration of a species |
| key [ list ] | processes [ Reduction, Uptake ] | list of references |
The = sign is the only thing that switches a line to evaluation. Without it, no arithmetic is attempted.
Two forms, and only two:
<mass><Symbol>/<mass><Symbol>, for example 53Cr/52Cr, 18O/16O, 123Sb/121Sb; the heavy isotope in the numerator;delta<mass><Symbol>, for example delta53Cr, delta123Sb.Forms such as Cr53/52 or Sb123 give IG103. Both symbols of a ratio must be identical:
FRACTIONATION Reduction isotope 53Cr/52Fe epsilon -3.5
Output of igl check for a model containing this block:
error[IG104]: mismatched element symbols across a ratio --> model.igl:26:13 | 26 | isotope 53Cr/52Fe | ^^^^^^^^^ `Cr` and `Fe` are different elements 1 error(s)
A ratio token is recognised before any arithmetic: 53Cr/52Cr is never a division. In a ratio, R is the abundance of the isotope written in the numerator over that of the isotope written in the denominator, and this is the quantity the engine evolves; δ values are converted on input and recomputed on output.
Every dimensioned value carries its unit, or receives the one set in the UNITS block. A unit of the wrong dimension gives IG204; a unit left out where several are admissible, IG205. Units are converted to the canonical unit during lowering: an engine only receives canonical units.
| Dimension | Accepted units | Canonical |
|---|---|---|
| Temperature | C, K, F | K |
| Time | s, min, h, d, a (Julian year, 31,557,600 s) | s |
| Volume | L, mL, m^3 | L |
| Mass | kg, g, mg, ug | kg |
| Amount | mol, mmol, umol, nmol | mol |
| Molality | mol/kgw, mmol/kgw, umol/kgw | mol/kgw |
| Mass concentration | g/L, mg/L, ug/L, ng/L | mg/L |
| Rate constant | 1/s, 1/min, 1/h, 1/d | 1/s |
| Pressure | bar, atm, Pa, kPa | bar |
| Potential | mV, V | mV |
| Isotopic composition | permil (or ‰) | permil |
| Dimensionless | none, or 1 | 1 |
alpha is dimensionless; epsilon and 1000ln_ are in ‰ and the unit may be left out.
UNITS concentration umol/kgw time d temperature C delta permil
Blocks fall into three profiles. The core profile is always accepted; an implementation may support identification without simulation, or the reverse. A block from an unsupported profile gives IG005, never silence.
| Block | Named | Repeatable | Profile | Role |
|---|---|---|---|---|
TITLE | no | no | core | readable title, one line |
META | no | no | core | author, date, version, language, description, licence, reference; no effect on the computation |
DATABASE | no | no | core | IGDB databases to load, in order; later ones take precedence |
UNITS | no | no | core | default units |
PARAMETERS | no | no | core | global parameters and expressions |
SPECIES | no | no | core | chemical species |
ISOTOPES | no | no | core | tracked ratios, and their mode (absolute or relative) |
STANDARD | no | no | core | reference standards, taking precedence over the databases |
CONDITIONS | no | no | core | temperature, pressure, pH, Eh, ionic strength of the model |
RESERVOIR | yes | yes | core | physical compartment |
PROCESS | yes | yes | core | physical or chemical process |
FRACTIONATION | yes | yes | core | fractionation factor of a process |
KINETICS | yes | yes | core | rate law of a process |
MODEL | yes | no | core | reservoirs and processes included, progress, stopping condition |
OUTPUT | no | no | core | recorded quantities |
EXPORT | no | yes | core | requested result files |
SAMPLE | yes | yes | identification | measured composition |
IDENTIFY | yes | yes | identification | search for the processes that explain a gap |
LAW | yes | yes | extended | reusable fractionation law |
PHREEQC | yes | yes | extended | call to PHREEQC |
RAYLEIGH, ADSORPTION, EXCHANGE | yes | yes | extended | shorthand for PROCESS and FRACTIONATION |
SOLUTION, INITIAL, DATASET, FIT, MONTE_, SENSITIVITY, PLOT, REPORT | extended | reserved names, content not yet defined: warning IG011, no effect |
A unique block written twice gives IG105. Block and property names specific to an implementation start with x_; other names belong to the specification.
Entities are created in a fixed dependency order, independent of their order in the file: META, DATABASE, UNITS, CONDITIONS, STANDARD, PHREEQC, PARAMETERS, SPECIES, ISOTOPES, LAW, RESERVOIR, PROCESS, FRACTIONATION, KINETICS, SAMPLE, MODEL, IDENTIFY, OUTPUT, EXPORT.
The PARAMETERS block declares global parameters, readable everywhere. A parameter statement in a PROCESS, a RESERVOIR or CONDITIONS declares a parameter local to that block, reached from outside through a two-part qualified name: Reduction.. A parameter may read another; a circular reference gives IG107. A local parameter shadowing a global one is accepted with the warning IG108.
PARAMETERS k_base = 0.01 1/d eps_red = -1.6 permil T_ref = 25 C PROCESS Reduction type reduction reactant Cr(VI) product Cr(III) parameter rate_constant = 2 * k_base RESERVOIR Groundwater volume 1 L Cr(VI) 1 umol/kgw delta53Cr 0 permil
Operators: +, -, *, /, ^. ^ is right-associative and binds tighter than * and /; unary minus applies after the power: -T^2 is -(T^2). Numbers accept scientific notation (1.5e-3).
| Function | Meaning |
|---|---|
exp(x), ln(x), log10(x) | exponential, natural and base-10 logarithms |
sqrt(x), abs(x) | square root, absolute value |
pow(x, y) | x ^ y |
min(a, b), max(a, b) | minimum, maximum |
| Name | Meaning | Unit |
|---|---|---|
R | molar gas constant, 8.314462618 | J/mol/K |
T | temperature of the enclosing reservoir, otherwise that of CONDITIONS; IG107 if neither | K, always |
time | elapsed simulation time | s |
T is in kelvin in every expression, whatever unit it was declared in: fractionation laws in the literature are written for kelvin.
SPECIES and ISOTOPESA species is written with an upper-case initial and may contain parentheses and signs: Cr(VI), Fe2+, Sb(V)_. A species is a redox pool: its internal speciation is not tracked and does not fractionate.
ISOTOPES declares the tracked ratios and their standard. With mode relative, no standard is required: δ values are differences from the model's origin and the results show the unit permil (relative). The default mode is absolute; a ratio with no resolvable standard, used with a δ value, then gives IG106.
ISOTOPES mode relative ratio 123Sb/121Sb SPECIES species Sb(V) species Sb(V)_ads
STANDARDA standard is declared by its name, the value of its ratio, the ratio concerned and, optionally, its uncertainty. A standard written in the model takes precedence over one from a database.
STANDARD standard NIST-SRM-979 0.11339 ratio 53Cr/52Cr uncertainty 0.00002 standard VSMOW 0.0020052 ratio 18O/16O
RESERVOIR| Statement | Meaning |
|---|---|
<species> value unit | initial concentration of a species |
delta<ratio> value permil | initial composition |
volume, mass | size of the reservoir |
temperature | local temperature, taking precedence over CONDITIONS |
parameter | local parameter |
CONDITIONSThe conditions of the model: temperature, pressure, pH, Eh, ionic_. They set T in expressions, and are used to pick from the databases a factor measured under conditions that contain them.
CONDITIONS temperature 9.4 C pH 5.23 Eh 132 mV ionic_strength 0.01 mol/kgw
type is required and sets the required fields. A process acts within one reservoir (location, inferred when there is only one; otherwise IG211) or moves matter from one reservoir to another (from, into). A product identical to the reactant gives IG214.
type | Required |
|---|---|
reduction, oxidation, dissolution, precipitation, evaporation, diffusion, ligand_ | reactant, product |
adsorption, uptake | reactant, sorbent |
exchange | phase_, phase_ |
mixing | two or more source, with their fraction; product (a reservoir) |
Optional fields, for every type: location, from, into, extent, context, regime, law, and local parameter statements.
extentIG305). Read only when the model advances by extent; under progress time, it is reported with IG306.regimeequilibrium or kinetic: how the factor was measured. It narrows the choice in the databases and, with equilibrium, makes the engine apply the closed-system equilibrium law; without it, the engine applies Rayleigh. It is never inferred from the presence or absence of KINETICS.contextpyrometallurgy, hydrometallurgy, natural or biotic: where the process takes place. It narrows the choice in the databases.A process is kinetic if a KINETICS block names it; there is no mechanism statement.
RESERVOIR Groundwater volume 1000 L Cr(VI) 0.85 umol/kgw delta53Cr -0.2 permil RESERVOIR Sediment mass 250 kg PROCESS Removal type precipitation reactant Cr(VI) product Cr(III) from Groundwater into Sediment extent 0.70 context natural regime kinetic
The source fractions must sum to 1 within 10−6 (IG215). The δ of the mixture is weighted by the amounts brought, concentration times fraction, not by the fractions alone.
RESERVOIR UpstreamRiver volume 500 L Cr(VI) 0.2 umol/kgw delta53Cr 0.8 permil RESERVOIR IndustrialEffluent volume 100 L Cr(VI) 5 umol/kgw delta53Cr 0.1 permil RESERVOIR DownstreamRiver volume 600 L PROCESS SourceMixing type mixing source UpstreamRiver 0.55 source IndustrialEffluent 0.45 product DownstreamRiver
FRACTIONATION <Process> attaches to the process of the same name. isotope is required; the factor is given in exactly one of the forms alpha, epsilon, law or law file (two at once: IG213). α is defined as product over reactant: α < 1 means a product depleted in the heavy isotope. No inverted convention is offered.
ε and 1000 ln α are never substituted for each other: their difference exceeds 0.01 ‰ beyond about |ε| = 5 ‰.
FRACTIONATION Reduction isotope 53Cr/52Cr law 1000ln_alpha = 3.10 * (10 ^ 6 / T ^ 2) - 2.41 CONDITIONS temperature 15 C
A law has alpha, epsilon or 1000ln_ as its left-hand side, and reads parameters, T and time. law file "path. points to a law written in a separate file. A LAW block (extended profile) declares a law once for several processes, which name it with law; a FRACTIONATION on the same process takes precedence for the ratio it names.
LAW HighTempCrLaw 1000ln_alpha = 3.10 * (10 ^ 6 / T ^ 2) - 2.41 PROCESS ThermalReduction type reduction reactant Cr(VI) product Cr(III) law HighTempCrLaw CONDITIONS temperature 850 C
Fractionation applies to the matter transferred by the process. The law depends on the regime: closed-system equilibrium if regime equilibrium and the product stays in contact, Rayleigh otherwise. With F the fraction that reacted and f = 1 − F:
A process with no written factor looks for its own in the declared databases (see Factor databases).
KINETICS <Process> makes the process kinetic. constant is a number with its unit or the name of a parameter, whose unit is used.
rate | Required constants |
|---|---|
zero_, first_, second_ | constant |
monod | constant, half_ (molality) |
KINETICS Reduction rate monod constant 0.01 1/d half_saturation 0.5 umol/kgw
MODEL: advancing the model| Statement | Meaning | Default |
|---|---|---|
progress | time (integration through time) or extent (each process consumes the fraction given by its extent) | time |
step | time step | |
until | stopping condition, required under progress time | |
reservoirs, processes | lists included; the process list also sets their order of application within a step | every declared entity |
Under progress time, the last step is shortened to land exactly on the stopping condition: step 10 d with until time >= 365 d stops at 365 days, not 370.
MODEL CrReduction reservoirs [ Groundwater ] processes [ Reduction ] step 0.5 d until time >= 365 d KINETICS Reduction rate first_order constant 0.003 1/d
The stopping condition can also bear on a concentration: until Groundwater.. A file contains a single MODEL block; the results name the one that was run.
OUTPUT and EXPORTEach variable line adds a column to the results; every sets the recording interval under progress time. The accepted paths:
| Path | Quantity | Kind (kind) | Unit |
|---|---|---|---|
time | elapsed time | time | s |
Reservoir. | amount in the pool | amount | mol/kgw or mg/L |
Reservoir. | composition of the pool | pool_ | permil |
Reservoir. | composition of the whole reservoir, amount-weighted mean of its pools | composition | permil |
Reservoir. | share of the initial pool still present, from 1 to 0; absent for a pool that started empty | fraction_ | 1 |
Reservoir. | share of the initial pool that has left it | fraction_ | 1 |
name, Block. | global or local parameter | parameter |
OUTPUT variable time variable Groundwater.Cr(VI).remaining variable Groundwater.Cr(VI).delta53Cr variable Groundwater.delta53Cr every 5 d
EXPORT declares one result file per format (isof, csv or json) and its path. The declaration is carried in the intermediate representation; the igl run command of the reference implementation currently writes only the JSON results file described below, and not yet the files declared by EXPORT.
EXPORT format csv file "cr_plume.csv"
An IGDB database is a TOML file in the IGDB 1.1 format. It contains a header ([database]: name, version, format version, licence), elements with their abundances, standards, species and fractionation factors. Every numeric value carries its citation.
| Field of a factor | Meaning |
|---|---|
ratio, process | ratio and mechanism (same values as PROCESS type) |
reactant, product, reactant_, product_ | the two sides of the reaction, and where each sits (aqueous, adsorbed, mineral, precipitate, vapour, melt, biomass, bulk, industrial) |
epsilon | alpha | law | the value, in exactly one form; product minus reactant |
delta_, delta_ | measured range, distinct from the central value |
uncertainty, uncertainty_ | uncertainty and its kind (standard, expanded_, range, unspecified) |
regime, equilibrium_, context | intended regime, whether equilibrium was actually reached, context |
temperature_ (K), ph_ | measurement domain |
oxidant_, time_, industrial_ | reaction agent, duration of the experiment, industrial operation |
isotope_ | mass_ (default) or nuclear_ |
citation, doi, note | the source |
A path with a separator, or an absolute path, is taken as written, relative to the model. A bare name is looked for in this order: next to the model, in the directory named by the IGL_ environment variable, in a databases directory near the executable. No network access takes place.
IG212.A STANDARD or a FRACTIONATION in the model takes precedence over the database, with no diagnostic. When a factor comes from a database, the diagnostics in the results cite the entry. The factors of the IsoFind Atlas are published in this format on the IGDB databases page.
SAMPLE| Statement | Meaning |
|---|---|
element | measured element (required) |
delta<ratio> | measured composition |
uncertainty, uncertainty_ | analytical uncertainty; standard (one standard deviation) or expanded_ (expanded, k = 2), the default |
dispersion | standard deviation of a population the sample stands for; combined in quadrature with the uncertainty |
material, note | description |
SAMPLE OreDeposits element Sb delta123Sb 0.38 permil uncertainty 0.04 permil uncertainty_kind standard dispersion 0.11 permil note "Mean of 14 measurements over 3 deposits"
IDENTIFY| Statement | Meaning | Default |
|---|---|---|
source, product | the two samples | required |
mode | single, chain, rayleigh; hybrid is reserved to implementations that define it | required |
candidates | mechanisms admitted | all |
context, regime | restrictions on the search | none |
product_ | product (what formed) or residue (what remains of the reactant) | product |
extent | known extent; refused with mode chain (IG213) | swept from 0 to 1 |
coverage | coverage factor k | 2 |
tolerance | added to each bound of the measured interval | 0 |
max_ | maximum number of steps in a chain | 3 |
top | number of explanations listed; all are still counted | all |
SAMPLE Concentrate element Sb delta123Sb 0.42 permil uncertainty 0.05 permil SAMPLE Ingot element Sb delta123Sb 0.70 permil uncertainty 0.03 permil IDENTIFY SmeltingRoute source Concentrate product Ingot mode chain candidates [ reduction, evaporation ] context pyrometallurgy max_chain 3
expanded_k2 value is halved); u = √(us² + up²); measured interval [Δm − k·u − t, Δm + k·u + t].CONDITIONS are set aside before the search, and listed with the reason.discriminates is false as soon as two or more explanations are compatible.IG307, not an empty set.| Statement | Meaning |
|---|---|
input file "…" | PHREEQC input file, which remains runnable on its own (required) |
database "…" | PHREEQC thermodynamic database; by default, the one in the engine configuration |
mode | oneshot (default): PHREEQC's final state, held for the whole run; series: every recorded state, read at the model's current time, without interpolation |
export "column" to name | binds a SELECTED_ column to a read-only global parameter (IG110 if assigned) |
PHREEQC computes speciation within a redox pool; the isotope engine carries out every transfer between pools and all isotopic accounting. A series mode is read against the model's clock and needs progress time (IG306 otherwise); a read before the first recorded state gives IG404. Without PHREEQC available, IG401, with no substitute computation; this is always the case in the browser. Step-by-step coupling through PhreeqcRM is not defined.
Three blocks of the extended profile expand, during lowering, into a PROCESS and a FRACTIONATION. Both writings produce the same model graph.
RAYLEIGH Distillation reservoir Groundwater isotope 53Cr/52Cr epsilon -1.6 reactant Cr(VI) product Cr(III)
RAYLEIGH describes an open-system distillation, whose product is removed as it forms: the Rayleigh law applies even with an equilibrium factor. ADSORPTION (reactant, sorbent) and EXCHANGE (phase_, phase_) expand into PROCESS type adsorption and PROCESS type exchange.
A diagnostic carries a code, a severity, a position (file, line, column), the faulty excerpt underlined and, where possible, a suggested correction: for an unknown name, the closest declared name. The compiler does not stop at the first error; it resumes at the next block and reports everything the file allows. Runtime codes (IG3xx, IG4xx) are written to the results file, together with the rows computed before the error. igl explain IG104 explains a code, with a rejected and an accepted example.
The block below contains an error; its diagnostics appear as you type.
| Code | Severity | Meaning |
|---|---|---|
| Syntax, IG0xx | ||
IG001 | error | unexpected token |
IG002 | error | unterminated string |
IG003 | error | unknown block header |
IG004 | error | statement is not indented |
IG005 | error | block belongs to an unsupported profile |
IG006 | error | non-ASCII character outside an accepted position |
IG007 | error | malformed expression |
IG008 | error | unknown or malformed unit |
IG009 | error | named block is missing its identifier |
IG010 | warning | block identifier does not begin with an uppercase letter |
IG011 | warning | a block this implementation does not honour |
| Semantic, IG1xx | ||
IG101 | error | reference to an undeclared entity |
IG102 | error | duplicate name in the global namespace |
IG103 | error | malformed or unknown isotope ratio |
IG104 | error | mismatched element symbols across a ratio |
IG105 | error | duplicate of a block that must be unique |
IG106 | error | no reference standard resolvable for a ratio |
IG107 | error | unresolved symbol in an expression |
IG108 | warning | local symbol shadows a global one |
IG109 | error | ill-formed qualified name |
IG110 | error | assignment to a read-only symbol |
| Validation, IG2xx | ||
IG201 | error | value outside the admissible range |
IG202 | error | value does not match the expected type |
IG204 | error | unit incompatible with the expected dimension |
IG205 | error | unit omitted where several are admissible |
IG210 | error | unknown property for this block type |
IG211 | error | required property missing |
IG212 | warning | recommended property absent |
IG213 | error | mutually exclusive properties both present |
IG214 | error | physically inadmissible configuration |
IG215 | error | mixing fractions do not sum to one |
| Execution, IG3xx | ||
IG301 | error | solver failed to converge |
IG302 | error | numerical instability |
IG303 | error | division by zero during evaluation |
IG304 | error | negative remaining fraction |
IG305 | error | reaction progress outside 0 to 1 |
IG306 | warning | a statement the chosen progress does not read |
IG307 | error | an identification had no factor to consult |
| Backend, IG4xx | ||
IG401 | error | required backend unavailable |
IG402 | error | backend reported a failure |
IG403 | error | backend communication timeout |
IG404 | error | a backend series read outside what it recorded |
*.iglir.json igl build. The model after resolution, validation, unit conversion and expansion of shorthand forms, with its provenance (path and SHA-256 digest of the source). It is the contract between the language and an engine; it is versioned.*.results.json igl run. format_version ; engine (name and version of the code that computed); model (version of the intermediate representation, path and digest of the source, MODEL block run); backends if an external engine was called; columns, each with its name, kind, canonical unit and references resolved to names; rows; diagnostics; identifications. A reader ignores fields it does not know within a major version and refuses a major version it does not implement.*.igdb An excerpt of results, for a composition column:
{
"name": "Groundwater.Cr(VI).delta53Cr",
"kind": "pool_composition",
"unit": "permil",
"reservoir": "Groundwater",
"species": "Cr(VI)",
"isotope": "53Cr/52Cr"
}
The reference implementation provides the igl command. No version has been published for download yet.
| Command | Effect |
|---|---|
igl check <file>… | reports diagnostics |
igl parse <file> | prints the syntax tree (--json for machine-readable output) |
igl build <file> | produces the intermediate representation, next to the source or at -o |
igl run <model> [<results>] | runs an intermediate representation and writes the results |
igl fmt <file>… | rewrites in canonical form; --check reports a difference without rewriting |
igl explain <code> | explains a diagnostic code |
check, parse and build take --profile core|identification|extended, core by default; the core profile stays accepted whichever is declared. A model containing SAMPLE and IDENTIFY is therefore built with --profile identification.
igl check --profile identification sb-smelting.igl igl build --profile identification sb-smelting.igl igl run sb-smelting.iglir.json
| Exit code | Meaning |
|---|---|
| 0 | no errors |
| 1 | the source has errors, or fmt --check found a difference |
| 2 | bad invocation, or a file could not be read |
| 3 | a defect in the program: nothing it produced can be trusted |
Environment variable: IGL_, directory in which to look for databases named without a path.
IsoFind brings together several services around isotope geochemistry. The Atlas gathers published values for ore deposits, contaminated sites and fractionation, free to browse, with more than 4,100 reference pages in English and French. The IsoFind software is for working on your own measurements, offline. Free online tools such as the standards conversion and two open formats, ISOF (Isotopic Secure Open Format) and IGL (Isotope Geochemistry Language), complete it.
All Rights Reserved by IsoFind