7
7
############################################ From shared processes
8
8
9
9
def celsius_to_kelvin (tempc : xr .DataArray ) -> xr .DataArray :
10
- return tempc + 273.16
11
-
12
-
13
-
14
- def kelvin_to_celsius (tempk : xr .DataArray ) -> xr .DataArray :
15
- return tempk - 273.16
16
-
10
+ return tempc + 273.15
17
11
18
12
def arrhenius_correction (
19
13
TwaterC : xr .DataArray ,
@@ -1512,6 +1506,8 @@ def NH4_ApGrowth(
1512
1506
def NH4_AbRespiration (
1513
1507
use_Balgae : bool ,
1514
1508
rnb : xr .DataArray ,
1509
+ Fb : xr .DataArray ,
1510
+ depth : xr .DataArray ,
1515
1511
AbRespiration : xr .DataArray ,
1516
1512
1517
1513
) -> xr .DataArray :
@@ -1521,10 +1517,12 @@ def NH4_AbRespiration(
1521
1517
use_Balgae: true/false to use benthic algae module (unitless),
1522
1518
rnb: xr.DataArray,
1523
1519
AbRespiration: Benthic algal respiration rate (g/m^2/d),
1520
+ depth: water depth (m),
1521
+ Fb: Fraction of bottom area for benthic algae (unitless),
1524
1522
"""
1525
1523
# TODO changed the calculation for respiration from the inital FORTRAN due to conflict with the reference guide
1526
1524
1527
- return xr .where (use_Balgae , rnb * AbRespiration , 0.0 )
1525
+ return xr .where (use_Balgae , ( rnb * AbRespiration * Fb ) / depth , 0.0 )
1528
1526
1529
1527
def NH4_AbGrowth (
1530
1528
use_Balgae : bool ,
@@ -2022,17 +2020,21 @@ def DIP_ApGrowth(
2022
2020
def DIP_AbRespiration (
2023
2021
rpb : xr .DataArray ,
2024
2022
AbRespiration : xr .DataArray ,
2025
- use_Balgae : bool
2023
+ use_Balgae : bool ,
2024
+ Fb : xr .DataArray ,
2025
+ depth : xr .DataArray
2026
2026
2027
2027
) -> xr .DataArray :
2028
2028
"""Calculate DIP_AbRespiration: Dissolved inorganic phosphorus released for benthic algal respiration (mg-P/L/d).
2029
2029
2030
2030
Args:
2031
2031
rpb: Benthic algal P : Benthic algal dry ratio (mg-P/mg-D)
2032
2032
AbRespiration: Benthic algal respiration rate (g/m^2/d)
2033
- use_Blgae: true/false to use benthic algae module (t/f)
2033
+ use_Blgae: true/false to use benthic algae module (t/f)
2034
+ Fb: Fraction of bottom area available for benthic algal (unitless)
2035
+ depth: water depth (m)
2034
2036
"""
2035
- return xr .where (use_Balgae , rpb * AbRespiration ,0 )
2037
+ return xr .where (use_Balgae , rpb * Fb * AbRespiration / depth ,0 )
2036
2038
2037
2039
def DIP_AbGrowth (
2038
2040
rpb : xr .DataArray ,
@@ -2199,7 +2201,7 @@ def POM_algal_settling(
2199
2201
Ap : xr .DataArray ,
2200
2202
vsap : xr .DataArray ,
2201
2203
rda : xr .DataArray ,
2202
- depth : xr .DataArray ,
2204
+ h2 : xr .DataArray ,
2203
2205
use_Algae : xr .DataArray
2204
2206
) -> xr .DataArray :
2205
2207
"""Calculates the particulate organic matter concentration change due to algal mortality
@@ -2208,10 +2210,10 @@ def POM_algal_settling(
2208
2210
Ap: Algae concentration (mg/L)
2209
2211
vsap: Algal settling velocity (m/d)
2210
2212
rda: Ratio of algal biomass to chlorophyll-a
2211
- depth: Depth of water in computation cell (m)
2213
+ h2: active sediment layer thickness (m)
2212
2214
use_Algae: Option to consider algal kinetics
2213
2215
"""
2214
- da : xr .DataArray = xr .where (use_Algae == True , vsap * Ap * rda / depth , 0 )
2216
+ da : xr .DataArray = xr .where (use_Algae == True , vsap * Ap * rda / h2 , 0 )
2215
2217
2216
2218
return da
2217
2219
@@ -2234,7 +2236,7 @@ def POM_dissolution(
2234
2236
def POM_POC_settling (
2235
2237
POC : xr .DataArray ,
2236
2238
vsoc : xr .DataArray ,
2237
- depth : xr .DataArray ,
2239
+ h2 : xr .DataArray ,
2238
2240
fcom : xr .DataArray ,
2239
2241
use_POC : xr .DataArray
2240
2242
) -> xr .DataArray :
@@ -2243,11 +2245,11 @@ def POM_POC_settling(
2243
2245
Args:
2244
2246
POC: Concentration of particulate organic carbon (mg/L)
2245
2247
vsoc: POC settling velocity (m/d)
2246
- depth: Depth of water (m)
2248
+ h2: active sediment layer thickness (m)
2247
2249
fcom: Fraction of carbon in organic matter (mg-C/mg-D)
2248
2250
use_POC: Option to consider particulate organic carbon
2249
2251
"""
2250
- da : xr .DataArray = xr .where (use_POC == True , vsoc * POC / depth / fcom , 0 )
2252
+ da : xr .DataArray = xr .where (use_POC == True , vsoc * POC / h2 / fcom , 0 )
2251
2253
2252
2254
return da
2253
2255
@@ -2257,7 +2259,7 @@ def POM_benthic_algae_mortality(
2257
2259
kdb_tc : xr .DataArray ,
2258
2260
Fb : xr .DataArray ,
2259
2261
Fw : xr .DataArray ,
2260
- depth : xr .DataArray ,
2262
+ h2 : xr .DataArray ,
2261
2263
use_Balgae : xr .DataArray
2262
2264
) -> xr .DataArray :
2263
2265
"""Calculates particulate organic matter concentration change due to benthic algae mortality
@@ -2267,10 +2269,10 @@ def POM_benthic_algae_mortality(
2267
2269
kdb_tc: Benthic algae death rate (1/d)
2268
2270
Fb: Fraction of bottom area available for benthic algae growth
2269
2271
Fw: Fraction of benthic algae mortality into water column
2270
- depth: Depth of water in computation cell (m)
2272
+ h2: active sediment layer thickness (m)
2271
2273
use_Balgae: Option for considering benthic algae in DOC budget (boolean)
2272
2274
"""
2273
- da : xr .DataArray = xr .where (use_Balgae == True , Ab * kdb_tc * Fb * (1 - Fw ) / depth , 0 )
2275
+ da : xr .DataArray = xr .where (use_Balgae == True , Ab * kdb_tc * Fb * (1 - Fw ) / h2 , 0 )
2274
2276
2275
2277
return da
2276
2278
@@ -2279,16 +2281,16 @@ def POM_benthic_algae_mortality(
2279
2281
def POM_burial (
2280
2282
vb : xr .DataArray ,
2281
2283
POM : xr .DataArray ,
2282
- depth : xr .DataArray
2284
+ h2 : xr .DataArray
2283
2285
) -> xr .DataArray :
2284
2286
"""Calculates particulate organic matter concentration change due to POM burial in the sediments
2285
2287
2286
2288
Args:
2287
2289
vb: Velocity of burial (m/d)
2288
2290
POM: POM concentration (mg/L)
2289
- depth: Depth of water in computation cell (m)
2291
+ h2: active sediment layer thickness (m)
2290
2292
"""
2291
- return vb * POM / depth
2293
+ return vb * POM / h2 #note removed 365 from FORTRAN
2292
2294
2293
2295
2294
2296
@@ -2898,19 +2900,19 @@ def DOs_atm_alpha(
2898
2900
2899
2901
def DOX_sat (
2900
2902
TwaterK : xr .DataArray ,
2901
- pressure_atm : xr .DataArray ,
2903
+ pressure_mb : xr .DataArray ,
2902
2904
pwv : xr .DataArray ,
2903
2905
DOs_atm_alpha : xr .DataArray
2904
2906
) -> xr .DataArray :
2905
2907
"""Calculate DO saturation value
2906
2908
2907
2909
Args:
2908
2910
TwaterK: Water temperature kelvin
2909
- pressure_atm : Atmospheric pressure (atm )
2911
+ pressure_mb : Atmospheric pressure (mb )
2910
2912
pwv: Patrial pressure of water vapor (atm)
2911
2913
DOs_atm_alpha: DO saturation atmospheric correction coefficient
2912
2914
"""
2913
- pressure_atm = pressure_atm * 0.000986923
2915
+ pressure_atm = pressure_mb * 0.000986923
2914
2916
2915
2917
DOX_sat_uncorrected = np .exp (- 139.34410 + ( 1.575701E05 / TwaterK ) - ( 6.642308E07 / (TwaterK ** 2.0 ) ) + ( 1.243800E10 / (TwaterK ** 3.0 ) ) - ( 8.621949E11 / (TwaterK ** 4.0 ) ))
2916
2918
@@ -3465,36 +3467,21 @@ def KHN2_tc(
3465
3467
return 0.00065 * np .exp (1300.0 * (1.0 / TwaterK - 1 / 298.15 ))
3466
3468
3467
3469
3468
- def P_wv (
3469
- TwaterK : xr .DataArray ,
3470
- ) -> xr .DataArray :
3471
-
3472
- """Calculate partial pressure water vapor (atm)
3473
-
3474
- Constant values found in documentation
3475
-
3476
- Args:
3477
- TwaterK: water temperature kelvin (K)
3478
-
3479
- """
3480
- return np .exp (11.8571 - (3840.70 / TwaterK ) - (216961.0 / (TwaterK ** 2 )))
3481
-
3482
-
3483
3470
def N2sat (
3484
3471
KHN2_tc : xr .DataArray ,
3485
- pressure_atm : xr .DataArray ,
3486
- P_wv : xr .DataArray
3472
+ pressure_mb : xr .DataArray ,
3473
+ pwv : xr .DataArray
3487
3474
) -> xr .DataArray :
3488
3475
3489
3476
"""Calculate N2 at saturation f(Twater and atm pressure) (mg-N/L)
3490
3477
3491
3478
Args:
3492
3479
KHN2_tc: Henry's law constant (mol/L/atm)
3493
- pressure_atm : atmosphric pressure in atm (atm )
3494
- P_wv : Partial pressure of water vapor (atm)
3480
+ pressure_mb : atmosphric pressure in mb (mb )
3481
+ pwv : Partial pressure of water vapor (atm)
3495
3482
"""
3496
3483
3497
- N2sat = 2.8E+4 * KHN2_tc * 0.79 * (pressure_atm - P_wv )
3484
+ N2sat = 2.8E+4 * KHN2_tc * 0.79 * (pressure_mb * 0.000986923 - pwv )
3498
3485
N2sat = xr .where (N2sat < 0.0 ,0.000001 ,N2sat ) #Trap saturation concentration to ensure never negative
3499
3486
3500
3487
return N2sat
0 commit comments