Conceptual Models > Incorporation PHREEQC in programming languages
Using phreeqc in python
(1/1)
fangshangyue:
Hello!
I am now in the phase of learning PHREEQC. Recently I was trying to replicate a paper on my computer, I encountered many problems during the process.
So I want to know:
1.After compiling the IPhreeqc library, in Python I refer to the iPhreeQC .dll whether the file is the IPHREEQC .dll in the release folder, because after being generated by cmake and vscode, it seems that only this folder has IPHREEQC .dll.
2.If the above steps are correct, I run the program and find that phreeqc does not run correctly.
--- Code: ---phreeqc_result = selected_array(os.path.join(datpath, 'pesti.dat'), input_string)
--- End code ---
In the results, it was found that the concentration of the substance I was going to calculate was 0 after the reaction. So I wondered if I missed some step that caused the program to run successfully without reporting an error, but got the wrong calculation result.
Tips:The code is visible in ”https://github.com/yakiwei/CPqPy_V1/blob/main/CPqPy_Case2.py“
The papar:https://doi.org/10.1111/gwat.13144
charlton:
Hello fangshangyue,
You need to add checks for error conditions.
for example:
--- Code: ---import phreeqpy.iphreeqc.phreeqc_dll as phreeqc_mod
p = phreeqc_mod.IPhreeqc()
p.load_database("C:/Program Files/USGS/phreeqc-3.7.3-15968-x64/database/phreeqc.dat.XXX")
if p.phc_database_error_count > 0:
print(p.get_error_string())
--- End code ---
You may need to look at the phreeqc_dll.py source file for things like 'phc_database_error_count'.
The previous code should print:
--- Code: ---'ERROR: LoadDatabase: Unable to open:"C:/Program Files/USGS/phreeqc-3.7.3-15968-x64/database/phreeqc.dat.XXX".\n'
--- End code ---
Scott
Navigation
[0] Message Index
Go to full version