Databases

ChemistryLab.extract_primary_speciesFunction
extract_primary_species(file_path::AbstractString) -> DataFrame

Extract primary aqueous species from a PHREEQC database file.

Arguments

  • file_path: path to PHREEQC .dat file.

Returns

  • DataFrame with columns: species, symbol, formula, aggregate_state, atoms, charge, gamma.

Parses the SOLUTION_SPECIES section to extract master species and their properties. The "Zz" charge placeholder is handled specially. Gamma coefficients for activity models are extracted from "-gamma" lines.

source
ChemistryLab.read_thermofun_databaseFunction
read_thermofun_database(filename::AbstractString) -> (DataFrame, DataFrame, DataFrame)

Read a ThermoFun database from a JSON file.

Arguments

  • filename: path to the JSON database file.

Returns

  • df_elements: DataFrame of chemical elements.
  • df_substances: DataFrame of chemical substances (species).
  • df_reactions: DataFrame of chemical reactions.
source
ChemistryLab.build_speciesFunction
build_species(df_substances::AbstractDataFrame, list_symbols=nothing; verbose=false) -> Vector{Species}

Build Species objects from a substance DataFrame.

Arguments

  • df_substances: DataFrame containing substance data.
  • list_symbols: optional list of symbols to filter (default: nothing, process all).
  • verbose: if true, print details during processing (default: false).

Returns

  • Vector of Species.
source
ChemistryLab.build_reactionsFunction
build_reactions(df_reactions::AbstractDataFrame, dict_species=Dict(), list_symbols=nothing; verbose=false) -> Vector{Reaction}

Build Reaction objects from a reaction DataFrame.

Arguments

  • df_reactions: DataFrame containing reaction data.
  • species_list: vector of existing Species objects to use in reactions.
  • list_symbols: optional list of reaction symbols to filter (default: nothing, process all).
  • verbose: if true, print details during processing (default: false).

Returns

  • Vector of Reaction objects.
source
ChemistryLab.get_compatible_speciesFunction
get_compatible_species(df_substances::AbstractDataFrame, species_list; aggregate_states=[AS_AQUEOUS], exclude_species=[], union=false) -> DataFrame

Find species in the database compatible with a given list of species (sharing atoms).

Arguments

  • df_substances: substance DataFrame.
  • species_list: list of target species symbols.
  • aggregate_states: filter for specific aggregate states (default: [AS_AQUEOUS]).
  • exclude_species: list of species symbols to exclude.
  • union: if true, includes the original species_list in the result (default: false).

Returns

  • DataFrame of compatible substances.
source
ChemistryLab.merge_jsonFunction
merge_json(json_path::AbstractString, dat_path::AbstractString, output_path::AbstractString)

Merge PHREEQC .dat phase data into a ThermoFun JSON database file.

Arguments

  • json_path: path to input ThermoFun JSON file.
  • dat_path: path to PHREEQC .dat file containing phase definitions.
  • output_path: path for output merged JSON file.

Reads both files, extracts phases from the .dat file, merges them into the JSON database structure, and writes the result preserving the original JSON formatting.

source