PhreeqcUsers Discussion Forum

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 

  • Forum Home
  • Login
  • Register

  • PhreeqcUsers Discussion Forum »
  • USER_PUNCH/USER_GRAPH »
  • BASIC functions »
  • USER_GRAPH and EQUILIBRIUM_PHASES
« previous next »
  • Print
Pages: [1]   Go Down

Author Topic: USER_GRAPH and EQUILIBRIUM_PHASES  (Read 1352 times)

NicolevJ

  • Contributor
  • Posts: 3
USER_GRAPH and EQUILIBRIUM_PHASES
« on: July 19, 2019, 02:51:02 PM »
Hi,

To show and calculate the phosphorus removal by P precipitation in waste waters I want to create two different graphs using the keywords Phases, Reaction, Equilibrium_phases and User_Graph.

Graph 1: Showing the SI values vs the pH
Graph 2: Showing the SI values vs the pH while Equilibrium_Phases are defined.

With the following script my Graph 1 takes into account the equilibrium_phases defined later (incorrect graph). If I were to not implement Equilibrium_Phase and the second graph the plot does turn out like desired.

Is there a way to exclude equilibrium phases from my first graph and then include it in my second graph?

I understand that one might think why don't you use the attached graphs as your desired result, but I would like to apply the similair script for different variables and water compositions.

Thank you in advance,
Nicole

Script:

TITLE Nicole Black Water pH Effect
#Black water composition as defined by De Graaff 2010.

PHASES
# Defining phases that are not in the phreeqc.dat database:

ATCP      # Amorphous tricalcium phosphate: Ca3(PO4)2(am2)   from minteq database (from Smith 2003 NIST database, see Gustafsson 2008)
Ca3(PO4)2 = 3 Ca+2 + 2 PO4-3
log_k   -28.25
delta_h   -87       # kJ/mol

TCP      #Via Maņas, NSIT Database 2011
   Ca3(PO4)2 = 3Ca+2 + 2PO4-3
    log_k -32.69
END

SOLUTION  1 Black Water  @De Graaff 2010
-units   mg/l
-temp   20         #
pH      4.8        # 8.8
P       25         # 25 mgPO4-P/l
Amm     286        # 286 mgN/l
K       116        # 116 mg/l
Na      221        # 221 mg/l
Mg      24         # 24 mg/l  = 0.504mmoles
S(6)    31.6      # 31.6
Cl   246      # 246
N(5)   11.4      # 11.4
Ca      54.6       # 54.6 mg/l
Alkalinity    1525  as HCO3    # as HCO3, (is HCO3+CO3- mg/l)

REACTION 1
NaOH
1.4 in 18 steps    #
END
 
USE Solution 1
USE Reaction 1
USER_GRAPH 1   
    -headings       pH TCP Hydroxyapatite ATCP   
    -axis_titles            "pH" "SI"
    -chart_title            "Saturation Index vs. pH"
    -initial_solutions      false
    -axis_scale x_axis       auto auto   # X pH
     -axis_scale y_axis       auto auto     # Y SI
    -connect_simulations    true
-start
10 pH = -LA("H+")
20 GRAPH_X pH
30 GRAPH_Y SI("TCP")
40 GRAPH_Y SI("Hydroxyapatite")
50 GRAPH_Y SI("ATCP")
  -end
END
 
EQUILIBRIUM_PHASES 
ATCP         0 0
Hydroxyapatite        0 0
TCP          0 0 
  USER_GRAPH 2
    -headings               pH TCP Hydroxyapatite  ATCP %P-removal
    -axis_titles            "pH" "SI" "P removal %"
    -chart_title            "Saturation Index vs. pH"
    -initial_solutions      true
    -axis_scale x_axis       auto auto        # pH
    -axis_scale y_axis       auto auto       # SI 
    -axis_scale sy_axis     0 100          # %P removal
    -connect_simulations    true
  -start
 10 pH = -LA("H+")
110 GRAPH_X pH
120 GRAPH_Y SI("TCP")
130 GRAPH_Y SI("Hydroxyapatite")
160 GRAPH_Y SI("ATCP")
180 P0  = 8.081e-04            # initial P concentration
190 GRAPH_SY     ((P0-tot("P"))/P0)*100,    # %P removal
  -end
END
Logged

dlparkhurst

  • Top Contributor
  • Posts: 2483
Re: USER_GRAPH and EQUILIBRIUM_PHASES
« Reply #1 on: July 19, 2019, 03:13:36 PM »
I don't see anything wrong with your file. If you leave the "END" after USER_GRAPH 1, you get the SIs with USER_GRAPH 1 when there are no reactions with EQUILIBRIUM_PHASES. All SIs monotonically increase.

If you comment the END (#END) then EQUILIBRIUM_PHASES is used and USER_GRAPH 1 shows just the SIs, and USER_GRAPH 2 also shows the percent removal. At pH above 6 TCP form and its SI stays constant at 0.0. The other mineral SIs evolve accordingly with ATCP remaining constant and undersaturated and hydroxyapatitie increasing in SI, but remaining undersaturated.
Logged

NicolevJ

  • Contributor
  • Posts: 3
Re: USER_GRAPH and EQUILIBRIUM_PHASES
« Reply #2 on: October 17, 2019, 12:20:30 PM »
Hi,

I realized I oversimplified my script I shared (some keywords before USER_GRAPH 2 were missing).
The problem that actually arose when using the non simplified script was that Graph 1 was using the input of Graph 2 as well. Causing double lines in Graph 1 where I didn't want it to do so. I found out that by adding

USER_GRAPH 1
-detach

After the END of USER_GRAPH 1 the double lines don't occur anymore.

I have added the 'correct' simplified script in the attachment.
So future users might benefit from it as well. :)

Have a nice day :)
Nicole

ps: 'correct' being as correct as my knowledge can value
Logged

  • Print
Pages: [1]   Go Up
« previous next »
  • PhreeqcUsers Discussion Forum »
  • USER_PUNCH/USER_GRAPH »
  • BASIC functions »
  • USER_GRAPH and EQUILIBRIUM_PHASES
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines | Terms and Policies
  • XHTML
  • RSS
  • WAP2