PhreeqcUsers Discussion Forum

Processes => Inverse modelling => Topic started by: ztwatson on April 21, 2014, 09:53:16 PM

Title: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on April 21, 2014, 09:53:16 PM
Hello,

I am currently trying to do some inverse modeling to determine fractional contributions of fluids to a final solution. However I cannot figure out a way to just mix the solutions and prevent the dissolution or precipitation of minerals. Can anyone help me with a command for this? It seems that PHREEQC accounts for increased NaCl concentrations by just dissolving halite.

Furthermore the solutions that I am working with are supersaturated with carbonate minerals but during their transport time I would like to prevent any precipitation of these minerals.

Any help is welcome!
TIA

-Zach
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: Tom on April 22, 2014, 06:01:56 PM
Hi Zach,

Someone else will likely be able to provide a more appropriate response but have you attempted the use of "pre" or "diss" on the phases line of INVERSE_MODELING ?

Or are you attempting to prevent both precipitation and dissolution of the same phase under different conditions?

An extract from an example (PHREEQC manual) is as follows:

INVERSE_MODELING
-phases
 Calcite     force  pre  -1.0   1
 Anhydrite   force  dis  13.5   2

The explanation is:

"dissolve or precipitate--The phase may be constrained only to enter the aqueous phase, " dissolve", or leave the aqueous phase, " precipitate". Any set of initial letters from these two words are sufficient to define a constraint"


See:

http://wwwbrr.cr.usgs.gov/projects/GWC_coupled/phreeqc/html/final-44.html#pgfId-254827

Apologies if I misunderstood your question.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on April 22, 2014, 08:14:26 PM
I am trying to do the inverse modeling based solely on the solutions. I dont want phreeqc to think it can dissolve a mineral to account for the elemental difference in solutions as there is no interaction with any minerals along the flow path. Its a relatively rapid mixing process. Furthermore I dont want anything to precipitate out to account for a change in solution. But its more important to prevent dissolution.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on April 24, 2014, 02:40:06 AM
You can enter just the solutions (-solution n1 n2 n3 n4 ...) with no entries for -phases. However, the phases are used by default to determine the elements for which mole balance equations are included. So you get no mole balance equations unless you use -balance to include the major elements (usually Ca, Mg, Na, (K), C, S, and Cl).

It still can be difficult to establish the mixing fraction. If you find no models, try upping the uncertainties a little (-uncertainty). Also include any stable istotope information that you have. 
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on April 24, 2014, 07:00:22 PM
Thanks dlparkhurst,

I ran the model as shown in the image. This worked but the uncertainties are pretty high. High enough to where I wonder if the output that I get is even reasonable or realistic.

I only received one solution for the modeling. Ideally this is what you would want. But I still am skeptical about the results.

Any criticisms about how my model is set up?
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on April 24, 2014, 07:50:46 PM
20 percent uncertainty is on the high side, on the other hand you are trying to match at least seven mole balances with essentially just one mixing fraction.

I am a little suspicious of your analyses that have identical pH and alkalinity for all three waters, and some missing data for the brine (Ca, Mg). Alkalinity should be a pretty stable number, but pH can be affected by CO2 degassing before sampling, depending on the water and the sampling procedure. I think you could reasonably add CO2(g) as a phase unless you are absolutely confident in your measuring procedure.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on April 24, 2014, 09:58:52 PM
Well part of my decision to unify the values is so the model actually runs. Changing alkalinity and pH makes it so the model produces no solutions.

Is it possible to remove pH and alkalinity from the solution?

Two of the fluids come from depth (~250 m) and the ending fluid is seen at the surface. Thus the pH and alkalinity are also a function of the pressure regime at depth. This is a study of a CO2 driven geyser, so the system is quite dynamic with respect to CO2, alkalinity and pH. While all of these things change and have some impact on the system the major ions can be considered tracers of the mix which occurs as the fluids migrate up the conduit and produce the eruption at the surface.

Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on April 25, 2014, 07:19:52 PM
You cannot really remove mole balance constraints with PHREEQC. Netpath does allow you to pick your constraints. You can always up the uncertainties of pH, Alkalinity, C to 1.0, but I think you are loosing some information. While pH and TDIC vary with loss of CO2, alkalinity does not, unless there are additional mineral reactions (calcite precipitation most likely). Including CO2(g) as a phase should, in theory account for gain and loss of CO2.  Bottom line is that it is probably difficult to make all the mole balances work out. Perhaps you should just calculate mixing fractions with individual elements, and then see if there is relative agreement.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on April 29, 2014, 05:54:47 PM
Can anyone explain what this error in the output means?

