oscarbranson / cbsyst

Python module for calculating carbon and boron solution chemistry.
MIT License
29 stars 17 forks source link

Alternative Constants? #14

Open oscarbranson opened 7 years ago

oscarbranson commented 7 years ago

Would other constants be useful?

At present, there are no options for different constants in cbsyst. Do people want/need choices?

Request constants in the comments below. If they get traction (i.e. lots of +1's), we'll implement them.

At present:

Constants as a function of Temperature and Salinity:

Pressure Corrections All pressure correction parameters from Millero (2007), with modifications:

Conserved Seawater Compositions: As a function of salinity:

tompc35 commented 7 years ago

It might be good to include all constants recommended as best practices in Dickson, Sabine and Christian (2007), even if there are more recent formulations. I see two differences:

1) TB, which Orr et al., 2015 tested in a sensitivity analysis and still recommend:

For now, users are also advised to avoid the new total boron-to- salinity ratio (Lee et al., 2010) and favor the “best-practices” ratio (Uppström, 1974), which was used to compute K1 and K2 from laboratory measurements (Mehrbach et al., 1973, Eq. 8).

2) KF - Dickson, Sabine and Christian (2007) recommend Perez and Fraga, 1987. However, they say that there is reasonable agreement with Dickson and Riley (1979), which is also what CO2SYS uses.

oscarbranson commented 7 years ago

Good thoughts @tompc35. Briefly:

  1. TB: You can also specify BT at S=35 manually, and it scales it with salinity. Falls back on Lee value IF not value is provided. Although in testing against GLODAPv2 I found the Lee value messed up Alkalinity, so I might switch the default back to Uppstrom.

  2. I originally used the KF described in the 2007 handbook, but found that it gave quite different results to Dickson and Riley, and didn't fit the GLODAPv2 data as well (possibly b/c typos?). Happy to revisit this.

markusritschel commented 5 years ago

Hi. One question, since I'm not super familiar with the backgrounds of this program and the respective algorithms but using it for my master thesis: Is there a way to specify the H2CO3 and HCO3- dissociation constants K1 and K2 (in Matlab: k1k2c=4="Mehrbach refit") and the HSO4- dissociation constants KSO4 (in Matlab: kso4c=1="Dickson")? Thanks a lot in advance!

oscarbranson commented 5 years ago

Hi @markusritschel, thanks for getting in touch!

The short answer to your specific question is 'no'. It's not currently possible to select alternative parameter sets as an option. I've only incorporated the ones listed above, as they're listed in the 'Best Practices' guide and seem to provide the best match to GLODAP bottle data (see project README).

The longer answer is that this is possible by manually specifying constants... although this is a little clunky at present. You just need to pass a full set of Ks to the 'Csys' function call. For example:

import cbsyst as cb

# calculate standard cbsyst Ks
Ks  = cb.calc_Ks(T=25, S=35, P=0, Mg=0.0528171, Ca=0.0102821, TS=cb.calc_TS(35), TF=cb.calc_TF(35))

# this returns a complete set of conditional Ks, modified for T, S and P.
# you can then substitute in the values you want:
Ks['K1'] = 99.3  
Ks['K2'] = 83.6 
# obviously a nonsense illustrative values!

# and then pass these Ks directly to the Csys function call:
cb.Csys(pHtot=8.1, DIC=2000, Ks=Ks)

This would become a bit more of a nuisance if you were calculating a lot of samples with varying T/S/P, as calculation of conditional Ks would not be handled automatically - i.e. you'd have to adjust them for T/S/P yourself. This would become particularly tricky when dealing with different input/output conditions.

It wouldn't be too much of a nuisance to incorporate other Ks... although the motivation for me to do it is low, as I work predominantly in seawater where the Ks I've already got work well! If I get enough interest in it, I'll look into it in the New Year.