PhreeqcUsers Discussion Forum

Registrations currently disabled due to excessive spam. Please email phreeqcusers at gmail.com to request an account.
Welcome Guest
 

  • Forum Home
  • Login
  • Register

  • PhreeqcUsers Discussion Forum »
  • Beginners »
  • BASIC functions »
  • The INVERSE_MODELING and SELECTED_OUTPUT modules cannot be opened in my code
« previous next »
  • Print
Pages: [1]   Go Down

Author Topic: The INVERSE_MODELING and SELECTED_OUTPUT modules cannot be opened in my code  (Read 938 times)

yisongxu

  • Frequent Contributor
  • Posts: 17
The INVERSE_MODELING and SELECTED_OUTPUT modules cannot be opened in my code
« on: 26/05/25 03:58 »
Hello,
I used GPT to help me organize my thoughts, and then I copied the code it provided. However, I can't open the INVERSE_MODELING and SELECTED_OUTPUT modules in the software, and the running result shows that the input file is incorrect. Is it because the configuration of my computer is too low? Or for other reasons? I sincerely ask for your guidance. The following is the code provided by GPT:
Code: [Select]
SOLUTION 1
    temp      25
    pH        4.0
    pe        4
    redox     pe
    units     mol/L
    Fe(2)     0.0789
    Cl        0.0789
    -water    0.1

SOLUTION 2
    temp      25
    pH        10.0
    pe        4
    redox     pe
    units     mol/L
    Fe(2)     0.0007
    Fe(3)     0.000052
    Cl        0.0789
    Na        0.05   # 来自 5 mL 1M NaOH
    OH        charge
    -water    0.105

INVERSE_MODELING
    -solutions 1 2
    -phases
        Fe(OH)3(s)
        Fe(OH)2(s)
        FeOOH
    -balances
        Fe Cl Na
    -uncertainty 1e-9
    -mineral_water true

SELECTED_OUTPUT
    -file inverse_output.txt
    -molalities Fe(2) Fe(3)
Logged

dlparkhurst

  • Global Moderator
  • *****
  • Posts: 4069
Re: The INVERSE_MODELING and SELECTED_OUTPUT modules cannot be opened in my code
« Reply #1 on: 26/05/25 05:08 »
You would do better looking at the INVERSE_MODELING examples (16, 17, and 18) in the PHREEQC version 3 manual.

Note that you will need a mineral, gas, or exchange source/sink for every element. All these reactants must be defined in PHASES or EXCHANGE. Reasonable uncertainty is 0.05 or greater.
Logged

yisongxu

  • Frequent Contributor
  • Posts: 17
Re: The INVERSE_MODELING and SELECTED_OUTPUT modules cannot be opened in my code
« Reply #2 on: 26/05/25 10:01 »
Dear dlparkhurst, thank you for your reply.

I'm learning by example, but I'm encountering two problems. In the "Phase"-"Dissolution reaction", the reaction I want to input is 2[Fe(OH)₂?2FeOOH] = 3γ-Fe₂O₃ + 2e⁻ + 2H⁺ + 3H₂O.

Question 1: The parameter of γ-Fe₂O₃ is required to be 1, but 2/3 cannot be input in the software. Then, should I input 0.67 or as many digits as possible (for example, 0.6666667)?

Question 2: It seems that "γ" cannot be input in the software. So how should I represent it?
Logged

dlparkhurst

  • Global Moderator
  • *****
  • Posts: 4069
Re: The INVERSE_MODELING and SELECTED_OUTPUT modules cannot be opened in my code
« Reply #3 on: 26/05/25 15:04 »
Here is an example you can learn from. The script performs a forward reaction that starts with an FeCl2 solution and adds NaCl and oxidizes Fe(2). The result is stored as solution 2. The reactions required to produce the composition of solution 2 from solution 1are then deduced by inverse modeling. I have included HCl as a phase because, with real world solutions, you will need an independent source/sink for every element in the system.

Code: [Select]
PHASES
HCl
HCl = H+ + Cl-
END
SOLUTION 1
pH 7 charge
-units mmol/kgw
Fe 1
Cl 2
END
USE solution 1
REACTION 1
NaCl 1
0.01
EQUILIBRIUM_PHASES 1
O2(g) -0.7 10
Goethite 0 0
SAVE solution 2
END
INVERSE_MODELING 1
    -solutions      1        2
    -uncertainty    0.05     0.05
    -phases
        HCl
        Goethite
        O2(g)
        Halite
    -tolerance         1e-10
    -mineral_water     true
END
Logged

yisongxu

  • Frequent Contributor
  • Posts: 17
Re: The INVERSE_MODELING and SELECTED_OUTPUT modules cannot be opened in my code
« Reply #4 on: 04/06/25 04:12 »
I'm very sorry to disturb you again on this issue. However, I attempted to simulate my solution based on your code. I saved the file name in Chinese, but when I ran it, it prompted "ERROR:Cannot open file,C\Users\xxs\Desktop\模拟拟合.pqi. Name of input file?Diffite C\Users\xxs\Desktop\模拟拟合.pqi "And I can't close the software.

I don't know what this is related to. Hope you can give me some guidance
Code: [Select]
PHASES
GR_Cl
    Fe4(OH)8Cl + 8H+ = Cl- + 3Fe+2 + Fe+3 + 8H2O
    log_k     41.5
Magnetite
    Fe3O4 + 8H+ = Fe+2 + 2Fe+3 + 4H2O
    log_k     10.35
Fe(OH)2_active
    Fe(OH)2 = Fe+2 + 2OH-
    log_k     -14
Fix_pH
    H+ = H+
    log_k     0
Fe_ox2
    FeOOH + 3H+ = Fe+3 + 2H2O
    log_k     -0.16