I did not receive any potential models.

Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on April 29, 2014, 09:46:10 PM
The post-mortem printout is sometimes useful and sometimes not. I think here it is not particularly informative, but looks like there is a problem with redox transfomations. However, I ran the file and got a model; so, I am not sure what the difference is between your run and mine. I may have a typo. I did remove aragonite from the list of phases. Adding more than one mineral with the same stoichiometry just generates more models.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on April 30, 2014, 04:29:30 PM
Thanks dlparkhurst.

I have a question about the balances for specific elements. Using 0.2 (20%) allows the model to put out a fair amount of potential mixes. Though I worry that this value is too high.

To make sure I understand what the 20% means, if I have 7 mmol of K then the model is allowed to add or subtract 1.4 mmol of K to the specific solution prior to mixing?
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on April 30, 2014, 11:18:35 PM
Correct. Note that it applies to each solution, so that each solution could change the potassium concentration by up to +/1 20%. The optimization method tries to minimize the sum of the relative changes.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on May 01, 2014, 03:49:19 PM
I thought each column of balances refers to their respective position. So first column refers to solution 1, second to solution 2 etc. Balances is merely a way of addressing the uncertainty of a specific element in a specific solution.

And then the uncertainty applies to all elements in all solutions. If the balance values are greater than the uncertainty value, then they override the uncertainty.

correct?

Also, when I click on balances in the toolbar a comment in the bottom comes up stating

"Any element not present in the phases to be used"

What does this mean?
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on May 01, 2014, 06:54:08 PM
I thought each column of balances refers to their respective position. So first column refers to solution 1, second to solution 2 etc. Balances is merely a way of addressing the uncertainty of a specific element in a specific solution.

Q. And then the uncertainty applies to all elements in all solutions. If the balance values are greater than the uncertainty value, then they override the uncertainty.

A. -balance allows an uncertainty to be entered for each solution. If fewer uncertainties are entered than the number of solutions, the final uncertainty is applied to the remaining solutions. -balance overrides the uncertainty defined by -uncertainty, whether it is larger or smaller.

Q. Also, when I click on balances in the toolbar a comment in the bottom comes up stating

"Any element not present in the phases to be used"

What does this mean?

A. By default, any element in any mineral is included in the set of mole-balance equations. (There is no way to remove any of these mole-balance equations except by removing all minerals that contain an element.) -balances can be used to include elements that are not present in any of the minerals. For example, if you do not want to include a Cl-containing mineral, but you want to include a Cl mole-balance equation as a conservative constituent, then you can add the Cl mole-balance equation with -balance.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on May 05, 2014, 08:47:28 PM
I am trying to add strontium to my model as another element. However whenever I type in Sr (which is what I assume its abbreviation would be) it becomes italicized. Is Sr and abbreviation for something else?

How do I put strontium into Phreeqc?
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on May 05, 2014, 11:30:53 PM
What interface are you using? NP++ or Phreeqc for Windows?

The colorization/italicisor is interpreting Sr as the Basic function SR (saturation ratio). You should be able to use Sr as the strontium element. Hopefully, the italics is just in the interface and does not affect the calculation.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on May 09, 2014, 06:47:56 PM
I'm using Phreeqc for Windows.

The addition of Strontium works, not sure why its italicized but it works.

I am having issues adding 18O in the model. I am just trying to add the recorded values for each solution
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on May 09, 2014, 07:24:37 PM
You add one of the available isotopes (13C, 34S, 2H, 18O, 87Sr) with -isotope in SOLUTION

SOLUTION
-isotope 18O  -1   # permil

and you add -isotopes in INVERSE_MODELING to include a mole balance on the isotope.

INVERSE_MODELING
-isotopes
         18O  0.1 # permil uncertainty

See example 18 in the version 3 manual for an example with 13C and 34S.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on May 09, 2014, 08:55:50 PM
Can you explain what may be wrong with my input, and why I am getting this error?

I have attached an image of my input
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on May 12, 2014, 07:12:43 PM
It is actually a couple of bugs.

For now, you can either define an uncertainty for 18O for each solution in the -isotopes of INVERSE_MODELING, that is, include two values:

