PhreeqcUsers Discussion Forum

Welcome Guest
 

  • Forum Home
  • Login
  • Register

  • PhreeqcUsers Discussion Forum »
  • Conceptual Models »
  • Program coupling »
  • Getting/Setting Equilibrium Phases
« previous next »
  • Print
Pages: [1]   Go Down

Author Topic: Getting/Setting Equilibrium Phases  (Read 9084 times)

dallimor

  • Contributor
  • Posts: 3
Getting/Setting Equilibrium Phases
« on: 22/08/24 02:58 »
Hi,

I'm looking at coupling PhreeqcRM to a surface water body Hydrodynamic model with one of the aims to look at the transport, settling, and resuspension of particulate precipitates.

Thanks to the examples I've got everything linked together and I think I understand how to initialize, retrieve, and set species/constituent concentrations but I'm struggling to see how to do this for the solid equilibrium phases.

Is the only way to get the equilibrium phase concentration via the GetSelectedOutput method?

Any pointers are greatly appreciated.

Chris
Logged

dlparkhurst

  • Global Moderator
  • *****
  • Posts: 4000
Re: Getting/Setting Equilibrium Phases
« Reply #1 on: 22/08/24 04:50 »
The latest PhreeqcRM (3.8.0, soon to be 3.8.1) has a subclass BMIPhreeqcRM. This latest version is available for C++, Fortran, and C at https://github.com/usgs-coupled/phreeqcrm in Releases on the right-hand side of the page, or you can clone the repository. Python is available from

Code: [Select]
pip install phreeqcrm
or
conda install -c conda-forge phreeqcrm

There are BMI examples in the Tests directory for C++, Fortran, and C, and in the SWIG directory for Python.

BMIPhreeqcRM has the necessary Basic Model Interface (BMI) methods to link Phreeqc with other models; all BMI models have the same base set of methods. For the most part, BMIPhreeqcRM is simply a reorganization of PhreeqcRM capabilities; however, the BMI methods do add some functionality, as well as a simplification for setting (SetValue) and retrieving (GetValue) variables.

An additional method in BMIPhreeqcRM is AddOutputVars. You can define the following

Code: [Select]
AddOutputVars("EquilibriumPhases", "true");

which will allow retrieval of the variables named "equilibrium_phases_moles_xxx" and "equilibrium_phases_delta_moles_xxx", where xxx is any mineral in the EQUILIBRIUM_PHASES definitions. There are similar methods for exchange, surface, and other reactants, as well as for molalities and activities of aqueous species. By default, all are true, except for activities and molalities. It is also possible to limit the lists to specific items, as in only certain minerals. The BMI method GetOutputVars returns a list of all of the variables that can be retrieved with the method GetValue.

It is still possible to use the PhreeqcRM method GetSelectedOutput to retrieve selected-output data. In fact, the AddOutputVars method uses a special SELECTED_OUTPUT definition numbered 333, which contains all the variables defined by default or specific definitions of AddOutputVars.

All PhreeqcRM methods are available if you instantiate a BMIPhreeqcRM instance instead of a PhreeqcRM instance, so your code should still work, but the additional methods will be available.

Documentation of all methods for PhreeqcRM, BMIPhreeqcRM, and a helper class YAMLPhreeqcRM are found in the directory Doxygen/html of the current distribution.
« Last Edit: 22/08/24 14:36 by dlparkhurst »
Logged

dallimor

  • Contributor
  • Posts: 3
Re: Getting/Setting Equilibrium Phases
« Reply #2 on: 29/08/24 03:08 »
Thanks very much, I've got the new version compiled into our code and it looks like I should be able to do everything we need.
Logged

dallimor

  • Contributor
  • Posts: 3
Re: Getting/Setting Equilibrium Phases
« Reply #3 on: 10/09/24 05:37 »
Hi,  I'm getting a run time error when trying to set an equilibrium phase.  Reading back through your 1st response it looks like it may only be the GetValue method that is implemented for the equilibrium phases.  Is that correct?

Thanks
Logged

dlparkhurst

  • Global Moderator
  • *****
  • Posts: 4000
Re: Getting/Setting Equilibrium Phases
« Reply #4 on: 10/09/24 10:43 »
They are output variables, so yes, you can only use GetValue (not SetValue) on the variables defined by AddOutputVars.

It is possible to change values of EQUILIBRIUM_PHASES and other reactants using EQUILIBRIUM_PHASES_MODIFY. There are complications if you use this datablock with MPI, where the cells are distributed to different processes. It would probably work for the OpenMP version.

I will send a message to you to discuss your issues.
Logged

  • Print
Pages: [1]   Go Up
« previous next »
  • PhreeqcUsers Discussion Forum »
  • Conceptual Models »
  • Program coupling »
  • Getting/Setting Equilibrium Phases
 

  • SMF 2.0.19 | SMF © 2021, Simple Machines | Terms and Policies
  • XHTML
  • RSS
  • WAP2