! BioCGT auxiliaries file
! ***********************
! properties of auxiliaries:  (auxiliary values that are calculated)
! name=               variable name in the code
! description=        e.g. "absolute temperature [K]" default=""
! temp1= ... temp9=   for calculating a temporary value which appears in the formula. e.g. temp1=no3*no3 temp2=no3limit*no3limit formula=temp1/(temp1+temp2), default=""
! formula=            formula as it appears in the code
! calcAfterProcesses= 1=calculate this auxiliary after all process rates are known, default=0
! iterations=         how often this auxiliary variable is calculated in an iterative loop, default=0
! iterInit=           the initial value in the iterative loop, default="0.0"
! isOutput=           1=occurs as output in model results; 0=internal use only (default)
! isUsedElsewhere=    1=make the value of this auxiliary accessible from outside the biological model (e.g. use a "diagnostic tracer" in MOM4); 0=internal use only (default)
! isZGradient=        1=is a vertical gradient of a tracer, 0=is not (default). If 1, "formula" must be the name of the tracer, which must have vertLoc=WAT. isZGradient=1 requires vertLoc=WAT.
! isZIntegral=        1=is a vertical integral (of value times density) of a tracer or an auxiliary variable, 0=is not (default). If 1 "formula" must be the name of the tracer, which must have vertLoc=WAT. isZIntegral=1 requires vertLoc=SED.
! vertLoc=            WAT=z-dependent (default), SED=in the bottom cell only, SUR=in the surface cell only
! comment=            e.g. a literature reference, default=""
!
! All entries with the same value of calcAfterProcesses are calculated in given order.
! *************************************************************************************
name               = temp_k
formula            = cgt_temp + 273.15
iterations         = 1
description        = absolute temperature [K]
***********************
name               = ph_temp
formula            = 0.0-log(h3o)/log(10.0)
iterations         = 10
description        = temporary value assumed for pH [1]
vertLoc            = SUR
***********************
name               = k_water
formula            = exp( -13847.26 / temp_k + 148.96502 - 23.6521 * log(temp_k) + (118.67/temp_k - 5.977 + 1.0495 * log(temp_k)) * sqrt(cgt_sali) - 0.01615 * cgt_sali)
iterations         = 1
description        = self-ionization constant of Water [mol2/kg2]
comment            = Millero (1995) (in Dickson and Goyet (1994, Chapter 5, p.18))
vertLoc            = SUR
***********************
name               = k0_co2
formula            = exp(9345.17 / temp_k - 60.2409 + 23.3585 * (log(temp_k) - 4.605170186) + cgt_sali*(0.023517 - 0.00023656 * temp_k + 0.00000047036 *temp_k*temp_k))/101325.0
iterations         = 1
description        = Solubility of CO2 [mol/kg/Pa]
comment            = Weiss , 1974; Dickson, 2007: Guide to Best Practices for Ocean CO2 Measurements \\ value is given in [mol/kg/atm] in Dickson, 2007, (chapter 5 section 7 eqn 30), the factor \\101325.0 is to convert between atm and Pa.
vertLoc            = SUR
isOutput           = 1
***********************
name               = k1_co2
formula            = power(10.0,( -3633.86 / temp_k + 61.2172 - 9.6777 * log(temp_k) + 0.011555 * cgt_sali - 0.0001152 * cgt_sali * cgt_sali))
iterations         = 1
description        = Acid dissociation constant CO2 + 2 H2O <-> HCO3- + H3O+ [mol/kg]
comment            = k1_co2 = [HCO3 -] * ([H3O+] + [HSO4 -]) / ([CO2] + [H2CO3]) \\ Dickson 2007: Guide to Best Practices for Ocean CO2 Measurements
vertLoc            = SUR
isOutput           = 1
***********************
name               = k2_co2
formula            = power(10.0,( -471.78 / temp_k - 25.929 + 3.16967 * log(temp_k) + 0.01781 * cgt_sali - 0.0001122 * cgt_sali * cgt_sali))
iterations         = 1
description        = Acid dissociation constant HCO3- + H2O <-> [CO3 2-] + H3O+ [mol/kg]
comment            = Dickson 2007: Guide to Best Practices for Ocean CO2 Measurements
vertLoc            = SUR
isOutput           = 1
***********************
name               = k_boron
formula            = exp(( -8966.9 - 2890.53*sqrt(cgt_sali) - 77.942*cgt_sali + 1.728*cgt_sali*sqrt(cgt_sali) - 0.0996*cgt_sali*cgt_sali) / temp_k + 148.0248 + 137.1942*sqrt(cgt_sali) + 1.62142*cgt_sali + (-24.4344 - 25.085*sqrt(cgt_sali) - 0.2474*cgt_sali)*log(temp_k) + 0.053105*sqrt(cgt_sali)*temp_k )
iterations         = 1
description        = Acid dissociation constant of boric acid [mol/kg]
comment            = B(OH)3 + 2 H2O <-> [B(OH)4 -] + H3O+ \\ Dickson 2007: Guide to Best Practices for Ocean CO2 Measurements
vertLoc            = SUR
***********************
name               = k1_po4
formula            = exp( -4576.752/temp_k + 115.525 - 18.453*log(temp_k) + (0.69171 - 106.736/temp_k)*sqrt(cgt_sali) - (0.01844 + 0.65643/temp_k)*cgt_sali )
iterations         = 1
description        = Acid dissociation constant H3PO4 + H2O <-> [H2PO4 -] + H3O+ [mol/kg]
comment            = Dickson 2007: Guide to Best Practices for Ocean CO2 Measurements \\ (originally by Millero, 1995)
vertLoc            = SUR
***********************
name               = k2_po4
formula            = exp( -8814.715/temp_k + 172.0883 - 27.927*log(temp_k) + (1.35660 - 160.340/temp_k)*sqrt(cgt_sali) - (0.05778 - 0.37335/temp_k)*cgt_sali )
iterations         = 1
description        = Acid dissociation constant [H2PO4 -] + H2O+ <-> [HPO4 2-] + H3O+ [mol/kg]
comment            = Dickson 2007: Guide to Best Practices for Ocean CO2 Measurements \\ (originally by Millero, 1995)
vertLoc            = SUR
***********************
name               = k3_po4
formula            = exp( -3070.75/temp_k - 18.141 + (2.81197 + 17.27039/temp_k)*sqrt(cgt_sali) - (0.09984 + 44.99486/temp_k)*cgt_sali )
iterations         = 1
description        = Acid dissociation constant [HPO4 2-] + H2O <-> [PO4 3-] + H3O+ [mol/kg]
comment            = Dickson 2007: Guide to Best Practices for Ocean CO2 Measurements \\ (originally by Millero, 1995)
vertLoc            = SUR
***********************
name               = k1_h2s
formula            = exp( -3131.42/temp_k + 5.818 + 0.368*(power(max(0.0,cgt_sali),(1.0/3.0))))
iterations         = 1
description        = Acid dissociation constant H2S + H2O <-> HS- + H3O+ [mol/kg]
comment            = Goldhaber and Kaplan, 1975: Apparent dissociation constants of hydrogen sulfide in chloride \\solutions, Marine Chemistry 3 (2), 1975, pages 83104
vertLoc            = SUR
***********************
name               = boron_total
formula            = 0.000416 * cgt_sali/35.0
iterations         = 1
description        = total concentration of boron [mol/kg]
comment            = Moberg and Harding 1933: The Boron Content of Sea Water, Science
vertLoc            = SUR
***********************
name               = alk_boron
formula            = boron_total * k_boron / (k_boron + h3o)
iterations         = 10
description        = boron alkalinity [mol/kg]
comment            = concentration of [B(OH)4]-
vertLoc            = SUR
isOutput           = 1
***********************
name               = alk_h2s
formula            = t_h2s * k1_h2s / (k1_h2s + h3o)
iterations         = 10
description        = hydrogen sulfide alkalinity [mol/kg]
comment            = concentration of HS-
vertLoc            = SUR
isOutput           = 1
***********************
name               = alk_water
formula            = k_water / h3o - h3o
iterations         = 10
description        = water alkalinity [mol/kg]
comment            = concentration of OH- - H3O+
vertLoc            = SUR
isOutput           = 1
***********************
name               = alk_po4_denominator
formula            = (h3o*h3o*h3o + k1_po4*h3o*h3o + k1_po4*k2_po4*h3o + k1_po4*k2_po4*k3_po4)
iterations         = 10
description        = denominator in phosphate alkalinity formula [mol3/kg3]
vertLoc            = SUR
***********************
name               = alk_po4
formula            = t_po4*(k1_po4*k2_po4*h3o + 2.0*k1_po4*k2_po4*k3_po4 - h3o*h3o*h3o) / alk_po4_denominator
iterations         = 10
description        = phosphate alkalinity [mol/kg]
comment            = concentration of - [H3PO4] + [HPO4 2-] + 2*[PO4 3-]
vertLoc            = SUR
isOutput           = 1
***********************
name               = alk_co2_denominator
formula            = (h3o*h3o + k1_co2*h3o + k1_co2*k2_co2)
iterations         = 10
description        = denominator in carbonate alkalinity formula [mol2/kg2]
vertLoc            = SUR
***********************
name               = alk_co2
formula            = t_dic*k1_co2*(h3o+2*k2_co2)/alk_co2_denominator
iterations         = 10
description        = carbonate alkalinity [mol/kg]
comment            = concentration of [HCO3-] + 2*[CO3 2-]
vertLoc            = SUR
isOutput           = 1
***********************
name               = alk_residual
formula            = t_alk - alk_co2 - alk_po4 - alk_boron - alk_h2s - alk_water
iterations         = 10
description        = error in total alkalinity calculation at the assumed pH [mol/kg]
vertLoc            = SUR
isOutput           = 1
***********************
name               = dalkp_dh3o
formula            = t_po4*(0.0-k1_po4*h3o*h3o*h3o*h3o-4*k1_po4*k2_po4*h3o*h3o*h3o-(k1_po4*k1_po4*k2_po4+9*k1_po4*k2_po4*k3_po4)*h3o*h3o-4*k1_po4*k1_po4*k2_po4*k3_po4*h3o-k1_po4*k1_po4*k2_po4*k2_po4*k3_po4)/(alk_po4_denominator*alk_po4_denominator)
iterations         = 10
description        = derivative of phosphate alkalinity with respect to h3o [1]
vertLoc            = SUR
isOutput           = 1
***********************
name               = dalkc_dh3o
formula            = t_dic*(0.0-k1_co2*h3o*h3o-k1_co2*k1_co2*k2_co2-4*k1_co2*k2_co2*h3o)/(alk_co2_denominator*alk_co2_denominator)
iterations         = 10
description        = derivative of carbonate alkalinity with respect to h3o [1]
vertLoc            = SUR
isOutput           = 1
***********************
name               = dalkresidual_dpH
formula            = 0.0-log(10.0)*h3o*(alk_boron/(k_boron+h3o)+alk_h2s/(k1_h2s+h3o)+k_water/(h3o*h3o)+1-dalkp_dh3o-dalkc_dh3o)
iterations         = 10
description        = derivative of residual_alk with respect to pH [mol/kg]
comment            = h3o = exp(-pH*ln(10))\\so\\dh3o/dpH = -ln(10)*h3o\\dalk/dpH = dalk/dh3o * dh3o/dpH
vertLoc            = SUR
isOutput           = 1
***********************
name               = ph
temp1              = alk_residual/dalkresidual_dpH
formula            = ph_temp - temp1 + theta(abs(temp1) - 1)*0.5*temp1
iterations         = 10
description        = newly determined pH value [1]
comment            = Newton iteration to find the zero of residual_alk
vertLoc            = SUR
isOutput           = 1
***********************
name               = h3o
formula            = power(10.0,0.0-max(1.0,min(13.0,ph)))
iterations         = 10
iterInit           = 1.0e-8
description        = h3o ion concentration [mol/kg]
comment            = h3o = [H3O+] + [HSO4-] \\ this is used as a diagnostic tracer, it is calculated from alk_t and dic. If oxonium is \\created, it goes to the virtual tracer h3oplus and modifies alk_t. \\ Solution is limited to a reasonable range since otherwise in river estuaries solution \\takes very long to converge.\\The reason is that the change of alk_water with pH is very shallow at moderate pH and only \\steep at high pH, therefore, newton iteration may suggest a pH which is very very large. \\Limit to pH of 1 to 13.
vertLoc            = SUR
isOutput           = 1
isUsedElsewhere    = 1
***********************
name               = pco2
formula            = t_dic / k0_co2 / (1 + k1_co2/h3o + k1_co2*k2_co2/h3o/h3o)
description        = co2 partial pressure [Pa]
comment            = The concentration of dissolved co2 is calculated from dic and the pH (given as H3O+ \\concentration). This concentration is divided by the solubility to obtain the partial \\pressure.
vertLoc            = SUR
isOutput           = 1
***********************
name               = co2
formula            = pco2*k0_co2
description        = CO2 concentration in the surface layer [mol/kg]
vertLoc            = SUR
isOutput           = 1
***********************
name               = schmidtnumber_co2
formula            = 2068.9 + cgt_temp*((-118.63) + cgt_temp*(2.9311 + cgt_temp*(-0.027)))
description        = Schmidt number for CO2 surface flux [1]
vertLoc            = SUR
***********************
name               = frac_denit_sed
formula            = (1-theta(cgt_bottomdepth-6.8))*0.85 + theta(cgt_bottomdepth-6.8)*(1-theta(cgt_bottomdepth-9.8))*(0.85-(0.1/3.0)*(cgt_bottomdepth-6.8)) + theta(cgt_bottomdepth-9.8)*(1-theta(cgt_bottomdepth-92.7))*0.75 + theta(cgt_bottomdepth-92.7)*(1-theta(cgt_bottomdepth-167.5))*(0.75-(0.15/75.0)*(cgt_bottomdepth-92.7)) + theta(cgt_bottomdepth-167.5)*0.6
description        = fraction of ammonium that is immediately nitrified and denitrified after remineralization in oxic sediments
vertLoc            = SED
***********************
name               = o2_sat
formula            = (10.18e0+((5.306e-3-4.8725e-5*cgt_temp)*cgt_temp-0.2785e0)*cgt_temp+cgt_sali*((2.2258e-3+(4.39e-7*cgt_temp-4.645e-5)*cgt_temp)*cgt_temp-6.33e-2))*44.66e0*1e-6
description        = oxygen saturation concentration [mol/kg]
comment            = derived from \\www.helcom.fi/Monas/CombineManual2/PartB/AnnexB-\\8Appendix3.pdf\\now found under\\http://www.helcom.fi/groups/monas/CombineManual/AnnexesB/en_\\GB/annex8app3/\\ 1[ml/l] = 44.66e-6 [mmol/m], max error < +/- 0.15 for t=0\\-36C, s=0-36psu; 1e-6 converts [mmol/m3] to [mol/kg]
***********************
name               = solubility_o2
formula            = o2_sat*4.71265e-5
description        = solubility of oxygen [mol/kg/Pa]
comment            = o2_sat gives concentration at pressure of 1 atm = 101325 Pa\\We assume an atmospheric oxygen content of 0.20942\\=> partial pressure of O2 was 21219.4815 Pa\\its inverse is 4.71265e-5 Pa-1
vertLoc            = SUR
***********************
name               = schmidtnumber_o2
formula            = 1929.7 + cgt_temp*((-117.46) + cgt_temp*(3.116 + cgt_temp*(-0.0306)))
description        = Schmidt number for oxygen surface flux [1]
vertLoc            = SUR
***********************
name               = n2_sat
temp1              = log((298.15-cgt_temp)/(273.15+cgt_temp))
temp2              = temp1*temp1
temp3              = temp2*temp1
formula            = 1e-6*exp(6.42931 + 2.92704*temp1 + 4.32531*temp2 + 4.69149*temp3 + cgt_sali*(0.0 -7.44129e-3 - 8.02566e-3*temp1 - 1.46775e-2*temp2))
description        = dissolved molecular nitrogen saturation concentration [mol/kg]
comment            = Hamme, R.C., Emerson, S.R., 2004. The solubility of neon, nitrogen and argon in distilled \\water and seawater. Deep Sea Res I Oceanogr Res Pap. 51 (11), 15171528.
***********************
name               = solubility_n2
formula            = n2_sat * 1.263925e-5
description        = solubility of molecular nitrogen [mol/kg/Pa]
comment            = n2sat gives concentration at pressure of 1 atm = 101325 Pa\\We assume an atmospheric nitrogen content of 0.78084\\=> partial pressure of N2 was 79.118,613 Pa\\its inverse is 1.263925e-5 Pa-1
***********************
name               = schmidtnumber_n2
formula            = 2206.1 + cgt_temp*((-144.86) + cgt_temp*(4.5413 + cgt_temp*(-0.056988)))
description        = Schmidt number for oxygen surface flux [1]
comment            = source unclear
vertLoc            = SUR
***********************
name               = temp_sq
formula            = max(0.0,cgt_temp)*max(0.0,cgt_temp)
description        = square of positive temperature [C * C]
***********************
name               = zoo_eff
formula            = t_zoo*t_zoo/zoo_cl
description        = effectice zooplankton concentration assumed for mortality and respiration process [mol/kg]
***********************
name               = din
formula            = t_no3+t_nh4
description        = dissolved inorganic nitrogen [mol/kg]
***********************
name               = din_sq
formula            = din*din
description        = squared DIN [mol2/kg2]
***********************
name               = po4_sq
formula            = t_po4*t_po4
description        = squared phosphate [mol**2/kg**2]
***********************
name               = pp
formula            = t_lpp+t_spp+t_cya
description        = total phytoplankton [mol/kg]
***********************
name               = lpp_plus_lpp0
formula            = t_lpp+lpp0
description        = large-cell phytoplankton plus seed concentration [mol/kg]
***********************
name               = spp_plus_spp0
formula            = t_spp+spp0
description        = small-cell phytoplankton plus seed concentration [mol/kg]
***********************
name               = cya_plus_cya0
formula            = t_cya+cya0
description        = diazotroph cyanobacteria plus seed concentration [mol/kg]
***********************
name               = food_zoo
formula            = t_lpp+t_spp+0.5*t_cya
description        = suitable food for zooplankton (weighted with food preferences) [mol/kg]
***********************
name               = lim_light_lpp
formula            = cgt_light/max(cgt_light/2.0,light_opt_lpp)*exp(1-cgt_light/max(cgt_light/2.0,light_opt_lpp))
description        = light limitation factor for large-cell phytoplankton growth [1]
***********************
name               = lim_light_spp
temp1              = max(cgt_light/2.0,light_opt_spp)
formula            = cgt_light/temp1*exp(1-cgt_light/temp1)
description        = light limitation factor for small-cell phytoplankton growth [1]
***********************
name               = lim_light_cya
formula            = cgt_light/max(cgt_light/2.0,light_opt_lpp)*exp(1-cgt_light/max(cgt_light/2.0,light_opt_lpp))
description        = light limitation factor for diazotroph cyanobacteria growth [1]
***********************
name               = lr_assim_lpp
formula            = r_lpp_assim*theta(t_o2-2*t_h2s)*min(din_sq/(din_sq+din_min_lpp*din_min_lpp),min(po4_sq/(po4_sq+din_min_lpp*din_min_lpp*rfr_p*rfr_p),lim_light_lpp))
description        = growth rate of large-cell phytoplankton, limited by DIN, DIP, light and oxygen [1/day]
***********************
name               = lr_assim_spp
formula            = r_spp_assim*theta(t_o2-2*t_h2s)*min(din_sq/(din_sq+din_min_spp*din_min_spp),min(po4_sq/(po4_sq+din_min_spp*din_min_spp*rfr_p*rfr_p),lim_light_spp))*(1+temp_sq/(temp_sq+temp_min_spp*temp_min_spp))
description        = growth rate of small-cell phytoplankton, limited by DIN, DIP, light, oxygen and temperature [1/day]
***********************
name               = lr_assim_cya
formula            = r_cya_assim*theta(t_o2-2*t_h2s)*min(po4_sq/(po4_sq+dip_min_cya*dip_min_cya),lim_light_spp)*(1/(1+exp(temp_min_cya-cgt_temp)))*(1/(1+exp(cgt_sali-sali_max_cya)))*(1/(1+exp(sali_min_cya-cgt_sali)))
description        = growth rate of diazotroph cyanobacteria, limited by DIP, light, oxygen, temperature and salinity [1/day]
***********************
name               = lr_graz_zoo
formula            = r_zoo_graz*(1-exp(-food_zoo*food_zoo/(food_min_zoo*food_min_zoo)))*theta(t_o2-2*t_h2s)*(1.0+temp_sq/(temp_opt_zoo*temp_opt_zoo)*exp(2.0-cgt_temp*2.0/temp_opt_zoo))
description        = growth rate of zooplankton, limited by food, oxygen and temperature [1/day]
***********************
name               = sed_active
formula            = max(0.0,min(t_sed,sed_max/4.5))
description        = detritus in active sediment layer [mol/m**2]
vertLoc            = SED
***********************
name               = lr_sed_rec
formula            = r_sed_rec*exp(q10_sed_rec*cgt_temp)*(1.0-0.9*theta(2*t_h2s-t_o2))
description        = recycling rate of sediment detritus, limited by oxygen [1/d]
vertLoc            = SED
***********************
name               = ips_eff
formula            = max(t_ips,t_ips+t_ips*(t_ips-ips_threshold)/ips_cl)
description        = effective concentration of iron phosphate in the sediment assumed for burial (enhanced burial above a threshold) [mol/m**2]
vertLoc            = SED
***********************
name               = frac_po4retent
formula            = 0.15 + 0.3*theta(cgt_latitude-60.75)
description        = fraction of phosphate which is retained as iron-bound phosphate instead of being released after mineralization in the sediment [1]
comment            = 0.45 in Bothnian Bay, 0.15 elsewhere\\This is a parameterization for the large amount of iron which is found in the \\Bothnian Bay.\\It traps the phosphate more effectively.
***********************
name               = erosion_is_active
formula            = theta(cgt_current_wave_stress - critical_stress)
description        = switch (1=erosion, 0=no erosion) which depends on the combined bottom stress of currents and waves
vertLoc            = SED
***********************