INVERSE_MODELING
-isotopes
   -18O  0.1 0.1

or define the uncertainty for each solution in SOLUTION

SOLUTION
-i 18O -10 0.1

If you define uncertainties in both places, the INVERSE_MODELING definition will take precedence.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on May 12, 2014, 10:42:22 PM
OK. I got it working. Thanks.

I have a model with 3 solutions. The 18O ranges from 2.2 to -14.7

The final solution which is -15. All uncertainties for the 18O are set at 0.1

The model runs fine and gives me a reasonable output but I am curious as to how the model accounts for 18O when the final solution lies outside of a mix between solutions. The final solution is more negative than any of the inputs. Nothing other than mixing and some dissolution and precipitation occurs. This model does include the "CL1: Roundoff errors in optimization. Try using -multiple_precision in INVERSE_MODELING" in the output. I assume this refers to the discrepancy I am describing (it does not show up where the final solution lies within the range of initial solutions)
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on May 13, 2014, 06:18:30 PM
I am not sure how you could account for an 18O outside the range. You need to look at the model and the section above where it shows adjustments to the analytical data. In general the right-most column (Input+Delta) times the mixing fractions for the initial solution(s) plus the mole transfers of the model (first numerical column of "Phase mole transfers") will equal the moles of the final solution (Input+Delta).

If the model gets printed, I think these relations will hold. I don't think the warnings should apply to a printed model, but I would have to see the results to be sure (an ascii file is handier than the jpgs).
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on May 13, 2014, 07:49:53 PM
Right. Well I'll attach this file and you can take a look if you have a chance.

When I look at the output it seems that the isotopes are not included where you see the input and delta section.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on May 13, 2014, 11:51:04 PM
Sorry, the results are not right. The clue is the large Sum of residuals, and the large deltas (> 1e3). The numerical method obviously failed. If you include 18O in INVERSE_MODELING, some of the mixing fractions are negative, that is the way it got a mole balance on 18O.

Attached is a more reasonable model by upping 18O uncertainty and lowering the tolerance. I am not happy about lowering the tolerance; it is not an obvious thing to try, but in this case, it helps. The sum of residuals is ~8, which you can interpret as approximately eight data items have been changed by their maximum uncertainty.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on May 16, 2014, 03:16:27 PM
Thanks dlparkhurst. All of your help is greatly appreciated.

I am curious though why my model gets single digit (5-9) sum of residuals when run but the isotopes don't show up in the output (running the model I attached in my previous post).

Also, what does lowering the tolerance do for the model. I've read about it in the inverse modeling section but I am still a bit unclear as to what it does.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on May 16, 2014, 07:31:59 PM
No isotopes show up because you have not added isotope balances in INVERSE_MODELING with the -isotopes option.

As for tolerance, I am probably repeating the manual, but inverse modeling uses a simplex-like algorithm to solve an optimization problem (mole balance equations, constraints on deltas, dissolution/precipitation constraints, and others). The algorithm does something similar to a Gaussian elimination, pivoting on row/column elements. I suspect the result of -tolerance is to treat row/column elements less than the tolerance value as zeros, an will not pivot on those values.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on October 21, 2014, 08:45:31 PM
I am curious about the dissolution and precipitation of minerals.

My final solution has a calcite SI of 1.00 while the other samples are below this value. In my result it says that it dissolved calcite. Does the model dissolve calcite to reach the desired saturation?
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on October 22, 2014, 05:59:09 AM
Inverse modeling is strictly mole balance. The calculation does not take into account the saturation indices of minerals. If SI calcite is consistently above 0.0, it does not make thermodynamic sense that calcite is dissolving. I would look for other models if possible. SI(calcite) > 0 can be caused by silicate mineral dissolution, but most commonly by CO2 degassing before measuring the pH. So it could be a sampling problem. For most aquifer systems calcite is expected to be near equilibrium when calcite is present. I would not expect to see persistent supersaturation in an aquifer. Streams are another case, with diurnal cycles of respiration, temperature change, and CO2 degassing.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on October 22, 2014, 04:49:04 PM
So in my phase mole transfers where calcite dissolves and gypsum precipitates this refers to mole transfers from the final (desired) solution?

Or alternatively, as the fluid mix these minerals dissolve or precipitate out of solution to result in the final solution?

