Skip to content
Preview.pqi@modelscript/phreeqc 10 diagnostic rules
Parser WASM GLR
Diagnostics 10 rules
DAE Arena Lowering
Simulation Native Solvers
Projections Modelica, DAE
Live ExampleCalciteEquilibrium.pqi

PHREEQC Aqueous Speciation & Calcite Dissolution

Hydrogeochemical input deck equilibrating a Ca-HCO3-Cl groundwater solution with calcite and CO2(g) partial pressure.

Playground
Source (14 lines)
1TITLE Calcite and CO2(g) Equilibrium Speciation
2SOLUTION 1 Limestone Aquifer Water
3    temp      25.0
4    pH        7.35
5    pe        4.0
6    units     mmol/kgw
7    Ca        1.85
8    Mg        0.42
9    Alkalinity 3.60 as HCO3
10    Cl        1.10
11EQUILIBRIUM_PHASES 1
12    Calcite   0.0   10.0
13    CO2(g)   -2.1   1.0
14END
PHREEQC Aqueous Speciation & Mineral Equilibria
mass action equilibrate «aqueous phase» SOLUTION 1 «parameters» pH = 7.35, T = 25 C Ca = 1.85 mmol/kgw «mineral buffer» EQUILIBRIUM_PHASES «model» Calcite (SI = 0.0) CO2(g) (logP = -2.1) «newton-raphson» SpeciationResult «verification» charge balance ionic strength I
Drag to pan · Click % to reset

USGS PHREEQC Aqueous Geochemistry & Speciation (.pqi, .dat) ​

@modelscript/phreeqc (languages/phreeqc) provides native WebAssembly GLR parsing, ionic strength and Davies / Extended Debye-Hückel activity coefficient calculation, aqueous carbonate/redox speciation, mineral Saturation Index (SI) evaluation, DAEBuilder lowering, and Modelica 3.x projection for USGS PHREEQC hydrogeochemical, brine scaling, carbon mineralization, and water treatment models.


Supported Extensions & Standards ​

ExtensionFormatDescription
.pqiPHREEQC Input DeckKeyword data blocks (TITLE, SOLUTION, EQUILIBRIUM_PHASES, REACTION, KINETICS, MIX, SELECTED_OUTPUT, END)
.datThermodynamic DatabaseAqueous species (SOLUTION_SPECIES) and mineral solubility (PHASES) database definitions

Key Capabilities ​

1. Ionic Strength & Activity Coefficients ​

  • Computes solution ionic strength I=12∑imizi2, charge balance error (% CBE), and ion activity coefficients γi using the Davies or WATEQ Extended Debye-Hückel equation:log10⁡γi=−Azi2(I1+I−0.3I)

2. Mineral Saturation Indices (SI) & Equilibrium Phases ​

  • Evaluates Ion Activity Products (IAP) and mineral Saturation Indices across carbonate, sulfate, and silicate phases (Calcite, Dolomite, Gypsum, Anhydrite, Barite, Halite, Quartz):SI=log10(IAPKsp(T))identifying supersaturated scaling hazards (SI>0) and undersaturated dissolution regimes (SI<0).

3. DAE Arena Lowering & Modelica Projection ​

  • Lowers aqueous mass-action, charge-balance, and kinetic mineral dissolution/precipitation equations into @modelscript/runtime's DAEBuilder arena and projects them into Modelica 3.x hydrochemical blocks.

Pre-Flight Diagnostics ​

10 rules8 error2 warning

CodeRuleSeverityMessage
M9551ph-out-of-physical-boundserrorSOLUTION '<solutionNumber>' specifies pH '<pH>' outside standard aqueous bounds [0, 14].
M9552pe-out-of-redox-stability-boundswarningSOLUTION '<solutionNumber>' specifies redox potential pe '<pe>' outside water stability bounds [-15, 25].
M9553non-physical-temperatureerrorSOLUTION '<solutionNumber>' specifies non-physical aqueous temperature '<tempC>' °C (valid range: [0, 350] °C).
M9554negative-solute-concentrationerrorSolute '<element>' in SOLUTION '<solutionNumber>' specifies negative concentration '<concentration>'.
M9555charge-imbalance-exceededwarningSOLUTION '<solutionNumber>' exhibits relative electrical charge imbalance '<value>%' (> 5%) without a 'charge' balance element.
M9556unknown-aqueous-master-specieserrorSOLUTION '<solutionNumber>' references unrecognized aqueous master species '<element>'.
M9557unknown-equilibrium-mineral-phaseerrorEQUILIBRIUM_PHASES '<blockNumber>' references unrecognized mineral phase '<mineralName>'.
M9558negative-mineral-moleserrorEquilibrium mineral phase '<mineralName>' specifies negative initial moles '<initialMoles>'.
M9559unresolved-mix-solutionerrorMIX '<mixNumber>' references undefined SOLUTION '<solutionNumber>'.
M9560empty-phreeqc-deckerrorPHREEQC deck contains no SOLUTION, EQUILIBRIUM_PHASES, REACTION, KINETICS, MIX, or database definitions.

Generated from languages/phreeqc/src/errors.ts. All languages →


CLI Usage ​

bash
# Validate electrical charge balance, pH/pe bounds, and phase blocks
msx lint GeothermalBrine.pqi

# Parse and inspect PHREEQC keyword blocks
msx parse GeothermalBrine.pqi

Open-Core under the GNU AGPL v3 License; Enterprise Edition (ee/) under the ModelScript Enterprise License. • Pricing • Trademark Policy