END

SOLUTION 1
    temp      25
    pH        7
    pe        4
    redox     pe
    units     mmol/kgw
    density   1
    Fe(2)     1
    Cl        2
    -water    1 # kg
END

USE solution 1
EQUILIBRIUM_PHASES 1
    O2(g)     -0.25 10
    GR_Cl     0 10

SAVE solution 2

END
SOLUTION_SPREAD
 Fe(2) Fe(3)
  5.61   0.37
  6.16   0.19
  5.89   0.68
  4.56   0.23
   3.6   0.32
  2.95   0.78
  2.59   0.59
   2.5   0.91
  1.95   0.85
  1.44   0.78
  1.17   0.59
  0.34   0.55
  0.89   0.28
  0.53    0.5
  0.43   0.55
   0.3   0.55
     0   1.08
     0   0.71
  0.02   0.51
  0.16   0.46
  0.43   0.19
INVERSE_MODELING 1
    -solutions      1        2
    -uncertainty    0.05     0.05
    -phases
        GR_Cl
        Magnetite
        O2(g)
        Fe(OH)2_active
    -tolerance         1e-010
    -mineral_water     true

END
« Last Edit: 04/06/25 04:18 by yisongxu »
Logged

dlparkhurst

  • Global Moderator
  • *****
  • Posts: 4069
Re: The INVERSE_MODELING and SELECTED_OUTPUT modules cannot be opened in my code
« Reply #5 on: 04/06/25 14:23 »
Did you look at the composition of the solution 2 that you made? It has 14 mol/kgw of Fe and over 60 mol of solutes per kilogram of water. The water is 10 orders of magnitude supersaturated with many iron oxides that form easily.

Equilibrium with GR_Cl at a high partial pressure of oxygen is not realistic. Try again with a more plausible reaction to form solution 2.

I don't know about Chinese file names. We did fix a problem related to Chinese characters within the last year, but I'm not surprised there could be problems. Perhaps some of the Chinese users could help.
Logged

yisongxu

  • Frequent Contributor
  • Posts: 17
Re: The INVERSE_MODELING and SELECTED_OUTPUT modules cannot be opened in my code
« Reply #6 on: 06/06/25 02:36 »
Thank you for your reply. I will reset my parameters.
Logged

yisongxu

  • Frequent Contributor
  • Posts: 17
Re: The INVERSE_MODELING and SELECTED_OUTPUT modules cannot be opened in my code
« Reply #7 on: 13/06/25 08:31 »
Dear dlparkhurst,

I dissolved 2 g FeCl2 in 100 mL of water, added 1 g/L NaOH to it at a rate of 1 ml/min, recorded the pH and Eh of the solution every minute, and the oxygen concentration in the container was 0.5 mg/ L. The purpose of the experiment was to synthesize green rust (Fe₄(OH)₈Cl).

I hoped to fit "time-ph", but when I ran my code, the output image was blank and had no curve. Could you please tell me what's wrong?
Code: [Select]
PHASES
Green_Rust_Cl
    Fe4(OH)8Cl + 8H+ = 3Fe+2 + Fe+3 + Cl- + 8H2O
    log_k 57.5

Fe(OH)3(s)
    Fe(OH)3 + 3H+ = Fe+3 + 3H2O
    log_k 3.5

Fe(OH)2(s)
    Fe(OH)2 + 2H+ = Fe+2 + 2H2O
    log_k 8.1

SOLUTION 1
    temp      25
    pH        4
    pe        4
    redox     pe
    units     mol/L
    Fe(2)     0.0158     # 2 g FeCl2 in 100 mL = 0.0158 mol
    Cl        0.0316
    O(0)      1.56e-5    # 0.5 mg/L O2 = 1.56e-5 mol/L
    -water    0.1        # 100 mL

EQUILIBRIUM_PHASES 1
    Green_Rust_Cl  0.0  0
    Fe(OH)3(s)     0.0  0
    Fe(OH)2(s)     0.0  0

REACTION 1
    NaOH 1
    0.0001 in 11 steps   # 1 mL/min ? 1 g/L = 0.001 mol/min ? 11 min = 0.0011 mol ≈ step of 0.0001

USE solution 1
USE equilibrium_phases 1

USER_GRAPH 1
    -headings   time  pH
    -axis_titles "Time (min)" "pH"
    -chart_title "pH vs Time during NaOH addition"
    -start
      10
    -step
      GRAPH_X = STEP_NO
      GRAPH_Y = -LA("H+")
    -end

SELECTED_OUTPUT
    -file green_rust_output.txt
    -reset false
    -step true
    -pH true
    -totals Fe Fe(2) Fe(3) Cl Na
    -equilibrium_phases Green_Rust_Cl Fe(OH)3 Fe(OH)2
Logged

dlparkhurst

  • Global Moderator
  • *****
  • Posts: 4069
Re: The INVERSE_MODELING and SELECTED_OUTPUT modules cannot be opened in my code
« Reply #8 on: 13/06/25 13:22 »
If you want to fit precipitation with time, you will need to use the KINETICS and RATES data blocks, and your X axis will be the Basic function TOTAL_TIME.


Code: [Select]
USER_GRAPH 1
    -headings   time  pH
    -axis_titles "Time (min)" "pH"
    -chart_title "pH vs Time during NaOH addition"
    -start
10     GRAPH_X  STEP_NO
20     GRAPH_Y  -LA("H+")
    -end
Logged

  • Print
Pages: [1]   Go Up
« previous next »
  • PhreeqcUsers Discussion Forum »
  • Beginners »
  • BASIC functions »
  • The INVERSE_MODELING and SELECTED_OUTPUT modules cannot be opened in my code
 

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