I provided an image of one of the results.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on October 23, 2014, 08:48:18 PM
The transfers are the net reaction needed to start with the initial solution composition (or a mixture of initial solutions) and end up with the final solution composition. Essentially,

solution1 + reactants = solution2 + products

However, the solution compositions may be adjusted within the uncertainty limits that you provide. Look at the deltas in the output. It is true that the column of concentrations plus deltas combined with the mineral mole transfers will provide exact balance for each element .
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on October 28, 2014, 05:13:34 PM
OK Thanks David.


Inverse modeling is strictly mole balance. The calculation does not take into account the saturation indices of minerals. If SI calcite is consistently above 0.0, it does not make thermodynamic sense that calcite is dissolving. I would look for other models if possible. SI(calcite) > 0 can be caused by silicate mineral dissolution, but most commonly by CO2 degassing before measuring the pH. So it could be a sampling problem. For most aquifer systems calcite is expected to be near equilibrium when calcite is present. I would not expect to see persistent supersaturation in an aquifer. Streams are another case, with diurnal cycles of respiration, temperature change, and CO2 degassing.

To help give you a better idea of the system I should add some information.

The samples are from a CO2-driven geyser. Thus, the concentration of CO2 is quite high. The 2 aquifers supplying the geyser have depths of 30-150 m and 200-320 m. Artesian conditions drive these fluids to the surface. As these fluids migrate upwards there is a lot of evolution with respect to the carbonate system and redox conditions (reduced to oxidized). Because the samples from the geyser evolve like they do, we have to consider what data we have as a snap shot of the system. Values like dissolved CO2, HCO3 and pH will change rapidly during sampling, the data that we have can be trusted, but we have to take into account that many things change from depth to the surface. The range of values in the aquifers are shown below.

pH - 5.1 - 5.4
HCO3 - 2 - 3 g/L
CO2 - 22 - 40 g/l

As of now my model doesn't include CO2 as a species in the input. The actual HCO3 concentration at depth is used. The surface pH is used, not the at depth pH value. This model produces one mixing model which degasses CO2 (this model and the output are attached). This is what I am lookin for but I know some improvements could be made. Any further criticisms or ideas on making the model more robust would be appreciated. Especially with respect to the carbonate and redox conditions.


Thanks.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on November 02, 2014, 03:11:46 AM
Looks like solution 2 is the primary water source.  However, the final solution (4) is more concentrated in most elements. If you use solution uncertainties close to the charge balance errors (0.05, 0.05, 0.1, 0.15), the preferred model is dissolving (!) calcite and degassing CO2. Maybe you could make a case, but seems unlikely to dissolve calcite. If you add the brine, it has relatively little Ca, so you still end up needing Ca. Perhaps there is some loss of water, but I did not find anything better including H2O(g) as a reactant. On the other hand, you are accounting for many 7 elements with one or two mole transfers. 

You can crank up the uncertainties, and you can probably find a model that has little change from solution 2 to solution 4. Perhaps it is really the case that you don't know all the end members that well, so attributing larger uncertainties is appropriate.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on November 05, 2014, 05:00:37 PM
Well Solution 3 is the majority. But both 2 and 3 contribute a lot. Did you run the model as well?

What do you mean be accounting for 7 elements with one or two mole transfers? Are you referencing the phases (hematite and CO2(g))? As far as I understand I should be able to account for all elements without any minerals as part of the mixing, if sufficient quantities are there in the solutions with the proper ratios.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on November 06, 2014, 03:15:02 AM
I was ignoring Fe, it's concentrations are fairly small. I was considering CO2 and calcite. Of course there are additional degrees of freedom with the number of solutions that mix.

Inverse modeling is more difficult than it appears to be. You have measured solutions and the have to have evolved from some set of waters. It seems reasonable the CO2 and perhaps water are released as pressure decreases, and they would be the primary mineral/gas transfers, perhaps with some calcite formation. But you may not have exactly endmember waters that form your final solution, so there is only so much that you can do. With uncertainties in the range of 15 percent for the final water (which has a charge imbalance over 10%) you can find models.  The match is not perfect, and I would interpret that as not having the exact endmember waters. 
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on November 11, 2014, 05:17:27 PM
Thanks dlparkhurst.

Another question. I am trying to determine how much my isotopic values have changed during the modeling. I have attached an image of my output and how the desired solution has been altered. The isotopes show up as 2H(0) and 2H(1), 18O(-2) and 18O(0). As you can see some of these values have been altered during the process. How do I know if my isotopes values have been altered as some of them are unaltered where some are altered?

