-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactors gas exchange carbon chemistry (+ adds some complexity) #186
Conversation
@bethcandish you could do some testing with the "best practice" parameters with this branch and see if it makes any difference, and if so change them here. |
…ed gas exchange docstring
@@ -151,12 +151,12 @@ resulting in the equilibrium constant: | |||
K_B = \frac{\ce{[B(OH)^-_4][H^+]}}{\ce{[B(OH)_3]}}. | |||
``` | |||
|
|||
Finally, taking the DIC and Alkalinity in micro equivalents (i.e. scaled by ``10^{-3}/\rho_o`` from mmol C/m``^3``) denoted by ``\bar{DIC}`` and ``\bar{Alk}``, the carbonate alkalinity is given by ``Alk_C = \bar{Alk} + [B(OH)^-_4] + [OH^-]``, and we define the boron content, ``B``, to be ``R_{B:S}S`` mol/kg. | |||
Finally, taking the DIC and Alkalinity in mol / kg and equivilants / kg (i.e. scaled by ``10^{-3}/\rho_o``) denoted by ``\bar{DIC}`` and ``\bar{Alk}``, the carbonate alkalinity is given by ``Alk_C = \bar{Alk} + [B(OH)^-_4] + [OH^-]``, and we define the boron content, ``B``, to be ``R_{B:S}S`` mol/kg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling should be equivalents, I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The edits look good to me. There are some comments in the carbon chemistry function that can be cleaned up. It was a great idea to put the carbon ehcmistry as a separate model type - this will be very useful!
# Centigrade to kelvin | ||
T += 273.15 | ||
|
||
# mili-equivilants / m³ to equivilants / kg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling should be "equivalents" throughout
@johnryantaylor do you think it would make sense to move carbon chemistry to be a property of Previously we had only used it in the CO2 flux but PISCES needs the calcite saturation for various things, and it makes sense to me that we separate it so it can be used for any model. It wouldn't cause many changes and will just be there to be called, e.g. by the boundary condition. |
Also, I will update the docs page at some point but the code now includes the pressure correction for the rate constants. I have added some tests which ensure we have the constants right (when using the "best practice" parameters) like how Kgen does, so I think the only difference between the functionality here and cbsyst on the carbon front is the Mg and Ca bits. |
Final comment for now, I'm pretty sure that this PR isn't breaking since |
…r things happen instead
TODO: check model_implemntation page when rendered update: it was broken |
validation/glodap_fit.jl
Outdated
silicate = data[n, Si_name] * density * 1e-3 | ||
phosphate = data[n, PO_name] * density * 1e-3 | ||
|
||
silicate = ifelse(silicate == -9999, 0, silicate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ifelse statement should probably go before the units of silicate and phosphate are converted? Same with P
This PR refactors the carbon chemistry calculations improving the clarity and supersedes #179.
It also moves both the carbon chemistry and gas exchange functions to
Models
since they are models, and separates them.This PR also implements the full carbon chemistry standards of the best practice (https://www.ncei.noaa.gov/access/ocean-carbon-acidification-data-system/oceans/Handbook_2007/Guide_all_in_one.pdf) so it can depend on Si and PO4, and approximated fluoride and sulfate. It also introduces proper (TEOS10 and polynomial approximations) density calculations.
Also, all of the equilibrium and pressure correction constants are also tested now.
I also introduce a function
calcite_saturation
that can computecalcite_concentration
and saturation for use in other models.This should also be faster since it removed a branching operation.
Finally, I changed the structure of
GasExchange
to make it more flexible (and correct, there was a bug in the computation of x(CO2) from fCO2).Also, closes #197, #200