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 »
  • BASIC PUT/GET Between blocks of USER_PUNCH and USER_PRINT
« previous next »
  • Print
Pages: [1]   Go Down

Author Topic: BASIC PUT/GET Between blocks of USER_PUNCH and USER_PRINT  (Read 976 times)

artshap

  • Contributor
  • Posts: 4
BASIC PUT/GET Between blocks of USER_PUNCH and USER_PRINT
« on: September 30, 2019, 04:27:57 AM »
Dear All,

I am starting to use PHREEQC, and I am confused a bit about how values are passed between different sections of code.

For example, I have this code where I am equilibrating two solutions separately with CO2(g) and Calcite and I want to print out (or user punch) the values of pH after the equilibrium has been established.

Below is the code that does that:
Code: [Select]
PRINT
-reset false
-user_print true

SOLUTION 1 SW
temperature 25
units mg/L
density 1.015
pH 7 charge
Ca 650
Mg 2110
Na 18300
Cl 32399
S(6) 4290
water 0.02 #kg=20mL brine
EQUILIBRIUM_PHASES 1
Calcite 0 1e-4 #mol=10mg powder
CO2(g) -3.44 1


USER_PRINT
-start
10 PUT(-LA("H+"), 1)
-end
END


SOLUTION 2 SW4SO
temperature 25
units mg/L
density 1.015
pH 7 charge
Ca 650
Mg 2110
Na 24467
Cl 17160
S(6) 2145
water 0.02 #kg=20mL brine
EQUILIBRIUM_PHASES 2
Calcite 0 1e-4 #mol=10mg powder
CO2(g) -3.44 1



USER_PRINT
-start
10 PUT(-LA("H+"), 2)
-end
END



SOLUTION 3

USER_PRINT
-start
05 PRINT "ph1" "ph2"
10 pH1 = GET(1)
20 pH2 = GET(2)
30 PRINT pH1, pH2
-end
END

However, this stops working if I change it to, for example:

Code: [Select]
PRINT
-reset false
-user_print true

SOLUTION 1 SW
temperature 25
units mg/L
density 1.015
pH 7 charge
Ca 650
Mg 2110
Na 18300
Cl 32399
S(6) 4290
water 0.02 #kg=20mL brine
EQUILIBRIUM_PHASES 1
Calcite 0 1e-4 #mol=10mg powder
CO2(g) -3.44 1


USER_PUNCH
-start
10 PUT(-LA("H+"), 1)
-end
END


SOLUTION 2 SW4SO
temperature 25
units mg/L
density 1.015
pH 7 charge
Ca 650
Mg 2110
Na 24467
Cl 17160
S(6) 2145
water 0.02 #kg=20mL brine
EQUILIBRIUM_PHASES 2
Calcite 0 1e-4 #mol=10mg powder
CO2(g) -3.44 1



USER_PUNCH
-start
10 PUT(-LA("H+"), 2)
-end
END



SOLUTION 3

USER_PRINT
-start
05 PRINT "ph1" "ph2"
10 pH1 = GET(1)
20 pH2 = GET(2)
30 PRINT pH1, pH2
-end
END

I was under the impression that this should be working all the same. Can somebody please explain to me the difference?
Logged

Yongqiang

  • Top Contributor
  • Posts: 67
Re: BASIC PUT/GET Between blocks of USER_PUNCH and USER_PRINT
« Reply #1 on: September 30, 2019, 06:02:16 AM »
Is it because that the USER_PUNCH keyword needs to be used with SELECTED OUTPUT?
Logged

artshap

  • Contributor
  • Posts: 4
Re: BASIC PUT/GET Between blocks of USER_PUNCH and USER_PRINT
« Reply #2 on: September 30, 2019, 06:27:31 AM »
Hmm... So if I do not have a SELECTED_OUTPUT connected to my USER_PUNCH, USER_PUNCH is skipped? Because if I run
Code: [Select]
PRINT
-reset false
-user_print true

SOLUTION 1 SW
temperature 25
units mg/L
density 1.015
pH 7 charge
Ca 650
Mg 2110
Na 18300
Cl 32399
S(6) 4290
water 0.02 #kg=20mL brine
EQUILIBRIUM_PHASES 1
Calcite 0 1e-4 #mol=10mg powder
CO2(g) -3.44 1


USER_PRINT
-start
10 PUT(-LA("H+"), 1)
-end
END


SOLUTION 2 SW4SO
temperature 25
units mg/L
density 1.015
pH 7 charge
Ca 650
Mg 2110
Na 24467
Cl 17160
S(6) 2145
water 0.02 #kg=20mL brine
EQUILIBRIUM_PHASES 2
Calcite 0 1e-4 #mol=10mg powder
CO2(g) -3.44 1

USER_PRINT
-start
10 PUT(-LA("H+"), 2)
-end
END


SOLUTION 3

USER_PUNCH
-headings ph1 ph2
-start
10 pH1 = GET(1)
20 pH2 = GET(2)
30 PUNCH pH1, pH2
-end

SELECTED_OUTPUT 1; -reset false; -file two_solutions.txt

there is no problem. But if I would replace those two middle USER_PRINT with USER_PUNCH it will return zero values.
Logged

dlparkhurst

  • Top Contributor
  • Posts: 2483
Re: BASIC PUT/GET Between blocks of USER_PUNCH and USER_PRINT
« Reply #3 on: September 30, 2019, 06:46:38 AM »
SELECTED_OUTPUT n needs to be defined to allow USER_PUNCH n to be executed.

Sorry, it is just the way the program evolved. From the manual, "USER_PUNCH has no effect unless a SELECTED_OUTPUT data block has been defined."
Logged

artshap

  • Contributor
  • Posts: 4
Re: BASIC PUT/GET Between blocks of USER_PUNCH and USER_PRINT
« Reply #4 on: September 30, 2019, 06:55:10 AM »
Thank you for the confirmation! I was just reading the manual and I guess I have skipped that line.
Logged

artshap

  • Contributor
  • Posts: 4
Re: BASIC PUT/GET Between blocks of USER_PUNCH and USER_PRINT
« Reply #5 on: September 30, 2019, 07:38:03 AM »
Another thing I have noticed now, is that if I run this:

Code: [Select]
PRINT
-reset false
-user_print true

SOLUTION 1 SW
temperature 25
units mg/L
density 1.015
pH 7 charge
Ca 650
Mg 2110
Na 18300
Cl 32399
S(6) 4290
water 0.02 #kg=20mL brine
EQUILIBRIUM_PHASES 1
Calcite 0 1e-4 #mol=10mg powder
CO2(g) -3.44 1


USER_PUNCH
-start
10 PUT(-LA("H+"), 1)
-end
SELECTED_OUTPUT
END


SOLUTION 2 SW4SO
temperature 25
units mg/L
density 1.015
pH 7 charge
Ca 650
Mg 2110
Na 24467
Cl 17160
S(6) 2145
water 0.02 #kg=20mL brine
EQUILIBRIUM_PHASES 2
Calcite 0 1e-4 #mol=10mg powder
CO2(g) -3.44 1

USER_PUNCH
-start
10 PUT(-LA("H+"), 2)
-end
SELECTED_OUTPUT
END

SOLUTION 3
USER_PRINT
-start
05 PRINT "ph1" "ph2"
10 pH1 = GET(1)
20 pH2 = GET(2)
30 PRINT pH1, pH2
-end
END

The second pH value that is printed out is the one before the equilibrium.

If I replace the last USER_PRINT with USER_PUNCH, then both correct values are punched.

Code: [Select]
PRINT
-reset false
-user_print true

SOLUTION 1 SW
temperature 25
units mg/L
density 1.015
pH 7 charge
Ca 650
Mg 2110
Na 18300
Cl 32399
S(6) 4290
water 0.02 #kg=20mL brine
EQUILIBRIUM_PHASES 1
Calcite 0 1e-4 #mol=10mg powder
CO2(g) -3.44 1


USER_PUNCH
-start
10 PUT(-LA("H+"), 1)
-end
SELECTED_OUTPUT
END


SOLUTION 2 SW4SO
temperature 25
units mg/L
density 1.015
pH 7 charge
Ca 650
Mg 2110
Na 24467
Cl 17160
S(6) 2145
water 0.02 #kg=20mL brine
EQUILIBRIUM_PHASES 2
Calcite 0 1e-4 #mol=10mg powder
CO2(g) -3.44 1

USER_PUNCH
-start
10 PUT(-LA("H+"), 2)
-end
SELECTED_OUTPUT
END

SOLUTION 3

USER_PUNCH
-headings ph1 ph2
-start
10 pH1 = GET(1)
20 pH2 = GET(2)
30 PUNCH pH1, pH2
-end

SELECTED_OUTPUT 1; -reset false; -file two_solutions.txt
END
Logged

  • Print
Pages: [1]   Go Up
« previous next »
  • PhreeqcUsers Discussion Forum »
  • USER_PUNCH/USER_GRAPH »
  • BASIC functions »
  • BASIC PUT/GET Between blocks of USER_PUNCH and USER_PRINT
 

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