Additionally, I am using a file you provided and under the constraints of the model the isotopes are 2H 2 2 2 2 for the 4 solutions. Can you explain what this means? Is this the uncertainty? I've provided an image of the input as well for you to see what I am referencing.

Thanks,
Zach
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on November 11, 2014, 06:06:59 PM
You see the changes to the isotopes in the delta values for each solution. You show solution 4, where 2H(1) and 18O(-2)--the water isotopes--have been modified for this model. They will vary from model to model. However, the deltas are constrained to be less than the specified uncertainties. The 2H 2 2 2 2 assigns 2 permil uncertainty (+/-) to each solution. It is also possible to assign uncertainties in the SOLUTION definition. Default uncertainties are applied if not defined in either of these two places.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on January 22, 2015, 07:45:47 PM
Hey David,

I've been having more success with the development of this model however I am not sure why my solution fractions are not adding up to 100%

for example, I have a model that supplies 0.001061, 0.647 and 0.3338 to the final solution from endmembers 1-3, respectively. This adds up to 0.981861. The model does exsolve 0.4767 mol of CO2 and dissolves 0.004126 mol of CaCO3.

Does the exsolution of CO2 somehow account for the loss of water? If I am producing CO2 through H+ + HCO3- > H2O + CO2 is this what is happening?
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on January 22, 2015, 09:14:02 PM
You are generating some water from the mineral reactions. The most obvious would be if you dissolved gypsum (CaSO4:2H2O), but other reactions like the one you mention could produce or consume water.

A little bit of water is still a lot of reactions (in your case, ~2 percent of 55.5 moles is 1 mol of water from reactions). That could be reasonable in brines, but probably not for dilute waters.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on January 22, 2015, 10:19:47 PM
So no water is generated from the production of CO2(g)? The amount of gypsum precipitated or dissolved is usually small (0.1 to 1 mmol/L). I don't know how I could be losing water other than the production of CO2(g). I began to model with the pH measured in the aquifers (5.0-5.3) which evolve into a fluid at a pH of ~6.5. This drives the CO2 exsolution process.

My sum of residuals and deltas are always in the 0.5 to 25 (2.5e+01) range. This is reasonable right? I've been trying to only consider models with small residuals and delta uncertainties.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on January 22, 2015, 10:52:52 PM
Sorry, did not mean to rule out CO2(g). I think CO2 gain or loss would affect the water mass balance. You still need a large mole transfer (0.5 mol?) to account for a mixing fraction of 0.98.

Sums of residuals or deltas of 25 are pretty large. I look at it like this; you have manipulated 25 deltas to their maximum extent. However, you should still be constrained by the uncertainty limits, so that no delta exceeded its limit.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on January 23, 2015, 12:05:56 AM
I guess I don't understand how this could occur during the model. The deltas and residuals are a bit high but I think acceptable for the large number of inputs. Should the missing moles from the output match those lost during a reaction? (Ie CO2 degassing or gypsum precipitation). These models are doing basically everything is like them to so it's a bit disheartening to have this is problem.

What else could cause the missing moles?
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on January 23, 2015, 09:42:48 PM
I don't look at it as missing moles; it is completely accounting for the total H and O in your solutions.  Your model exsolves ~0.5 mol CO2(g). It may depend on which database you use and what your initial solution composition is. With phreeqc.dat, dissolved CO2 is represented as CO2, whereas minteq.dat uses H2CO3.

Let's say your initial solution had 0.5 m CO3-2 and you are using phreeqc.dat. Then

CO3-2 + 2H+ = CO2(g) + H2O

The inverse modeling basically includes that H2O when it does its mole balances, so the H2O in the final water is composed of the H2O in the initial water (apparently ~0.98 kg) plus the water generated by the degassing (apparently ~0.02 kg).

If you had CO2(aq) in your initial water instead of CO3-2, I do not think you would see as large an effect with phreeqce.dat, but you would with minteq.dat:

CO2(aq) = CO2(g)

compared to

H2CO3(aq) = CO2(g) + H2O


If you do not want to consider the water generated by minerals, there is an option to ignore it (-mineral_water false).
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on January 26, 2015, 01:20:17 AM
Oh OK. So the degassing of CO2 is large enough to account for a small percentage of the total H2O mixture?

