Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/aed2_carbon.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1112,13 +1112,19 @@ SUBROUTINE Cal_pHfromTATC(TAx, TCx, pHx, K1F, K2F, TBF, KBF, KWF, KP1F, KP2F, KP

REAL :: H, Denom, CAlk, BAlk, OH, PhosTop, PhosBot, PAlk, SiAlk, &
& FREEtoTOT, Hfree, HSO4, HF, Residual, Slope, deltapH, pHTol, ln10

INTEGER :: count
INTEGER :: max_count

pHx = 8. !This is the first guess
pHTol = 0.0001 !tolerance for iterations end
ln10 = log(10.)
deltapH = pHTol + 1

count = 0
max_count = 100

DO WHILE (abs(deltapH) > pHTol)
DO WHILE (abs(deltapH) > pHTol .AND. count < max_count)
H = 10.**(-pHx)
Denom = (H*H + K1F*H + K1F*K2F)
CAlk = TCx*K1F*(H + 2.*K2F)/Denom
Expand All @@ -1143,6 +1149,7 @@ SUBROUTINE Cal_pHfromTATC(TAx, TCx, pHx, K1F, K2F, TBF, KBF, KWF, KP1F, KP2F, KP

pHx = pHx + deltapH !% Is on the same scale as K1 and K2 were calculated...

count = count + 1
END DO

END SUBROUTINE Cal_pHfromTATC
Expand Down