IPHreeqcCOM-based Na-K-Ca-Cl-SO4 five-element brine evaporation and concentration batch simulation method
By constructing an initial model and automatically synchronizing parameters using a graphical user interface (GUI) based on IPhreeqcCOM, the problem of Phreeqc software being unable to perform batch calculations and extract model output results was solved, achieving efficient and accurate simulation of the evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine.
Patent Information
- Application Number
- CN202510888802.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-10-28
AI Technical Summary
The existing Phreeqc software cannot automatically calculate numerical models with different input parameter values in batches, and the batch extraction of model output results is inefficient and prone to errors.
An initial model is built using the graphical user interface (GUI) based on IPhreeqcCOM, input files are automatically generated, and parameters are modified within the Phreeqc GUI. The parameter values in the input files are automatically and synchronously changed. The numerical model with combined parameter values is then traversed and run using the IPhreeqcCOM interface, and the output results are automatically extracted.
It enables automatic batch calculation of Pitzer models with different parameter combinations, reducing the human error rate and improving data analysis efficiency.
Smart Images

Figure CN120853701A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of brine concentration simulation technology, and in particular to a batch simulation method for the evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine based on IPhreeqcCOM. Background Technology
[0002] PhreeqC is a widely used computational software both domestically and internationally capable of handling various thermodynamic equilibrium reactions, including water-rock reactions, ion exchange reactions, surface complexation reactions, solid solutions, and water-gas equilibrium reactions.
[0003] The Pitzer model: Since 1973, Pitzer has published a series of papers proposing the Pitzer theory of electrolyte solutions. Starting from the radial distribution function of electrolyte aqueous solutions, and using the Virial expansion, Pitzer proposed an expression for the total excess free energy of the solution. Considering the long-range interaction energy and short-range repulsion energy between ions in the solution, he derived formulas for calculating the osmotic coefficient and activity coefficient. Through extensive experimental data, he regressed the parameters of more than 280 single electrolyte aqueous solutions and some mixed electrolyte aqueous solutions. The calculated values obtained using the fitted parameters showed good agreement with the experimental values, with a concentration range of up to 6 mol / kgw. He also provided the concentration range of the original thermodynamic data and the standard deviation of the fitted parameters. The Pitzer model has been widely adopted in engineering, such as calculating the activity coefficient of seawater, the solubility of multi-component water-salt systems, predicting the trend of brine evaporation, and the material reaction ratio in chemical processes. It has become one of the most widely used electrolyte solution theories in the world.
[0004] In various applications of Phreeqc software, it is often necessary to manually input different values for each parameter and run the model one by one. After each model is completed, the output result file must be opened to extract the required numerical simulation result data. As can be seen, the above processing method involves a lot of repetitive work, and human error may occur each time the results are extracted manually. It is computationally inefficient, error-prone, and difficult to check for errors after they occur. Summary of the Invention
[0005] The purpose of this invention is to provide a batch simulation method for the evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine based on IPhreeqcCOM. This method solves the problems of existing Phreeqc software being unable to automatically calculate numerical models based on different input parameter values in batches, as well as the low efficiency and error-proneness of batch extraction of model output results.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a batch simulation method for the evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine based on IPhreeqCOM, comprising the following steps: Step 1: Build an initial model based on the Phreeqc graphical user interface (GUI) and automatically generate an input file attached to the initial model. The input file is a collection of all input parameters. When the parameters are modified in the Phreeqc GUI, the corresponding parameter values in the input file will automatically change synchronously. Conversely, the parameters in the GUI will also automatically change synchronously as the parameter values in the input file are modified. Step 2: Modify the initial model's execution result and select a specified output result for the initial model; Step 3: Set up the database file "pitzer.dat" by copying it to the same directory as the initial model, so as to provide parameters when calling the initial model for calculation through external programs; Step 4: Read the batch calculation parameter values of the initial model and set the parameter values required for batch simulation of each parameter; Step 5: Read the input file of the initial model, locate the parameter line, and change the original fixed parameter values to variables so that the parameters can be rewritten when traversing the model; Step 6: Iterate through and run the numerical model with the required combined parameter values through the IPhreeqcCOM interface, and generate batch simulation results; Step 7: Perform batch extraction of output results: Create a new output result summary text file, and write the names of the parameters to be extracted as the first line of the text file; extract the required data columns from the output result file; during the process of running all models, extract the results of each batch simulation calculation and populate the newly created output result summary text file by appending them.
[0007] Preferably, the parameters that need to be input during the simulation in step four include Cl. - K + Mg 2+ Na + 、SO4 2- Concentration (mol / kgw) and solution density (g / cm³) 3 ).
[0008] Preferably, step four specifically includes: the input file is "BRC.pqi", the input file "BRC.pqi" of the initial model is read through the open() and readlines() functions, and the line number is located through line[]. After the parameter line is located, the original fixed parameter values are changed to variables {c_Cl}, {c_K}, {c_Mg}, {c_Na}, {c_S}, and {l} so that the parameters can be rewritten when traversing the model.
[0009] Preferably, the precipitated minerals in step one are all of simple composition, as shown in the table below: The remaining minerals can also be added as needed, and the remaining minerals are shown in the table below: Mineral Name (English) Mineral Name (in Chinese) Chemical formula Bloedite Sodium magnesium alum <![CDATA[Na2Mg(SO4)2:4H2O]]> Carnallite Carnallite <![CDATA[KMgCl3:6H2O]]> Glaserite Potassium sodium alum <![CDATA[NaK3(SO4)2]]> Kainite Potassium salt magnesium alum <![CDATA[KMgClSO4:3H2O]]> Leonite Potassium magnesium sulfate <![CDATA[K2Mg(SO4)2:4H2O]]> Misenite Potassium alum heptahydrate <![CDATA[K8H6(SO4)7]]> Pentahydrite Five Water Epsom Salt <![CDATA[MgSO4:5H2O]]> Schoenite Soft potassium magnesium alum <![CDATA[K2Mg(SO4)2:6H2O]]> A batch simulation system for the evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine based on IPhreeqcCOM includes: The initial model building module is used to build an initial model based on the Phreeqc graphical user interface (GUI) and automatically generate an input file attached to the initial model. The input file is a collection of all input parameters. When the parameters are modified in the Phreeqc GUI, the corresponding parameter values in the input file will automatically change synchronously. Conversely, the parameters in the GUI will also automatically change synchronously as the parameter values in the input file are modified. The output result modification module selects a specified output result for the initial model; The database file setting module copies the database file "pitzer.dat" to the same directory as the initial model, providing parameters for calculations when the initial model is called by an external program. The batch calculation parameter value reading module is used to read the parameter values required for batch simulation of each parameter that needs to be input during the simulation, according to user needs. The parameter rewriting module is used to read the input file of the initial model, locate the parameter line, and change the original fixed parameter values into variables so that the parameters can be rewritten when traversing the model. The batch simulation calculation execution module is used to call the program and iterate through the numerical model with the required combined parameter values. The batch output result extraction module is used to create a new summary text file of output results, write the names of the parameters to be extracted as the first line of the text file, and extract the required data columns from the output result file. The batch output extraction module automatically extracts each output result during the process of running all models and appends it to the newly created output result summary text file.
[0010] Preferably, the parameters that need to be input during simulation in the batch calculation parameter value determination module include Cl. - The concentrations c_Cl [mol / kgw] and K + Concentrations c_K [mol / kgw], Mg 2+ The concentrations of Mg [mol / kgw] and Na + Concentrations of Na [mol / kgw] and SO4 2- The concentration c_S [mol / kgw] and the solution density ρ [g / cm3].
[0011] Furthermore, the parameter rewriting module is specifically used to: read the input file of the initial model through the open() and readlines() functions, and locate the line number through line[]. After the parameter line is located, the original fixed parameter values are changed to variables {c_Cl}, {C_K}, {c_Mg}, {c_Na}, {c_S}, and {ρ} so that the parameters can be rewritten when traversing the model.
[0012] In summary, the present invention includes at least one of the following beneficial technical effects: When iterating through Pitzer models with different parameter combinations, the system automatically extracts the parameters to be analyzed from the model output files, greatly reducing the error rate of human operation and improving data analysis efficiency. Attached Figure Description
[0013] Figure 1 This is a schematic diagram of the method flow of the present invention; Figure 2 This is a graph showing the change in precipitated salt content of a single sample as water evaporates, according to an embodiment of the present invention. Figure 3 This is a schematic diagram of the output results of batch processing according to an embodiment of the present invention. Detailed Implementation
[0014] The following is in conjunction with the appendix Figure 1 -Attached Figure 3 The present invention will be further described in detail below.
[0015] This invention provides a batch simulation method for the evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine based on IPhreeqcCOM, comprising the following steps: (1) Constructing the initial model Based on user requirements, an initial model "BRC.pqi" is built using Phreeqc. To facilitate output result extraction, the initial model can be run once first. After creating and running "BRC.pqi", a subfolder is automatically generated in the same directory as the file. The subfolder contains one input information file ("BRC.pqi") and one output result file ("BRC.pqo").
[0016] (2) Modify the initial model run completion result. After each model run in the Phreeqc software, the default output result is "BRC.pqo". However, "BRC.pqo" contains a large amount of complete output content, which is not conducive to reading the output results. The Phreeqc software's "SELECTED_OUTPUT" can be used to select the output content to "selected_output.txt". In this batch calculation method, the output mainly includes "Totals" and "Equilibrium_phases".
[0017] (3) Configure the database file "pitzer.dat" Copy the database file "pitzer.dat" to the same directory as the initial model to provide parameters when the initial model is called for calculations by an external program.
[0018] (4) Read batch calculation parameter values Based on user requirements, this function reads the parameter values needed for batch simulation of each parameter (c_Cl, c_K, c_Mg, c_Na, c_S, ρ) required for the simulation. The PyCharm code is as follows: (5) Execution parameter rewriting The initial model's input file "BRC.pqi" is read using the `open()` and `readlines()` functions, and the line number is located using `line[]`. After locating the parameter lines, the original fixed parameter values are changed to variables {c_Cl}, {c_K}, {c_Mg}, {c_Na}, {c_S}, and {ρ} (ρ is not necessary; the Pitzer database can calculate ρ) so that the parameters can be rewritten when traversing the model.
[0019] In this embodiment, the file "BRC.pqi" is read using the readlines() function, and then the parameter lines are located using line[]. The fixed values c_Cl, c_K, c_Mg, c_Na, and c_S are changed to the variables "c_Cl", "c_K", "c_Mg", "c_Na", and "c_S" so that the parameters can be rewritten when traversing the model. With the initial model structure unchanged, the parameter line numbers in "BRC.pqi" will not change; in this case, they are lines 9, 10, 11, 12, and 13 respectively. However, the line index starts from 0, meaning that in this example, the positions of the original parameter values at lines[8], [9],
[10] ,
[11] , and
[12] are changed to variables. In PyCharm, the parameter rewriting function is implemented using modify_Input(), as shown in the following code: def modify_Input(): (6) Perform batch simulation calculations The numerical model with the required combined parameter values is run through the IPhreeqcCOM interface. The PyCharm code is as follows: (7) Perform batch extraction of output results During batch model calculations, each parameter combination produces a set of calculation results. Modifying parameters in the initial model, saving it as a new model, and then running it will consume a significant amount of computer storage and increase labor costs considerably during batch calculations. Modifying parameters within the same initial model can significantly reduce the computational and storage burden, but the simulation results will overwrite the previous simulation results. Therefore, after each model run, the results need to be extracted before the next calculation. The specific steps are as follows: Create a new output result summary text file, writing the names of the parameters to be extracted as the first line; extract the required data columns from the output result file; while iterating through all models, automatically extract the output results for each run and append them to the newly created output result summary text file.
[0020] This invention directly rewrites the model input file "BRC.pqi" by traversing functions, automatically batch-calculating Pitzer models with different parameter combinations, saving a significant amount of manpower and improving computational efficiency. When traversing Pitzer models with different parameter combinations, it automatically extracts the parameters to be analyzed from the model output file, greatly reducing the error rate of human operation and improving data analysis efficiency.
[0021] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A batch simulation method for the evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine based on IPhreeqcCOM, characterized in that, The following steps are involved: Step 1: Construct an initial model based on the Phreeqc graphical user interface (GUI) and generate the input file associated with the initial model; Step 2: Modify the initial model's execution result and select a specified output result for the initial model; Step 3: Set up the database file "pitzer.dat" by copying it to the same directory as the initial model, so as to provide parameters when calling the initial model for calculation through external programs; Step 4: Read the batch calculation parameter values of the initial model and set the parameter values required for batch simulation of each parameter; Step 5: Read the input file of the initial model, locate the parameter line, and change the original fixed parameter values to variables so that the parameters can be rewritten when traversing the model; Step 6: Iterate through and run the numerical model with the required combined parameter values through the IPhreeqcCOM interface, and generate batch simulation results; Step 7: Perform batch extraction of output results: Create a new output result summary text file, and write the names of the parameters to be extracted as the first line of the text file; extract the required data columns from the output result file; during the process of running all models, extract the results of each batch simulation calculation and populate the newly created output result summary text file by appending them.
2. The batch simulation method for evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine based on IPhreeqcCOM according to claim 1, characterized in that, The input file is used to represent the set of all input parameters. When the parameters are modified in the Phreeqc graphical user interface (GUI), the corresponding parameter values in the input file will automatically change synchronously. Conversely, the parameters in the GUI will also automatically change synchronously as the parameter values in the input file are modified.
3. The batch simulation method for evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine based on IPhreeqcCOM according to claim 1, characterized in that, The parameters that need to be input during the simulation in step four include Cl. - K + Mg 2+ Na + and SO4 2- Concentration, and solution density ρ.
4. The batch simulation method for evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine based on IPhreeqcCOM according to claim 1, characterized in that, Step five specifically includes: the input file is "BRC.pqi", the initial model input file "BRC.pqi" is read by the open() and readlines() functions, and the line number is located by line[]. After the parameter line is located, the original fixed parameter values are changed to variables {c_Cl}, {c_K}, {c_Mg}, {c_Na}, {c_S}, and {ρ} so that the parameters can be rewritten when traversing the model.
5. A batch simulation system for the evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine based on IPhreeqcCOM, and a batch simulation method for the evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine based on IPhreeqcCOM according to any one of claims 1-4, characterized in that, include: The initial model building module is used to build an initial model based on the Phreeqc graphical user interface (GUI) and generate an input file attached to the initial model. The input file is used to represent a set of input parameters. When the parameters are modified in the Phreeqc GUI, the corresponding parameter values in the input file will automatically change synchronously. Conversely, the parameters in the GUI will also automatically change synchronously as the parameter values in the input file are modified. The output result modification module selects a specified output result for the initial model; The database file setting module copies the database file "pitzer.dat" to the same directory as the initial model, providing parameters for calculations when the initial model is called by an external program. The batch calculation parameter value reading module is used to read the parameter values required for batch simulation of each parameter that needs to be input during the simulation, according to user needs. The parameter rewriting module is used to read the input file of the initial model, locate the parameter line, and change the original fixed parameter values into variables so that the parameters can be rewritten when traversing the model. The batch simulation calculation execution module is used to call the program and iterate through the numerical model with the required combined parameter values. The batch output result extraction module is used to create a new summary text file of output results, write the names of the parameters to be extracted as the first line of the text file, and extract the required data columns from the output result file. During the process of iterating through all models, the output results are automatically extracted each time and appended to the newly created summary text file of output results.
6. The batch simulation method for evaporation and concentration of Na-K-Ca-Cl-SO4 pentagonal brine based on IPhreeqcCOM according to claim 1, characterized in that, The parameter rewriting module is specifically used to: read the input file of the initial model through the open() and readlines() functions, and locate the line number through line[]. After the parameter line is located, the original fixed parameter values are changed to variables {c_Cl}, {C_K}, {c_Mg}, {c_Na}, {c_S}, and {ρ} so that the parameters can be rewritten when traversing the model.