However, the degassing of CO2 (~0.5 mol) seems to only account for roughly 1% of the water present in the mixing. I still am unsure as to where the other 1% is coming from. The mineral reactions are too small in quantity to account for the other 1%. What other species transformations or the like could cause this? Does the mass of CO2 (of which some is lost during mixing) in the total mixture account for this in some way?

Thanks again for your help.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on January 26, 2015, 05:11:04 PM
I cannot tell you the exact water balance. There is a water uncertainty input in INVERSE_MODELING that could have an effect, but the default is zero. If you attach your input file, I will look, but I think you are worrying about a minor effect in this case. It is an issue when all of the water is generated by reactions.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on January 26, 2015, 05:35:34 PM
Here is a simple example using phreeqc.dat. The mixing fraction is 1.06 of solution 1, and the CO2 transfer is 0.327.

55.5*1.06 -1*0.327 = 55.5.

The program makes an assumption that the minerals dissolve to the master species for the elements. In this case, the master species for C is HCO3-. So the program assumes that the following reaction occurs:

CO2(g) + H2O = HCO3- + H+.

The assumption in this case is not correct because the CO2(g) ends up as CO2(aq). In this case, it would be better to ignore the mineral water by using     "-mineral_water     false".


SOLUTION 1
   pH 7 charge
END
SOLUTION 2
   pH   4 charge
   C   1   CO2(g) 1
END
knobs
# -debug_inverse

INVERSE_MODELING 1
    -solutions      1        2
    -uncertainty    0.05     0.05
    -phases
        CO2(g)
    -tolerance         1e-10
end
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on January 27, 2015, 05:37:36 PM
Thanks David. I some models that work out perfectly. For example, the total mixing fractions from the three endmembers is 0.991772. The mole transfer for CO2 is 0.4565 moles. If we then assume that 0.008228 kg of H2O are "missing" that equates to 0.456654 moles of H2O. So the degassing of CO2 accounts for the additional ~1% of H2O.

However, the models that include mineral water are a bit off (trying to turn off mineral water causes problems with the outputs). Or seem to be by my calculation. I've included one model, the first output mixing model (with the lowest residuals and uncertainties) is the one to look at. This is the Phreeqc for Windows.

Solution 1: 0.008716
Solution 2: 0.6523
Solution 3: 0.3295
Total: 0.990516
Mass of H2O from other source: 0.009484 kg
Moles of H2O from other source: 0.526362
Moles of CO2 degassed: 0.5257
Moles of H2O lost from gypsum precipitation: 0.0019986

So it should be (if I understand correctly): Moles of H2O 0.526362 = 0.5257 (CO2 generated H2O) - 0.0019986 (gypsum generated H2O)

But that does not work out exactly. Do I lose some of the accuracy due to the amount of significant digits present in the model? For example Solution 1 gets to an accuracy less than a milligram where as Solution 2 and 3 only get down to just below a gram. Could this be the cause for the small inaccuracies with moles totals?
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on January 27, 2015, 08:28:15 PM
I could not reproduce your numbers. The difference you are looking at is close to the precision with which the numbers are printed, and you are working with ~55.5 moles of water, so the difference (0.001) is about in the fifth significant figure.


More problematic is that the numerical method is not perfect. I assume it is caused by roundoff errors (there are close to 200 equations and inequalities in your problem), but some results from regular precision will differ from multiprecision results. Sometimes negative mixing fractions are calculated, which should not happen. Sometimes models are not found when they should be. I would worry about these cases more than the fifth decimal case of the water balance.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on January 27, 2015, 08:42:37 PM
OK Thanks David.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: dlparkhurst on January 27, 2015, 09:07:48 PM
I did a little more with your input file. I think part of the problem I was having was related to the tiny concentration of H(0) (1e-10) in your second solution. It caused numerical roundoff errors. i Added a large uncertainty for H(0) (2), and then results do not show errors for Cl1, and multiprecision matches regular precision.

Solution fractions:                   Minimum        Maximum
   Solution   1      8.709e-03      0.000e+00      0.000e+00
   Solution   2      6.528e-01      0.000e+00      0.000e+00
   Solution   3      3.295e-01      0.000e+00      0.000e+00
   Solution   4      1.000e+00      0.000e+00      0.000e+00

