Skip to content
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

Fix inexact slope solver pH from TA #9

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

briochemc
Copy link

This PR is a follow-up from CO2SYS-MATLAB PR #7. It computes the exact slope used in the Newton solver for determining pH from TA.

This PR also includes some extra script called compare_against_master for comparing between versions of CO2-System-Extd. It is similar to compare_versions except it only runs the CO2-System-Extd version, with the difference that it uses git to switch between the v3.2.0 tag and the current commit. (Figuring out how to run git inside a script and have it actually take effect took me a while to figure out, hence the numerous commits, which can all be squashed into a single merge commit of course.) Here's the output I get (max relative change since v3.2.0 seems to be of order 1e-7):

>> compare_against_master
Running CO2SYS v3.2.0
Note: switching to 'v3.2.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 40e49f9 Merge pull request #8 from jonathansharp/Development
Elapsed time is 0.335852 seconds.
Running CO2SYS current commit/head
Previous HEAD position was 40e49f9 Merge pull request #8 from jonathansharp/Development
Switched to branch 'master'
Your branch is ahead of 'fork/master' by 8 commits.
  (use "git push" to publish your local commits)
Elapsed time is 0.393273 seconds.


Relative change vs v3.2.0:
            Variable     Mean rel. change      Min rel. change      Max rel. change         # of samples
                TAlk                    0                    0                    0                 4320
                TCO2                    0                    0                    0                 4320
                pHin                    0                    0                    0                 4320
              pCO2in                    0                    0                    0                 4320
              fCO2in                    0                    0                    0                 4320
              HCO3in                    0                    0                    0                 4320
               CO3in                    0                    0                    0                 4320
               CO2in                    0                    0                    0                 4320
              BAlkin                    0                    0                    0                 4320
                OHin                    0                    0                    0                 4320
              PAlkin                    0                    0                    0                 4320
             SiAlkin                    0                    0                    0                 4320
            AmmAlkin                  NaN                  NaN                  NaN                 4320
             HSAlkin                  NaN                  NaN                  NaN                 4320
             Hfreein                    0                    0                    0                 4320
                RFin              2.5e-07              2.5e-07              2.5e-07                 4320
           OmegaCAin                    0                    0                    0                 4320
           OmegaARin                    0                    0                    0                 4320
              xCO2in                    0                    0                    0                 4320
               SIRin                    0                    0                    0                 4320
               pHout              4.1e-10              4.1e-10              4.1e-10                 4320
             pCO2out              8.6e-09              8.6e-09              8.6e-09                 4320
             fCO2out              8.6e-09              8.6e-09              8.6e-09                 4320
             HCO3out              8.6e-10              8.6e-10              8.6e-10                 4320
              CO3out              6.9e-09              6.9e-09              6.9e-09                 4320
              CO2out              8.6e-09              8.6e-09              8.6e-09                 4320
             BAlkout              5.7e-09              5.7e-09              5.7e-09                 4320
               OHout              7.8e-09              7.8e-09              7.8e-09                 4320
             PAlkout              8.9e-10              8.9e-10              8.9e-10                 4320
            SiAlkout              7.4e-09              7.4e-09              7.4e-09                 4320
           AmmAlkout                  NaN                  NaN                  NaN                 4320
            HSAlkout                  NaN                  NaN                  NaN                 4320
            Hfreeout              7.8e-09              7.8e-09              7.8e-09                 4320
               RFout              5.2e-08              5.2e-08              5.2e-08                 4320
          OmegaCAout              6.9e-09              6.9e-09              6.9e-09                 4320
          OmegaARout              6.9e-09              6.9e-09              6.9e-09                 4320
             xCO2out              8.6e-09              8.6e-09              8.6e-09                 4320
              SIRout              6.9e-09              6.9e-09              6.9e-09                 4320
           pHinTOTAL                    0                    0                    0                 4320
             pHinSWS                    0                    0                    0                 4320
            pHinFREE                    0                    0                    0                 4320
             pHinNBS                    0                    0                    0                 4320
          pHoutTOTAL              4.1e-10              4.1e-10              4.1e-10                 4320
            pHoutSWS              4.1e-10              4.1e-10              4.1e-10                 4320
           pHoutFREE              4.1e-10              4.1e-10              4.1e-10                 4320
            pHoutNBS                4e-10                4e-10                4e-10                 4320
              TEMPIN                    0                    0                    0                 4320
             TEMPOUT                    0                    0                    0                 4320
              PRESIN                    0                    0                    0                 4320
             PRESOUT                    0                    0                    0                 4320
            PAR1TYPE                    0                    0                    0                 4320
            PAR2TYPE                    0                    0                    0                 4320
       K1K2CONSTANTS                    0                    0                    0                 4320
        KSO4CONSTANT                    0                    0                    0                 4320
          KFCONSTANT                    0                    0                    0                 4320
               BORON                    0                    0                    0                 4320
           pHSCALEIN                    0                    0                    0                 4320
                 SAL                    0                    0                    0                 4320
                 PO4                    0                    0                    0                 4320
                  SI                    0                    0                    0                 4320
                 NH4                  NaN                  NaN                  NaN                 4320
                 H2S                  NaN                  NaN                  NaN                 4320
             K0input                    0                    0                    0                 4320
             K1input                    0                    0                    0                 4320
             K2input                    0                    0                    0                 4320
            pK1input                    0                    0                    0                 4320
            pK2input                    0                    0                    0                 4320
             KWinput                    0                    0                    0                 4320
             KBinput                    0                    0                    0                 4320
             KFinput                    0                    0                    0                 4320
             KSinput                    0                    0                    0                 4320
            KP1input                    0                    0                    0                 4320
            KP2input                    0                    0                    0                 4320
            KP3input                    0                    0                    0                 4320
            KSiinput                    0                    0                    0                 4320
           KNH4input                    0                    0                    0                 4320
           KH2Sinput                    0                    0                    0                 4320
            K0output                    0                    0                    0                 4320
            K1output                    0                    0                    0                 4320
            K2output                    0                    0                    0                 4320
           pK1output                    0                    0                    0                 4320
           pK2output                    0                    0                    0                 4320
            KWoutput                    0                    0                    0                 4320
            KBoutput                    0                    0                    0                 4320
            KFoutput                    0                    0                    0                 4320
            KSoutput                    0                    0                    0                 4320
           KP1output                    0                    0                    0                 4320
           KP2output                    0                    0                    0                 4320
           KP3output                    0                    0                    0                 4320
           KSioutput                    0                    0                    0                 4320
          KNH4output                    0                    0                    0                 4320
          KH2Soutput                    0                    0                    0                 4320
                  TB                    0                    0                    0                 4320
                  TF                    0                    0                    0                 4320
                  TS                    0                    0                    0                 4320
                  TP                    0                    0                    0                 4320
                 TSi                    0                    0                    0                 4320
                TNH4                  NaN                  NaN                  NaN                 4320
                TH2S                  NaN                  NaN                  NaN                 4320

@briochemc
Copy link
Author

Gentle bump! :)

@jonathansharp
Copy link
Owner

Thanks for this, @briochemc! And sorry I just recently noticed it. I'm not a frequent or (more importantly) adept GitHub user, and I don't seem to get email notifications for new pull requests. Doing my best to change all those things.

This is great and particularly beneficial I'm sure for those in the modeling community who really don't want CO2SYS to ever hang when doing a lot of automated computations.

I've updated my main branch since this pull request was opened. Will merging this PR revert those commits? Do I need to push those new commits to your master branch before merging? Again, not a particularly adept user :) so let me know what to do! And sorry again for missing this.

@briochemc
Copy link
Author

Hi @jonathansharp,

No worries! I don't think merging would have reverted anything on your side (unless there is a conflict) but I just updated my branch (I pulled your changes into my branch), so you can now safely merge this if you are happy with it :)

Cheers!

@jonathansharp
Copy link
Owner

Perfect, thanks! I'm out on vacation this week but I'll review the changes when I return.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants