PhreeqcUsers Discussion Forum

Beginners => PHREEQC basics => Topic started by: deso55 on March 07, 2018, 02:15:12 AM

Title: USER_GRAPH legend or label
Post by: deso55 on March 07, 2018, 02:15:12 AM
Hi,
I have used PHREEQC a little before, but tended to output data rather than use USER_GRAPH.
For my recent application I need to quickly visualize results, so I need to use USER_GRAPH
I have a problem in assigning the labels in the legend of USER_GRAPH properly. Mostly, I can't get the legend to appear, and when i do it is not correct

To get my code right, I am first starting using a modified example, example 22 Modelling Gas Solubilities: CO2 at high pressures

If i use this code below, i get a graph, but no legend/labels

TITLE CO2 solubility at different temperature
# a modifcation of example 22
PRINT; -reset false
SOLUTION 1
GAS_PHASE 1
    -fixed_volume
    CO2(g) 0
    H2O(g) 0
REACTION
 CO2 1; 0 27*1
INCREMENTAL_REACTIONS true

USER_GRAPH 1 Example 22,
  -chart_title "CO2 solubility at high pressures, 25 - 100 oC"
  -axis_titles "Pressure / atm" "CO2 / (mol/kgw)"
 -axis_scale x_axis 0 500
 -axis_scale y_axis 0 2
 -connect_simulations false
 10 graph_x PR_P("CO2(g)")
 20 graph_y TOT("C(4)")
END

If I assign headings, using -headings, then what happens is the first heading is never used, and only the second heading appears in legend. E.g see code below. The legend in the graph generated by this code assigns the second heading "??" to the 25oC data - since there is only one set of data, there should be only one data label/heading. If i use "-heading 25", then there is no label/legend.

TITLE CO2 solubility at different temperature
# a modifcation of example 22
PRINT; -reset false
SOLUTION 1
GAS_PHASE 1
    -fixed_volume
    CO2(g) 0
    H2O(g) 0
REACTION
 CO2 1; 0 27*1
INCREMENTAL_REACTIONS true

USER_GRAPH 1 Example 22,
  -chart_title "CO2 solubility at high pressures, 25 - 100 oC"
-headings 25 ??
  -axis_titles "Pressure / atm" "CO2 / (mol/kgw)"
 -axis_scale x_axis 0 500
 -axis_scale y_axis 0 2
 -connect_simulations false
 10 graph_x PR_P("CO2(g)")
 20 graph_y TOT("C(4)")
END

If I include the rest of the code for this example (i.e. the reactions at 50, 75 and 100 oC) then the graph plots the data OK, but the legend still doesn't appear. If I use the -headings command, it will still ignore the first heading and the remainder headings and assign the second heading to the first lot of data (i.e. the 25oC data will be labelled as 50oC and there are no other labels in the legend).

TITLE CO2 solubility at different temperature
# a modifcation of example 22
PRINT; -reset false
SOLUTION 1
GAS_PHASE 1
    -fixed_volume
    CO2(g) 0
    H2O(g) 0
REACTION
 CO2 1; 0 27*1
INCREMENTAL_REACTIONS true

USER_GRAPH 1 Example 22,
  -chart_title "CO2 solubility at high pressures, 25 - 100 oC"
-headings 25 50 75 100
  -axis_titles "Pressure / atm" "CO2 / (mol/kgw)"
 -axis_scale x_axis 0 500
 -axis_scale y_axis 0 2
 -connect_simulations false
 10 graph_x PR_P("CO2(g)")
 20 graph_y TOT("C(4)")
END

###
USE solution 1
USE gas_phase 1
USE reaction 1
REACTION_TEMPERATURE 2
 50
USER_GRAPH 1
 -headings 50
END

USE solution 1
USE gas_phase 1
USE reaction 1
REACTION_TEMPERATURE 3
 75
USER_GRAPH 1
 -headings 75
END

USE solution 1
USE gas_phase 1
USE reaction 1
REACTION_TEMPERATURE 4
 100
USER_GRAPH 1
 -headings 100
END

Any ideas what I am doing wrong with the code? I would prefer to write code that labels the graph accordingly, rather than call on a file for the labels as I need to keep running different examples. I am sure there must be a way to simply assign a legend to the data but I couldn't find this in the manual. I don't understand why the -headings command behaves the way it does as per above (particularly that it ignores the first heading and only uses the second heading)

Cheers

Des
Title: Re: USER_GRAPH legend or label
Post by: dlparkhurst on March 07, 2018, 04:23:39 AM
Look at example 2 for USER_GRAPH in the manual.

-headings --Identifier provides labels for chart curves. The labels are separated by spaces and correspond with the order of the items calculated with Basic statements. Unlike Example data block 1, the headings include an entry for the item plotted on the X axis. Optionally, heading , headings , or -h [ headings ].
Title: Re: USER_GRAPH legend or label
Post by: deso55 on March 07, 2018, 04:51:30 AM
Thanks. So it seems I needed to add a heading for the X axis

I got around it by just assigning a dummy first heading, see code below.

By the way, my intention is to look at CH4 solubility at low pressure (0-100 atm) in different salinity compositions (NaCl and NaHCO3 water). It seems that PHREEQC does not apply salting out coefficients for individual ions, rather an over all  salting out effect based on the activity coefficient of the water. If I wanted to apply individual salting out coefficients for individual ions (e.g. Stoessell and Byrne 1982) would it be possible to modify the equations in PHREEQC?

This is how i used dummy headings -
TITLE CH4 solubility at different temperature
# a modifcation of example 22
PRINT; -reset false
SOLUTION 1
temp 15
GAS_PHASE 1
    -fixed_volume
    CH4(g) 0
    H2O(g) 0
REACTION
 CH4 0.5; 0 27*0.5 #runs the reaction steps 27 times (adding 0.5 mol CH4)
INCREMENTAL_REACTIONS true

USER_GRAPH 1 Example 22,
  -chart_title "CH4 solubility at high pressures, 25 - 100 oC"
-headings ?? 15.oC
  -axis_titles "Pressure / atm" "CH4 / (mol/kgw)"
 -axis_scale x_axis 0 100
 -axis_scale y_axis 0 0.2
 -connect_simulations false
 10 graph_x PR_P("CH4(g)")
 20 graph_y TOT("C(-4)")
END

USE solution 1
USE gas_phase 1
USE reaction 1
REACTION_TEMPERATURE 2
 20
USER_GRAPH 1
 -headings ?? 20.oC
END

USE solution 1
USE gas_phase 1
USE reaction 1
REACTION_TEMPERATURE 3
 25
USER_GRAPH 1
 -headings ?? 25.oC
END

USE solution 1
USE gas_phase 1
USE reaction 1
REACTION_TEMPERATURE 4
 30
USER_GRAPH 1
 -headings ?? 30.oC
END
Title: Re: USER_GRAPH legend or label
Post by: dlparkhurst on March 07, 2018, 05:19:20 AM
Depends on which database you use. llnl.dat uses a single value derived from CO2. phreeqc.dat has bdot (log gamma = bdot * mu). pitzer.dat has a more complicated parameterization for the activities of species.