Phase mole transfers:                 Minimum        Maximum
         CO2(g)     -5.019e-01      0.000e+00      0.000e+00   CO2
         Gypsum     -1.008e-03      0.000e+00      0.000e+00   CaSO4:2H2O

Using greater precision the balance is as follows:

(1) Solution 1
8.70891E-03 x 5.55062E+01=4.83399E-01
(2) Solution 2
6.52826E-01 x 5.55062E+01 = 3.62359E+01
(3) Solution 3
3.29459E-01 x 5.55062E+01 = 1.82870E+01
(4) CO2 transfer
-5.01884E-01 x 1 = -5.01884E-01
(5 ) Gypsum transfer
-1.00780E-03 x 2 = -2.01560E-03

(1) + (2) + (3) - (4) + (5) = 5.55062E+01, which is the number of moles in 1 kilogram water, where water has a molecular wt of 18.016.




SOLUTION 1 Kharaka 1997 Brine
    temp      20
    pH        6.32
    pe        -1.69
    redox     pe
    units     ppm
    density   1
    Alkalinity 313
    Ca        1390
    Cl        150000
    Fe(2)     1
    K         4200
    Mg        1480
    Na        91700
    S(6)      5940
    Sr        25
    -isotope  18O     2.2 0.1
    -isotope  2H      -42 0.2
    -water    1 # kg
SOLUTION 2 Navajo 322 meters
    temp      18.3
    pH        5.13
    pe        -1.69
    redox     pe
    units     mmol/l
    density   1
    Alkalinity 63.74
    Ca        24.1
    Cl        84.9
    Fe(2)     0.0366
    K         7.2
    Mg        10.1
    Na        112.5
    S(6)      20.7
    Sr        0.135
    -isotope  18O     -14.7 0.1
    -isotope  2H      -114.6 0.2
    -water    1 # kg
SOLUTION 3 Entrada 98 meters
    temp      13.6
    pH        5.7
    pe        -1.69
    redox     pe
    units     mmol/l
    density   1
    Alkalinity 45
    Ca        27.6
    Cl        26.8
    Fe(2)     0.349
    K         3.3
    Mg        10.7
    Na        47.6
    S(6)      17.9
    Sr        0.186
    -isotope  18O     -13.09 0.1
    -isotope  2H      -110.1 0.2
    -water    1 # kg
SOLUTION 4 A Type Water
    temp      17.2
    pH        6.55
    pe        -1.69
    redox     pe
    units     mmol/l
    density   1
    Alkalinity 72.53
    Ca        22.94
    Cl        112.96
    Fe(2)     0.176
    K         7.83
    Mg        8.58
    Na        164.2
    S(6)      19.71
    Sr        0.1478
    -isotope  18O     -14.6 0.1
    -isotope  2H      -112.6 0.2
    -water    1 # kg
INVERSE_MODELING 1
    -solutions      1        2        3        4
    -uncertainty    0.1      0.1      0.1      0.2
    -phases
        CO2(g)           
        gypsum
        #calcite
        ##O2(g)
    -balances
        Fe          0.1      0.1      0.1      0.15
        Na          0.1      0.1      0.1      0.15
        Cl          0.1      0.1      0.1      0.15
        S(6)        0.1      0.1      0.1      0.15
        Ca          0.1      0.1      0.1      0.15
        Mg          0.1      0.1      0.1      0.15
        Alkalinity  0.1      0.1      0.1      0.15
        K           0.1      0.1      0.1      0.15
        C(4)        0.1      0.1      0.1      0.15
        Sr          0.1      0.1      0.1      0.15
        H(0)        2
    -isotopes
        2H          2        2        2        2
        18O         2        2        2        2
    -mineral_water     true
    #-multiple_precision     true
    #-mp_tolerance 1e-10
    #-censor_mp 1e-20
END

Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on January 27, 2015, 09:17:08 PM
Wow thanks David. That is really appreciated. Let me apply this to the other models and see if it removes all of the round off errors.
Title: Re: Preventing Mineral Dissolution/Precipitation
Post by: ztwatson on January 27, 2015, 10:52:16 PM
OK So i've applied this change to all of the models in addition to removing the -minimal command, -tolerance 1e-8 and -range. These were included a previous model you helped me with and removing them seemed to remove the erroneous models.

I now get 4-6 models per run all with relatively low sum of residuals and delta uncertainties in addition to no CL1 errors.

I really appreciate your help! I think I've finally gotten this model to where it could/should be.