PhreeqcUsers Discussion Forum

Beginners => PHREEQC basics => Topic started by: mbrandely on March 19, 2020, 10:39:25 AM

Title: Saving all data of a multisteps REACTION calculation
Post by: mbrandely on March 19, 2020, 10:39:25 AM
Dear Phreeq-c Users,
I am a PhD student from France which, right now, have plenty of time to struggle with Phreeq-c modeling.
I would be honoured if you could take a little time to think about this :
I am wondering if it is possible to save in a dump_file each steps of a REACTION calculation. Since SELECTED_OUTPUT could give us such results, I assume that somehow a file can be generated in a readable format for further simulation.
For example, let's say that I am trying to add 1 mol of NaOH to an EQUILIBRIUM_PHASES in 100 steps.
Is it possible to save all data in a way that PHREEQ-C could read them in an other input file? It would lead to the creation of 100 EQUILIBRIUM_PHASES for each increment and 100 SOLUTIONS.
I can only imagine doing that by creating a REACTION for each step which is really time consuming (script writing and data extraction).

I bring to you an example of the script I am currently writing in case it could help you visualize the issue.

### Script example ###
SOLUTION 1
   -ph       7 charge
   -redox   pe
   -units   mol/kgw
   -temp      25
   -water    1
SAVE SOLUTION 1
END


EQUILIBRIUM_PHASES 1
Calcite         0.0   0.2087   dissolve_only
Dolomite         0.0   0.1757   #dissolve_only
Celestite          0.0   0.04      dissolve_only
Quartz(alpha)      0.0   0.1165   dissolve_only   
SAVE EQUILIBRIUM_PHASES 1
END


GAS_PHASE 1
   -fixed_volume
   #-equilibrate with solution 1
   -volume 1.5
   -pressure 1.000
N2(g)      0.78   
O2(g)    0.21
CO2(g)    0.0004
SAVE GAS_PHASE 1
END


SELECTED_OUTPUT
       -file                    Output_01.txt
       -reaction          true
   -ionic_strength      true
   -totals          Ca Mg S(6) Sr
      -equilibrium_phases   Calcite Dolomite Celestite Quartz(alpha) Strontianite Ettringite
   -gases         CO2(g) O2(g) N2(g)
   -saturation_indices   Calcite Dolomite Celestite Quartz(alpha) Strontianite Ettringite


USE SOLUTION 1
USE GAS_PHASE 1
USE EQUILIBRIUM_PHASES 1
   REACTION 2
      NaOH 1
      1 mole in 100 steps


DUMP
-file               dump_01.txt
-append            false
-reaction
-equilibrium_phases
-solution
END



Thanks in advance for your help.
Take care
Maxime
Title: Re: Saving all data of a multisteps REACTION calculation
Post by: dlparkhurst on March 19, 2020, 02:50:21 PM
I think you are right. DUMP is executed after the reaction calculations are completed, so you would need to do the simulation one REACTION step at a time.

I can think of two options. You can use IPhreeqc or IPhreeqcCOM under program (C, C++, or Fortran) or scripting control (Excel or Matlab, for example) to do the simulations one at a time.

Alternatively, your could use SELECTED_OUTPUT and USER_PUNCH to write the long input file, which you can run with INCLUDE$. See example .

Or you can just generate a long input file. If you define REACTION 1 as 1/100 of the total, I think something like the following would work. RUN_CELLS will run a simulation and SAVE all the results. You need to choose whether you want to append to the dump file, or define a new file for each DUMP.

RUN_CELLS
-cells 1
DUMP
...
END
RUN_CELLS
-cells 1
DUMP
...
END
...