Databases
ChemistryLab.build_reactionsChemistryLab.build_speciesChemistryLab.extract_primary_speciesChemistryLab.get_compatible_speciesChemistryLab.merge_jsonChemistryLab.read_thermofun_database
ChemistryLab.extract_primary_species — Function
extract_primary_species(file_path::AbstractString) -> DataFrameExtract 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.
ChemistryLab.read_thermofun_database — Function
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.
ChemistryLab.build_species — Function
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.
ChemistryLab.build_reactions — Function
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 existingSpeciesobjects 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
Reactionobjects.
ChemistryLab.get_compatible_species — Function
get_compatible_species(df_substances::AbstractDataFrame, species_list; aggregate_states=[AS_AQUEOUS], exclude_species=[], union=false) -> DataFrameFind 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 originalspecies_listin the result (default: false).
Returns
- DataFrame of compatible substances.
ChemistryLab.merge_json — Function
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.