From 23fbee558b211c34704d4748c1bebe4603c1f42e Mon Sep 17 00:00:00 2001 From: kewalak Date: Fri, 19 Jul 2024 13:39:06 -0700 Subject: [PATCH 1/9] Phosphorus Tests Branched from current main --- src/clearwater_modules/nsm1/processes.py | 10 +- tests/test_14_nsm_phosphrous_calculations.py | 1200 ++++++++++++++++++ 2 files changed, 1207 insertions(+), 3 deletions(-) create mode 100644 tests/test_14_nsm_phosphrous_calculations.py diff --git a/src/clearwater_modules/nsm1/processes.py b/src/clearwater_modules/nsm1/processes.py index ca9fa10..bb3fbd7 100644 --- a/src/clearwater_modules/nsm1/processes.py +++ b/src/clearwater_modules/nsm1/processes.py @@ -1997,7 +1997,9 @@ def DIP_ApGrowth( def DIP_AbRespiration( rpb: xr.DataArray, AbRespiration: xr.DataArray, - use_Balgae: bool + use_Balgae: bool, + Fb: xr.DataArray, + depth: xr.DataArray ) -> xr.DataArray : """Calculate DIP_AbRespiration: Dissolved inorganic phosphorus released for benthic algal respiration (mg-P/L/d). @@ -2005,9 +2007,11 @@ def DIP_AbRespiration( Args: rpb: Benthic algal P : Benthic algal dry ratio (mg-P/mg-D) AbRespiration: Benthic algal respiration rate (g/m^2/d) - use_Blgae: true/false to use benthic algae module (t/f) + use_Blgae: true/false to use benthic algae module (t/f) + Fb: Fraction of bottom area available for benthic algal (unitless) + depth: water depth (m) """ - return xr.where(use_Balgae, rpb * AbRespiration,0) + return xr.where(use_Balgae, rpb * Fb * AbRespiration /depth,0) def DIP_AbGrowth( rpb: xr.DataArray, diff --git a/tests/test_14_nsm_phosphrous_calculations.py b/tests/test_14_nsm_phosphrous_calculations.py new file mode 100644 index 0000000..287f1cd --- /dev/null +++ b/tests/test_14_nsm_phosphrous_calculations.py @@ -0,0 +1,1200 @@ +from numba import ( + types, + typed, +) +import pytest + +from clearwater_modules.nsm1 import NutrientBudget +from clearwater_modules.nsm1.constants import ( + AlgaeStaticVariables, + AlkalinityStaticVariables, + BalgaeStaticVariables, + NitrogenStaticVariables, + CarbonStaticVariables, + CBODStaticVariables, + DOXStaticVariables, + N2StaticVariables, + POMStaticVariables, + PathogenStaticVariables, + PhosphorusStaticVariables, + GlobalParameters, + GlobalVars +) + + +@pytest.fixture(scope='function') +def initial_nsm1_state() -> dict[str, float]: + """Return initial state values for the model.""" + return { + + 'Ap': 36.77, + 'Ab': 24, + 'NH4': 0.063, + 'NO3': 5.54, + 'OrgN': 1.726, + 'N2': 1, + 'TIP': 0.071, + 'OrgP': 0.24, + 'POC': 4.356, + 'DOC': 1, + 'DIC': 1, + 'POM': 10, + 'CBOD': 5, + 'DOX': 8, + 'PX': 1, + 'Alk': 1 + + } + +@pytest.fixture(scope='module') +def time_steps() -> int: + return 1 + +@pytest.fixture(scope='function') +def default_algae_params() -> AlgaeStaticVariables: + """Returns default algae static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return AlgaeStaticVariables( + AWd = 100, + AWc= 40, + AWn= 7.2, + AWp= 1, + AWa= 1000, + KL= 10, + KsN= 0.04, + KsP= 0.0012, + mu_max_20= 1, + kdp_20= 0.15, + krp_20= 0.2, + vsap= 0.15, + growth_rate_option = 1, + light_limitation_option = 1, + ) + +@pytest.fixture(scope='function') +def default_alkalinity_params() -> AlkalinityStaticVariables: + """Returns default alkalinity static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return AlkalinityStaticVariables( + r_alkaa = 14.0 / 106.0 / 12.0 / 1000.0, + r_alkan= 18.0 / 106.0 / 12.0 / 1000.0, + r_alkn = 2.0 / 14.0 / 1000.0, + r_alkden = 4.0 / 14.0 / 1000.0, + r_alkba = 14.0 / 106.0 / 12.0 / 1000.0, + r_alkbn =18.0 / 106.0 / 12.0 / 1000.0 + ) + +@pytest.fixture(scope='function') +def default_balgae_params() -> BalgaeStaticVariables: + """Returns default Benthic Algae static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return BalgaeStaticVariables( + BWd = 100, + BWc= 40, + BWn=7.2, + BWp= 1, + BWa= 5000, + KLb= 10, + KsNb= 0.25, + KsPb=0.125, + Ksb=10, + mub_max_20=0.4, + krb_20=0.2, + kdb_20=0.3, + b_growth_rate_option=1, + b_light_limitation_option=1, + Fw=0.9, + Fb=0.9 + ) + +@pytest.fixture(scope='function') +def default_nitrogen_params() -> NitrogenStaticVariables: + """Returns default nitrogen static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return NitrogenStaticVariables( + KNR= 0.6 , + knit_20= 0.1, + kon_20=0.1, + kdnit_20=0.002, + rnh4_20=0, + vno3_20=0, + KsOxdn=0.1, + PN=0.5, + PNb=0.5 + ) + +@pytest.fixture(scope='function') +def default_carbon_params() -> CarbonStaticVariables: + """Returns default carbon static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return CarbonStaticVariables( + f_pocp = 0.9, + kdoc_20= 0.01, + f_pocb=0.9, + kpoc_20= 0.005, + KsOxmc=1.0, + pCO2 = 383.0, + FCO2 = 0.2, + roc = 32.0/12.0 + ) + +@pytest.fixture(scope='function') +def default_CBOD_params() -> CBODStaticVariables: + """Returns default CBOD static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return CBODStaticVariables( + KsOxbod = 0.5, + kbod_20 = 0.12, + ksbod_20 = 0.0 + ) + +@pytest.fixture(scope='function') +def default_DOX_params() -> DOXStaticVariables: + """Returns default DOX static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return DOXStaticVariables( + ron = 2.0 * 32.0 / 14.0, + KsSOD =1, + ) + +@pytest.fixture(scope='function') +def default_N2_params() -> N2StaticVariables: + """Returns default N2 static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return N2StaticVariables( + + ) + +@pytest.fixture(scope='function') +def default_POM_params() -> POMStaticVariables: + """Returns default POM static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return POMStaticVariables( + kpom_20 = 0.1 + ) + +@pytest.fixture(scope='function') +def default_pathogen_params() -> PathogenStaticVariables: + """Returns default Pathogens static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return PathogenStaticVariables( + kdx_20=0.8, + apx=1, + vx=1 + ) + +@pytest.fixture(scope='function') +def default_phosphorus_params() -> PhosphorusStaticVariables: + """Returns default phosphorus static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return PhosphorusStaticVariables( + kop_20 = 0.1, + rpo4_20 =0, + kdpo4 = 0.0, + ) + +@pytest.fixture(scope='function') +def default_gp_params() -> GlobalParameters: + """Returns default global parameter static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return GlobalParameters( + use_NH4= False, + use_NO3= False, + use_OrgN= False, + use_OrgP = True, + use_TIP= True, + use_SedFlux= False, + use_POC = False, + use_DOC = False, + use_DOX= False, + use_DIC= False, + use_Algae= True, + use_Balgae= True, + use_N2 = False, + use_Pathogen = False, + use_Alk = False, + use_POM = False + ) + +@pytest.fixture(scope='function') +def default_gvars_params() -> GlobalVars: + """Returns default global variables static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return GlobalVars( + vson = 0.01, + vsoc = 0.01, + vsop = 0.01, + vs = 1, + SOD_20 = 999, + SOD_theta = 999, + vb = 0.01, + fcom = 0.4, + kaw_20_user = 999, + kah_20_user = 999, + hydraulic_reaeration_option = 2, + wind_reaeration_option = 2, + timestep = 1, #TODO Dynamic or static? + depth = 1.5, #TODO Dynamic or static? + TwaterC = 25, + theta = 1.047, + velocity = 1, + flow = 150, + topwidth = 100, + slope = 0.0002, + shear_velocity = 0.05334, + pressure_atm = 1, + wind_speed = 3, + q_solar = 500, + Solid = 1, + lambda0 = .02, + lambda1 = .0088, + lambda2 = .054, + lambdas = .052, + lambdam = .174, + Fr_PAR = .47 + ) + +def get_nutrient_budget_instance( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + +) -> NutrientBudget: + """Return an instance of the NSM1 class.""" + return NutrientBudget( + time_steps=time_steps, + initial_state_values=initial_nsm1_state, + algae_parameters=default_algae_params, + alkalinity_parameters=default_alkalinity_params, + balgae_parameters=default_balgae_params, + nitrogen_parameters=default_nitrogen_params, + carbon_parameters=default_carbon_params, + CBOD_parameters=default_CBOD_params, + DOX_parameters=default_DOX_params, + N2_parameters=default_N2_params, + POM_parameters=default_POM_params, + pathogen_parameters=default_pathogen_params, + phosphorus_parameters=default_phosphorus_params, + global_parameters=default_gp_params, + global_vars=default_gvars_params, + time_dim='nsm1_time_step', + ) + +@pytest.fixture(scope='module') +def tolerance() -> float: + """Controls the precision of the pytest.approx() function.""" + return 0.000001 + +def test_defaults( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.100763082 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.26406066 + +def test_change_kop( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_phosphorus_params['kop_20'] = 0.2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.1309587507 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.233864988 + +def test_change_rpo4( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_phosphorus_params['rpo4_20'] = 0.1 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.196027374917 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.2640606566 + +def test_change_use_OrgP( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_OrgP'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.0705674135387 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.24 + +def test_change_use_TIP( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_TIP'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.071 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.26406065661024 + +def test_change_use_algae( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_Algae'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.13233980536753 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.25712131452332 + +def test_change_use_Balgae( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_Balgae'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.0687962668837321 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.21514367350092 + +def test_change_vsop( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['vsop'] = 1 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.100763082124724 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.10566065661024 + +def test_change_TIP( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['TIP'] = 1 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 1.01955224933265 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.26406065661024 + +def test_change_OrgP( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['OrgP'] = 1 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.196382699313724 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.923374372754573 + +def test_change_depth( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['depth'] = 0.5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.161233449642345 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.358694622828881 + +def test_change_TwaterC( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['TwaterC'] = 35 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.12612604665317 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.279019500801769 + +def test_change_Ap( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['Ap'] = 25 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) ==0.110370059884936 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.261839387739883 + +def test_change_Fw( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['Fw'] = 0.95 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.100763082124724 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.26677826678298 + +def test_change_Fb( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['Fb'] = 0.5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.0865556086842829 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) ==0.24231977522832 \ No newline at end of file From d9652650b26270f5d031f43291fcb64fc0ce02fc Mon Sep 17 00:00:00 2001 From: kewalak Date: Fri, 19 Jul 2024 18:08:58 -0700 Subject: [PATCH 2/9] One Working Test for POM and PX --- src/clearwater_modules/nsm1/constants.py | 4 +- src/clearwater_modules/nsm1/processes.py | 28 +- .../nsm1/static_variables.py | 8 + tests/test_15_nsm_POM_calculations.py | 492 ++++++++++++++++++ tests/test_16_nsm_PX_calculations.py | 488 +++++++++++++++++ 5 files changed, 1005 insertions(+), 15 deletions(-) create mode 100644 tests/test_15_nsm_POM_calculations.py create mode 100644 tests/test_16_nsm_PX_calculations.py diff --git a/src/clearwater_modules/nsm1/constants.py b/src/clearwater_modules/nsm1/constants.py index 14af78b..62c120a 100644 --- a/src/clearwater_modules/nsm1/constants.py +++ b/src/clearwater_modules/nsm1/constants.py @@ -170,9 +170,11 @@ class N2StaticVariables(TypedDict): class POMStaticVariables(TypedDict): kpom_20: float + h2: float DEFAULT_POM = POMStaticVariables( - kpom_20 = 0.1 + kpom_20 = 0.1, + h2=0.1 ) diff --git a/src/clearwater_modules/nsm1/processes.py b/src/clearwater_modules/nsm1/processes.py index bb3fbd7..4d8a65c 100644 --- a/src/clearwater_modules/nsm1/processes.py +++ b/src/clearwater_modules/nsm1/processes.py @@ -2175,7 +2175,7 @@ def POM_algal_settling( Ap: xr.DataArray, vsap: xr.DataArray, rda: xr.DataArray, - depth: xr.DataArray, + h2: xr.DataArray, use_Algae: xr.DataArray ) -> xr.DataArray: """Calculates the particulate organic matter concentration change due to algal mortality @@ -2184,10 +2184,10 @@ def POM_algal_settling( Ap: Algae concentration (mg/L) vsap: Algal settling velocity (m/d) rda: Ratio of algal biomass to chlorophyll-a - depth: Depth of water in computation cell (m) + h2: active sediment layer thickness (m) use_Algae: Option to consider algal kinetics """ - da: xr.DataArray = xr.where(use_Algae == True, vsap * Ap * rda / depth, 0) + da: xr.DataArray = xr.where(use_Algae == True, vsap * Ap * rda / h2, 0) return da @@ -2210,7 +2210,7 @@ def POM_dissolution( def POM_POC_settling( POC: xr.DataArray, vsoc: xr.DataArray, - depth: xr.DataArray, + h2: xr.DataArray, fcom: xr.DataArray, use_POC: xr.DataArray ) -> xr.DataArray: @@ -2219,11 +2219,11 @@ def POM_POC_settling( Args: POC: Concentration of particulate organic carbon (mg/L) vsoc: POC settling velocity (m/d) - depth: Depth of water (m) + h2: active sediment layer thickness (m) fcom: Fraction of carbon in organic matter (mg-C/mg-D) use_POC: Option to consider particulate organic carbon """ - da: xr.DataArray = xr.where(use_POC == True, vsoc * POC / depth / fcom, 0) + da: xr.DataArray = xr.where(use_POC == True, vsoc * POC / h2 / fcom, 0) return da @@ -2233,7 +2233,7 @@ def POM_benthic_algae_mortality( kdb_tc: xr.DataArray, Fb: xr.DataArray, Fw: xr.DataArray, - depth: xr.DataArray, + h2: xr.DataArray, use_Balgae: xr.DataArray ) -> xr.DataArray: """Calculates particulate organic matter concentration change due to benthic algae mortality @@ -2243,10 +2243,10 @@ def POM_benthic_algae_mortality( kdb_tc: Benthic algae death rate (1/d) Fb: Fraction of bottom area available for benthic algae growth Fw: Fraction of benthic algae mortality into water column - depth: Depth of water in computation cell (m) + h2: active sediment layer thickness (m) use_Balgae: Option for considering benthic algae in DOC budget (boolean) """ - da: xr.DataArray = xr.where(use_Balgae == True, Ab * kdb_tc * Fb * (1 - Fw) / depth, 0) + da: xr.DataArray = xr.where(use_Balgae == True, Ab * kdb_tc * Fb * (1 - Fw) / h2, 0) return da @@ -2255,16 +2255,16 @@ def POM_benthic_algae_mortality( def POM_burial( vb: xr.DataArray, POM: xr.DataArray, - depth: xr.DataArray + h2: xr.DataArray ) -> xr.DataArray: """Calculates particulate organic matter concentration change due to POM burial in the sediments Args: vb: Velocity of burial (m/d) POM: POM concentration (mg/L) - depth: Depth of water in computation cell (m) + h2: active sediment layer thickness (m) """ - return vb * POM / depth + return vb * POM / h2 #note removed 365 from FORTRAN @@ -2854,14 +2854,14 @@ def pwv( def DOs_atm_alpha( - TwaterK: xr.DataArray + TwaterC: xr.DataArray ) -> xr.DataArray: """Calculate DO saturation atmospheric correction coefficient Args: TwaterK: Water temperature kelvin """ - return .000975 - 1.426 * 10 ** -5 * TwaterK + 6.436 * 10 ** -8 * TwaterK ** 2 + return .000975 - 1.426 * 10 ** -5 * TwaterC + 6.436 * 10 ** -8 * TwaterC ** 2 diff --git a/src/clearwater_modules/nsm1/static_variables.py b/src/clearwater_modules/nsm1/static_variables.py index 0d0cabc..884f1bf 100644 --- a/src/clearwater_modules/nsm1/static_variables.py +++ b/src/clearwater_modules/nsm1/static_variables.py @@ -750,6 +750,14 @@ class Variable(base.Variable): use='static' ) +Variable( + name='h2', + long_name='active sediment layer thickness', + units='m', + description='active sediment layer thickness', + use='static' +) + ############################################ From CBOD Variable( name='kbod_20', diff --git a/tests/test_15_nsm_POM_calculations.py b/tests/test_15_nsm_POM_calculations.py new file mode 100644 index 0000000..dffd8f1 --- /dev/null +++ b/tests/test_15_nsm_POM_calculations.py @@ -0,0 +1,492 @@ +from numba import ( + types, + typed, +) +import pytest + +from clearwater_modules.nsm1 import NutrientBudget +from clearwater_modules.nsm1.constants import ( + AlgaeStaticVariables, + AlkalinityStaticVariables, + BalgaeStaticVariables, + NitrogenStaticVariables, + CarbonStaticVariables, + CBODStaticVariables, + DOXStaticVariables, + N2StaticVariables, + POMStaticVariables, + PathogenStaticVariables, + PhosphorusStaticVariables, + GlobalParameters, + GlobalVars +) + + +@pytest.fixture(scope='function') +def initial_nsm1_state() -> dict[str, float]: + """Return initial state values for the model.""" + return { + + 'Ap': 36.77, + 'Ab': 24, + 'NH4': 0.063, + 'NO3': 5.54, + 'OrgN': 1.726, + 'N2': 1, + 'TIP': 0.071, + 'OrgP': 0.24, + 'POC': 4.356, + 'DOC': 1, + 'DIC': 1, + 'POM': 10, + 'CBOD': 5, + 'DOX': 8, + 'PX': 1, + 'Alk': 1 + + } + +@pytest.fixture(scope='module') +def time_steps() -> int: + return 1 + +@pytest.fixture(scope='function') +def default_algae_params() -> AlgaeStaticVariables: + """Returns default algae static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return AlgaeStaticVariables( + AWd = 100, + AWc= 40, + AWn= 7.2, + AWp= 1, + AWa= 1000, + KL= 10, + KsN= 0.04, + KsP= 0.0012, + mu_max_20= 1, + kdp_20= 0.15, + krp_20= 0.2, + vsap= 0.15, + growth_rate_option = 1, + light_limitation_option = 1, + ) + +@pytest.fixture(scope='function') +def default_alkalinity_params() -> AlkalinityStaticVariables: + """Returns default alkalinity static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return AlkalinityStaticVariables( + r_alkaa = 14.0 / 106.0 / 12.0 / 1000.0, + r_alkan= 18.0 / 106.0 / 12.0 / 1000.0, + r_alkn = 2.0 / 14.0 / 1000.0, + r_alkden = 4.0 / 14.0 / 1000.0, + r_alkba = 14.0 / 106.0 / 12.0 / 1000.0, + r_alkbn =18.0 / 106.0 / 12.0 / 1000.0 + ) + +@pytest.fixture(scope='function') +def default_balgae_params() -> BalgaeStaticVariables: + """Returns default Benthic Algae static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return BalgaeStaticVariables( + BWd = 100, + BWc= 40, + BWn=7.2, + BWp= 1, + BWa= 5000, + KLb= 10, + KsNb= 0.25, + KsPb=0.125, + Ksb=10, + mub_max_20=0.4, + krb_20=0.2, + kdb_20=0.3, + b_growth_rate_option=1, + b_light_limitation_option=1, + Fw=0.9, + Fb=0.9 + ) + +@pytest.fixture(scope='function') +def default_nitrogen_params() -> NitrogenStaticVariables: + """Returns default nitrogen static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return NitrogenStaticVariables( + KNR= 0.6 , + knit_20= 0.1, + kon_20=0.1, + kdnit_20=0.002, + rnh4_20=0, + vno3_20=0, + KsOxdn=0.1, + PN=0.5, + PNb=0.5 + ) + +@pytest.fixture(scope='function') +def default_carbon_params() -> CarbonStaticVariables: + """Returns default carbon static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return CarbonStaticVariables( + f_pocp = 0.9, + kdoc_20= 0.01, + f_pocb=0.9, + kpoc_20= 0.005, + KsOxmc=1.0, + pCO2 = 383.0, + FCO2 = 0.2, + roc = 32.0/12.0 + ) + +@pytest.fixture(scope='function') +def default_CBOD_params() -> CBODStaticVariables: + """Returns default CBOD static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return CBODStaticVariables( + KsOxbod = 0.5, + kbod_20 = 0.12, + ksbod_20 = 0.0 + ) + +@pytest.fixture(scope='function') +def default_DOX_params() -> DOXStaticVariables: + """Returns default DOX static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return DOXStaticVariables( + ron = 2.0 * 32.0 / 14.0, + KsSOD =1, + ) + +@pytest.fixture(scope='function') +def default_N2_params() -> N2StaticVariables: + """Returns default N2 static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return N2StaticVariables( + + ) + +@pytest.fixture(scope='function') +def default_POM_params() -> POMStaticVariables: + """Returns default POM static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return POMStaticVariables( + kpom_20 = 0.1, + h2 = 0.1 + ) + +@pytest.fixture(scope='function') +def default_pathogen_params() -> PathogenStaticVariables: + """Returns default Pathogens static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return PathogenStaticVariables( + kdx_20=0.8, + apx=1, + vx=1 + ) + +@pytest.fixture(scope='function') +def default_phosphorus_params() -> PhosphorusStaticVariables: + """Returns default phosphorus static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return PhosphorusStaticVariables( + kop_20 = 0.1, + rpo4_20 =0, + kdpo4 = 0.0, + ) + +@pytest.fixture(scope='function') +def default_gp_params() -> GlobalParameters: + """Returns default global parameter static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return GlobalParameters( + use_NH4= False, + use_NO3= False, + use_OrgN= False, + use_OrgP = False, + use_TIP= False, + use_SedFlux= False, + use_POC = True, + use_DOC = False, + use_DOX= False, + use_DIC= False, + use_Algae= True, + use_Balgae= True, + use_N2 = False, + use_Pathogen = False, + use_Alk = False, + use_POM = True + ) + +@pytest.fixture(scope='function') +def default_gvars_params() -> GlobalVars: + """Returns default global variables static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return GlobalVars( + vson = 0.01, + vsoc = 0.01, + vsop = 0.01, + vs = 1, + SOD_20 = 999, + SOD_theta = 999, + vb = 0.01, + fcom = 0.4, + kaw_20_user = 999, + kah_20_user = 999, + hydraulic_reaeration_option = 2, + wind_reaeration_option = 2, + timestep = 1, #TODO Dynamic or static? + depth = 1.5, #TODO Dynamic or static? + TwaterC = 25, + theta = 1.047, + velocity = 1, + flow = 150, + topwidth = 100, + slope = 0.0002, + shear_velocity = 0.05334, + pressure_atm = 1, + wind_speed = 3, + q_solar = 500, + Solid = 1, + lambda0 = .02, + lambda1 = .0088, + lambda2 = .054, + lambdas = .052, + lambdam = .174, + Fr_PAR = .47 + ) + +def get_nutrient_budget_instance( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + +) -> NutrientBudget: + """Return an instance of the NSM1 class.""" + return NutrientBudget( + time_steps=time_steps, + initial_state_values=initial_nsm1_state, + algae_parameters=default_algae_params, + alkalinity_parameters=default_alkalinity_params, + balgae_parameters=default_balgae_params, + nitrogen_parameters=default_nitrogen_params, + carbon_parameters=default_carbon_params, + CBOD_parameters=default_CBOD_params, + DOX_parameters=default_DOX_params, + N2_parameters=default_N2_params, + POM_parameters=default_POM_params, + pathogen_parameters=default_pathogen_params, + phosphorus_parameters=default_phosphorus_params, + global_parameters=default_gp_params, + global_vars=default_gvars_params, + time_dim='nsm1_time_step', + ) + +@pytest.fixture(scope='module') +def tolerance() -> float: + """Controls the precision of the pytest.approx() function.""" + return 0.000001 + +def test_defaults( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + POM_algal_settling = nsm1.dataset.isel(nsm1_time_step=-1).POM_algal_settling.values.item() + assert isinstance(POM_algal_settling, float) + print("POM_algal_settling",POM_algal_settling) + + POM_dissolution = nsm1.dataset.isel(nsm1_time_step=-1).POM_dissolution.values.item() + assert isinstance(POM_dissolution, float) + print("POM_dissolution",POM_dissolution) + + POM_POC_settling = nsm1.dataset.isel(nsm1_time_step=-1).POM_POC_settling.values.item() + assert isinstance(POM_POC_settling, float) + print("POM_POC_settling",POM_POC_settling) + + POM_benthic_algae_mortality = nsm1.dataset.isel(nsm1_time_step=-1).POM_benthic_algae_mortality.values.item() + assert isinstance(POM_benthic_algae_mortality, float) + print("POM_benthic_algae_mortality",POM_benthic_algae_mortality) + + POM_burial = nsm1.dataset.isel(nsm1_time_step=-1).POM_burial.values.item() + assert isinstance(POM_burial, float) + print("POM_burial",POM_burial) + + + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 22.49917766047 + + +''' +def test_change_kop( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_phosphorus_params['kop_20'] = 0.2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.1309587507 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.233864988 +''' diff --git a/tests/test_16_nsm_PX_calculations.py b/tests/test_16_nsm_PX_calculations.py new file mode 100644 index 0000000..c5e2ef4 --- /dev/null +++ b/tests/test_16_nsm_PX_calculations.py @@ -0,0 +1,488 @@ +from numba import ( + types, + typed, +) +import pytest + +from clearwater_modules.nsm1 import NutrientBudget +from clearwater_modules.nsm1.constants import ( + AlgaeStaticVariables, + AlkalinityStaticVariables, + BalgaeStaticVariables, + NitrogenStaticVariables, + CarbonStaticVariables, + CBODStaticVariables, + DOXStaticVariables, + N2StaticVariables, + POMStaticVariables, + PathogenStaticVariables, + PhosphorusStaticVariables, + GlobalParameters, + GlobalVars +) + + +@pytest.fixture(scope='function') +def initial_nsm1_state() -> dict[str, float]: + """Return initial state values for the model.""" + return { + + 'Ap': 36.77, + 'Ab': 24, + 'NH4': 0.063, + 'NO3': 5.54, + 'OrgN': 1.726, + 'N2': 1, + 'TIP': 0.071, + 'OrgP': 0.24, + 'POC': 4.356, + 'DOC': 1, + 'DIC': 1, + 'POM': 10, + 'CBOD': 5, + 'DOX': 8, + 'PX': 1, + 'Alk': 1 + + } + +@pytest.fixture(scope='module') +def time_steps() -> int: + return 1 + +@pytest.fixture(scope='function') +def default_algae_params() -> AlgaeStaticVariables: + """Returns default algae static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return AlgaeStaticVariables( + AWd = 100, + AWc= 40, + AWn= 7.2, + AWp= 1, + AWa= 1000, + KL= 10, + KsN= 0.04, + KsP= 0.0012, + mu_max_20= 1, + kdp_20= 0.15, + krp_20= 0.2, + vsap= 0.15, + growth_rate_option = 1, + light_limitation_option = 1, + ) + +@pytest.fixture(scope='function') +def default_alkalinity_params() -> AlkalinityStaticVariables: + """Returns default alkalinity static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return AlkalinityStaticVariables( + r_alkaa = 14.0 / 106.0 / 12.0 / 1000.0, + r_alkan= 18.0 / 106.0 / 12.0 / 1000.0, + r_alkn = 2.0 / 14.0 / 1000.0, + r_alkden = 4.0 / 14.0 / 1000.0, + r_alkba = 14.0 / 106.0 / 12.0 / 1000.0, + r_alkbn =18.0 / 106.0 / 12.0 / 1000.0 + ) + +@pytest.fixture(scope='function') +def default_balgae_params() -> BalgaeStaticVariables: + """Returns default Benthic Algae static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return BalgaeStaticVariables( + BWd = 100, + BWc= 40, + BWn=7.2, + BWp= 1, + BWa= 5000, + KLb= 10, + KsNb= 0.25, + KsPb=0.125, + Ksb=10, + mub_max_20=0.4, + krb_20=0.2, + kdb_20=0.3, + b_growth_rate_option=1, + b_light_limitation_option=1, + Fw=0.9, + Fb=0.9 + ) + +@pytest.fixture(scope='function') +def default_nitrogen_params() -> NitrogenStaticVariables: + """Returns default nitrogen static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return NitrogenStaticVariables( + KNR= 0.6 , + knit_20= 0.1, + kon_20=0.1, + kdnit_20=0.002, + rnh4_20=0, + vno3_20=0, + KsOxdn=0.1, + PN=0.5, + PNb=0.5 + ) + +@pytest.fixture(scope='function') +def default_carbon_params() -> CarbonStaticVariables: + """Returns default carbon static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return CarbonStaticVariables( + f_pocp = 0.9, + kdoc_20= 0.01, + f_pocb=0.9, + kpoc_20= 0.005, + KsOxmc=1.0, + pCO2 = 383.0, + FCO2 = 0.2, + roc = 32.0/12.0 + ) + +@pytest.fixture(scope='function') +def default_CBOD_params() -> CBODStaticVariables: + """Returns default CBOD static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return CBODStaticVariables( + KsOxbod = 0.5, + kbod_20 = 0.12, + ksbod_20 = 0.0 + ) + +@pytest.fixture(scope='function') +def default_DOX_params() -> DOXStaticVariables: + """Returns default DOX static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return DOXStaticVariables( + ron = 2.0 * 32.0 / 14.0, + KsSOD =1, + ) + +@pytest.fixture(scope='function') +def default_N2_params() -> N2StaticVariables: + """Returns default N2 static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return N2StaticVariables( + + ) + +@pytest.fixture(scope='function') +def default_POM_params() -> POMStaticVariables: + """Returns default POM static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return POMStaticVariables( + kpom_20 = 0.1, + h2 = 0.1 + ) + +@pytest.fixture(scope='function') +def default_pathogen_params() -> PathogenStaticVariables: + """Returns default Pathogens static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return PathogenStaticVariables( + kdx_20=0.8, + apx=1, + vx=1 + ) + +@pytest.fixture(scope='function') +def default_phosphorus_params() -> PhosphorusStaticVariables: + """Returns default phosphorus static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return PhosphorusStaticVariables( + kop_20 = 0.1, + rpo4_20 =0, + kdpo4 = 0.0, + ) + +@pytest.fixture(scope='function') +def default_gp_params() -> GlobalParameters: + """Returns default global parameter static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return GlobalParameters( + use_NH4= False, + use_NO3= False, + use_OrgN= False, + use_OrgP = False, + use_TIP= False, + use_SedFlux= False, + use_POC = False, + use_DOC = False, + use_DOX= False, + use_DIC= False, + use_Algae= False, + use_Balgae= False, + use_N2 = False, + use_Pathogen = True, + use_Alk = False, + use_POM = False + ) + +@pytest.fixture(scope='function') +def default_gvars_params() -> GlobalVars: + """Returns default global variables static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return GlobalVars( + vson = 0.01, + vsoc = 0.01, + vsop = 0.01, + vs = 1, + SOD_20 = 999, + SOD_theta = 999, + vb = 0.01, + fcom = 0.4, + kaw_20_user = 999, + kah_20_user = 999, + hydraulic_reaeration_option = 2, + wind_reaeration_option = 2, + timestep = 1, #TODO Dynamic or static? + depth = 1.5, #TODO Dynamic or static? + TwaterC = 25, + theta = 1.047, + velocity = 1, + flow = 150, + topwidth = 100, + slope = 0.0002, + shear_velocity = 0.05334, + pressure_atm = 1, + wind_speed = 3, + q_solar = 500, + Solid = 1, + lambda0 = .02, + lambda1 = .0088, + lambda2 = .054, + lambdas = .052, + lambdam = .174, + Fr_PAR = .47 + ) + +def get_nutrient_budget_instance( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + +) -> NutrientBudget: + """Return an instance of the NSM1 class.""" + return NutrientBudget( + time_steps=time_steps, + initial_state_values=initial_nsm1_state, + algae_parameters=default_algae_params, + alkalinity_parameters=default_alkalinity_params, + balgae_parameters=default_balgae_params, + nitrogen_parameters=default_nitrogen_params, + carbon_parameters=default_carbon_params, + CBOD_parameters=default_CBOD_params, + DOX_parameters=default_DOX_params, + N2_parameters=default_N2_params, + POM_parameters=default_POM_params, + pathogen_parameters=default_pathogen_params, + phosphorus_parameters=default_phosphorus_params, + global_parameters=default_gp_params, + global_vars=default_gvars_params, + time_dim='nsm1_time_step', + ) + +@pytest.fixture(scope='module') +def tolerance() -> float: + """Controls the precision of the pytest.approx() function.""" + return 0.000001 + +def test_defaults( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + PathogenDeath = nsm1.dataset.isel(nsm1_time_step=-1).PathogenDeath.item() + assert isinstance(PathogenDeath, float) + print("POM_algal_settling",PathogenDeath) + + PathogenDecay = nsm1.dataset.isel(nsm1_time_step=-1).PathogenDecay.item() + assert isinstance(PathogenDecay, float) + print("PathogenDecay",PathogenDecay) + + PathogenSettling = nsm1.dataset.isel(nsm1_time_step=-1).PathogenSettling.item() + assert isinstance(PathogenSettling, float) + print("PathogenSettling",PathogenSettling) + + L = nsm1.dataset.isel(nsm1_time_step=-1).L.item() + assert isinstance(L, float) + print("L",L) + + + PX = nsm1.dataset.isel(nsm1_time_step=-1).PX.values.item() + + assert isinstance(PX, float) + assert pytest.approx(PX, tolerance) == -493.363148909424 + + +''' +def test_change_kop( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_phosphorus_params['kop_20'] = 0.2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.1309587507 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.233864988 +''' From de545460d3c855f670b8b6ed24a797139649b73b Mon Sep 17 00:00:00 2001 From: kewalak Date: Wed, 24 Jul 2024 08:53:46 -0700 Subject: [PATCH 3/9] Test POM Update --- tests/test_15_nsm_POM_calculations.py | 722 +++++++++++++++++++++++++- 1 file changed, 696 insertions(+), 26 deletions(-) diff --git a/tests/test_15_nsm_POM_calculations.py b/tests/test_15_nsm_POM_calculations.py index dffd8f1..292b372 100644 --- a/tests/test_15_nsm_POM_calculations.py +++ b/tests/test_15_nsm_POM_calculations.py @@ -406,35 +406,612 @@ def test_defaults( # Run the model nsm1.increment_timestep() - POM_algal_settling = nsm1.dataset.isel(nsm1_time_step=-1).POM_algal_settling.values.item() - assert isinstance(POM_algal_settling, float) - print("POM_algal_settling",POM_algal_settling) + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 22.49917766047 + +def test_kpom_20( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_POM_params['kpom_20'] = 0.002 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 23.732167461065 + +def test_TwaterC( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['TwaterC'] = 10 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 19.0663938058932 + +def test_vb( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['vb'] = 0.002 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 23.29917766047 + +def test_h2( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_POM_params['h2'] = 0.5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 11.493313245894 + +def test_vsap( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_algae_params['vsap'] = 0.5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 35.36867766047 + +def test_Ap( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['Ap'] = 50 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 24.48367766047 + +def test_Fb( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['Fb'] = 0.2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 16.15808725741 + +def test_Fw( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['Fw'] = 0.97 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 16.792196297716 + +def test_vsoc( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['vsoc'] = 0.005 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 21.95467766047 + +def test_POC( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['POC'] = 2 - POM_dissolution = nsm1.dataset.isel(nsm1_time_step=-1).POM_dissolution.values.item() - assert isinstance(POM_dissolution, float) - print("POM_dissolution",POM_dissolution) + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() - POM_POC_settling = nsm1.dataset.isel(nsm1_time_step=-1).POM_POC_settling.values.item() - assert isinstance(POM_POC_settling, float) - print("POM_POC_settling",POM_POC_settling) + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() - POM_benthic_algae_mortality = nsm1.dataset.isel(nsm1_time_step=-1).POM_benthic_algae_mortality.values.item() - assert isinstance(POM_benthic_algae_mortality, float) - print("POM_benthic_algae_mortality",POM_benthic_algae_mortality) + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 21.91017766047 - POM_burial = nsm1.dataset.isel(nsm1_time_step=-1).POM_burial.values.item() - assert isinstance(POM_burial, float) - print("POM_burial",POM_burial) +def test_fcom( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['fcom'] = 0.2 + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() assert isinstance(POM, float) - assert pytest.approx(POM, tolerance) == 22.49917766047 + assert pytest.approx(POM, tolerance) == 23.58817766047 + +def test_POM( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['POM'] = 5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 18.628254089345 -''' -def test_change_kop( +def test_use_Algae( time_steps, initial_nsm1_state, default_algae_params, @@ -455,7 +1032,7 @@ def test_change_kop( """Test the model with default parameters.""" # alter parameters as necessary initial_state_dict = initial_nsm1_state - default_phosphorus_params['kop_20'] = 0.2 + default_gp_params['use_Algae'] = False # instantiate the model nsm1: NutrientBudget = get_nutrient_budget_instance( @@ -476,17 +1053,110 @@ def test_change_kop( default_gvars_params=default_gvars_params ) + # Run the model + nsm1.increment_timestep() + + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 16.98367766047 + +def test_use_Balgae( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_Balgae'] = False + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + # Run the model nsm1.increment_timestep() - TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() + + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 14.34634714225 + +def test_use_POC( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_POC'] = False - assert isinstance(TIP, float) - assert pytest.approx(TIP, tolerance) == 0.1309587507 + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() - OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + POM = nsm1.dataset.isel(nsm1_time_step=-1).POM.values.item() - assert isinstance(OrgP, float) - assert pytest.approx(OrgP, tolerance) == 0.233864988 -''' + assert isinstance(POM, float) + assert pytest.approx(POM, tolerance) == 21.41017766047 \ No newline at end of file From 98c734d9727f8aaf084c430a55a50c00fcb515fa Mon Sep 17 00:00:00 2001 From: kewalak Date: Wed, 31 Jul 2024 10:15:17 -0700 Subject: [PATCH 4/9] One working N2 Test --- src/clearwater_modules/nsm1/processes.py | 12 +- tests/test_16_nsm_N2_calculations.py | 491 +++++++++++++++++++++++ 2 files changed, 496 insertions(+), 7 deletions(-) create mode 100644 tests/test_16_nsm_N2_calculations.py diff --git a/src/clearwater_modules/nsm1/processes.py b/src/clearwater_modules/nsm1/processes.py index 4d8a65c..8ecdea6 100644 --- a/src/clearwater_modules/nsm1/processes.py +++ b/src/clearwater_modules/nsm1/processes.py @@ -7,7 +7,7 @@ ############################################ From shared processes def celsius_to_kelvin(tempc: xr.DataArray) -> xr.DataArray: - return tempc + 273.16 + return tempc + 273.15 @@ -115,16 +115,14 @@ def kah_20( def kah_tc( TwaterC: xr.DataArray, kah_20: xr.DataArray, - theta: xr.DataArray ) -> xr.DataArray: """Calculate the temperature adjusted hydraulic oxygen reaeration rate (/d) Args: TwaterC: Water temperature in Celsius kah_20: Hydraulic oxygen reaeration rate at 20 degrees Celsius - theta: Arrhenius coefficient """ - return arrhenius_correction(TwaterC, kah_20, theta) + return arrhenius_correction(TwaterC, kah_20, 1.024) def kaw_20( @@ -191,16 +189,16 @@ def kaw_20( def kaw_tc( TwaterC: xr.DataArray, kaw_20: xr.DataArray, - theta: xr.DataArray + ) -> xr.DataArray: """Calculate the temperature adjusted wind oxygen reaeration velocity (m/d) Args: water_temp_c: Water temperature in Celsius kaw_20: Wind oxygen reaeration velocity at 20 degrees Celsius - theta: Arrhenius coefficient + """ - return arrhenius_correction(TwaterC, kaw_20, theta) + return arrhenius_correction(TwaterC, kaw_20, 1.024) diff --git a/tests/test_16_nsm_N2_calculations.py b/tests/test_16_nsm_N2_calculations.py new file mode 100644 index 0000000..c39d40c --- /dev/null +++ b/tests/test_16_nsm_N2_calculations.py @@ -0,0 +1,491 @@ +from numba import ( + types, + typed, +) +import pytest + +from clearwater_modules.nsm1 import NutrientBudget +from clearwater_modules.nsm1.constants import ( + AlgaeStaticVariables, + AlkalinityStaticVariables, + BalgaeStaticVariables, + NitrogenStaticVariables, + CarbonStaticVariables, + CBODStaticVariables, + DOXStaticVariables, + N2StaticVariables, + POMStaticVariables, + PathogenStaticVariables, + PhosphorusStaticVariables, + GlobalParameters, + GlobalVars +) + + +@pytest.fixture(scope='function') +def initial_nsm1_state() -> dict[str, float]: + """Return initial state values for the model.""" + return { + + 'Ap': 36.77, + 'Ab': 24, + 'NH4': 0.063, + 'NO3': 5.54, + 'OrgN': 1.726, + 'N2': 1, + 'TIP': 0.071, + 'OrgP': 0.24, + 'POC': 4.356, + 'DOC': 1, + 'DIC': 1, + 'POM': 10, + 'CBOD': 5, + 'DOX': 8, + 'PX': 1, + 'Alk': 1 + + } + +@pytest.fixture(scope='module') +def time_steps() -> int: + return 1 + +@pytest.fixture(scope='function') +def default_algae_params() -> AlgaeStaticVariables: + """Returns default algae static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return AlgaeStaticVariables( + AWd = 100, + AWc= 40, + AWn= 7.2, + AWp= 1, + AWa= 1000, + KL= 10, + KsN= 0.04, + KsP= 0.0012, + mu_max_20= 1, + kdp_20= 0.15, + krp_20= 0.2, + vsap= 0.15, + growth_rate_option = 1, + light_limitation_option = 1, + ) + +@pytest.fixture(scope='function') +def default_alkalinity_params() -> AlkalinityStaticVariables: + """Returns default alkalinity static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return AlkalinityStaticVariables( + r_alkaa = 14.0 / 106.0 / 12.0 / 1000.0, + r_alkan= 18.0 / 106.0 / 12.0 / 1000.0, + r_alkn = 2.0 / 14.0 / 1000.0, + r_alkden = 4.0 / 14.0 / 1000.0, + r_alkba = 14.0 / 106.0 / 12.0 / 1000.0, + r_alkbn =18.0 / 106.0 / 12.0 / 1000.0 + ) + +@pytest.fixture(scope='function') +def default_balgae_params() -> BalgaeStaticVariables: + """Returns default Benthic Algae static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return BalgaeStaticVariables( + BWd = 100, + BWc= 40, + BWn=7.2, + BWp= 1, + BWa= 5000, + KLb= 10, + KsNb= 0.25, + KsPb=0.125, + Ksb=10, + mub_max_20=0.4, + krb_20=0.2, + kdb_20=0.3, + b_growth_rate_option=1, + b_light_limitation_option=1, + Fw=0.9, + Fb=0.9 + ) + +@pytest.fixture(scope='function') +def default_nitrogen_params() -> NitrogenStaticVariables: + """Returns default nitrogen static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return NitrogenStaticVariables( + KNR= 0.6 , + knit_20= 0.1, + kon_20=0.1, + kdnit_20=0.002, + rnh4_20=0, + vno3_20=0, + KsOxdn=0.1, + PN=0.5, + PNb=0.5 + ) + +@pytest.fixture(scope='function') +def default_carbon_params() -> CarbonStaticVariables: + """Returns default carbon static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return CarbonStaticVariables( + f_pocp = 0.9, + kdoc_20= 0.01, + f_pocb=0.9, + kpoc_20= 0.005, + KsOxmc=1.0, + pCO2 = 383.0, + FCO2 = 0.2, + roc = 32.0/12.0 + ) + +@pytest.fixture(scope='function') +def default_CBOD_params() -> CBODStaticVariables: + """Returns default CBOD static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return CBODStaticVariables( + KsOxbod = 0.5, + kbod_20 = 0.12, + ksbod_20 = 0.0 + ) + +@pytest.fixture(scope='function') +def default_DOX_params() -> DOXStaticVariables: + """Returns default DOX static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return DOXStaticVariables( + ron = 2.0 * 32.0 / 14.0, + KsSOD =1, + ) + +@pytest.fixture(scope='function') +def default_N2_params() -> N2StaticVariables: + """Returns default N2 static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return N2StaticVariables( + + ) + +@pytest.fixture(scope='function') +def default_POM_params() -> POMStaticVariables: + """Returns default POM static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return POMStaticVariables( + kpom_20 = 0.1, + h2 = 0.1 + ) + +@pytest.fixture(scope='function') +def default_pathogen_params() -> PathogenStaticVariables: + """Returns default Pathogens static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return PathogenStaticVariables( + kdx_20=0.8, + apx=1, + vx=1 + ) + +@pytest.fixture(scope='function') +def default_phosphorus_params() -> PhosphorusStaticVariables: + """Returns default phosphorus static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return PhosphorusStaticVariables( + kop_20 = 0.1, + rpo4_20 =0, + kdpo4 = 0.0, + ) + +@pytest.fixture(scope='function') +def default_gp_params() -> GlobalParameters: + """Returns default global parameter static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return GlobalParameters( + use_NH4= False, + use_NO3= False, + use_OrgN= False, + use_OrgP = False, + use_TIP= False, + use_SedFlux= False, + use_POC = False, + use_DOC = False, + use_DOX= True, + use_DIC= False, + use_Algae= False, + use_Balgae= False, + use_N2 = True, + use_Pathogen = False, + use_Alk = False, + use_POM = False + ) + +@pytest.fixture(scope='function') +def default_gvars_params() -> GlobalVars: + """Returns default global variables static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return GlobalVars( + vson = 0.01, + vsoc = 0.01, + vsop = 0.01, + vs = 1, + SOD_20 = 999, + SOD_theta = 999, + vb = 0.01, + fcom = 0.4, + kaw_20_user = 0, + kah_20_user = 1, + hydraulic_reaeration_option = 1, + wind_reaeration_option = 1, + timestep = 1, #TODO Dynamic or static? + depth = 1.5, #TODO Dynamic or static? + TwaterC = 25, + theta = 1.047, + velocity = 1, + flow = 150, + topwidth = 100, + slope = 0.0002, + shear_velocity = 0.05334, + pressure_atm = 1, + wind_speed = 3, + q_solar = 500, + Solid = 1, + lambda0 = .02, + lambda1 = .0088, + lambda2 = .054, + lambdas = .052, + lambdam = .174, + Fr_PAR = .47 + ) + +def get_nutrient_budget_instance( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + +) -> NutrientBudget: + """Return an instance of the NSM1 class.""" + return NutrientBudget( + time_steps=time_steps, + initial_state_values=initial_nsm1_state, + algae_parameters=default_algae_params, + alkalinity_parameters=default_alkalinity_params, + balgae_parameters=default_balgae_params, + nitrogen_parameters=default_nitrogen_params, + carbon_parameters=default_carbon_params, + CBOD_parameters=default_CBOD_params, + DOX_parameters=default_DOX_params, + N2_parameters=default_N2_params, + POM_parameters=default_POM_params, + pathogen_parameters=default_pathogen_params, + phosphorus_parameters=default_phosphorus_params, + global_parameters=default_gp_params, + global_vars=default_gvars_params, + time_dim='nsm1_time_step', + ) + +@pytest.fixture(scope='module') +def tolerance() -> float: + """Controls the precision of the pytest.approx() function.""" + return 0.000001 + +def test_defaults( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + ka_tc = nsm1.dataset.isel(nsm1_time_step=-1).ka_tc.item() + assert isinstance(ka_tc, float) + print("ka_tc",ka_tc) + + N2sat = nsm1.dataset.isel(nsm1_time_step=-1).N2sat.item() + assert isinstance(N2sat, float) + print("N2sat",N2sat) + + KHN2_tc = nsm1.dataset.isel(nsm1_time_step=-1).KHN2_tc.item() + assert isinstance(KHN2_tc, float) + print("KHN2_tc",KHN2_tc) + + P_wv = nsm1.dataset.isel(nsm1_time_step=-1).P_wv.item() + assert isinstance(P_wv, float) + print("P_wv",P_wv) + + TwaterK = nsm1.dataset.isel(nsm1_time_step=-1).TwaterK.item() + assert isinstance(TwaterK, float) + print("TwaterK",TwaterK) + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 16.0511281 + + +''' +def test_change_kop( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_phosphorus_params['kop_20'] = 0.2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + + # Run the model + nsm1.increment_timestep() + + TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + + assert isinstance(TIP, float) + assert pytest.approx(TIP, tolerance) == 0.1309587507 + + OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + + assert isinstance(OrgP, float) + assert pytest.approx(OrgP, tolerance) == 0.233864988 +''' From 78a59a9c1e125fc14e38306372945b1928833126 Mon Sep 17 00:00:00 2001 From: kewalak Date: Wed, 31 Jul 2024 12:56:08 -0700 Subject: [PATCH 5/9] Test Suit Added back in algae, balgae, and nitogen. Adapted all tests to new theta variable. One failing test change kbod in Carbon and Alkalinity. Incomplete suit for PX and N2. Questions on DOX_Sat concentration. --- src/clearwater_modules/nsm1/constants.py | 26 +- .../nsm1/dynamic_variables.py | 8 - src/clearwater_modules/nsm1/processes.py | 29 +- tests/test_14_nsm_phosphrous_calculations.py | 43 +- tests/test_15_nsm_POM_calculations.py | 45 +- tests/test_16_nsm_PX_calculations.py | 44 +- ...ions.py => test_17_nsm_N2_calculations.py} | 67 +- tests/test_7_nsm_algae_calculations.py | 66 +- tests/test_8_nsm_balgae_calculations.py | 2006 +++++++++++++++++ tests/test_9_nsm_nitrogen_calculations.py | 1997 ++++++++++++++++ 10 files changed, 4210 insertions(+), 121 deletions(-) rename tests/{test_16_nsm_N2_calculations.py => test_17_nsm_N2_calculations.py} (91%) create mode 100644 tests/test_8_nsm_balgae_calculations.py create mode 100644 tests/test_9_nsm_nitrogen_calculations.py diff --git a/src/clearwater_modules/nsm1/constants.py b/src/clearwater_modules/nsm1/constants.py index 3452bc5..28950c3 100644 --- a/src/clearwater_modules/nsm1/constants.py +++ b/src/clearwater_modules/nsm1/constants.py @@ -98,7 +98,7 @@ class BalgaeStaticVariables(TypedDict): krb_20=0.2, kdb_20=0.3, mub_max_theta = 1.047, - krb_theta = 1.047, + krb_theta = 1.06, kdb_theta = 1.047, b_growth_rate_option=1, b_light_limitation_option=1, @@ -130,11 +130,11 @@ class NitrogenStaticVariables(TypedDict): kdnit_20=0.002, rnh4_20=0, vno3_20=0, - knit_theta= 1.047, ## Check values RAS/Kelsey's - kon_theta= 1.047, - kdnit_theta= 1.047, + knit_theta= 1.083, + kon_theta= 1.074, + kdnit_theta= 1.08, rnh4_theta= 1.047, - vno3_theta= 1.047, + vno3_theta= 1.045, KsOxdn=0.1, PN=0.5, PNb=0.5 @@ -156,10 +156,10 @@ class CarbonStaticVariables(TypedDict): DEFAULT_CARBON = CarbonStaticVariables( f_pocp = 0.9, kdoc_20= 0.01, - kdoc_theta = 1.047, f_pocb=0.9, kpoc_20= 0.005, kpoc_theta = 1.047, + kdoc_theta = 1.047, KsOxmc=1.0, pCO2 = 383.0, FCO2 = 0.2, @@ -218,7 +218,7 @@ class PathogenStaticVariables(TypedDict): DEFAULT_PATHOGEN = PathogenStaticVariables( kdx_20=0.8, - kdx_theta = 1.047, + kdx_theta = 1.07, apx=1, vx=1 ) @@ -234,7 +234,7 @@ class PhosphorusStaticVariables(TypedDict): kop_20 = 0.1, rpo4_20 =0, kop_theta = 1.047, - rpo4_theta = 1.047, + rpo4_theta = 1.074, kdpo4 = 0.0, ) @@ -321,18 +321,18 @@ class GlobalVars(TypedDict): vs = 999, SOD_20 = 999, SOD_theta = 999, + theta=1.047, vb = 0.01, fcom = 0.4, kaw_20_user = 999, kah_20_user = 999, - kaw_theta = 1.047, - kah_theta = 1.047, - hydraulic_reaeration_option = 2, - wind_reaeration_option = 2, + kaw_theta = 1.024, + kah_theta = 1.024, + hydraulic_reaeration_option = 1, + wind_reaeration_option = 1, dt = 1, #TODO Dynamic or static? depth = 1.5, #TODO Dynamic or static? TwaterC = 20, - theta = 1.047, velocity = 1, flow = 2, topwidth = 1, diff --git a/src/clearwater_modules/nsm1/dynamic_variables.py b/src/clearwater_modules/nsm1/dynamic_variables.py index 6d925ef..686da5c 100644 --- a/src/clearwater_modules/nsm1/dynamic_variables.py +++ b/src/clearwater_modules/nsm1/dynamic_variables.py @@ -1371,14 +1371,6 @@ class Variable(base.Variable): process=processes.KHN2_tc ) -Variable( - name='P_wv', - long_name='Partial pressure water vapor', - units='atm', - description='Partial pressure water vapor', - use='dynamic', - process=processes.P_wv -) Variable( name='N2sat', diff --git a/src/clearwater_modules/nsm1/processes.py b/src/clearwater_modules/nsm1/processes.py index c8d85bc..4965864 100644 --- a/src/clearwater_modules/nsm1/processes.py +++ b/src/clearwater_modules/nsm1/processes.py @@ -12,7 +12,7 @@ def celsius_to_kelvin(tempc: xr.DataArray) -> xr.DataArray: def kelvin_to_celsius(tempk: xr.DataArray) -> xr.DataArray: - return tempk - 273.16 + return tempk - 273.15 def arrhenius_correction( @@ -1512,6 +1512,8 @@ def NH4_ApGrowth( def NH4_AbRespiration( use_Balgae: bool, rnb: xr.DataArray, + Fb: xr.DataArray, + depth: xr.DataArray, AbRespiration: xr.DataArray, ) -> xr.DataArray: @@ -1521,10 +1523,12 @@ def NH4_AbRespiration( use_Balgae: true/false to use benthic algae module (unitless), rnb: xr.DataArray, AbRespiration: Benthic algal respiration rate (g/m^2/d), + depth: water depth (m), + Fb: Fraction of bottom area for benthic algae (unitless), """ # TODO changed the calculation for respiration from the inital FORTRAN due to conflict with the reference guide - return xr.where(use_Balgae, rnb * AbRespiration, 0.0 ) + return xr.where(use_Balgae, (rnb * AbRespiration*Fb)/depth, 0.0 ) def NH4_AbGrowth( use_Balgae: bool, @@ -3469,25 +3473,10 @@ def KHN2_tc( return 0.00065 * np.exp(1300.0 * (1.0 / TwaterK - 1 / 298.15)) -def P_wv( - TwaterK : xr.DataArray, -) -> xr.DataArray : - - """Calculate partial pressure water vapor (atm) - - Constant values found in documentation - - Args: - TwaterK: water temperature kelvin (K) - - """ - return np.exp(11.8571 - (3840.70 / TwaterK) - (216961.0 / (TwaterK**2))) - - def N2sat( KHN2_tc : xr.DataArray, pressure_atm: xr.DataArray, - P_wv: xr.DataArray + pwv: xr.DataArray ) -> xr.DataArray: """Calculate N2 at saturation f(Twater and atm pressure) (mg-N/L) @@ -3495,10 +3484,10 @@ def N2sat( Args: KHN2_tc: Henry's law constant (mol/L/atm) pressure_atm: atmosphric pressure in atm (atm) - P_wv: Partial pressure of water vapor (atm) + pwv: Partial pressure of water vapor (atm) """ - N2sat = 2.8E+4 * KHN2_tc * 0.79 * (pressure_atm - P_wv) + N2sat = 2.8E+4 * KHN2_tc * 0.79 * (pressure_atm - pwv) N2sat = xr.where(N2sat < 0.0,0.000001,N2sat) #Trap saturation concentration to ensure never negative return N2sat diff --git a/tests/test_14_nsm_phosphrous_calculations.py b/tests/test_14_nsm_phosphrous_calculations.py index 287f1cd..66a0d30 100644 --- a/tests/test_14_nsm_phosphrous_calculations.py +++ b/tests/test_14_nsm_phosphrous_calculations.py @@ -74,6 +74,9 @@ def default_algae_params() -> AlgaeStaticVariables: vsap= 0.15, growth_rate_option = 1, light_limitation_option = 1, + mu_max_theta= 1.047, + kdp_theta= 1.047, + krp_theta= 1.047, ) @pytest.fixture(scope='function') @@ -119,7 +122,10 @@ def default_balgae_params() -> BalgaeStaticVariables: b_growth_rate_option=1, b_light_limitation_option=1, Fw=0.9, - Fb=0.9 + Fb=0.9, + mub_max_theta = 1.047, + krb_theta = 1.06, + kdb_theta = 1.047, ) @pytest.fixture(scope='function') @@ -140,7 +146,12 @@ def default_nitrogen_params() -> NitrogenStaticVariables: vno3_20=0, KsOxdn=0.1, PN=0.5, - PNb=0.5 + PNb=0.5, + knit_theta= 1.083, + kon_theta= 1.047, + kdnit_theta= 1.045, + rnh4_theta= 1.074, + vno3_theta= 1.08, ) @pytest.fixture(scope='function') @@ -160,7 +171,9 @@ def default_carbon_params() -> CarbonStaticVariables: KsOxmc=1.0, pCO2 = 383.0, FCO2 = 0.2, - roc = 32.0/12.0 + roc = 32.0/12.0, + kpoc_theta = 1.047, + kdoc_theta = 1.047, ) @pytest.fixture(scope='function') @@ -175,7 +188,9 @@ def default_CBOD_params() -> CBODStaticVariables: return CBODStaticVariables( KsOxbod = 0.5, kbod_20 = 0.12, - ksbod_20 = 0.0 + ksbod_20 = 0.0, + kbod_theta = 1.047, + ksbod_theta = 1.047 ) @pytest.fixture(scope='function') @@ -215,7 +230,9 @@ def default_POM_params() -> POMStaticVariables: Returns a typed dictionary, with string keys and float values. """ return POMStaticVariables( - kpom_20 = 0.1 + kpom_20 = 0.1, + h2 = 0.1, + kpom_theta = 1.047 ) @pytest.fixture(scope='function') @@ -230,7 +247,8 @@ def default_pathogen_params() -> PathogenStaticVariables: return PathogenStaticVariables( kdx_20=0.8, apx=1, - vx=1 + vx=1, + kdx_theta = 1.07, ) @pytest.fixture(scope='function') @@ -246,6 +264,8 @@ def default_phosphorus_params() -> PhosphorusStaticVariables: kop_20 = 0.1, rpo4_20 =0, kdpo4 = 0.0, + kop_theta = 1.047, + rpo4_theta = 1.074, ) @pytest.fixture(scope='function') @@ -294,14 +314,15 @@ def default_gvars_params() -> GlobalVars: SOD_theta = 999, vb = 0.01, fcom = 0.4, - kaw_20_user = 999, - kah_20_user = 999, - hydraulic_reaeration_option = 2, - wind_reaeration_option = 2, + kaw_20_user = 0, + kah_20_user = 1, + hydraulic_reaeration_option = 1, + wind_reaeration_option = 1, timestep = 1, #TODO Dynamic or static? depth = 1.5, #TODO Dynamic or static? TwaterC = 25, - theta = 1.047, + kaw_theta = 1.024, + kah_theta = 1.024, velocity = 1, flow = 150, topwidth = 100, diff --git a/tests/test_15_nsm_POM_calculations.py b/tests/test_15_nsm_POM_calculations.py index 292b372..96f5565 100644 --- a/tests/test_15_nsm_POM_calculations.py +++ b/tests/test_15_nsm_POM_calculations.py @@ -34,7 +34,7 @@ def initial_nsm1_state() -> dict[str, float]: 'OrgN': 1.726, 'N2': 1, 'TIP': 0.071, - 'OrgP': 0.24, + 'OrgP': 0.25, 'POC': 4.356, 'DOC': 1, 'DIC': 1, @@ -74,6 +74,9 @@ def default_algae_params() -> AlgaeStaticVariables: vsap= 0.15, growth_rate_option = 1, light_limitation_option = 1, + mu_max_theta= 1.047, + kdp_theta= 1.047, + krp_theta= 1.047, ) @pytest.fixture(scope='function') @@ -119,7 +122,10 @@ def default_balgae_params() -> BalgaeStaticVariables: b_growth_rate_option=1, b_light_limitation_option=1, Fw=0.9, - Fb=0.9 + Fb=0.9, + mub_max_theta = 1.047, + krb_theta = 1.06, + kdb_theta = 1.047, ) @pytest.fixture(scope='function') @@ -140,7 +146,12 @@ def default_nitrogen_params() -> NitrogenStaticVariables: vno3_20=0, KsOxdn=0.1, PN=0.5, - PNb=0.5 + PNb=0.5, + knit_theta= 1.083, + kon_theta= 1.047, + kdnit_theta= 1.045, + rnh4_theta= 1.074, + vno3_theta= 1.08, ) @pytest.fixture(scope='function') @@ -160,7 +171,9 @@ def default_carbon_params() -> CarbonStaticVariables: KsOxmc=1.0, pCO2 = 383.0, FCO2 = 0.2, - roc = 32.0/12.0 + roc = 32.0/12.0, + kpoc_theta = 1.047, + kdoc_theta = 1.047, ) @pytest.fixture(scope='function') @@ -175,7 +188,9 @@ def default_CBOD_params() -> CBODStaticVariables: return CBODStaticVariables( KsOxbod = 0.5, kbod_20 = 0.12, - ksbod_20 = 0.0 + ksbod_20 = 0.0, + kbod_theta = 1.047, + ksbod_theta = 1.047 ) @pytest.fixture(scope='function') @@ -216,7 +231,8 @@ def default_POM_params() -> POMStaticVariables: """ return POMStaticVariables( kpom_20 = 0.1, - h2 = 0.1 + h2 = 0.1, + kpom_theta = 1.047 ) @pytest.fixture(scope='function') @@ -231,7 +247,8 @@ def default_pathogen_params() -> PathogenStaticVariables: return PathogenStaticVariables( kdx_20=0.8, apx=1, - vx=1 + vx=1, + kdx_theta = 1.07, ) @pytest.fixture(scope='function') @@ -247,8 +264,9 @@ def default_phosphorus_params() -> PhosphorusStaticVariables: kop_20 = 0.1, rpo4_20 =0, kdpo4 = 0.0, + kop_theta = 1.047, + rpo4_theta = 1.074, ) - @pytest.fixture(scope='function') def default_gp_params() -> GlobalParameters: """Returns default global parameter static variable values for the model. @@ -295,14 +313,15 @@ def default_gvars_params() -> GlobalVars: SOD_theta = 999, vb = 0.01, fcom = 0.4, - kaw_20_user = 999, - kah_20_user = 999, - hydraulic_reaeration_option = 2, - wind_reaeration_option = 2, + kaw_20_user = 0, + kah_20_user = 1, + hydraulic_reaeration_option = 1, + wind_reaeration_option = 1, timestep = 1, #TODO Dynamic or static? depth = 1.5, #TODO Dynamic or static? TwaterC = 25, - theta = 1.047, + kaw_theta = 1.024, + kah_theta = 1.024, velocity = 1, flow = 150, topwidth = 100, diff --git a/tests/test_16_nsm_PX_calculations.py b/tests/test_16_nsm_PX_calculations.py index c5e2ef4..aaaf027 100644 --- a/tests/test_16_nsm_PX_calculations.py +++ b/tests/test_16_nsm_PX_calculations.py @@ -34,7 +34,7 @@ def initial_nsm1_state() -> dict[str, float]: 'OrgN': 1.726, 'N2': 1, 'TIP': 0.071, - 'OrgP': 0.24, + 'OrgP': 0.25, 'POC': 4.356, 'DOC': 1, 'DIC': 1, @@ -74,6 +74,9 @@ def default_algae_params() -> AlgaeStaticVariables: vsap= 0.15, growth_rate_option = 1, light_limitation_option = 1, + mu_max_theta= 1.047, + kdp_theta= 1.047, + krp_theta= 1.047, ) @pytest.fixture(scope='function') @@ -119,7 +122,10 @@ def default_balgae_params() -> BalgaeStaticVariables: b_growth_rate_option=1, b_light_limitation_option=1, Fw=0.9, - Fb=0.9 + Fb=0.9, + mub_max_theta = 1.047, + krb_theta = 1.06, + kdb_theta = 1.047, ) @pytest.fixture(scope='function') @@ -140,7 +146,12 @@ def default_nitrogen_params() -> NitrogenStaticVariables: vno3_20=0, KsOxdn=0.1, PN=0.5, - PNb=0.5 + PNb=0.5, + knit_theta= 1.083, + kon_theta= 1.047, + kdnit_theta= 1.045, + rnh4_theta= 1.074, + vno3_theta= 1.08, ) @pytest.fixture(scope='function') @@ -160,7 +171,9 @@ def default_carbon_params() -> CarbonStaticVariables: KsOxmc=1.0, pCO2 = 383.0, FCO2 = 0.2, - roc = 32.0/12.0 + roc = 32.0/12.0, + kpoc_theta = 1.047, + kdoc_theta = 1.047, ) @pytest.fixture(scope='function') @@ -175,7 +188,9 @@ def default_CBOD_params() -> CBODStaticVariables: return CBODStaticVariables( KsOxbod = 0.5, kbod_20 = 0.12, - ksbod_20 = 0.0 + ksbod_20 = 0.0, + kbod_theta = 1.047, + ksbod_theta = 1.047 ) @pytest.fixture(scope='function') @@ -216,7 +231,8 @@ def default_POM_params() -> POMStaticVariables: """ return POMStaticVariables( kpom_20 = 0.1, - h2 = 0.1 + h2 = 0.1, + kpom_theta = 1.047 ) @pytest.fixture(scope='function') @@ -231,7 +247,8 @@ def default_pathogen_params() -> PathogenStaticVariables: return PathogenStaticVariables( kdx_20=0.8, apx=1, - vx=1 + vx=1, + kdx_theta = 1.07, ) @pytest.fixture(scope='function') @@ -247,6 +264,8 @@ def default_phosphorus_params() -> PhosphorusStaticVariables: kop_20 = 0.1, rpo4_20 =0, kdpo4 = 0.0, + kop_theta = 1.047, + rpo4_theta = 1.074, ) @pytest.fixture(scope='function') @@ -295,14 +314,15 @@ def default_gvars_params() -> GlobalVars: SOD_theta = 999, vb = 0.01, fcom = 0.4, - kaw_20_user = 999, - kah_20_user = 999, - hydraulic_reaeration_option = 2, - wind_reaeration_option = 2, + kaw_20_user = 0, + kah_20_user = 1, + hydraulic_reaeration_option = 1, + wind_reaeration_option = 1, timestep = 1, #TODO Dynamic or static? depth = 1.5, #TODO Dynamic or static? TwaterC = 25, - theta = 1.047, + kaw_theta = 1.024, + kah_theta = 1.024, velocity = 1, flow = 150, topwidth = 100, diff --git a/tests/test_16_nsm_N2_calculations.py b/tests/test_17_nsm_N2_calculations.py similarity index 91% rename from tests/test_16_nsm_N2_calculations.py rename to tests/test_17_nsm_N2_calculations.py index c39d40c..47a6ef4 100644 --- a/tests/test_16_nsm_N2_calculations.py +++ b/tests/test_17_nsm_N2_calculations.py @@ -34,7 +34,7 @@ def initial_nsm1_state() -> dict[str, float]: 'OrgN': 1.726, 'N2': 1, 'TIP': 0.071, - 'OrgP': 0.24, + 'OrgP': 0.25, 'POC': 4.356, 'DOC': 1, 'DIC': 1, @@ -74,6 +74,9 @@ def default_algae_params() -> AlgaeStaticVariables: vsap= 0.15, growth_rate_option = 1, light_limitation_option = 1, + mu_max_theta= 1.047, + kdp_theta= 1.047, + krp_theta= 1.047, ) @pytest.fixture(scope='function') @@ -119,7 +122,10 @@ def default_balgae_params() -> BalgaeStaticVariables: b_growth_rate_option=1, b_light_limitation_option=1, Fw=0.9, - Fb=0.9 + Fb=0.9, + mub_max_theta = 1.047, + krb_theta = 1.06, + kdb_theta = 1.047, ) @pytest.fixture(scope='function') @@ -140,7 +146,12 @@ def default_nitrogen_params() -> NitrogenStaticVariables: vno3_20=0, KsOxdn=0.1, PN=0.5, - PNb=0.5 + PNb=0.5, + knit_theta= 1.083, + kon_theta= 1.047, + kdnit_theta= 1.045, + rnh4_theta= 1.074, + vno3_theta= 1.08, ) @pytest.fixture(scope='function') @@ -160,7 +171,9 @@ def default_carbon_params() -> CarbonStaticVariables: KsOxmc=1.0, pCO2 = 383.0, FCO2 = 0.2, - roc = 32.0/12.0 + roc = 32.0/12.0, + kpoc_theta = 1.047, + kdoc_theta = 1.047, ) @pytest.fixture(scope='function') @@ -175,7 +188,9 @@ def default_CBOD_params() -> CBODStaticVariables: return CBODStaticVariables( KsOxbod = 0.5, kbod_20 = 0.12, - ksbod_20 = 0.0 + ksbod_20 = 0.0, + kbod_theta = 1.047, + ksbod_theta = 1.047 ) @pytest.fixture(scope='function') @@ -216,7 +231,8 @@ def default_POM_params() -> POMStaticVariables: """ return POMStaticVariables( kpom_20 = 0.1, - h2 = 0.1 + h2 = 0.1, + kpom_theta = 1.047 ) @pytest.fixture(scope='function') @@ -231,7 +247,8 @@ def default_pathogen_params() -> PathogenStaticVariables: return PathogenStaticVariables( kdx_20=0.8, apx=1, - vx=1 + vx=1, + kdx_theta = 1.07, ) @pytest.fixture(scope='function') @@ -247,6 +264,8 @@ def default_phosphorus_params() -> PhosphorusStaticVariables: kop_20 = 0.1, rpo4_20 =0, kdpo4 = 0.0, + kop_theta = 1.047, + rpo4_theta = 1.074, ) @pytest.fixture(scope='function') @@ -302,7 +321,8 @@ def default_gvars_params() -> GlobalVars: timestep = 1, #TODO Dynamic or static? depth = 1.5, #TODO Dynamic or static? TwaterC = 25, - theta = 1.047, + kaw_theta = 1.024, + kah_theta = 1.024, velocity = 1, flow = 150, topwidth = 100, @@ -405,33 +425,36 @@ def test_defaults( # Run the model nsm1.increment_timestep() - + + ka_tc = nsm1.dataset.isel(nsm1_time_step=-1).ka_tc.item() assert isinstance(ka_tc, float) print("ka_tc",ka_tc) - N2sat = nsm1.dataset.isel(nsm1_time_step=-1).N2sat.item() - assert isinstance(N2sat, float) - print("N2sat",N2sat) - KHN2_tc = nsm1.dataset.isel(nsm1_time_step=-1).KHN2_tc.item() - assert isinstance(KHN2_tc, float) - print("KHN2_tc",KHN2_tc) + pwv = nsm1.dataset.isel(nsm1_time_step=-1).pwv.item() + assert isinstance(pwv, float) + print("pwv",pwv) - P_wv = nsm1.dataset.isel(nsm1_time_step=-1).P_wv.item() - assert isinstance(P_wv, float) - print("P_wv",P_wv) + DOX_sat = nsm1.dataset.isel(nsm1_time_step=-1).DOX_sat.item() + assert isinstance(DOX_sat, float) + print("DOX_sat",DOX_sat) + + DOX = nsm1.dataset.isel(nsm1_time_step=-1).DOX.item() + assert isinstance(DOX, float) + print("DOX",DOX) - TwaterK = nsm1.dataset.isel(nsm1_time_step=-1).TwaterK.item() - assert isinstance(TwaterK, float) - print("TwaterK",TwaterK) - N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() assert isinstance(N2, float) assert pytest.approx(N2, tolerance) == 16.0511281 +""" + TDG = nsm1.dataset.isel(nsm1_time_step=-1).TDG.values.item() + assert isinstance(TDG, float) + assert pytest.approx(TDG, tolerance) == 26.0020885 +""" ''' def test_change_kop( time_steps, diff --git a/tests/test_7_nsm_algae_calculations.py b/tests/test_7_nsm_algae_calculations.py index 79dbfb6..a5e100e 100644 --- a/tests/test_7_nsm_algae_calculations.py +++ b/tests/test_7_nsm_algae_calculations.py @@ -31,10 +31,10 @@ def initial_nsm1_state() -> dict[str, float]: 'Ab': 24, 'NH4': 0.05, 'NO3': 5, - 'OrgN': 1.7, + 'OrgN': 1.726, 'N2': 1, 'TIP': 0.07, - 'OrgP': 0.25, + 'OrgP': 0.24, 'POC': 4, 'DOC': 1, 'DIC': 1, @@ -74,6 +74,9 @@ def default_algae_params() -> AlgaeStaticVariables: vsap= 0.15, growth_rate_option = 1, light_limitation_option = 1, + mu_max_theta= 1.047, + kdp_theta= 1.047, + krp_theta= 1.047, ) @pytest.fixture(scope='function') @@ -108,7 +111,7 @@ def default_balgae_params() -> BalgaeStaticVariables: BWc= 40, BWn=7.2, BWp= 1, - BWa= 3500, + BWa= 5000, KLb= 10, KsNb= 0.25, KsPb=0.125, @@ -119,7 +122,10 @@ def default_balgae_params() -> BalgaeStaticVariables: b_growth_rate_option=1, b_light_limitation_option=1, Fw=0.9, - Fb=0.9 + Fb=0.9, + mub_max_theta = 1.047, + krb_theta = 1.06, + kdb_theta = 1.047, ) @pytest.fixture(scope='function') @@ -140,7 +146,12 @@ def default_nitrogen_params() -> NitrogenStaticVariables: vno3_20=0, KsOxdn=0.1, PN=0.5, - PNb=0.5 + PNb=0.5, + knit_theta= 1.083, + kon_theta= 1.074, + kdnit_theta= 1.08, + rnh4_theta= 1.047, + vno3_theta= 1.045, ) @pytest.fixture(scope='function') @@ -160,7 +171,9 @@ def default_carbon_params() -> CarbonStaticVariables: KsOxmc=1.0, pCO2 = 383.0, FCO2 = 0.2, - roc = 32.0/12.0 + roc = 32.0/12.0, + kpoc_theta = 1.047, + kdoc_theta = 1.047, ) @pytest.fixture(scope='function') @@ -175,7 +188,9 @@ def default_CBOD_params() -> CBODStaticVariables: return CBODStaticVariables( KsOxbod = 0.5, kbod_20 = 0.12, - ksbod_20 = 0.0 + ksbod_20 = 0.0, + kbod_theta = 1.047, + ksbod_theta = 1.047 ) @pytest.fixture(scope='function') @@ -215,7 +230,9 @@ def default_POM_params() -> POMStaticVariables: Returns a typed dictionary, with string keys and float values. """ return POMStaticVariables( - kpom_20 = 0.1 + kpom_20 = 0.1, + h2 = 0.1, + kpom_theta = 1.047 ) @pytest.fixture(scope='function') @@ -230,7 +247,8 @@ def default_pathogen_params() -> PathogenStaticVariables: return PathogenStaticVariables( kdx_20=0.8, apx=1, - vx=1 + vx=1, + kdx_theta = 1.07, ) @pytest.fixture(scope='function') @@ -246,6 +264,8 @@ def default_phosphorus_params() -> PhosphorusStaticVariables: kop_20 = 0.1, rpo4_20 =0, kdpo4 = 0.0, + kop_theta = 1.047, + rpo4_theta = 1.047, ) @pytest.fixture(scope='function') @@ -288,27 +308,29 @@ def default_gvars_params() -> GlobalVars: return GlobalVars( vson = 0.01, vsoc = 0.01, - vsop = 999, - vs = 999, + vsop = 0.01, + vs = 1, SOD_20 = 999, SOD_theta = 999, + theta=1.047, vb = 0.01, fcom = 0.4, - kaw_20_user = 999, - kah_20_user = 999, - hydraulic_reaeration_option = 2, - wind_reaeration_option = 2, + kaw_20_user = 0, + kah_20_user = 1, + hydraulic_reaeration_option = 1, + wind_reaeration_option = 1, timestep = 1, #TODO Dynamic or static? depth = 1.5, #TODO Dynamic or static? TwaterC = 25, - theta = 1.047, + kaw_theta = 1.024, + kah_theta = 1.024, velocity = 1, - flow = 2, - topwidth = 1, - slope = 2, - shear_velocity = 4, - pressure_atm = 2, - wind_speed = 4, + flow = 150, + topwidth = 100, + slope = 0.0002, + shear_velocity = 0.05334, + pressure_atm = 1, + wind_speed = 3, q_solar = 500, Solid = 1, lambda0 = .02, diff --git a/tests/test_8_nsm_balgae_calculations.py b/tests/test_8_nsm_balgae_calculations.py new file mode 100644 index 0000000..3d53282 --- /dev/null +++ b/tests/test_8_nsm_balgae_calculations.py @@ -0,0 +1,2006 @@ +from numba import ( + types, + typed, +) +import pytest + +from clearwater_modules.nsm1 import NutrientBudget +from clearwater_modules.nsm1.constants import ( + AlgaeStaticVariables, + AlkalinityStaticVariables, + BalgaeStaticVariables, + NitrogenStaticVariables, + CarbonStaticVariables, + CBODStaticVariables, + DOXStaticVariables, + N2StaticVariables, + POMStaticVariables, + PathogenStaticVariables, + PhosphorusStaticVariables, + GlobalParameters, + GlobalVars +) + + +@pytest.fixture(scope='function') +def initial_nsm1_state() -> dict[str, float]: + """Return initial state values for the model.""" + return { + + 'Ap': 36.77, + 'Ab': 24, + 'NH4': 0.063, + 'NO3': 5.54, + 'OrgN': 1.7, + 'N2': 1, + 'TIP': 0.071, + 'OrgP': 0.25, + 'POC': 4.356, + 'DOC': 1, + 'DIC': 1, + 'POM': 10, + 'CBOD': 5, + 'DOX': 8, + 'PX': 1, + 'Alk': 1 + + } + +@pytest.fixture(scope='module') +def time_steps() -> int: + return 1 + +@pytest.fixture(scope='function') +def default_algae_params() -> AlgaeStaticVariables: + """Returns default algae static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return AlgaeStaticVariables( + AWd = 100, + AWc= 40, + AWn= 7.2, + AWp= 1, + AWa= 1000, + KL= 10, + KsN= 0.04, + KsP= 0.0012, + mu_max_20= 1, + kdp_20= 0.15, + krp_20= 0.2, + vsap= 0.15, + growth_rate_option = 1, + light_limitation_option = 1, + mu_max_theta= 1.047, + kdp_theta= 1.047, + krp_theta= 1.047, + ) + +@pytest.fixture(scope='function') +def default_alkalinity_params() -> AlkalinityStaticVariables: + """Returns default alkalinity static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return AlkalinityStaticVariables( + r_alkaa = 14.0 / 106.0 / 12.0 / 1000.0, + r_alkan= 18.0 / 106.0 / 12.0 / 1000.0, + r_alkn = 2.0 / 14.0 / 1000.0, + r_alkden = 4.0 / 14.0 / 1000.0, + r_alkba = 14.0 / 106.0 / 12.0 / 1000.0, + r_alkbn =18.0 / 106.0 / 12.0 / 1000.0 + ) + +@pytest.fixture(scope='function') +def default_balgae_params() -> BalgaeStaticVariables: + """Returns default Benthic Algae static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return BalgaeStaticVariables( + BWd = 100, + BWc= 40, + BWn=7.2, + BWp= 1, + BWa= 5000, + KLb= 10, + KsNb= 0.25, + KsPb=0.125, + Ksb=10, + mub_max_20=0.4, + krb_20=0.2, + kdb_20=0.3, + b_growth_rate_option=1, + b_light_limitation_option=1, + Fw=0.9, + Fb=0.9, + mub_max_theta = 1.047, + krb_theta = 1.06, + kdb_theta = 1.047, + ) + +@pytest.fixture(scope='function') +def default_nitrogen_params() -> NitrogenStaticVariables: + """Returns default nitrogen static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return NitrogenStaticVariables( + KNR= 0.6 , + knit_20= 0.1, + kon_20=0.1, + kdnit_20=0.002, + rnh4_20=0, + vno3_20=0, + KsOxdn=0.1, + PN=0.5, + PNb=0.5, + knit_theta= 1.083, + kon_theta= 1.074, + kdnit_theta= 1.08, + rnh4_theta= 1.047, + vno3_theta= 1.045, + ) + +@pytest.fixture(scope='function') +def default_carbon_params() -> CarbonStaticVariables: + """Returns default carbon static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return CarbonStaticVariables( + f_pocp = 0.9, + kdoc_20= 0.01, + f_pocb=0.9, + kpoc_20= 0.005, + KsOxmc=1.0, + pCO2 = 383.0, + FCO2 = 0.2, + roc = 32.0/12.0, + kpoc_theta = 1.047, + kdoc_theta = 1.047, + ) + +@pytest.fixture(scope='function') +def default_CBOD_params() -> CBODStaticVariables: + """Returns default CBOD static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return CBODStaticVariables( + KsOxbod = 0.5, + kbod_20 = 0.12, + ksbod_20 = 0.0, + kbod_theta = 1.047, + ksbod_theta = 1.047 + ) + +@pytest.fixture(scope='function') +def default_DOX_params() -> DOXStaticVariables: + """Returns default DOX static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return DOXStaticVariables( + ron = 2.0 * 32.0 / 14.0, + KsSOD =1, + ) + +@pytest.fixture(scope='function') +def default_N2_params() -> N2StaticVariables: + """Returns default N2 static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return N2StaticVariables( + + ) + +@pytest.fixture(scope='function') +def default_POM_params() -> POMStaticVariables: + """Returns default POM static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return POMStaticVariables( + kpom_20 = 0.1, + h2 = 0.1, + kpom_theta = 1.047 + ) + +@pytest.fixture(scope='function') +def default_pathogen_params() -> PathogenStaticVariables: + """Returns default Pathogens static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return PathogenStaticVariables( + kdx_20=0.8, + apx=1, + vx=1, + kdx_theta = 1.07, + ) + +@pytest.fixture(scope='function') +def default_phosphorus_params() -> PhosphorusStaticVariables: + """Returns default phosphorus static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return PhosphorusStaticVariables( + kop_20 = 0.1, + rpo4_20 =0, + kdpo4 = 0.0, + kop_theta = 1.047, + rpo4_theta = 1.047, + ) + +@pytest.fixture(scope='function') +def default_gp_params() -> GlobalParameters: + """Returns default global parameter static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return GlobalParameters( + use_NH4= True, + use_NO3= True, + use_OrgN= True, + use_OrgP = True, + use_TIP= True, + use_SedFlux= False, + use_POC = True, + use_DOC = True, + use_DOX= True, + use_DIC= True, + use_Algae= True, + use_Balgae= True, + use_N2 = True, + use_Pathogen = True, + use_Alk = True, + use_POM = True + ) + +@pytest.fixture(scope='function') +def default_gvars_params() -> GlobalVars: + """Returns default global variables static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return GlobalVars( + vson = 0.01, + vsoc = 0.01, + vsop = 0.01, + vs = 1, + SOD_20 = 999, + SOD_theta = 999, + vb = 0.01, + fcom = 0.4, + kaw_20_user = 0, + kah_20_user = 1, + hydraulic_reaeration_option = 1, + wind_reaeration_option = 1, + timestep = 1, #TODO Dynamic or static? + depth = 1.5, #TODO Dynamic or static? + TwaterC = 25, + kaw_theta = 1.024, + kah_theta = 1.024, + velocity = 1, + flow = 150, + topwidth = 100, + slope = 0.0002, + shear_velocity = 0.05334, + pressure_atm = 1, + wind_speed = 3, + q_solar = 500, + Solid = 1, + lambda0 = .02, + lambda1 = .0088, + lambda2 = .054, + lambdas = .052, + lambdam = .174, + Fr_PAR = .47 + ) + +def get_nutrient_budget_instance( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + +) -> NutrientBudget: + """Return an instance of the NSM1 class.""" + return NutrientBudget( + time_steps=time_steps, + initial_state_values=initial_nsm1_state, + algae_parameters=default_algae_params, + alkalinity_parameters=default_alkalinity_params, + balgae_parameters=default_balgae_params, + nitrogen_parameters=default_nitrogen_params, + carbon_parameters=default_carbon_params, + CBOD_parameters=default_CBOD_params, + DOX_parameters=default_DOX_params, + N2_parameters=default_N2_params, + POM_parameters=default_POM_params, + pathogen_parameters=default_pathogen_params, + phosphorus_parameters=default_phosphorus_params, + global_parameters=default_gp_params, + global_vars=default_gvars_params, + time_dim='nsm1_time_step', + ) + +@pytest.fixture(scope='module') +def tolerance() -> float: + """Controls the precision of the pytest.approx() function.""" + return 0.000001 + +def test_defaults( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel(nsm1_time_step=-1).Ab.values.item() + + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.82632 + +def test_changed_KLb( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['KLb'] = 15 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.74222 + +def test_changed_KsNb( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['KsNb'] = 0.4 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.81861 + +def test_changed_KsPb( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['KsPb'] = 0.05 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 9.01754 + +def test_changed_Ksb( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['Ksb'] = 20 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.99459 + +def test_changed_mub_max( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['mub_max_20'] = 1.5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 9.67469 + +def test_changed_krb( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['krb_20'] = 0.01 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 14.92863 + +def test_changed_kdb( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['kdb_20'] = 0.8 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == -6.27152 + +def test_changed_Ab( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['Ab'] = 40 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 14.54599 + +def test_changed_NH4( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['NH4'] = 5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.83262 + +def test_changed_NO3( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['NO3'] = 2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.80525 + +def test_changed_TIP( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['TIP'] = 3 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 9.33539 + +def test_changed_TwaterC( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['TwaterC'] = 30 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 4.39484 + +def test_changed_depth( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['depth'] = 0.5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 9.56564 + +def test_changed_Ap( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['Ap'] = 20 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.96109 + +def test_changed_lambda0( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['lambda0'] = 5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.51805 + +def test_changed_lambda1( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['lambda1'] = 0.03 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.63363 + +def test_changed_lambda2( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['lambda2'] = 1 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.51782 + +def test_changed_lambdam( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['lambdam'] = 0.008 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 9.54539 + +def test_changed_POC( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['POC'] = 10 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.52808 + +def test_changed_fcom( + + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['fcom'] = 0.25 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.58832 + +def test_changed_use_algae( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_Algae'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 9.22085 + +def test_changed_q_solar( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['q_solar'] = 100 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.59497 + +def test_changed_use_TIP( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_TIP'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 9.36945 + +def test_changed_use_POC( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_POC'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 9.56670 + +def test_changed_use_NH4( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_NH4'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.82617 + +def test_changed_use_NO3( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_NO3'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.58268 + +def test_changed_use_NO3_use_NH4( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_NO3'] = False + default_gp_params['use_NH4'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.84008 + +def test_changed_g2_l1( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['b_growth_rate_option'] = 2 + default_balgae_params['b_light_limitation_option'] = 1 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.84008 + +def test_changed_g1_l2( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['b_growth_rate_option'] = 1 + default_balgae_params['b_light_limitation_option'] = 2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.90818 + +def test_changed_g2_l2( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['b_growth_rate_option'] = 2 + default_balgae_params['b_light_limitation_option'] = 2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 8.92559 + +def test_changed_g1_l3( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['b_growth_rate_option'] = 1 + default_balgae_params['b_light_limitation_option'] = 3 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 9.31883 + +def test_changed_g2_l3( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['b_growth_rate_option'] = 2 + default_balgae_params['b_light_limitation_option'] = 3 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + Ab = nsm1.dataset.isel( + nsm1_time_step=-1).Ab.values.item() + assert isinstance(Ab, float) + assert pytest.approx(Ab, tolerance) == 9.35457 \ No newline at end of file diff --git a/tests/test_9_nsm_nitrogen_calculations.py b/tests/test_9_nsm_nitrogen_calculations.py new file mode 100644 index 0000000..25f4d2e --- /dev/null +++ b/tests/test_9_nsm_nitrogen_calculations.py @@ -0,0 +1,1997 @@ +from numba import ( + types, + typed, +) +import pytest + +from clearwater_modules.nsm1 import NutrientBudget +from clearwater_modules.nsm1.constants import ( + AlgaeStaticVariables, + AlkalinityStaticVariables, + BalgaeStaticVariables, + NitrogenStaticVariables, + CarbonStaticVariables, + CBODStaticVariables, + DOXStaticVariables, + N2StaticVariables, + POMStaticVariables, + PathogenStaticVariables, + PhosphorusStaticVariables, + GlobalParameters, + GlobalVars +) + + +@pytest.fixture(scope='function') +def initial_nsm1_state() -> dict[str, float]: + """Return initial state values for the model.""" + return { + + 'Ap': 36.77, + 'Ab': 24, + 'NH4': 0.063, + 'NO3': 5.54, + 'OrgN': 1.726, + 'N2': 1, + 'TIP': 0.071, + 'OrgP': 0.25, + 'POC': 4.356, + 'DOC': 1, + 'DIC': 1, + 'POM': 10, + 'CBOD': 5, + 'DOX': 8, + 'PX': 1, + 'Alk': 1 + + } + +@pytest.fixture(scope='module') +def time_steps() -> int: + return 1 + +@pytest.fixture(scope='function') +def default_algae_params() -> AlgaeStaticVariables: + """Returns default algae static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return AlgaeStaticVariables( + AWd = 100, + AWc= 40, + AWn= 7.2, + AWp= 1, + AWa= 1000, + KL= 10, + KsN= 0.04, + KsP= 0.0012, + mu_max_20= 1, + kdp_20= 0.15, + krp_20= 0.2, + vsap= 0.15, + growth_rate_option = 1, + light_limitation_option = 1, + mu_max_theta= 1.047, + kdp_theta= 1.047, + krp_theta= 1.047, + ) + +@pytest.fixture(scope='function') +def default_alkalinity_params() -> AlkalinityStaticVariables: + """Returns default alkalinity static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return AlkalinityStaticVariables( + r_alkaa = 14.0 / 106.0 / 12.0 / 1000.0, + r_alkan= 18.0 / 106.0 / 12.0 / 1000.0, + r_alkn = 2.0 / 14.0 / 1000.0, + r_alkden = 4.0 / 14.0 / 1000.0, + r_alkba = 14.0 / 106.0 / 12.0 / 1000.0, + r_alkbn =18.0 / 106.0 / 12.0 / 1000.0 + ) + +@pytest.fixture(scope='function') +def default_balgae_params() -> BalgaeStaticVariables: + """Returns default Benthic Algae static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return BalgaeStaticVariables( + BWd = 100, + BWc= 40, + BWn=7.2, + BWp= 1, + BWa= 5000, + KLb= 10, + KsNb= 0.25, + KsPb=0.125, + Ksb=10, + mub_max_20=0.4, + krb_20=0.2, + kdb_20=0.3, + b_growth_rate_option=1, + b_light_limitation_option=1, + Fw=0.9, + Fb=0.9, + mub_max_theta = 1.047, + krb_theta = 1.06, + kdb_theta = 1.047, + ) + +@pytest.fixture(scope='function') +def default_nitrogen_params() -> NitrogenStaticVariables: + """Returns default nitrogen static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return NitrogenStaticVariables( + KNR= 0.6 , + knit_20= 0.1, + kon_20=0.1, + kdnit_20=0.002, + rnh4_20=0, + vno3_20=0, + KsOxdn=0.1, + PN=0.5, + PNb=0.5, + knit_theta= 1.083, + kon_theta= 1.047, + kdnit_theta= 1.045, + rnh4_theta= 1.074, + vno3_theta= 1.08, + ) + +@pytest.fixture(scope='function') +def default_carbon_params() -> CarbonStaticVariables: + """Returns default carbon static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return CarbonStaticVariables( + f_pocp = 0.9, + kdoc_20= 0.01, + f_pocb=0.9, + kpoc_20= 0.005, + KsOxmc=1.0, + pCO2 = 383.0, + FCO2 = 0.2, + roc = 32.0/12.0, + kpoc_theta = 1.047, + kdoc_theta = 1.047, + ) + +@pytest.fixture(scope='function') +def default_CBOD_params() -> CBODStaticVariables: + """Returns default CBOD static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return CBODStaticVariables( + KsOxbod = 0.5, + kbod_20 = 0.12, + ksbod_20 = 0.0, + kbod_theta = 1.047, + ksbod_theta = 1.047 + ) + +@pytest.fixture(scope='function') +def default_DOX_params() -> DOXStaticVariables: + """Returns default DOX static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return DOXStaticVariables( + ron = 2.0 * 32.0 / 14.0, + KsSOD =1, + ) + +@pytest.fixture(scope='function') +def default_N2_params() -> N2StaticVariables: + """Returns default N2 static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return N2StaticVariables( + + ) + +@pytest.fixture(scope='function') +def default_POM_params() -> POMStaticVariables: + """Returns default POM static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return POMStaticVariables( + kpom_20 = 0.1, + h2 = 0.1, + kpom_theta = 1.047 + ) + +@pytest.fixture(scope='function') +def default_pathogen_params() -> PathogenStaticVariables: + """Returns default Pathogens static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return PathogenStaticVariables( + kdx_20=0.8, + apx=1, + vx=1, + kdx_theta = 1.07, + ) + +@pytest.fixture(scope='function') +def default_phosphorus_params() -> PhosphorusStaticVariables: + """Returns default phosphorus static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return PhosphorusStaticVariables( + kop_20 = 0.1, + rpo4_20 =0, + kdpo4 = 0.0, + kop_theta = 1.047, + rpo4_theta = 1.047, + ) + +@pytest.fixture(scope='function') +def default_gp_params() -> GlobalParameters: + """Returns default global parameter static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return GlobalParameters( + use_NH4= True, + use_NO3= True, + use_OrgN= True, + use_OrgP = True, + use_TIP= False, + use_SedFlux= False, + use_POC = False, + use_DOC = True, + use_DOX= True, + use_DIC= True, + use_Algae= True, + use_Balgae= True, + use_N2 = True, + use_Pathogen = True, + use_Alk = True, + use_POM = True + ) + +@pytest.fixture(scope='function') +def default_gvars_params() -> GlobalVars: + """Returns default global variables static variable values for the model. + + NOTE: As of now (3/18/2022) these match the built in defaults, but are + copied here to allow for easy modification of the defaults in the future. + + Returns a typed dictionary, with string keys and float values. + """ + return GlobalVars( + vson = 0.01, + vsoc = 0.01, + vsop = 0.01, + vs = 1, + SOD_20 = 999, + SOD_theta = 999, + vb = 0.01, + fcom = 0.4, + kaw_20_user = 0, + kah_20_user = 1, + hydraulic_reaeration_option = 1, + wind_reaeration_option = 1, + timestep = 1, #TODO Dynamic or static? + depth = 1.5, #TODO Dynamic or static? + TwaterC = 25, + kaw_theta = 1.024, + kah_theta = 1.024, + velocity = 1, + flow = 150, + topwidth = 100, + slope = 0.0002, + shear_velocity = 0.05334, + pressure_atm = 1, + wind_speed = 3, + q_solar = 500, + Solid = 1, + lambda0 = .02, + lambda1 = .0088, + lambda2 = .054, + lambdas = .052, + lambdam = .174, + Fr_PAR = .47 + ) + +def get_nutrient_budget_instance( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + +) -> NutrientBudget: + """Return an instance of the NSM1 class.""" + return NutrientBudget( + time_steps=time_steps, + initial_state_values=initial_nsm1_state, + algae_parameters=default_algae_params, + alkalinity_parameters=default_alkalinity_params, + balgae_parameters=default_balgae_params, + nitrogen_parameters=default_nitrogen_params, + carbon_parameters=default_carbon_params, + CBOD_parameters=default_CBOD_params, + DOX_parameters=default_DOX_params, + N2_parameters=default_N2_params, + POM_parameters=default_POM_params, + pathogen_parameters=default_pathogen_params, + phosphorus_parameters=default_phosphorus_params, + global_parameters=default_gp_params, + global_vars=default_gvars_params, + time_dim='nsm1_time_step', + ) + +@pytest.fixture(scope='module') +def tolerance() -> float: + """Controls the precision of the pytest.approx() function.""" + return 0.000001 + +def test_defaults( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + nsm1.increment_timestep() + + + + krb_tc = nsm1.dataset.isel(nsm1_time_step=-1).krb_tc.item() + assert isinstance(krb_tc, float) + print("krb_tc",krb_tc) + + AbRespiration = nsm1.dataset.isel(nsm1_time_step=-1).AbRespiration.item() + assert isinstance(AbRespiration, float) + print("AbRespiration",AbRespiration) + + + NH4_AbRespiration = nsm1.dataset.isel(nsm1_time_step=-1).NH4_AbRespiration.item() + assert isinstance(NH4_AbRespiration, float) + print("NH4_AbRespiration",NH4_AbRespiration) + + + # Run the model + NH4 = nsm1.dataset.isel(nsm1_time_step=-1).NH4.values.item() + + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.6101494 + + NO3 = nsm1.dataset.isel(nsm1_time_step=-1).NO3.values.item() + + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.1260636 + + OrgN = nsm1.dataset.isel(nsm1_time_step=-1).OrgN.values.item() + + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.899502 + +def test_changed_knit( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_nitrogen_params['knit_20'] = 10 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == -0.3114223 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 6.0476352 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.8995017 + +def test_changed_kon( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_nitrogen_params['kon_20'] = 1 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 2.564564 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.1260636 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == -0.05491296 + +def test_changed_kdnit( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_nitrogen_params['kdnit_20'] = 2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.610149 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 4.955769 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.8995017 + +def test_changed_rnh4( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_nitrogen_params['rnh4_20'] = -1 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == -0.3424935 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.12606356 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.89950169 + +def test_changed_rnh4_KsOxdn( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_nitrogen_params['rnh4_20'] = 1 + default_nitrogen_params['KsOxdn'] = 10 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 1.5627923 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.11856308 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.89950169 + +def test_changed_vno3( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_nitrogen_params['vno3_20'] = 0.9 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.610149379 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 0.242017033 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.89950169 + +def test_changed_depth( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['depth'] = 3 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.472669296 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.23749182 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.729153886 + +def test_changed_TwaterC( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['TwaterC'] = 10 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.31604458 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.330296324 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.8073881 + +def test_changed_NH4( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['NH4'] = 0.01 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.569020898 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.114263537 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.89950169 + +def test_changed_NO3( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['NO3'] = 20 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.61359955 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 19.57664053 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.89950169 + +def test_changed_Ap( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['Ap'] = 5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.5553608647 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.3696889 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.85633245 + +def test_changed_DOX( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['DOX'] = 1 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.6152233076 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.1199048523 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.899501691 + +def test_changed_OrgN( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['OrgN'] = 7 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 1.2736991965 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.12606356 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 6.47479187 + +def test_changed_use_NH4( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_NH4'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.063 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.1120288 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.89950169 + +def test_changed_use_NO3( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_NO3'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.40213002 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.54 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.89950169 + +def test_changed_use_OrgN( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_OrgN'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.392992196 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.126063560 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.726 + +def test_changed_use_DOX( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_DOX'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.61007213 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.12631127 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.89950169 + +def test_changed_use_Algae( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_Algae'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.54676037 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.409982005 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.849538428 + +def test_changed_use_Balgae( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_Balgae'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.33406138337 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.24974272 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.547299413 + +def test_changed_PN( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_nitrogen_params['PN'] = 0.3 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.6120854746 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.124127465 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.899501691 + +def test_changed_PNb( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_nitrogen_params['PNb'] = 0.7 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.60832257266 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.127890367 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.89950169 + +def test_changed_Fw( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['Fw'] = 0.5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.610149379 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.12606356028 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.7429673455 + +def test_changed_Fb( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_balgae_params['Fb'] = 0.4 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.456767159 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.194774206 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.703833759 + +def test_changed_use_Algae_use_Balgae( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_Algae'] = False + default_gp_params['use_Balgae'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.2708483787 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.549138339 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.49733615 + +def test_changed_use_Algae_use_NH4( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_Algae'] = False + default_gp_params['use_NH4'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.063 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.39915906 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.849538428 + +def test_changed_use_Algae_use_NH4_use_NO3( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_Algae'] = False + default_gp_params['use_NH4'] = False + default_gp_params['use_NO3'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + NH4 = nsm1.dataset.isel( + nsm1_time_step=-1).NH4.values.item() + assert isinstance(NH4, float) + assert pytest.approx(NH4, tolerance) == 0.063 + + NO3 = nsm1.dataset.isel( + nsm1_time_step=-1).NO3.values.item() + assert isinstance(NO3, float) + assert pytest.approx(NO3, tolerance) == 5.54 + + OrgN = nsm1.dataset.isel( + nsm1_time_step=-1).OrgN.values.item() + assert isinstance(OrgN, float) + assert pytest.approx(OrgN, tolerance) == 1.849538428 \ No newline at end of file From a75305ce063b5320cb7620c5e22949c7b5a78d7d Mon Sep 17 00:00:00 2001 From: kewalak Date: Fri, 2 Aug 2024 08:37:00 -0700 Subject: [PATCH 6/9] Completed Testing Suite Still a few wrinkles to iron out. The following have negative values as test answers and I added code so none of the constituents have negative concentrations. Carbon test_change_kbod_20 test_change_kah_20_user test_change_kaw_20_user DOX test_change_krb_20 CBOD test_change_kbod_20 test_changed_ksbod_20 --- src/clearwater_modules/nsm1/processes.py | 32 +- tests/test_16_nsm_PX_calculations.py | 383 +++++- tests/test_17_nsm_N2_calculations.py | 1496 ++++++++++++++++++++- tests/test_8_nsm_balgae_calculations.py | 4 +- tests/test_9_nsm_nitrogen_calculations.py | 22 +- 5 files changed, 1875 insertions(+), 62 deletions(-) diff --git a/src/clearwater_modules/nsm1/processes.py b/src/clearwater_modules/nsm1/processes.py index 4965864..c43e1fb 100644 --- a/src/clearwater_modules/nsm1/processes.py +++ b/src/clearwater_modules/nsm1/processes.py @@ -700,7 +700,7 @@ def Ap( dApdt: Change in algae biomass concentration (ug-Chla/L/d) dt: current iteration dt (d) """ - return Ap + dApdt * dt + return xr.where(Ap + dApdt * dt >0, Ap + dApdt * dt ,0) ############################################ From benthic algae @@ -1104,7 +1104,7 @@ def Ab( """ - return Ab + dAbdt * dt + return xr.where(Ab + dAbdt * dt > 0 , Ab + dAbdt * dt, 0) def Chlb( @@ -1423,7 +1423,7 @@ def OrgN( """ - return OrgN + dOrgNdt * dt + return xr.where(OrgN + dOrgNdt * dt > 0 , OrgN + dOrgNdt * dt , 0) def NitrificationInhibition( use_DOX: bool, @@ -1605,7 +1605,7 @@ def NH4( """ - return NH4 + dNH4dt * dt + return xr.where(NH4 + dNH4dt * dt > 0 , NH4 + dNH4dt * dt , 0) def NO3_Denit( use_DOX: bool, @@ -1750,7 +1750,7 @@ def NO3( """ - return NO3 + dNO3dt * dt + return xr.where(NO3 + dNO3dt * dt > 0 , NO3 + dNO3dt * dt, 0) def DIN( @@ -2111,7 +2111,7 @@ def TIP( TIP: Total inorganic phosphorus water concentration (mg-P/L), dt: current iteration dt (d) """ - return TIP + dTIPdt * dt + return xr.where(TIP + dTIPdt * dt > 0, TIP + dTIPdt * dt,0) def OrgP( @@ -2127,7 +2127,7 @@ def OrgP( OrgP: Total organic phosphorus water concentration (mg-P/L), dt: current iteration dt (d) """ - return OrgP + dOrgPdt * dt + return xr.where(OrgP + dOrgPdt * dt >0 , OrgP + dOrgPdt * dt,0) def TOP( use_OrgP: bool, @@ -2332,7 +2332,7 @@ def POM( POM: POM concentration from previous dt (mg/L) dt: Current iteration dt (d) """ - return POM + dPOMdt * dt + return xr.where(POM + dPOMdt * dt >0, POM + dPOMdt * dt, 0) ################################## From CBOD @@ -2437,7 +2437,7 @@ def CBOD( dCBODdt: CBOD concentration change for current dt (mg/L/d) dt: current iteration dt (d) """ - return CBOD + dCBODdt * dt + return xr.where(CBOD + dCBODdt * dt >0, CBOD + dCBODdt * dt,0) ############################### From Carbon @@ -2565,7 +2565,7 @@ def POC( dPOCdt: POC concentration change for current dt (mg/L/d) dt: current iteration dt (d) """ - return POC + dPOCdt * dt + return xr.where(POC + dPOCdt * dt>0, POC + dPOCdt * dt,0) def DOC_algal_mortality( @@ -2686,7 +2686,7 @@ def DOC( dDOCdt: Dissolved organic carbon concentration change for current dt (mg/L/d) dt: current iteration dt (d) """ - return DOC + dDOCdt * dt + return xr.where(DOC + dDOCdt * dt > 0, DOC + dDOCdt * dt, 0) @@ -2873,7 +2873,7 @@ def DIC( dDICdt: Change in concentration of DIC for current dt (mg/L/d) dt: Current iteration dt (d) """ - return DIC + dDICdt * dt + return xr.where(DIC + dDICdt * dt >0, DIC + dDICdt * dt,0) ######################################## From DOX @@ -3138,7 +3138,7 @@ def DOX( dDOXdt: Change in dissolved oxygen concentration over dt dt: Current iteration dt (d) """ - return DOX + dDOXdt * dt + return xr.where(DOX + dDOXdt * dt>0, DOX + dDOXdt * dt, 0) ######################################### From pathogen @@ -3244,7 +3244,7 @@ def PX( PX: Pathogen concentration (cfu/100mL) dt: Current iteration dt (d) """ - return PX + dt * dPXdt + return xr.where(PX + dt * dPXdt >0, PX + dt * dPXdt , 0) ##################################### From alkalinity @@ -3450,7 +3450,7 @@ def Alk( dAlkdt: Change in concentration of alkalinity for current dt (mg/L/d) dt: Current iteration dt (d) """ - return Alk + dAlkdt * dt + return xr.where(Alk + dAlkdt * dt > 0, Alk + dAlkdt * dt, 0) ##################################### From N2 @@ -3524,7 +3524,7 @@ def N2( dt: Current iteration dt (d) """ - return N2 + dN2dt * dt + return xr.where(N2 + dN2dt * dt > 0 , N2 + dN2dt * dt , 0) def TDG( N2: xr.DataArray, diff --git a/tests/test_16_nsm_PX_calculations.py b/tests/test_16_nsm_PX_calculations.py index aaaf027..f441373 100644 --- a/tests/test_16_nsm_PX_calculations.py +++ b/tests/test_16_nsm_PX_calculations.py @@ -41,7 +41,7 @@ def initial_nsm1_state() -> dict[str, float]: 'POM': 10, 'CBOD': 5, 'DOX': 8, - 'PX': 1, + 'PX': 10, 'Alk': 1 } @@ -246,8 +246,8 @@ def default_pathogen_params() -> PathogenStaticVariables: """ return PathogenStaticVariables( kdx_20=0.8, - apx=1, - vx=1, + apx=0.01, + vx=0.01, kdx_theta = 1.07, ) @@ -320,7 +320,7 @@ def default_gvars_params() -> GlobalVars: wind_reaeration_option = 1, timestep = 1, #TODO Dynamic or static? depth = 1.5, #TODO Dynamic or static? - TwaterC = 25, + TwaterC = 10, kaw_theta = 1.024, kah_theta = 1.024, velocity = 1, @@ -330,7 +330,7 @@ def default_gvars_params() -> GlobalVars: shear_velocity = 0.05334, pressure_atm = 1, wind_speed = 3, - q_solar = 500, + q_solar = 1, Solid = 1, lambda0 = .02, lambda1 = .0088, @@ -428,7 +428,7 @@ def test_defaults( PathogenDeath = nsm1.dataset.isel(nsm1_time_step=-1).PathogenDeath.item() assert isinstance(PathogenDeath, float) - print("POM_algal_settling",PathogenDeath) + print("PathogenDeath",PathogenDeath) PathogenDecay = nsm1.dataset.isel(nsm1_time_step=-1).PathogenDecay.item() assert isinstance(PathogenDecay, float) @@ -446,11 +446,109 @@ def test_defaults( PX = nsm1.dataset.isel(nsm1_time_step=-1).PX.values.item() assert isinstance(PX, float) - assert pytest.approx(PX, tolerance) == -493.363148909424 + assert pytest.approx(PX, tolerance) == 5.768024108 +def test_kdx_20( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_pathogen_params['kdx_20'] = 1.2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + PX = nsm1.dataset.isel(nsm1_time_step=-1).PX.values.item() + + assert isinstance(PX, float) + assert pytest.approx(PX, tolerance) == 3.73462693954508 + +def test_TwaterC( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['TwaterC'] = 5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() -''' -def test_change_kop( + PX = nsm1.dataset.isel(nsm1_time_step=-1).PX.values.item() + + assert isinstance(PX, float) + assert pytest.approx(PX, tolerance) == 6.93525028802282 + +def test_apx( time_steps, initial_nsm1_state, default_algae_params, @@ -471,7 +569,7 @@ def test_change_kop( """Test the model with default parameters.""" # alter parameters as necessary initial_state_dict = initial_nsm1_state - default_phosphorus_params['kop_20'] = 0.2 + default_pathogen_params['apx'] = 0.001 # instantiate the model nsm1: NutrientBudget = get_nutrient_budget_instance( @@ -492,17 +590,268 @@ def test_change_kop( default_gvars_params=default_gvars_params ) + # Run the model + nsm1.increment_timestep() + + PathogenDecay = nsm1.dataset.isel(nsm1_time_step=-1).PathogenDecay.item() + assert isinstance(PathogenDecay, float) + print("PathogenDecay",PathogenDecay) + + PX = nsm1.dataset.isel(nsm1_time_step=-1).PX.values.item() + + assert isinstance(PX, float) + assert pytest.approx(PX, tolerance) == 5.85668750743843 + +def test_vx( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_pathogen_params['vx'] = 0.5 + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + # Run the model nsm1.increment_timestep() - TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + PX = nsm1.dataset.isel(nsm1_time_step=-1).PX.values.item() - assert isinstance(TIP, float) - assert pytest.approx(TIP, tolerance) == 0.1309587507 + assert isinstance(PX, float) + assert pytest.approx(PX, tolerance) == 2.50135744141729 - OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() +def test_PX( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_nsm1_state['PX'] = 20 - assert isinstance(OrgP, float) - assert pytest.approx(OrgP, tolerance) == 0.233864988 -''' + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + PX = nsm1.dataset.isel(nsm1_time_step=-1).PX.values.item() + + assert isinstance(PX, float) + assert pytest.approx(PX, tolerance) == 11.53604822 + +def test_depth( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['depth'] = 3 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + PX = nsm1.dataset.isel(nsm1_time_step=-1).PX.values.item() + + assert isinstance(PX, float) + assert pytest.approx(PX, tolerance) == 5.80281321889601 + +def test_q_solar( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['q_solar'] = 10 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + PX = nsm1.dataset.isel(nsm1_time_step=-1).PX.values.item() + + assert isinstance(PX, float) + assert pytest.approx(PX, tolerance) == 4.8813901145392 + +def test_use_Algae( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_Algae'] = True + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + L = nsm1.dataset.isel(nsm1_time_step=-1).L.item() + assert isinstance(L, float) + print("L",L) + + PX = nsm1.dataset.isel(nsm1_time_step=-1).PX.values.item() + + assert isinstance(PX, float) + assert pytest.approx(PX, tolerance) == 5.812953513 diff --git a/tests/test_17_nsm_N2_calculations.py b/tests/test_17_nsm_N2_calculations.py index 47a6ef4..31c46d5 100644 --- a/tests/test_17_nsm_N2_calculations.py +++ b/tests/test_17_nsm_N2_calculations.py @@ -449,14 +449,7 @@ def test_defaults( assert isinstance(N2, float) assert pytest.approx(N2, tolerance) == 16.0511281 -""" - TDG = nsm1.dataset.isel(nsm1_time_step=-1).TDG.values.item() - - assert isinstance(TDG, float) - assert pytest.approx(TDG, tolerance) == 26.0020885 -""" -''' -def test_change_kop( +def test_N2( time_steps, initial_nsm1_state, default_algae_params, @@ -477,7 +470,7 @@ def test_change_kop( """Test the model with default parameters.""" # alter parameters as necessary initial_state_dict = initial_nsm1_state - default_phosphorus_params['kop_20'] = 0.2 + initial_state_dict['N2'] = 2 # instantiate the model nsm1: NutrientBudget = get_nutrient_budget_instance( @@ -498,17 +491,1488 @@ def test_change_kop( default_gvars_params=default_gvars_params ) + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 15.8869475476111 + +def test_DOX( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + initial_state_dict['DOX'] = 8 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 16.0511280512864 + +def test_use_DOX( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gp_params['use_DOX'] = False + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 16.0511280512864 + +def test_pressure_atm( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['pressure_atm'] = 2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 32.7897153331295 + + +def test_TwaterC( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['TwaterC'] = 30 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 16.4930672056418 + +def test_Salinity( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['Salinity'] = 5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 16.0511280512864 + +def test_kah( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['kah_20_user'] = 2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 31.1022561025728 + +def test_kaw( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['kaw_20_user'] = 0.5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 21.0681707350485 + +def test_wr_2_hr_2( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 2 + default_gvars_params['wind_reaeration_option'] = 2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 65.9366965785228 + +def test_wr_3_hr_3( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 3 + default_gvars_params['wind_reaeration_option'] = 3 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 46.9755965621132 + +def test_wr_4_hr_4( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 4 + default_gvars_params['wind_reaeration_option'] = 4 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 46.94093398065 + +def test_wr_5_hr_5( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 5 + default_gvars_params['wind_reaeration_option'] = 5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 41.9426132334058 + +def test_wr_6_hr_6( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 6 + default_gvars_params['wind_reaeration_option'] = 6 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 63.7322409376813 + +def test_wr_7_hr_7( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 7 + default_gvars_params['wind_reaeration_option'] = 7 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 39.382889432894 + +def test_wr_8_hr_8( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 8 + default_gvars_params['wind_reaeration_option'] = 8 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 71.8185615550307 + +def test_wr_9_hr_9( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 9 + default_gvars_params['wind_reaeration_option'] = 9 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 13.2060831760727 + +def test_wr_10_hr_5_depth( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 5 + default_gvars_params['wind_reaeration_option'] = 10 + default_gvars_params['depth'] = 0.5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 301.508013077305 + +def test_wr_11_hr_6_depth( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 6 + default_gvars_params['wind_reaeration_option'] = 11 + default_gvars_params['depth'] = 0.5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 70.1055933861735 + +def test_wr_12_hr_7_depth( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 7 + default_gvars_params['wind_reaeration_option'] = 12 + default_gvars_params['depth'] = 0.5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 101.944511624376 + +def test_wr_13_hr_8_depth( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 8 + default_gvars_params['wind_reaeration_option'] = 13 + default_gvars_params['flow'] = 0.4 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + kah_tc = nsm1.dataset.isel(nsm1_time_step=-1).kah_tc.item() + assert isinstance(kah_tc, float) + print("kah_tc",kah_tc) + + kaw_tc = nsm1.dataset.isel(nsm1_time_step=-1).kaw_tc.item() + assert isinstance(kaw_tc, float) + print("kaw_tc",kaw_tc) + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 117.0476547 + +def test_wr_7_hr_2_wind_speed( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 2 + default_gvars_params['wind_reaeration_option'] = 7 + default_gvars_params['wind_speed'] = 5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 44.208087138308 + +def test_wr_9_hr_3_wind_speed( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 3 + default_gvars_params['wind_reaeration_option'] = 9 + default_gvars_params['wind_speed'] = 5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 47.7149213700046 + +def test_wr_13_hr_4_wind_speed( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 4 + default_gvars_params['wind_reaeration_option'] = 13 + default_gvars_params['wind_speed'] = 0.5 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 43.4278798307678 + +def test_wr_2_hr_2_velocity( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 2 + default_gvars_params['wind_reaeration_option'] = 2 + default_gvars_params['velocity'] = 2 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 79.2734163846862 + +def test_wr_3_hr_6_flow( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 6 + default_gvars_params['wind_reaeration_option'] = 3 + default_gvars_params['flow'] = 70 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 65.2387385186712 + +def test_wr_4_hr_7_slope( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 7 + default_gvars_params['wind_reaeration_option'] = 4 + default_gvars_params['slope'] = 0.001 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + kah_tc = nsm1.dataset.isel(nsm1_time_step=-1).kah_tc.item() + assert isinstance(kah_tc, float) + print("kah_tc",kah_tc) + + kaw_tc = nsm1.dataset.isel(nsm1_time_step=-1).kaw_tc.item() + assert isinstance(kaw_tc, float) + print("kaw_tc",kaw_tc) + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 62.0415408678264 + +def test_wr_5_hr_7_topwidth( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 7 + default_gvars_params['wind_reaeration_option'] = 5 + default_gvars_params['topwidth'] = 150 + + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + + + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 38.12999386 + +def test_wr_6_hr_6_wind_speed( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 6 + default_gvars_params['wind_reaeration_option'] = 6 + default_gvars_params['wind_speed'] = 1 + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + # Run the model nsm1.increment_timestep() + - TIP = nsm1.dataset.isel(nsm1_time_step=-1).TIP.values.item() + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() + + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 57.3724446605991 + +def test_wr_7_hr_9_shear_velocity( + time_steps, + initial_nsm1_state, + default_algae_params, + default_alkalinity_params, + default_balgae_params, + default_nitrogen_params, + default_carbon_params, + default_CBOD_params, + default_DOX_params, + default_N2_params, + default_POM_params, + default_pathogen_params, + default_phosphorus_params, + default_gp_params, + default_gvars_params, + tolerance, +) -> None: + """Test the model with default parameters.""" + # alter parameters as necessary + initial_state_dict = initial_nsm1_state + default_gvars_params['hydraulic_reaeration_option'] = 9 + default_gvars_params['wind_reaeration_option'] = 7 + default_gvars_params['shear_velocity'] = 0.01 - assert isinstance(TIP, float) - assert pytest.approx(TIP, tolerance) == 0.1309587507 + # instantiate the model + nsm1: NutrientBudget = get_nutrient_budget_instance( + time_steps=time_steps, + initial_nsm1_state=initial_nsm1_state, + default_algae_params=default_algae_params, + default_alkalinity_params=default_alkalinity_params, + default_balgae_params=default_balgae_params, + default_nitrogen_params=default_nitrogen_params, + default_carbon_params=default_carbon_params, + default_CBOD_params=default_CBOD_params, + default_DOX_params=default_DOX_params, + default_N2_params=default_N2_params, + default_POM_params=default_POM_params, + default_pathogen_params=default_pathogen_params, + default_phosphorus_params=default_phosphorus_params, + default_gp_params=default_gp_params, + default_gvars_params=default_gvars_params + ) + + # Run the model + nsm1.increment_timestep() + - OrgP = nsm1.dataset.isel(nsm1_time_step=-1).OrgP.values.item() + N2 = nsm1.dataset.isel(nsm1_time_step=-1).N2.values.item() - assert isinstance(OrgP, float) - assert pytest.approx(OrgP, tolerance) == 0.233864988 -''' + assert isinstance(N2, float) + assert pytest.approx(N2, tolerance) == 9.66922524093679 \ No newline at end of file diff --git a/tests/test_8_nsm_balgae_calculations.py b/tests/test_8_nsm_balgae_calculations.py index 3d53282..da8f37e 100644 --- a/tests/test_8_nsm_balgae_calculations.py +++ b/tests/test_8_nsm_balgae_calculations.py @@ -745,7 +745,7 @@ def test_changed_kdb( """Test the model with default parameters.""" # alter parameters as necessary initial_state_dict = initial_nsm1_state - default_balgae_params['kdb_20'] = 0.8 + default_balgae_params['kdb_20'] = 0.1 # instantiate the model nsm1: NutrientBudget = get_nutrient_budget_instance( @@ -771,7 +771,7 @@ def test_changed_kdb( Ab = nsm1.dataset.isel( nsm1_time_step=-1).Ab.values.item() assert isinstance(Ab, float) - assert pytest.approx(Ab, tolerance) == -6.27152 + assert pytest.approx(Ab, tolerance) == 14.8654507973722 def test_changed_Ab( time_steps, diff --git a/tests/test_9_nsm_nitrogen_calculations.py b/tests/test_9_nsm_nitrogen_calculations.py index 25f4d2e..ebd9ac4 100644 --- a/tests/test_9_nsm_nitrogen_calculations.py +++ b/tests/test_9_nsm_nitrogen_calculations.py @@ -478,7 +478,7 @@ def test_changed_knit( """Test the model with default parameters.""" # alter parameters as necessary initial_state_dict = initial_nsm1_state - default_nitrogen_params['knit_20'] = 10 + default_nitrogen_params['knit_20'] = 5 # instantiate the model nsm1: NutrientBudget = get_nutrient_budget_instance( @@ -504,17 +504,17 @@ def test_changed_knit( NH4 = nsm1.dataset.isel( nsm1_time_step=-1).NH4.values.item() assert isinstance(NH4, float) - assert pytest.approx(NH4, tolerance) == -0.3114223 + assert pytest.approx(NH4, tolerance) == 0.154017957758354 NO3 = nsm1.dataset.isel( nsm1_time_step=-1).NO3.values.item() assert isinstance(NO3, float) - assert pytest.approx(NO3, tolerance) == 6.0476352 + assert pytest.approx(NO3, tolerance) == 5.58219498187554 OrgN = nsm1.dataset.isel( nsm1_time_step=-1).OrgN.values.item() assert isinstance(OrgN, float) - assert pytest.approx(OrgN, tolerance) == 1.8995017 + assert pytest.approx(OrgN, tolerance) == 1.89950169149861 def test_changed_kon( time_steps, @@ -537,7 +537,7 @@ def test_changed_kon( """Test the model with default parameters.""" # alter parameters as necessary initial_state_dict = initial_nsm1_state - default_nitrogen_params['kon_20'] = 1 + default_nitrogen_params['kon_20'] = 0.5 # instantiate the model nsm1: NutrientBudget = get_nutrient_budget_instance( @@ -563,17 +563,17 @@ def test_changed_kon( NH4 = nsm1.dataset.isel( nsm1_time_step=-1).NH4.values.item() assert isinstance(NH4, float) - assert pytest.approx(NH4, tolerance) == 2.564564 + assert pytest.approx(NH4, tolerance) == 1.47877811233963 NO3 = nsm1.dataset.isel( nsm1_time_step=-1).NO3.values.item() assert isinstance(NO3, float) - assert pytest.approx(NO3, tolerance) == 5.1260636 + assert pytest.approx(NO3, tolerance) == 5.12606356028487 OrgN = nsm1.dataset.isel( nsm1_time_step=-1).OrgN.values.item() assert isinstance(OrgN, float) - assert pytest.approx(OrgN, tolerance) == -0.05491296 + assert pytest.approx(OrgN, tolerance) == 1.03087295850801 def test_changed_kdnit( time_steps, @@ -655,7 +655,7 @@ def test_changed_rnh4( """Test the model with default parameters.""" # alter parameters as necessary initial_state_dict = initial_nsm1_state - default_nitrogen_params['rnh4_20'] = -1 + default_nitrogen_params['rnh4_20'] = -0.5 # instantiate the model nsm1: NutrientBudget = get_nutrient_budget_instance( @@ -681,12 +681,12 @@ def test_changed_rnh4( NH4 = nsm1.dataset.isel( nsm1_time_step=-1).NH4.values.item() assert isinstance(NH4, float) - assert pytest.approx(NH4, tolerance) == -0.3424935 + assert pytest.approx(NH4, tolerance) == 0.133827915386814 NO3 = nsm1.dataset.isel( nsm1_time_step=-1).NO3.values.item() assert isinstance(NO3, float) - assert pytest.approx(NO3, tolerance) == 5.12606356 + assert pytest.approx(NO3, tolerance) == 5.12606356028487 OrgN = nsm1.dataset.isel( nsm1_time_step=-1).OrgN.values.item() From 3105badae439526ad04214730d8579ae0d016c3c Mon Sep 17 00:00:00 2001 From: kewalak Date: Tue, 6 Aug 2024 22:05:39 -0700 Subject: [PATCH 7/9] Fixed pressure_atm Pressure is now in millibar --- examples/dev_sandbox/DOX_sat_test.py | 8 ++++---- examples/dev_sandbox/model_architecture_nsm.ipynb | 10 +++++----- examples/dev_sandbox/prof_nsm.py | 2 +- src/clearwater_modules/nsm1/constants.py | 4 ++-- src/clearwater_modules/nsm1/processes.py | 12 ++++++------ src/clearwater_modules/nsm1/static_variables.py | 8 ++++---- tests/test_10_nsm_carbon_calculations.py | 2 +- tests/test_11_nsm_DOX_calculations.py | 6 +++--- tests/test_12_nsm_alkalinity_calculations.py | 2 +- tests/test_13_nsm_CBOD_calculations.py | 2 +- tests/test_14_nsm_phosphrous_calculations.py | 2 +- tests/test_15_nsm_POM_calculations.py | 2 +- tests/test_16_nsm_PX_calculations.py | 2 +- tests/test_17_nsm_N2_calculations.py | 4 ++-- tests/test_7_nsm_algae_calculations.py | 2 +- tests/test_8_nsm_balgae_calculations.py | 2 +- tests/test_9_nsm_nitrogen_calculations.py | 2 +- 17 files changed, 36 insertions(+), 36 deletions(-) diff --git a/examples/dev_sandbox/DOX_sat_test.py b/examples/dev_sandbox/DOX_sat_test.py index c733174..6a356f4 100644 --- a/examples/dev_sandbox/DOX_sat_test.py +++ b/examples/dev_sandbox/DOX_sat_test.py @@ -25,7 +25,7 @@ def DOs_atm_alpha( def DOX_sat( TwaterK: xr.DataArray, - pressure_atm: xr.DataArray, + pressure_mb: xr.DataArray, pwv: xr.DataArray, DOs_atm_alpha: xr.DataArray ) -> xr.DataArray: @@ -33,7 +33,7 @@ def DOX_sat( Args: TwaterK: Water temperature kelvin - pressure_atm: Atmospheric pressure (atm) + pressure_mb: Atmospheric pressure (mb) pwv: Patrial pressure of water vapor (atm) DOs_atm_alpha: DO saturation atmospheric correction coefficient """ @@ -44,8 +44,8 @@ def DOX_sat( DOX_sat_uncorrected = -139.34410 + ( 1.575701E05 / TwaterK ) - ( 6.642308E07 / (TwaterK**2.0) ) + ( 1.243800E10 / (TwaterK**3.0) ) - ( 8.621949E11 / (TwaterK**4.0) ) - DOX_sat_corrected = DOX_sat_uncorrected * pressure_atm * \ - (1 - pwv / pressure_atm) * (1 - DOs_atm_alpha * pressure_atm) / \ + DOX_sat_corrected = DOX_sat_uncorrected * pressure_mb * \ + (1 - pwv / pressure_mb) * (1 - DOs_atm_alpha * pressure_mb) / \ ((1 - pwv) * (1 - DOs_atm_alpha)) print(no_exp) diff --git a/examples/dev_sandbox/model_architecture_nsm.ipynb b/examples/dev_sandbox/model_architecture_nsm.ipynb index 7e0e78f..e71f6ad 100644 --- a/examples/dev_sandbox/model_architecture_nsm.ipynb +++ b/examples/dev_sandbox/model_architecture_nsm.ipynb @@ -686,7 +686,7 @@ "\n", " [[-268.60060435]]])
  • Alk
    (year, x, y)
    float64
    1.0 3.315
    long_name :
    Alkalinity
    units :
    mg-CaCO3/L
    description :
    Alkalinity concentration
    array([[[1.      ]],\n",
            "\n",
    -       "       [[3.315476]]])
  • vson
    (x, y)
    float64
    0.01
    long_name :
    Organic N settling velocity
    units :
    m/d
    description :
    Organic N settling velocity
    array([[0.01]])
  • vsoc
    (x, y)
    float64
    0.01
    long_name :
    POC settling velocity
    units :
    m/d
    description :
    POC settling velocity
    array([[0.01]])
  • vsop
    (x, y)
    float64
    0.01
    long_name :
    Organic phosphorus settling velocity
    units :
    m/d
    description :
    Organic phosphorus settling velocity
    array([[0.01]])
  • vs
    (x, y)
    float64
    0.01
    long_name :
    Sediment settling velocity
    units :
    m/d
    description :
    Sediment settling velocity
    array([[0.01]])
  • SOD_20
    (x, y)
    float64
    0.5
    long_name :
    Sediment oxygen demand at 20 degrees C
    units :
    g-O2/m/d
    description :
    Sediment oxygen demand at 20 degrees C
    array([[0.5]])
  • SOD_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for sediment oxygen demand
    units :
    unitless
    description :
    Arrhenius coefficient for sediment oxygen demand
    array([[1.047]])
  • kah_theta
    (x, y)
    int32
    1
    long_name :
    Arrhenius coefficient for hydraulic oxygen reaeration rate
    units :
    unitless
    description :
    Arrhenius coefficient for hydraulic oxygen reaeration rate
    array([[1]])
  • kaw_theta
    (x, y)
    int32
    0
    long_name :
    Arrhenius coefficient for wind oxygen reaeration velocity
    units :
    unitless
    description :
    Arrhenius coefficient for wind oxygen reaeration velocity
    array([[0]])
  • mu_max_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for algal max growth rate
    units :
    unitless
    description :
    Arrhenius coefficient for algal max growth rate
    array([[1.047]])
  • krp_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for algal respiration rate
    units :
    unitless
    description :
    Arrhenius coefficient for algal respiration rate
    array([[1.047]])
  • kdp_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for algal death rate
    units :
    unitless
    description :
    Arrhenius coefficient for algal death rate
    array([[1.047]])
  • mub_max_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for benthic algae max growth rate
    units :
    unitless
    description :
    Arrhenius coefficient for benthic algae max growth rate
    array([[1.047]])
  • krb_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for benthic algae respiration rate
    units :
    unitless
    description :
    Arrhenius coefficient for benthic algae respiration rate
    array([[1.047]])
  • kdb_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for benthic algae death rate
    units :
    unitless
    description :
    Arrhenius coefficient for benthic algae death rate
    array([[1.047]])
  • knit_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for ammonia decay rate
    units :
    unitless
    description :
    Arrhenius coefficient for ammonia decay rate
    array([[1.047]])
  • rnh4_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for rate of sediment release rate of NH4
    units :
    unitless
    description :
    Arrhenius coefficient for rate of sediment release rate of NH4
    array([[1.047]])
  • vno3_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for sediment denitrification rate
    units :
    unitless
    description :
    Arrhenius coefficient for sediment denitrification rate
    array([[1.047]])
  • kon_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for decay rate of OrgN
    units :
    unitless
    description :
    Arrhenius coefficient for decay rate of OrgN
    array([[1.047]])
  • kdnit_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for denitrification rate
    units :
    unitless
    description :
    Arrhenius coefficient for denitrification rate
    array([[1.047]])
  • kop_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for decay rate of organic P
    units :
    unitless
    description :
    Arrhenius coefficient for decay rate of organic P
    array([[1.047]])
  • rpo4_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for sediment release rate of DIP
    units :
    unitless
    description :
    Arrhenius coefficient for sediment release rate of DIP
    array([[1.047]])
  • kpom_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for POM dissolution rate
    units :
    unitless
    description :
    Arrhenius coefficient for POM dissolution rate
    array([[1.047]])
  • kbod_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for CBOD oxidation rate
    units :
    unitless
    description :
    Arrhenius coefficient for CBOD oxidation rate
    array([[1.047]])
  • ksbod_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for CBOD sedimentation rate
    units :
    unitless
    description :
    Arrhenius coefficient for CBOD sedimentation rate
    array([[1.047]])
  • kpoc_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for POC hydrolysis rate
    units :
    unitless
    description :
    Arrhenius coefficient for POC hydrolysis rate
    array([[1.047]])
  • kdoc_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for DOC oxidation rate
    units :
    unitless
    description :
    Arrhenius coefficient for DOX oxidation rate
    array([[1.047]])
  • kdx_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for pathogen death rate
    units :
    unitless
    description :
    Arrhenius coefficient for pathogen death rate
    array([[1.047]])
  • fcom
    (x, y)
    float64
    0.4
    long_name :
    Fraction of carbon in organic matter
    units :
    mg-C/mg-D
    description :
    Fraction of carbon in organic matter
    array([[0.4]])
  • vb
    (x, y)
    float64
    0.01
    long_name :
    Burial velocity
    units :
    m/d
    description :
    Rate at which constituents are buried on the bottom
    array([[0.01]])
  • kaw_20_user
    (x, y)
    int32
    0
    long_name :
    Wind oxygen reaeration velocity at 20C
    units :
    m/d
    description :
    Wind oxygen reaeration velocity at 20C
    array([[0]])
  • kah_20_user
    (x, y)
    int32
    1
    long_name :
    Hydraulic oxygen reaeration rate at 20C
    units :
    1/d
    description :
    Hydraulic oxygen reaeration rate at 20C
    array([[1]])
  • hydraulic_reaeration_option
    (x, y)
    int32
    1
    long_name :
    Option for chosing the method by which O2 reaeration rate is calculated
    units :
    unitless
    description :
    Selects method for computing O2 reaeration rate
    array([[1]])
  • wind_reaeration_option
    (x, y)
    int32
    1
    long_name :
    Option for chosing the method by which wind reaeration is calculated
    units :
    unitless
    description :
    Selects method for computing O2 reaeration due to wind
    array([[1]])
  • use_NH4
    (x, y)
    bool
    True
    long_name :
    Use ammonium module
    units :
    unitless
    description :
    True/False use ammonium module
    array([[ True]])
  • use_NO3
    (x, y)
    bool
    True
    long_name :
    Use nitrate module
    units :
    unitless
    description :
    True/False use nitrate module
    array([[ True]])
  • use_OrgN
    (x, y)
    bool
    False
    long_name :
    Use organic nitrogen module
    units :
    unitless
    description :
    True/False use organic nitrogen module
    array([[False]])
  • use_SedFlux
    (x, y)
    bool
    False
    long_name :
    Use sediment flux module
    units :
    unitless
    description :
    True/False use sediment flux module
    array([[False]])
  • use_DOX
    (x, y)
    bool
    True
    long_name :
    Use dissolved oxygen module
    units :
    unitless
    description :
    True/False use dissolved oxygen module
    array([[ True]])
  • use_Algae
    (x, y)
    bool
    True
    long_name :
    Use algae module
    units :
    unitless
    description :
    True/False use algae module
    array([[ True]])
  • use_Balgae
    (x, y)
    bool
    True
    long_name :
    Use benthic algae module
    units :
    unitless
    description :
    True/False use benthic algae module
    array([[ True]])
  • use_TIP
    (x, y)
    bool
    True
    long_name :
    Use total inorganic phosphorus module
    units :
    unitless
    description :
    True/False use total inorganic phosphorus module
    array([[ True]])
  • use_OrgP
    (x, y)
    bool
    False
    long_name :
    Use total organic phosphorus module
    units :
    unitless
    description :
    True/False use total organic phosphorus module
    array([[False]])
  • use_POC
    (x, y)
    bool
    False
    long_name :
    Use particulate organic carbon module
    units :
    unitless
    description :
    True/False use particulate organic carbon module
    array([[False]])
  • use_DOC
    (x, y)
    bool
    False
    long_name :
    Use dissolved organic carbon module
    units :
    unitless
    description :
    True/False use dissolved organic carbon module
    array([[False]])
  • use_DIC
    (x, y)
    bool
    False
    long_name :
    Use dissolved inorganic carbon module
    units :
    unitless
    description :
    True/False use dissolved inorganic carbon module
    array([[False]])
  • use_N2
    (x, y)
    bool
    False
    long_name :
    Use dissolved N2 module
    units :
    unitless
    description :
    True/False use N2 module
    array([[False]])
  • use_Pathogen
    (x, y)
    bool
    False
    long_name :
    Use pathogen module
    units :
    unitless
    description :
    True/False use pathogen module
    array([[False]])
  • use_Alk
    (x, y)
    bool
    True
    long_name :
    Use alkalinity module
    units :
    unitless
    description :
    True/False use alkalinity module
    array([[ True]])
  • use_POM
    (x, y)
    bool
    False
    long_name :
    Use particulate organic matter module
    units :
    unitless
    description :
    True/False use particulate organic matter module
    array([[False]])
  • dt
    (x, y)
    int32
    1
    long_name :
    dt
    units :
    d
    description :
    calculation dt
    array([[1]])
  • depth
    (x, y)
    float64
    1.5
    long_name :
    Depth of water in cell
    units :
    m
    description :
    Depth of water in cell
    array([[1.5]])
  • TwaterC
    (x, y)
    int32
    25
    long_name :
    Water temperature in celsius
    units :
    degrees C
    description :
    Water temperature in celsius
    array([[25]])
  • theta
    (x, y)
    float64
    1.047
    long_name :
    Water temperature theta adjustment factor
    units :
    unitless
    description :
    Water temperature theta adjustment factor
    array([[1.047]])
  • velocity
    (x, y)
    int32
    1
    long_name :
    velocity
    units :
    m/s
    description :
    Average water velocity in cell
    array([[1]])
  • flow
    (x, y)
    int32
    150
    long_name :
    flow
    units :
    m3/s
    description :
    Average flow rate in cell
    array([[150]])
  • topwidth
    (x, y)
    int32
    100
    long_name :
    topwidth
    units :
    m
    description :
    Average topwidth of cell
    array([[100]])
  • slope
    (x, y)
    float64
    0.0002
    long_name :
    slope
    units :
    TODO
    description :
    Average slope of bottom surface
    array([[0.0002]])
  • shear_velocity
    (x, y)
    float64
    0.05334
    long_name :
    shear_velocity
    units :
    TODO
    description :
    Average shear velocity on bottom surface
    array([[0.05334]])
  • pressure_atm
    (x, y)
    float64
    1.013e+03
    long_name :
    pressure_atm
    units :
    TODO
    description :
    atmospheric pressure in atm
    array([[1013.25]])
  • wind_speed
    (x, y)
    int32
    3
    long_name :
    Wind speed at 10 meters above the water surface
    units :
    m/s
    description :
    Wind speed at 10 meters above the water surface
    array([[3]])
  • q_solar
    (x, y)
    int32
    500
    long_name :
    Incident short-wave solar radiation
    units :
    W/m2
    description :
    Incident short-wave solar radiation
    array([[500]])
  • Solid
    (x, y)
    int32
    1
    long_name :
    Solid reaeration option
    units :
    Unknown
    description :
    Solid
    array([[1]])
  • AWd
    (x, y)
    int32
    100
    long_name :
    Algal Dry Weight
    units :
    mg
    description :
    Algal Dry Weight
    array([[100]])
  • AWc
    (x, y)
    int32
    40
    long_name :
    Carbon Weight
    units :
    mg
    description :
    Carbon Weight
    array([[40]])
  • AWn
    (x, y)
    float64
    7.2
    long_name :
    Nitrogen Weight
    units :
    mg
    description :
    Nitrogen Weight
    array([[7.2]])
  • AWp
    (x, y)
    int32
    1
    long_name :
    Phosphorus Weight
    units :
    mg
    description :
    Phosphorus Weight
    array([[1]])
  • AWa
    (x, y)
    int32
    1000
    long_name :
    Algal Chlorophyll
    units :
    ug Chla
    description :
    Algal Chlorophyll
    array([[1000]])
  • KL
    (x, y)
    int32
    10
    long_name :
    Light Limiting Constant for Algal Growth
    units :
    W/m^2
    description :
    Light Limiting Constant for Algal Growth
    array([[10]])
  • KsN
    (x, y)
    float64
    0.04
    long_name :
    Half-Saturation N Limiting Constant for Algal Growth
    units :
    mg-N/L
    description :
    Half-Saturation N Limiting Constant for Algal Growth
    array([[0.04]])
  • KsP
    (x, y)
    float64
    0.0012
    long_name :
    Half-Saturation P Limiting Constant for Algal Growth
    units :
    mg-P/L
    description :
    Half-Saturation P Limiting Constant for Algal Growth
    array([[0.0012]])
  • mu_max_20
    (x, y)
    int32
    1
    long_name :
    Max Algae Growth
    units :
    1/d
    description :
    Max Algae Growth at 20C
    array([[1]])
  • kdp_20
    (x, y)
    float64
    0.15
    long_name :
    Algal Mortality Rate
    units :
    1/d
    description :
    Algal Mortality Rate at 20C
    array([[0.15]])
  • krp_20
    (x, y)
    float64
    0.2
    long_name :
    Algal Respiration Rate
    units :
    1/d
    description :
    Algal Respiration Rate at 20C
    array([[0.2]])
  • vsap
    (x, y)
    float64
    0.15
    long_name :
    Algal Setting Velocity
    units :
    m/d
    description :
    Algal Setting Velocity
    array([[0.15]])
  • growth_rate_option
    (x, y)
    int32
    1
    long_name :
    Growth Rate Option
    units :
    1/d
    description :
    Algal growth rate option 1) multiplicative, 2) Limiting Nutrient, 3) Harmonic Mean Option
    array([[1]])
  • light_limitation_option
    (x, y)
    int32
    1
    long_name :
    Light Limitation Option
    units :
    1/d
    description :
    Algal light limitation 1) half-saturation, 2) Smith model, 3) Steele model
    array([[1]])
  • lambda0
    (x, y)
    float64
    0.02
    long_name :
    lambda0
    units :
    1/m
    description :
    background portion
    array([[0.02]])
  • lambda1
    (x, y)
    float64
    0.0088
    long_name :
    lambda1
    units :
    1/m/(ug Chla/L)
    description :
    linear self shading
    array([[0.0088]])
  • lambda2
    (x, y)
    float64
    0.054
    long_name :
    lambda2
    units :
    unitless
    description :
    nonlinear
    array([[0.054]])
  • lambdas
    (x, y)
    float64
    0.056
    long_name :
    lambdas
    units :
    L/mg/m
    description :
    ISS portion
    array([[0.056]])
  • lambdam
    (x, y)
    float64
    0.174
    long_name :
    lambdam
    units :
    L/mg/m
    description :
    POM portion
    array([[0.174]])
  • Fr_PAR
    (x, y)
    float64
    0.47
    long_name :
    fraction PAR
    units :
    unitless
    description :
    fraction of solar radiation within the PAR of the spectrum
    array([[0.47]])
  • Fw
    (x, y)
    float64
    0.9
    long_name :
    Fraction of benthic algae mortality into water column
    units :
    unitless
    description :
    Fraction of benthic algae mortality into water column
    array([[0.9]])
  • Fb
    (x, y)
    float64
    0.9
    long_name :
    Fraction of bottom area available for benthic algae
    units :
    unitless
    description :
    Fraction of bottom area available for benthic algae
    array([[0.9]])
  • BWd
    (x, y)
    int32
    100
    long_name :
    Benthic algae dry weight
    units :
    unitless
    description :
    Benthic algae dry weight
    array([[100]])
  • BWc
    (x, y)
    int32
    40
    long_name :
    Benthic algae carbon
    units :
    unitless
    description :
    Benthic algae carbon
    array([[40]])
  • BWn
    (x, y)
    float64
    7.2
    long_name :
    Benthic algae nitrogen
    units :
    unitless
    description :
    Benthic algae nitrogen
    array([[7.2]])
  • BWp
    (x, y)
    int32
    1
    long_name :
    Benthic algae phosphorus
    units :
    unitless
    description :
    Benthic algae phosphorus
    array([[1]])
  • BWa
    (x, y)
    int32
    5000
    long_name :
    Benthic algae Chla
    units :
    unitless
    description :
    Benthic algae Chla
    array([[5000]])
  • KLb
    (x, y)
    int32
    10
    long_name :
    Light limiting constant for benthic algae growth
    units :
    W/m^2
    description :
    Light limiting constant for benthic algae growth
    array([[10]])
  • KsNb
    (x, y)
    float64
    0.25
    long_name :
    Half-Saturation N limiting constant for Benthic algae
    units :
    mg-N/L
    description :
    Half-Saturation N limiting constant for Benthic algae
    array([[0.25]])
  • KsPb
    (x, y)
    float64
    0.125
    long_name :
    Half-Saturation P limiting constant for Benthic algae
    units :
    mg-P/L
    description :
    Half-Saturation P limiting constant for Benthic algae
    array([[0.125]])
  • Ksb
    (x, y)
    int32
    10
    long_name :
    Half-Saturation density constant for benthic algae growth
    units :
    g-D/m^2
    description :
    Half-Saturation density constant for benthic algae growth
    array([[10]])
  • mub_max_20
    (x, y)
    float64
    0.4
    long_name :
    Maximum benthic algal growth rate
    units :
    1/d
    description :
    maximum benthic algal growth rate
    array([[0.4]])
  • krb_20
    (x, y)
    float64
    0.2
    long_name :
    Benthic algal respiration rate
    units :
    1/d
    description :
    Benthic algal respiration rate
    array([[0.2]])
  • kdb_20
    (x, y)
    float64
    0.3
    long_name :
    Benthic algal mortality rate
    units :
    1/d
    description :
    Benthic algal mortality rate
    array([[0.3]])
  • b_growth_rate_option
    (x, y)
    int32
    1
    long_name :
    Benthic Algal growth rate options
    units :
    unitless
    description :
    Benthic Algal growth rate with two options: 1) Multiplicative, 2) Limiting Nutritent
    array([[1]])
  • b_light_limitation_option
    (x, y)
    int32
    1
    long_name :
    Benthic Algal light limitation rate options
    units :
    unitless
    description :
    Benthic Algal light limitation rate with three options: 1) Half-saturation formulation, 2) Smiths Model, 3) Steeles Model
    array([[1]])
  • KNR
    (x, y)
    float64
    0.6
    long_name :
    Oxygen inhabitation factor for nitrification
    units :
    mg-O2/L
    description :
    Oxygen inhabitation factor for nitrification
    array([[0.6]])
  • knit_20
    (x, y)
    float64
    0.1
    long_name :
    Nitrification Rate Ammonia decay at 20C
    units :
    1/d
    description :
    Nitrification Rate Ammonia NH4 -> NO3 decay at 20C
    array([[0.1]])
  • kon_20
    (x, y)
    float64
    0.1
    long_name :
    Decay Rate of OrgN to NH4 at 20C
    units :
    1/d
    description :
    Decay Rate of OrgN to NH4 at 20C
    array([[0.1]])
  • kdnit_20
    (x, y)
    float64
    0.002
    long_name :
    Denitrification rate at 20C
    units :
    1/d
    description :
    Denitrification rate at 20C
    array([[0.002]])
  • rnh4_20
    (x, y)
    int32
    0
    long_name :
    Sediment release rate of NH4 at 20C
    units :
    g-N/m^2/d
    description :
    Sediment release rate of NH4 at 20C
    array([[0]])
  • vno3_20
    (x, y)
    int32
    0
    long_name :
    Sediment denitrification velocity at 20C
    units :
    m/d
    description :
    Sediment denitrification velocity at 20C
    array([[0]])
  • KsOxdn
    (x, y)
    float64
    0.1
    long_name :
    Half-saturation oxygen inhibition constant for denitrification
    units :
    mg-O2/L
    description :
    Half-saturation oxygen inhibition constant for denitrification
    array([[0.1]])
  • PN
    (x, y)
    float64
    0.5
    long_name :
    NH4 preference factor algae
    units :
    unitless
    description :
    NH4 preference factor algae (1=full NH4, 0=full NO3)
    array([[0.5]])
  • PNb
    (x, y)
    float64
    0.5
    long_name :
    NH4 preference factor benthic algae
    units :
    unitless
    description :
    NH4 preference factor benthic algae (1=full NH4, 0=full NO3)
    array([[0.5]])
  • kop_20
    (x, y)
    float64
    0.1
    long_name :
    Decay rate of organic P to DIP
    units :
    1/d
    description :
    Decay rate of organic P to DIP
    array([[0.1]])
  • rpo4_20
    (x, y)
    int32
    0
    long_name :
    Benthic sediment release rate of DIP
    units :
    g-P/m^2/d
    description :
    Benthic sediment release rate of DIP
    array([[0]])
  • kdpo4
    (x, y)
    int32
    100
    long_name :
    solid partitioning coeff. of PO4
    units :
    L/kg
    description :
    solid partitioning coeff. of PO4
    array([[100]])
  • kpom_20
    (x, y)
    float64
    0.1
    long_name :
    POM dissolution rate at 20C
    units :
    1/d
    description :
    POM dissolution rate at 20C
    array([[0.1]])
  • kbod_20
    (x, y)
    float64
    0.12
    long_name :
    CBOD oxidation rate at 20C
    units :
    1/d
    description :
    CBOD oxidation rate at 20C
    array([[0.12]])
  • ksbod_20
    (x, y)
    int32
    0
    long_name :
    CBOD sedimentation rate at 20C
    units :
    m/d
    description :
    CBOD sedimentation rate at 20C
    array([[0]])
  • KsOxbod
    (x, y)
    float64
    0.5
    long_name :
    Half saturation oxygen attenuation constant for CBOD oxidation
    units :
    mg-O2/L
    description :
    Half saturation oxygen attenuation constant for CBOD oxidation
    array([[0.5]])
  • f_pocp
    (x, y)
    float64
    0.9
    long_name :
    Fraction of algal mortality into POC
    units :
    unitless
    description :
    Fraction of dead algae that converts to particulate organic carbon
    array([[0.9]])
  • kdoc_20
    (x, y)
    float64
    0.01
    long_name :
    Dissolved organic carbon oxidation rate
    units :
    1/d
    description :
    Dissolved organic carbon oxidation rate
    array([[0.01]])
  • f_pocb
    (x, y)
    float64
    0.9
    long_name :
    fraction of benthic algal mortality into POC
    units :
    unitless
    description :
    fraction of benthic algal mortality into POC
    array([[0.9]])
  • kpoc_20
    (x, y)
    float64
    0.005
    long_name :
    POC hydrolysis rate at 20 degrees Celsius
    units :
    1/d
    description :
    POC hydrolysis rate at 20 degrees Celsius
    array([[0.005]])
  • KsOxmc
    (x, y)
    int32
    1
    long_name :
    half saturation oxygen attenuation constant for DOC oxidation rate
    units :
    mg-O2/L
    description :
    half saturation oxygen attenuation constant for DOC oxidation rate
    array([[1]])
  • pCO2
    (x, y)
    int32
    383
    long_name :
    partial atmospheric CO2 pressure
    units :
    ppm
    description :
    partial pressure of CO2 in the atmosphere
    array([[383]])
  • FCO2
    (x, y)
    float64
    0.2
    long_name :
    CO2 reaeration rate
    units :
    1/d
    description :
    CO2 reaeration rate
    array([[0.2]])
  • roc
    (x, y)
    float64
    2.667
    long_name :
    O2:C ratio for carbon oxidation
    units :
    mg-O2/mg-C
    description :
    O2:C ratio for carbon oxidation (32/12)
    array([[2.66666667]])
  • ron
    (x, y)
    float64
    4.571
    long_name :
    O2:N ratio for nitrification
    units :
    mg-O2/mg-N
    description :
    O2:N ratio for nitrification (2*32/14)
    array([[4.57142857]])
  • KsSOD
    (x, y)
    int32
    1
    long_name :
    half saturation oxygen attenuation constant for SOD
    units :
    mg/L
    description :
    half saturation oxygen attenuation constant for SOD
    array([[1]])
  • kdx_20
    (x, y)
    float64
    0.8
    long_name :
    Pathogen death rate at 20C
    units :
    1/d
    description :
    Pathogen death rate at 20C
    array([[0.8]])
  • apx
    (x, y)
    int32
    1
    long_name :
    Light efficiency factor for pathogen decay
    units :
    unitless
    description :
    Light efficiency factor for pathogen decay
    array([[1]])
  • vx
    (x, y)
    int32
    1
    long_name :
    Pathogen net settling velocity
    units :
    unitless
    description :
    Pathogen net settling velocity
    array([[1]])
  • r_alkaa
    (x, y)
    float64
    1.101e-05
    long_name :
    Ratio translating algal growth into Alk if NH4 is the N source
    units :
    eq/ug-Chla
    description :
    Ratio translating algal growth into Alk if NH4 is the N source
    array([[1.10062893e-05]])
  • r_alkan
    (x, y)
    float64
    1.415e-05
    long_name :
    Ratio translating algal growth into Alk if NO3 is the N source
    units :
    eq/ug-Chla
    description :
    Ratio translating algal growth into Alk if NO3 is the N source
    array([[1.41509434e-05]])
  • r_alkn
    (x, y)
    float64
    0.0001429
    long_name :
    Ratio translating NH4 nitrification into Alk
    units :
    eq/mg-N
    description :
    Ratio translating NH4 nitrification into Alk
    array([[0.00014286]])
  • r_alkden
    (x, y)
    float64
    0.0002857
    long_name :
    Ratio translating NO3 denitrification into Alk
    units :
    eq/mg-N
    description :
    Ratio translating NO3 denitrification into Alk
    array([[0.00028571]])
  • r_alkba
    (x, y)
    float64
    1.101e-05
    long_name :
    Ratio translating benthic algae growth into Alk if NH4 is the N source
    units :
    eq/mg-D
    description :
    Ratio translating benthic algae growth into Alk if NH4 is the N source
    array([[1.10062893e-05]])
  • r_alkbn
    (x, y)
    float64
    1.415e-05
    long_name :
    Ratio translating benthic algae growth into Alk if NO3 is the N source
    units :
    eq/mg-D
    description :
    Ratio translating benthic algae growth into Alk if NO3 is the N source
    array([[1.41509434e-05]])
  • TwaterK
    (year, x, y)
    float64
    nan 298.2
    long_name :
    Water Temperature K
    units :
    K
    description :
    Water temperature degree kelvin
    array([[[   nan]],\n",
    +       "       [[3.315476]]])
  • vson
    (x, y)
    float64
    0.01
    long_name :
    Organic N settling velocity
    units :
    m/d
    description :
    Organic N settling velocity
    array([[0.01]])
  • vsoc
    (x, y)
    float64
    0.01
    long_name :
    POC settling velocity
    units :
    m/d
    description :
    POC settling velocity
    array([[0.01]])
  • vsop
    (x, y)
    float64
    0.01
    long_name :
    Organic phosphorus settling velocity
    units :
    m/d
    description :
    Organic phosphorus settling velocity
    array([[0.01]])
  • vs
    (x, y)
    float64
    0.01
    long_name :
    Sediment settling velocity
    units :
    m/d
    description :
    Sediment settling velocity
    array([[0.01]])
  • SOD_20
    (x, y)
    float64
    0.5
    long_name :
    Sediment oxygen demand at 20 degrees C
    units :
    g-O2/m/d
    description :
    Sediment oxygen demand at 20 degrees C
    array([[0.5]])
  • SOD_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for sediment oxygen demand
    units :
    unitless
    description :
    Arrhenius coefficient for sediment oxygen demand
    array([[1.047]])
  • kah_theta
    (x, y)
    int32
    1
    long_name :
    Arrhenius coefficient for hydraulic oxygen reaeration rate
    units :
    unitless
    description :
    Arrhenius coefficient for hydraulic oxygen reaeration rate
    array([[1]])
  • kaw_theta
    (x, y)
    int32
    0
    long_name :
    Arrhenius coefficient for wind oxygen reaeration velocity
    units :
    unitless
    description :
    Arrhenius coefficient for wind oxygen reaeration velocity
    array([[0]])
  • mu_max_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for algal max growth rate
    units :
    unitless
    description :
    Arrhenius coefficient for algal max growth rate
    array([[1.047]])
  • krp_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for algal respiration rate
    units :
    unitless
    description :
    Arrhenius coefficient for algal respiration rate
    array([[1.047]])
  • kdp_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for algal death rate
    units :
    unitless
    description :
    Arrhenius coefficient for algal death rate
    array([[1.047]])
  • mub_max_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for benthic algae max growth rate
    units :
    unitless
    description :
    Arrhenius coefficient for benthic algae max growth rate
    array([[1.047]])
  • krb_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for benthic algae respiration rate
    units :
    unitless
    description :
    Arrhenius coefficient for benthic algae respiration rate
    array([[1.047]])
  • kdb_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for benthic algae death rate
    units :
    unitless
    description :
    Arrhenius coefficient for benthic algae death rate
    array([[1.047]])
  • knit_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for ammonia decay rate
    units :
    unitless
    description :
    Arrhenius coefficient for ammonia decay rate
    array([[1.047]])
  • rnh4_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for rate of sediment release rate of NH4
    units :
    unitless
    description :
    Arrhenius coefficient for rate of sediment release rate of NH4
    array([[1.047]])
  • vno3_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for sediment denitrification rate
    units :
    unitless
    description :
    Arrhenius coefficient for sediment denitrification rate
    array([[1.047]])
  • kon_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for decay rate of OrgN
    units :
    unitless
    description :
    Arrhenius coefficient for decay rate of OrgN
    array([[1.047]])
  • kdnit_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for denitrification rate
    units :
    unitless
    description :
    Arrhenius coefficient for denitrification rate
    array([[1.047]])
  • kop_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for decay rate of organic P
    units :
    unitless
    description :
    Arrhenius coefficient for decay rate of organic P
    array([[1.047]])
  • rpo4_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for sediment release rate of DIP
    units :
    unitless
    description :
    Arrhenius coefficient for sediment release rate of DIP
    array([[1.047]])
  • kpom_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for POM dissolution rate
    units :
    unitless
    description :
    Arrhenius coefficient for POM dissolution rate
    array([[1.047]])
  • kbod_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for CBOD oxidation rate
    units :
    unitless
    description :
    Arrhenius coefficient for CBOD oxidation rate
    array([[1.047]])
  • ksbod_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for CBOD sedimentation rate
    units :
    unitless
    description :
    Arrhenius coefficient for CBOD sedimentation rate
    array([[1.047]])
  • kpoc_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for POC hydrolysis rate
    units :
    unitless
    description :
    Arrhenius coefficient for POC hydrolysis rate
    array([[1.047]])
  • kdoc_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for DOC oxidation rate
    units :
    unitless
    description :
    Arrhenius coefficient for DOX oxidation rate
    array([[1.047]])
  • kdx_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for pathogen death rate
    units :
    unitless
    description :
    Arrhenius coefficient for pathogen death rate
    array([[1.047]])
  • fcom
    (x, y)
    float64
    0.4
    long_name :
    Fraction of carbon in organic matter
    units :
    mg-C/mg-D
    description :
    Fraction of carbon in organic matter
    array([[0.4]])
  • vb
    (x, y)
    float64
    0.01
    long_name :
    Burial velocity
    units :
    m/d
    description :
    Rate at which constituents are buried on the bottom
    array([[0.01]])
  • kaw_20_user
    (x, y)
    int32
    0
    long_name :
    Wind oxygen reaeration velocity at 20C
    units :
    m/d
    description :
    Wind oxygen reaeration velocity at 20C
    array([[0]])
  • kah_20_user
    (x, y)
    int32
    1
    long_name :
    Hydraulic oxygen reaeration rate at 20C
    units :
    1/d
    description :
    Hydraulic oxygen reaeration rate at 20C
    array([[1]])
  • hydraulic_reaeration_option
    (x, y)
    int32
    1
    long_name :
    Option for chosing the method by which O2 reaeration rate is calculated
    units :
    unitless
    description :
    Selects method for computing O2 reaeration rate
    array([[1]])
  • wind_reaeration_option
    (x, y)
    int32
    1
    long_name :
    Option for chosing the method by which wind reaeration is calculated
    units :
    unitless
    description :
    Selects method for computing O2 reaeration due to wind
    array([[1]])
  • use_NH4
    (x, y)
    bool
    True
    long_name :
    Use ammonium module
    units :
    unitless
    description :
    True/False use ammonium module
    array([[ True]])
  • use_NO3
    (x, y)
    bool
    True
    long_name :
    Use nitrate module
    units :
    unitless
    description :
    True/False use nitrate module
    array([[ True]])
  • use_OrgN
    (x, y)
    bool
    False
    long_name :
    Use organic nitrogen module
    units :
    unitless
    description :
    True/False use organic nitrogen module
    array([[False]])
  • use_SedFlux
    (x, y)
    bool
    False
    long_name :
    Use sediment flux module
    units :
    unitless
    description :
    True/False use sediment flux module
    array([[False]])
  • use_DOX
    (x, y)
    bool
    True
    long_name :
    Use dissolved oxygen module
    units :
    unitless
    description :
    True/False use dissolved oxygen module
    array([[ True]])
  • use_Algae
    (x, y)
    bool
    True
    long_name :
    Use algae module
    units :
    unitless
    description :
    True/False use algae module
    array([[ True]])
  • use_Balgae
    (x, y)
    bool
    True
    long_name :
    Use benthic algae module
    units :
    unitless
    description :
    True/False use benthic algae module
    array([[ True]])
  • use_TIP
    (x, y)
    bool
    True
    long_name :
    Use total inorganic phosphorus module
    units :
    unitless
    description :
    True/False use total inorganic phosphorus module
    array([[ True]])
  • use_OrgP
    (x, y)
    bool
    False
    long_name :
    Use total organic phosphorus module
    units :
    unitless
    description :
    True/False use total organic phosphorus module
    array([[False]])
  • use_POC
    (x, y)
    bool
    False
    long_name :
    Use particulate organic carbon module
    units :
    unitless
    description :
    True/False use particulate organic carbon module
    array([[False]])
  • use_DOC
    (x, y)
    bool
    False
    long_name :
    Use dissolved organic carbon module
    units :
    unitless
    description :
    True/False use dissolved organic carbon module
    array([[False]])
  • use_DIC
    (x, y)
    bool
    False
    long_name :
    Use dissolved inorganic carbon module
    units :
    unitless
    description :
    True/False use dissolved inorganic carbon module
    array([[False]])
  • use_N2
    (x, y)
    bool
    False
    long_name :
    Use dissolved N2 module
    units :
    unitless
    description :
    True/False use N2 module
    array([[False]])
  • use_Pathogen
    (x, y)
    bool
    False
    long_name :
    Use pathogen module
    units :
    unitless
    description :
    True/False use pathogen module
    array([[False]])
  • use_Alk
    (x, y)
    bool
    True
    long_name :
    Use alkalinity module
    units :
    unitless
    description :
    True/False use alkalinity module
    array([[ True]])
  • use_POM
    (x, y)
    bool
    False
    long_name :
    Use particulate organic matter module
    units :
    unitless
    description :
    True/False use particulate organic matter module
    array([[False]])
  • dt
    (x, y)
    int32
    1
    long_name :
    dt
    units :
    d
    description :
    calculation dt
    array([[1]])
  • depth
    (x, y)
    float64
    1.5
    long_name :
    Depth of water in cell
    units :
    m
    description :
    Depth of water in cell
    array([[1.5]])
  • TwaterC
    (x, y)
    int32
    25
    long_name :
    Water temperature in celsius
    units :
    degrees C
    description :
    Water temperature in celsius
    array([[25]])
  • theta
    (x, y)
    float64
    1.047
    long_name :
    Water temperature theta adjustment factor
    units :
    unitless
    description :
    Water temperature theta adjustment factor
    array([[1.047]])
  • velocity
    (x, y)
    int32
    1
    long_name :
    velocity
    units :
    m/s
    description :
    Average water velocity in cell
    array([[1]])
  • flow
    (x, y)
    int32
    150
    long_name :
    flow
    units :
    m3/s
    description :
    Average flow rate in cell
    array([[150]])
  • topwidth
    (x, y)
    int32
    100
    long_name :
    topwidth
    units :
    m
    description :
    Average topwidth of cell
    array([[100]])
  • slope
    (x, y)
    float64
    0.0002
    long_name :
    slope
    units :
    TODO
    description :
    Average slope of bottom surface
    array([[0.0002]])
  • shear_velocity
    (x, y)
    float64
    0.05334
    long_name :
    shear_velocity
    units :
    TODO
    description :
    Average shear velocity on bottom surface
    array([[0.05334]])
  • pressure_mb
    (x, y)
    float64
    1.013e+03
    long_name :
    pressure_mb
    units :
    TODO
    description :
    atmospheric pressure in atm
    array([[1013.25]])
  • wind_speed
    (x, y)
    int32
    3
    long_name :
    Wind speed at 10 meters above the water surface
    units :
    m/s
    description :
    Wind speed at 10 meters above the water surface
    array([[3]])
  • q_solar
    (x, y)
    int32
    500
    long_name :
    Incident short-wave solar radiation
    units :
    W/m2
    description :
    Incident short-wave solar radiation
    array([[500]])
  • Solid
    (x, y)
    int32
    1
    long_name :
    Solid reaeration option
    units :
    Unknown
    description :
    Solid
    array([[1]])
  • AWd
    (x, y)
    int32
    100
    long_name :
    Algal Dry Weight
    units :
    mg
    description :
    Algal Dry Weight
    array([[100]])
  • AWc
    (x, y)
    int32
    40
    long_name :
    Carbon Weight
    units :
    mg
    description :
    Carbon Weight
    array([[40]])
  • AWn
    (x, y)
    float64
    7.2
    long_name :
    Nitrogen Weight
    units :
    mg
    description :
    Nitrogen Weight
    array([[7.2]])
  • AWp
    (x, y)
    int32
    1
    long_name :
    Phosphorus Weight
    units :
    mg
    description :
    Phosphorus Weight
    array([[1]])
  • AWa
    (x, y)
    int32
    1000
    long_name :
    Algal Chlorophyll
    units :
    ug Chla
    description :
    Algal Chlorophyll
    array([[1000]])
  • KL
    (x, y)
    int32
    10
    long_name :
    Light Limiting Constant for Algal Growth
    units :
    W/m^2
    description :
    Light Limiting Constant for Algal Growth
    array([[10]])
  • KsN
    (x, y)
    float64
    0.04
    long_name :
    Half-Saturation N Limiting Constant for Algal Growth
    units :
    mg-N/L
    description :
    Half-Saturation N Limiting Constant for Algal Growth
    array([[0.04]])
  • KsP
    (x, y)
    float64
    0.0012
    long_name :
    Half-Saturation P Limiting Constant for Algal Growth
    units :
    mg-P/L
    description :
    Half-Saturation P Limiting Constant for Algal Growth
    array([[0.0012]])
  • mu_max_20
    (x, y)
    int32
    1
    long_name :
    Max Algae Growth
    units :
    1/d
    description :
    Max Algae Growth at 20C
    array([[1]])
  • kdp_20
    (x, y)
    float64
    0.15
    long_name :
    Algal Mortality Rate
    units :
    1/d
    description :
    Algal Mortality Rate at 20C
    array([[0.15]])
  • krp_20
    (x, y)
    float64
    0.2
    long_name :
    Algal Respiration Rate
    units :
    1/d
    description :
    Algal Respiration Rate at 20C
    array([[0.2]])
  • vsap
    (x, y)
    float64
    0.15
    long_name :
    Algal Setting Velocity
    units :
    m/d
    description :
    Algal Setting Velocity
    array([[0.15]])
  • growth_rate_option
    (x, y)
    int32
    1
    long_name :
    Growth Rate Option
    units :
    1/d
    description :
    Algal growth rate option 1) multiplicative, 2) Limiting Nutrient, 3) Harmonic Mean Option
    array([[1]])
  • light_limitation_option
    (x, y)
    int32
    1
    long_name :
    Light Limitation Option
    units :
    1/d
    description :
    Algal light limitation 1) half-saturation, 2) Smith model, 3) Steele model
    array([[1]])
  • lambda0
    (x, y)
    float64
    0.02
    long_name :
    lambda0
    units :
    1/m
    description :
    background portion
    array([[0.02]])
  • lambda1
    (x, y)
    float64
    0.0088
    long_name :
    lambda1
    units :
    1/m/(ug Chla/L)
    description :
    linear self shading
    array([[0.0088]])
  • lambda2
    (x, y)
    float64
    0.054
    long_name :
    lambda2
    units :
    unitless
    description :
    nonlinear
    array([[0.054]])
  • lambdas
    (x, y)
    float64
    0.056
    long_name :
    lambdas
    units :
    L/mg/m
    description :
    ISS portion
    array([[0.056]])
  • lambdam
    (x, y)
    float64
    0.174
    long_name :
    lambdam
    units :
    L/mg/m
    description :
    POM portion
    array([[0.174]])
  • Fr_PAR
    (x, y)
    float64
    0.47
    long_name :
    fraction PAR
    units :
    unitless
    description :
    fraction of solar radiation within the PAR of the spectrum
    array([[0.47]])
  • Fw
    (x, y)
    float64
    0.9
    long_name :
    Fraction of benthic algae mortality into water column
    units :
    unitless
    description :
    Fraction of benthic algae mortality into water column
    array([[0.9]])
  • Fb
    (x, y)
    float64
    0.9
    long_name :
    Fraction of bottom area available for benthic algae
    units :
    unitless
    description :
    Fraction of bottom area available for benthic algae
    array([[0.9]])
  • BWd
    (x, y)
    int32
    100
    long_name :
    Benthic algae dry weight
    units :
    unitless
    description :
    Benthic algae dry weight
    array([[100]])
  • BWc
    (x, y)
    int32
    40
    long_name :
    Benthic algae carbon
    units :
    unitless
    description :
    Benthic algae carbon
    array([[40]])
  • BWn
    (x, y)
    float64
    7.2
    long_name :
    Benthic algae nitrogen
    units :
    unitless
    description :
    Benthic algae nitrogen
    array([[7.2]])
  • BWp
    (x, y)
    int32
    1
    long_name :
    Benthic algae phosphorus
    units :
    unitless
    description :
    Benthic algae phosphorus
    array([[1]])
  • BWa
    (x, y)
    int32
    5000
    long_name :
    Benthic algae Chla
    units :
    unitless
    description :
    Benthic algae Chla
    array([[5000]])
  • KLb
    (x, y)
    int32
    10
    long_name :
    Light limiting constant for benthic algae growth
    units :
    W/m^2
    description :
    Light limiting constant for benthic algae growth
    array([[10]])
  • KsNb
    (x, y)
    float64
    0.25
    long_name :
    Half-Saturation N limiting constant for Benthic algae
    units :
    mg-N/L
    description :
    Half-Saturation N limiting constant for Benthic algae
    array([[0.25]])
  • KsPb
    (x, y)
    float64
    0.125
    long_name :
    Half-Saturation P limiting constant for Benthic algae
    units :
    mg-P/L
    description :
    Half-Saturation P limiting constant for Benthic algae
    array([[0.125]])
  • Ksb
    (x, y)
    int32
    10
    long_name :
    Half-Saturation density constant for benthic algae growth
    units :
    g-D/m^2
    description :
    Half-Saturation density constant for benthic algae growth
    array([[10]])
  • mub_max_20
    (x, y)
    float64
    0.4
    long_name :
    Maximum benthic algal growth rate
    units :
    1/d
    description :
    maximum benthic algal growth rate
    array([[0.4]])
  • krb_20
    (x, y)
    float64
    0.2
    long_name :
    Benthic algal respiration rate
    units :
    1/d
    description :
    Benthic algal respiration rate
    array([[0.2]])
  • kdb_20
    (x, y)
    float64
    0.3
    long_name :
    Benthic algal mortality rate
    units :
    1/d
    description :
    Benthic algal mortality rate
    array([[0.3]])
  • b_growth_rate_option
    (x, y)
    int32
    1
    long_name :
    Benthic Algal growth rate options
    units :
    unitless
    description :
    Benthic Algal growth rate with two options: 1) Multiplicative, 2) Limiting Nutritent
    array([[1]])
  • b_light_limitation_option
    (x, y)
    int32
    1
    long_name :
    Benthic Algal light limitation rate options
    units :
    unitless
    description :
    Benthic Algal light limitation rate with three options: 1) Half-saturation formulation, 2) Smiths Model, 3) Steeles Model
    array([[1]])
  • KNR
    (x, y)
    float64
    0.6
    long_name :
    Oxygen inhabitation factor for nitrification
    units :
    mg-O2/L
    description :
    Oxygen inhabitation factor for nitrification
    array([[0.6]])
  • knit_20
    (x, y)
    float64
    0.1
    long_name :
    Nitrification Rate Ammonia decay at 20C
    units :
    1/d
    description :
    Nitrification Rate Ammonia NH4 -> NO3 decay at 20C
    array([[0.1]])
  • kon_20
    (x, y)
    float64
    0.1
    long_name :
    Decay Rate of OrgN to NH4 at 20C
    units :
    1/d
    description :
    Decay Rate of OrgN to NH4 at 20C
    array([[0.1]])
  • kdnit_20
    (x, y)
    float64
    0.002
    long_name :
    Denitrification rate at 20C
    units :
    1/d
    description :
    Denitrification rate at 20C
    array([[0.002]])
  • rnh4_20
    (x, y)
    int32
    0
    long_name :
    Sediment release rate of NH4 at 20C
    units :
    g-N/m^2/d
    description :
    Sediment release rate of NH4 at 20C
    array([[0]])
  • vno3_20
    (x, y)
    int32
    0
    long_name :
    Sediment denitrification velocity at 20C
    units :
    m/d
    description :
    Sediment denitrification velocity at 20C
    array([[0]])
  • KsOxdn
    (x, y)
    float64
    0.1
    long_name :
    Half-saturation oxygen inhibition constant for denitrification
    units :
    mg-O2/L
    description :
    Half-saturation oxygen inhibition constant for denitrification
    array([[0.1]])
  • PN
    (x, y)
    float64
    0.5
    long_name :
    NH4 preference factor algae
    units :
    unitless
    description :
    NH4 preference factor algae (1=full NH4, 0=full NO3)
    array([[0.5]])
  • PNb
    (x, y)
    float64
    0.5
    long_name :
    NH4 preference factor benthic algae
    units :
    unitless
    description :
    NH4 preference factor benthic algae (1=full NH4, 0=full NO3)
    array([[0.5]])
  • kop_20
    (x, y)
    float64
    0.1
    long_name :
    Decay rate of organic P to DIP
    units :
    1/d
    description :
    Decay rate of organic P to DIP
    array([[0.1]])
  • rpo4_20
    (x, y)
    int32
    0
    long_name :
    Benthic sediment release rate of DIP
    units :
    g-P/m^2/d
    description :
    Benthic sediment release rate of DIP
    array([[0]])
  • kdpo4
    (x, y)
    int32
    100
    long_name :
    solid partitioning coeff. of PO4
    units :
    L/kg
    description :
    solid partitioning coeff. of PO4
    array([[100]])
  • kpom_20
    (x, y)
    float64
    0.1
    long_name :
    POM dissolution rate at 20C
    units :
    1/d
    description :
    POM dissolution rate at 20C
    array([[0.1]])
  • kbod_20
    (x, y)
    float64
    0.12
    long_name :
    CBOD oxidation rate at 20C
    units :
    1/d
    description :
    CBOD oxidation rate at 20C
    array([[0.12]])
  • ksbod_20
    (x, y)
    int32
    0
    long_name :
    CBOD sedimentation rate at 20C
    units :
    m/d
    description :
    CBOD sedimentation rate at 20C
    array([[0]])
  • KsOxbod
    (x, y)
    float64
    0.5
    long_name :
    Half saturation oxygen attenuation constant for CBOD oxidation
    units :
    mg-O2/L
    description :
    Half saturation oxygen attenuation constant for CBOD oxidation
    array([[0.5]])
  • f_pocp
    (x, y)
    float64
    0.9
    long_name :
    Fraction of algal mortality into POC
    units :
    unitless
    description :
    Fraction of dead algae that converts to particulate organic carbon
    array([[0.9]])
  • kdoc_20
    (x, y)
    float64
    0.01
    long_name :
    Dissolved organic carbon oxidation rate
    units :
    1/d
    description :
    Dissolved organic carbon oxidation rate
    array([[0.01]])
  • f_pocb
    (x, y)
    float64
    0.9
    long_name :
    fraction of benthic algal mortality into POC
    units :
    unitless
    description :
    fraction of benthic algal mortality into POC
    array([[0.9]])
  • kpoc_20
    (x, y)
    float64
    0.005
    long_name :
    POC hydrolysis rate at 20 degrees Celsius
    units :
    1/d
    description :
    POC hydrolysis rate at 20 degrees Celsius
    array([[0.005]])
  • KsOxmc
    (x, y)
    int32
    1
    long_name :
    half saturation oxygen attenuation constant for DOC oxidation rate
    units :
    mg-O2/L
    description :
    half saturation oxygen attenuation constant for DOC oxidation rate
    array([[1]])
  • pCO2
    (x, y)
    int32
    383
    long_name :
    partial atmospheric CO2 pressure
    units :
    ppm
    description :
    partial pressure of CO2 in the atmosphere
    array([[383]])
  • FCO2
    (x, y)
    float64
    0.2
    long_name :
    CO2 reaeration rate
    units :
    1/d
    description :
    CO2 reaeration rate
    array([[0.2]])
  • roc
    (x, y)
    float64
    2.667
    long_name :
    O2:C ratio for carbon oxidation
    units :
    mg-O2/mg-C
    description :
    O2:C ratio for carbon oxidation (32/12)
    array([[2.66666667]])
  • ron
    (x, y)
    float64
    4.571
    long_name :
    O2:N ratio for nitrification
    units :
    mg-O2/mg-N
    description :
    O2:N ratio for nitrification (2*32/14)
    array([[4.57142857]])
  • KsSOD
    (x, y)
    int32
    1
    long_name :
    half saturation oxygen attenuation constant for SOD
    units :
    mg/L
    description :
    half saturation oxygen attenuation constant for SOD
    array([[1]])
  • kdx_20
    (x, y)
    float64
    0.8
    long_name :
    Pathogen death rate at 20C
    units :
    1/d
    description :
    Pathogen death rate at 20C
    array([[0.8]])
  • apx
    (x, y)
    int32
    1
    long_name :
    Light efficiency factor for pathogen decay
    units :
    unitless
    description :
    Light efficiency factor for pathogen decay
    array([[1]])
  • vx
    (x, y)
    int32
    1
    long_name :
    Pathogen net settling velocity
    units :
    unitless
    description :
    Pathogen net settling velocity
    array([[1]])
  • r_alkaa
    (x, y)
    float64
    1.101e-05
    long_name :
    Ratio translating algal growth into Alk if NH4 is the N source
    units :
    eq/ug-Chla
    description :
    Ratio translating algal growth into Alk if NH4 is the N source
    array([[1.10062893e-05]])
  • r_alkan
    (x, y)
    float64
    1.415e-05
    long_name :
    Ratio translating algal growth into Alk if NO3 is the N source
    units :
    eq/ug-Chla
    description :
    Ratio translating algal growth into Alk if NO3 is the N source
    array([[1.41509434e-05]])
  • r_alkn
    (x, y)
    float64
    0.0001429
    long_name :
    Ratio translating NH4 nitrification into Alk
    units :
    eq/mg-N
    description :
    Ratio translating NH4 nitrification into Alk
    array([[0.00014286]])
  • r_alkden
    (x, y)
    float64
    0.0002857
    long_name :
    Ratio translating NO3 denitrification into Alk
    units :
    eq/mg-N
    description :
    Ratio translating NO3 denitrification into Alk
    array([[0.00028571]])
  • r_alkba
    (x, y)
    float64
    1.101e-05
    long_name :
    Ratio translating benthic algae growth into Alk if NH4 is the N source
    units :
    eq/mg-D
    description :
    Ratio translating benthic algae growth into Alk if NH4 is the N source
    array([[1.10062893e-05]])
  • r_alkbn
    (x, y)
    float64
    1.415e-05
    long_name :
    Ratio translating benthic algae growth into Alk if NO3 is the N source
    units :
    eq/mg-D
    description :
    Ratio translating benthic algae growth into Alk if NO3 is the N source
    array([[1.41509434e-05]])
  • TwaterK
    (year, x, y)
    float64
    nan 298.2
    long_name :
    Water Temperature K
    units :
    K
    description :
    Water temperature degree kelvin
    array([[[   nan]],\n",
            "\n",
            "       [[298.16]]])
  • SOD_tc
    (year, x, y)
    float64
    nan 0.3145
    long_name :
    Sediment Oxygen Demand at water temperature tc
    units :
    mg/L
    description :
    Sediment Oxygen Demand at water temperature tc
    array([[[       nan]],\n",
            "\n",
    @@ -1205,7 +1205,7 @@
         "    'topwidth': 100,\n",
         "    'slope': .0002,\n",
         "    'shear_velocity': 0.05334,\n",
    -    "    'pressure_atm': 1013.25,\n",
    +    "    'pressure_mb': 1013.25,\n",
         "    'wind_speed': 3,\n",
         "    'q_solar': 500,\n",
         "    'Solid': 1,\n",
    @@ -1638,7 +1638,7 @@
         "    'topwidth': 100,\n",
         "    'slope': .0002,\n",
         "    'shear_velocity': 0.05334,\n",
    -    "    'pressure_atm': 1013.25,\n",
    +    "    'pressure_mb': 1013.25,\n",
         "    'wind_speed': 3,\n",
         "    'q_solar': 500,\n",
         "    'Solid': 1,\n",
    @@ -2720,7 +2720,7 @@
            "\n",
            "       [[100.00000062]],\n",
            "\n",
    -       "       [[100.00000063]]])
  • vson
    (x, y)
    float64
    0.01
    long_name :
    Organic N settling velocity
    units :
    m/d
    description :
    Organic N settling velocity
    array([[0.01]])
  • vsoc
    (x, y)
    float64
    0.01
    long_name :
    POC settling velocity
    units :
    m/d
    description :
    POC settling velocity
    array([[0.01]])
  • vsop
    (x, y)
    float64
    0.01
    long_name :
    Organic phosphorus settling velocity
    units :
    m/d
    description :
    Organic phosphorus settling velocity
    array([[0.01]])
  • vs
    (x, y)
    float64
    0.01
    long_name :
    Sediment settling velocity
    units :
    m/d
    description :
    Sediment settling velocity
    array([[0.01]])
  • SOD_20
    (x, y)
    float64
    0.24
    long_name :
    Sediment oxygen demand at 20 degrees C
    units :
    g-O2/m/d
    description :
    Sediment oxygen demand at 20 degrees C
    array([[0.24]])
  • SOD_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for sediment oxygen demand
    units :
    unitless
    description :
    Arrhenius coefficient for sediment oxygen demand
    array([[1.047]])
  • fcom
    (x, y)
    float64
    0.4
    long_name :
    Fraction of carbon in organic matter
    units :
    mg-C/mg-D
    description :
    Fraction of carbon in organic matter
    array([[0.4]])
  • vb
    (x, y)
    float64
    0.01
    long_name :
    Burial velocity
    units :
    m/d
    description :
    Rate at which constituents are buried on the bottom
    array([[0.01]])
  • kaw_20_user
    (x, y)
    float64
    3.263
    long_name :
    Wind oxygen reaeration velocity at 20C
    units :
    m/d
    description :
    Wind oxygen reaeration velocity at 20C
    array([[3.26278]])
  • kah_20_user
    (x, y)
    float64
    2.139
    long_name :
    Hydraulic oxygen reaeration rate at 20C
    units :
    1/d
    description :
    Hydraulic oxygen reaeration rate at 20C
    array([[2.13922]])
  • hydraulic_reaeration_option
    (x, y)
    int32
    1
    long_name :
    Option for chosing the method by which O2 reaeration rate is calculated
    units :
    unitless
    description :
    Selects method for computing O2 reaeration rate
    array([[1]])
  • wind_reaeration_option
    (x, y)
    int32
    1
    long_name :
    Option for chosing the method by which wind reaeration is calculated
    units :
    unitless
    description :
    Selects method for computing O2 reaeration due to wind
    array([[1]])
  • use_NH4
    (x, y)
    bool
    True
    long_name :
    Use ammonium module
    units :
    unitless
    description :
    True/False use ammonium module
    array([[ True]])
  • use_NO3
    (x, y)
    bool
    True
    long_name :
    Use nitrate module
    units :
    unitless
    description :
    True/False use nitrate module
    array([[ True]])
  • use_OrgN
    (x, y)
    bool
    True
    long_name :
    Use organic nitrogen module
    units :
    unitless
    description :
    True/False use organic nitrogen module
    array([[ True]])
  • use_SedFlux
    (x, y)
    bool
    False
    long_name :
    Use sediment flux module
    units :
    unitless
    description :
    True/False use sediment flux module
    array([[False]])
  • use_DOX
    (x, y)
    bool
    True
    long_name :
    Use dissolved oxygen module
    units :
    unitless
    description :
    True/False use dissolved oxygen module
    array([[ True]])
  • use_Algae
    (x, y)
    bool
    True
    long_name :
    Use algae module
    units :
    unitless
    description :
    True/False use algae module
    array([[ True]])
  • use_Balgae
    (x, y)
    bool
    True
    long_name :
    Use benthic algae module
    units :
    unitless
    description :
    True/False use benthic algae module
    array([[ True]])
  • use_TIP
    (x, y)
    bool
    True
    long_name :
    Use total inorganic phosphorus module
    units :
    unitless
    description :
    True/False use total inorganic phosphorus module
    array([[ True]])
  • use_OrgP
    (x, y)
    bool
    True
    long_name :
    Use total organic phosphorus module
    units :
    unitless
    description :
    True/False use total organic phosphorus module
    array([[ True]])
  • use_POC
    (x, y)
    bool
    True
    long_name :
    Use particulate organic carbon module
    units :
    unitless
    description :
    True/False use particulate organic carbon module
    array([[ True]])
  • use_DOC
    (x, y)
    bool
    True
    long_name :
    Use dissolved organic carbon module
    units :
    unitless
    description :
    True/False use dissolved organic carbon module
    array([[ True]])
  • use_DIC
    (x, y)
    bool
    True
    long_name :
    Use dissolved inorganic carbon module
    units :
    unitless
    description :
    True/False use dissolved inorganic carbon module
    array([[ True]])
  • use_N2
    (x, y)
    bool
    True
    long_name :
    Use dissolved N2 module
    units :
    unitless
    description :
    True/False use N2 module
    array([[ True]])
  • use_Pathogen
    (x, y)
    bool
    True
    long_name :
    Use pathogen module
    units :
    unitless
    description :
    True/False use pathogen module
    array([[ True]])
  • use_Alk
    (x, y)
    bool
    True
    long_name :
    Use alkalinity module
    units :
    unitless
    description :
    True/False use alkalinity module
    array([[ True]])
  • use_POM
    (x, y)
    bool
    True
    long_name :
    Use particulate organic matter module
    units :
    unitless
    description :
    True/False use particulate organic matter module
    array([[ True]])
  • dt
    (x, y)
    float64
    1.157e-05
    long_name :
    dt
    units :
    d
    description :
    calculation dt
    array([[1.15740741e-05]])
  • depth
    (x, y)
    float64
    1.5
    long_name :
    Depth of water in cell
    units :
    m
    description :
    Depth of water in cell
    array([[1.5]])
  • TwaterC
    (x, y)
    int32
    25
    long_name :
    Water temperature in celsius
    units :
    degrees C
    description :
    Water temperature in celsius
    array([[25]])
  • theta
    (x, y)
    float64
    1.047
    long_name :
    Water temperature theta adjustment factor
    units :
    unitless
    description :
    Water temperature theta adjustment factor
    array([[1.047]])
  • velocity
    (x, y)
    int32
    1
    long_name :
    velocity
    units :
    m/s
    description :
    Average water velocity in cell
    array([[1]])
  • flow
    (x, y)
    int32
    150
    long_name :
    flow
    units :
    m3/s
    description :
    Average flow rate in cell
    array([[150]])
  • topwidth
    (x, y)
    int32
    100
    long_name :
    topwidth
    units :
    m
    description :
    Average topwidth of cell
    array([[100]])
  • slope
    (x, y)
    float64
    0.0002
    long_name :
    slope
    units :
    TODO
    description :
    Average slope of bottom surface
    array([[0.0002]])
  • shear_velocity
    (x, y)
    float64
    0.05334
    long_name :
    shear_velocity
    units :
    TODO
    description :
    Average shear velocity on bottom surface
    array([[0.05334]])
  • pressure_atm
    (x, y)
    float64
    1.013e+03
    long_name :
    pressure_atm
    units :
    TODO
    description :
    atmospheric pressure in atm
    array([[1013.25]])
  • wind_speed
    (x, y)
    int32
    3
    long_name :
    Wind speed at 10 meters above the water surface
    units :
    m/s
    description :
    Wind speed at 10 meters above the water surface
    array([[3]])
  • q_solar
    (x, y)
    int32
    500
    long_name :
    Incident short-wave solar radiation
    units :
    W/m2
    description :
    Incident short-wave solar radiation
    array([[500]])
  • Solid
    (x, y)
    int32
    1
    long_name :
    Solid reaeration option
    units :
    Unknown
    description :
    Solid
    array([[1]])
  • AWd
    (x, y)
    int32
    100
    long_name :
    Algal Dry Weight
    units :
    mg
    description :
    Algal Dry Weight
    array([[100]])
  • AWc
    (x, y)
    int32
    40
    long_name :
    Carbon Weight
    units :
    mg
    description :
    Carbon Weight
    array([[40]])
  • AWn
    (x, y)
    float64
    7.2
    long_name :
    Nitrogen Weight
    units :
    mg
    description :
    Nitrogen Weight
    array([[7.2]])
  • AWp
    (x, y)
    int32
    1
    long_name :
    Phosphorus Weight
    units :
    mg
    description :
    Phosphorus Weight
    array([[1]])
  • AWa
    (x, y)
    int32
    1000
    long_name :
    Algal Chlorophyll
    units :
    ug Chla
    description :
    Algal Chlorophyll
    array([[1000]])
  • KL
    (x, y)
    int32
    10
    long_name :
    Light Limiting Constant for Algal Growth
    units :
    W/m^2
    description :
    Light Limiting Constant for Algal Growth
    array([[10]])
  • KsN
    (x, y)
    float64
    0.04
    long_name :
    Half-Saturation N Limiting Constant for Algal Growth
    units :
    mg-N/L
    description :
    Half-Saturation N Limiting Constant for Algal Growth
    array([[0.04]])
  • KsP
    (x, y)
    float64
    0.0012
    long_name :
    Half-Saturation P Limiting Constant for Algal Growth
    units :
    mg-P/L
    description :
    Half-Saturation P Limiting Constant for Algal Growth
    array([[0.0012]])
  • mu_max_20
    (x, y)
    int32
    1
    long_name :
    Max Algae Growth
    units :
    1/d
    description :
    Max Algae Growth at 20C
    array([[1]])
  • kdp_20
    (x, y)
    float64
    0.15
    long_name :
    Algal Mortality Rate
    units :
    1/d
    description :
    Algal Mortality Rate at 20C
    array([[0.15]])
  • krp_20
    (x, y)
    float64
    0.2
    long_name :
    Algal Respiration Rate
    units :
    1/d
    description :
    Algal Respiration Rate at 20C
    array([[0.2]])
  • vsap
    (x, y)
    float64
    0.15
    long_name :
    Algal Setting Velocity
    units :
    m/d
    description :
    Algal Setting Velocity
    array([[0.15]])
  • growth_rate_option
    (x, y)
    int32
    1
    long_name :
    Growth Rate Option
    units :
    1/d
    description :
    Algal growth rate option 1) multiplicative, 2) Limiting Nutrient, 3) Harmonic Mean Option
    array([[1]])
  • light_limitation_option
    (x, y)
    int32
    1
    long_name :
    Light Limitation Option
    units :
    1/d
    description :
    Algal light limitation 1) half-saturation, 2) Smith model, 3) Steele model
    array([[1]])
  • lambda0
    (x, y)
    float64
    0.1
    long_name :
    lambda0
    units :
    1/m
    description :
    background portion
    array([[0.1]])
  • lambda1
    (x, y)
    float64
    0.0098
    long_name :
    lambda1
    units :
    1/m/(ug Chla/L)
    description :
    linear self shading
    array([[0.0098]])
  • lambda2
    (x, y)
    float64
    0.064
    long_name :
    lambda2
    units :
    unitless
    description :
    nonlinear
    array([[0.064]])
  • lambdas
    (x, y)
    float64
    0.056
    long_name :
    lambdas
    units :
    L/mg/m
    description :
    ISS portion
    array([[0.056]])
  • lambdam
    (x, y)
    float64
    0.184
    long_name :
    lambdam
    units :
    L/mg/m
    description :
    POM portion
    array([[0.184]])
  • Fr_PAR
    (x, y)
    float64
    0.47
    long_name :
    fraction PAR
    units :
    unitless
    description :
    fraction of solar radiation within the PAR of the spectrum
    array([[0.47]])
  • Fw
    (x, y)
    float64
    0.9
    long_name :
    Fraction of benthic algae mortality into water column
    units :
    unitless
    description :
    Fraction of benthic algae mortality into water column
    array([[0.9]])
  • Fb
    (x, y)
    float64
    0.9
    long_name :
    Fraction of bottom area available for benthic algae
    units :
    unitless
    description :
    Fraction of bottom area available for benthic algae
    array([[0.9]])
  • BWd
    (x, y)
    int32
    100
    long_name :
    Benthic algae dry weight
    units :
    unitless
    description :
    Benthic algae dry weight
    array([[100]])
  • BWc
    (x, y)
    int32
    40
    long_name :
    Benthic algae carbon
    units :
    unitless
    description :
    Benthic algae carbon
    array([[40]])
  • BWn
    (x, y)
    float64
    7.2
    long_name :
    Benthic algae nitrogen
    units :
    unitless
    description :
    Benthic algae nitrogen
    array([[7.2]])
  • BWp
    (x, y)
    int32
    1
    long_name :
    Benthic algae phosphorus
    units :
    unitless
    description :
    Benthic algae phosphorus
    array([[1]])
  • BWa
    (x, y)
    int32
    5000
    long_name :
    Benthic algae Chla
    units :
    unitless
    description :
    Benthic algae Chla
    array([[5000]])
  • KLb
    (x, y)
    int32
    10
    long_name :
    Light limiting constant for benthic algae growth
    units :
    W/m^2
    description :
    Light limiting constant for benthic algae growth
    array([[10]])
  • KsNb
    (x, y)
    float64
    0.25
    long_name :
    Half-Saturation N limiting constant for Benthic algae
    units :
    mg-N/L
    description :
    Half-Saturation N limiting constant for Benthic algae
    array([[0.25]])
  • KsPb
    (x, y)
    float64
    0.125
    long_name :
    Half-Saturation P limiting constant for Benthic algae
    units :
    mg-P/L
    description :
    Half-Saturation P limiting constant for Benthic algae
    array([[0.125]])
  • Ksb
    (x, y)
    int32
    10
    long_name :
    Half-Saturation density constant for benthic algae growth
    units :
    g-D/m^2
    description :
    Half-Saturation density constant for benthic algae growth
    array([[10]])
  • mub_max_20
    (x, y)
    float64
    0.4
    long_name :
    Maximum benthic algal growth rate
    units :
    1/d
    description :
    maximum benthic algal growth rate
    array([[0.4]])
  • krb_20
    (x, y)
    float64
    0.2
    long_name :
    Benthic algal respiration rate
    units :
    1/d
    description :
    Benthic algal respiration rate
    array([[0.2]])
  • kdb_20
    (x, y)
    float64
    0.3
    long_name :
    Benthic algal mortality rate
    units :
    1/d
    description :
    Benthic algal mortality rate
    array([[0.3]])
  • b_growth_rate_option
    (x, y)
    int32
    1
    long_name :
    Benthic Algal growth rate options
    units :
    unitless
    description :
    Benthic Algal growth rate with two options: 1) Multiplicative, 2) Limiting Nutritent
    array([[1]])
  • b_light_limitation_option
    (x, y)
    int32
    1
    long_name :
    Benthic Algal light limitation rate options
    units :
    unitless
    description :
    Benthic Algal light limitation rate with three options: 1) Half-saturation formulation, 2) Smiths Model, 3) Steeles Model
    array([[1]])
  • KNR
    (x, y)
    float64
    0.6
    long_name :
    Oxygen inhabitation factor for nitrification
    units :
    mg-O2/L
    description :
    Oxygen inhabitation factor for nitrification
    array([[0.6]])
  • knit_20
    (x, y)
    float64
    0.1
    long_name :
    Nitrification Rate Ammonia decay at 20C
    units :
    1/d
    description :
    Nitrification Rate Ammonia NH4 -> NO3 decay at 20C
    array([[0.1]])
  • kon_20
    (x, y)
    float64
    0.1
    long_name :
    Decay Rate of OrgN to NH4 at 20C
    units :
    1/d
    description :
    Decay Rate of OrgN to NH4 at 20C
    array([[0.1]])
  • kdnit_20
    (x, y)
    float64
    0.002
    long_name :
    Denitrification rate at 20C
    units :
    1/d
    description :
    Denitrification rate at 20C
    array([[0.002]])
  • rnh4_20
    (x, y)
    int32
    0
    long_name :
    Sediment release rate of NH4 at 20C
    units :
    g-N/m^2/d
    description :
    Sediment release rate of NH4 at 20C
    array([[0]])
  • vno3_20
    (x, y)
    int32
    0
    long_name :
    Sediment denitrification velocity at 20C
    units :
    m/d
    description :
    Sediment denitrification velocity at 20C
    array([[0]])
  • KsOxdn
    (x, y)
    float64
    0.1
    long_name :
    Half-saturation oxygen inhibition constant for denitrification
    units :
    mg-O2/L
    description :
    Half-saturation oxygen inhibition constant for denitrification
    array([[0.1]])
  • PN
    (x, y)
    float64
    0.5
    long_name :
    NH4 preference factor algae
    units :
    unitless
    description :
    NH4 preference factor algae (1=full NH4, 0=full NO3)
    array([[0.5]])
  • PNb
    (x, y)
    float64
    0.5
    long_name :
    NH4 preference factor benthic algae
    units :
    unitless
    description :
    NH4 preference factor benthic algae (1=full NH4, 0=full NO3)
    array([[0.5]])
  • kop_20
    (x, y)
    float64
    0.1
    long_name :
    Decay rate of organic P to DIP
    units :
    1/d
    description :
    Decay rate of organic P to DIP
    array([[0.1]])
  • rpo4_20
    (x, y)
    int32
    0
    long_name :
    Benthic sediment release rate of DIP
    units :
    g-P/m^2/d
    description :
    Benthic sediment release rate of DIP
    array([[0]])
  • kdpo4
    (x, y)
    int32
    100
    long_name :
    solid partitioning coeff. of PO4
    units :
    L/kg
    description :
    solid partitioning coeff. of PO4
    array([[100]])
  • kpom_20
    (x, y)
    float64
    0.1
    long_name :
    POM dissolution rate at 20C
    units :
    1/d
    description :
    POM dissolution rate at 20C
    array([[0.1]])
  • kbod_20
    (x, y)
    float64
    0.12
    long_name :
    CBOD oxidation rate at 20C
    units :
    1/d
    description :
    CBOD oxidation rate at 20C
    array([[0.12]])
  • ksbod_20
    (x, y)
    int32
    0
    long_name :
    CBOD sedimentation rate at 20C
    units :
    m/d
    description :
    CBOD sedimentation rate at 20C
    array([[0]])
  • KsOxbod
    (x, y)
    float64
    0.5
    long_name :
    Half saturation oxygen attenuation constant for CBOD oxidation
    units :
    mg-O2/L
    description :
    Half saturation oxygen attenuation constant for CBOD oxidation
    array([[0.5]])
  • f_pocp
    (x, y)
    float64
    0.9
    long_name :
    Fraction of algal mortality into POC
    units :
    unitless
    description :
    Fraction of dead algae that converts to particulate organic carbon
    array([[0.9]])
  • kdoc_20
    (x, y)
    float64
    0.01
    long_name :
    Dissolved organic carbon oxidation rate
    units :
    1/d
    description :
    Dissolved organic carbon oxidation rate
    array([[0.01]])
  • f_pocb
    (x, y)
    float64
    0.9
    long_name :
    fraction of benthic algal mortality into POC
    units :
    unitless
    description :
    fraction of benthic algal mortality into POC
    array([[0.9]])
  • kpoc_20
    (x, y)
    float64
    0.005
    long_name :
    POC hydrolysis rate at 20 degrees Celsius
    units :
    1/d
    description :
    POC hydrolysis rate at 20 degrees Celsius
    array([[0.005]])
  • KsOxmc
    (x, y)
    float64
    1.0
    long_name :
    half saturation oxygen attenuation constant for DOC oxidation rate
    units :
    mg-O2/L
    description :
    half saturation oxygen attenuation constant for DOC oxidation rate
    array([[1.]])
  • pCO2
    (x, y)
    int32
    383
    long_name :
    partial atmospheric CO2 pressure
    units :
    ppm
    description :
    partial pressure of CO2 in the atmosphere
    array([[383]])
  • FCO2
    (x, y)
    float64
    0.2
    long_name :
    CO2 reaeration rate
    units :
    1/d
    description :
    CO2 reaeration rate
    array([[0.2]])
  • roc
    (x, y)
    float64
    2.667
    long_name :
    O2:C ratio for carbon oxidation
    units :
    mg-O2/mg-C
    description :
    O2:C ratio for carbon oxidation (32/12)
    array([[2.66666667]])
  • ron
    (x, y)
    float64
    4.571
    long_name :
    O2:N ratio for nitrification
    units :
    mg-O2/mg-N
    description :
    O2:N ratio for nitrification (2*32/14)
    array([[4.57142857]])
  • KsSOD
    (x, y)
    int32
    1
    long_name :
    half saturation oxygen attenuation constant for SOD
    units :
    mg/L
    description :
    half saturation oxygen attenuation constant for SOD
    array([[1]])
  • kdx_20
    (x, y)
    float64
    0.8
    long_name :
    Pathogen death rate at 20C
    units :
    1/d
    description :
    Pathogen death rate at 20C
    array([[0.8]])
  • apx
    (x, y)
    int32
    1
    long_name :
    Light efficiency factor for pathogen decay
    units :
    unitless
    description :
    Light efficiency factor for pathogen decay
    array([[1]])
  • vx
    (x, y)
    int32
    1
    long_name :
    Pathogen net settling velocity
    units :
    unitless
    description :
    Pathogen net settling velocity
    array([[1]])
  • r_alkaa
    (x, y)
    float64
    1.101e-05
    long_name :
    Ratio translating algal growth into Alk if NH4 is the N source
    units :
    eq/ug-Chla
    description :
    Ratio translating algal growth into Alk if NH4 is the N source
    array([[1.10062893e-05]])
  • r_alkan
    (x, y)
    float64
    1.415e-05
    long_name :
    Ratio translating algal growth into Alk if NO3 is the N source
    units :
    eq/ug-Chla
    description :
    Ratio translating algal growth into Alk if NO3 is the N source
    array([[1.41509434e-05]])
  • r_alkn
    (x, y)
    float64
    0.0001429
    long_name :
    Ratio translating NH4 nitrification into Alk
    units :
    eq/mg-N
    description :
    Ratio translating NH4 nitrification into Alk
    array([[0.00014286]])
  • r_alkden
    (x, y)
    float64
    0.0002857
    long_name :
    Ratio translating NO3 denitrification into Alk
    units :
    eq/mg-N
    description :
    Ratio translating NO3 denitrification into Alk
    array([[0.00028571]])
  • r_alkba
    (x, y)
    float64
    1.101e-05
    long_name :
    Ratio translating benthic algae growth into Alk if NH4 is the N source
    units :
    eq/mg-D
    description :
    Ratio translating benthic algae growth into Alk if NH4 is the N source
    array([[1.10062893e-05]])
  • r_alkbn
    (x, y)
    float64
    1.415e-05
    long_name :
    Ratio translating benthic algae growth into Alk if NO3 is the N source
    units :
    eq/mg-D
    description :
    Ratio translating benthic algae growth into Alk if NO3 is the N source
    array([[1.41509434e-05]])
  • TwaterK
    (year, x, y)
    float64
    nan 298.2 298.2 ... 298.2 298.2
    long_name :
    Water Temperature K
    units :
    K
    description :
    Water temperature degree kelvin
    array([[[   nan]],\n",
    +       "       [[100.00000063]]])
  • vson
    (x, y)
    float64
    0.01
    long_name :
    Organic N settling velocity
    units :
    m/d
    description :
    Organic N settling velocity
    array([[0.01]])
  • vsoc
    (x, y)
    float64
    0.01
    long_name :
    POC settling velocity
    units :
    m/d
    description :
    POC settling velocity
    array([[0.01]])
  • vsop
    (x, y)
    float64
    0.01
    long_name :
    Organic phosphorus settling velocity
    units :
    m/d
    description :
    Organic phosphorus settling velocity
    array([[0.01]])
  • vs
    (x, y)
    float64
    0.01
    long_name :
    Sediment settling velocity
    units :
    m/d
    description :
    Sediment settling velocity
    array([[0.01]])
  • SOD_20
    (x, y)
    float64
    0.24
    long_name :
    Sediment oxygen demand at 20 degrees C
    units :
    g-O2/m/d
    description :
    Sediment oxygen demand at 20 degrees C
    array([[0.24]])
  • SOD_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for sediment oxygen demand
    units :
    unitless
    description :
    Arrhenius coefficient for sediment oxygen demand
    array([[1.047]])
  • fcom
    (x, y)
    float64
    0.4
    long_name :
    Fraction of carbon in organic matter
    units :
    mg-C/mg-D
    description :
    Fraction of carbon in organic matter
    array([[0.4]])
  • vb
    (x, y)
    float64
    0.01
    long_name :
    Burial velocity
    units :
    m/d
    description :
    Rate at which constituents are buried on the bottom
    array([[0.01]])
  • kaw_20_user
    (x, y)
    float64
    3.263
    long_name :
    Wind oxygen reaeration velocity at 20C
    units :
    m/d
    description :
    Wind oxygen reaeration velocity at 20C
    array([[3.26278]])
  • kah_20_user
    (x, y)
    float64
    2.139
    long_name :
    Hydraulic oxygen reaeration rate at 20C
    units :
    1/d
    description :
    Hydraulic oxygen reaeration rate at 20C
    array([[2.13922]])
  • hydraulic_reaeration_option
    (x, y)
    int32
    1
    long_name :
    Option for chosing the method by which O2 reaeration rate is calculated
    units :
    unitless
    description :
    Selects method for computing O2 reaeration rate
    array([[1]])
  • wind_reaeration_option
    (x, y)
    int32
    1
    long_name :
    Option for chosing the method by which wind reaeration is calculated
    units :
    unitless
    description :
    Selects method for computing O2 reaeration due to wind
    array([[1]])
  • use_NH4
    (x, y)
    bool
    True
    long_name :
    Use ammonium module
    units :
    unitless
    description :
    True/False use ammonium module
    array([[ True]])
  • use_NO3
    (x, y)
    bool
    True
    long_name :
    Use nitrate module
    units :
    unitless
    description :
    True/False use nitrate module
    array([[ True]])
  • use_OrgN
    (x, y)
    bool
    True
    long_name :
    Use organic nitrogen module
    units :
    unitless
    description :
    True/False use organic nitrogen module
    array([[ True]])
  • use_SedFlux
    (x, y)
    bool
    False
    long_name :
    Use sediment flux module
    units :
    unitless
    description :
    True/False use sediment flux module
    array([[False]])
  • use_DOX
    (x, y)
    bool
    True
    long_name :
    Use dissolved oxygen module
    units :
    unitless
    description :
    True/False use dissolved oxygen module
    array([[ True]])
  • use_Algae
    (x, y)
    bool
    True
    long_name :
    Use algae module
    units :
    unitless
    description :
    True/False use algae module
    array([[ True]])
  • use_Balgae
    (x, y)
    bool
    True
    long_name :
    Use benthic algae module
    units :
    unitless
    description :
    True/False use benthic algae module
    array([[ True]])
  • use_TIP
    (x, y)
    bool
    True
    long_name :
    Use total inorganic phosphorus module
    units :
    unitless
    description :
    True/False use total inorganic phosphorus module
    array([[ True]])
  • use_OrgP
    (x, y)
    bool
    True
    long_name :
    Use total organic phosphorus module
    units :
    unitless
    description :
    True/False use total organic phosphorus module
    array([[ True]])
  • use_POC
    (x, y)
    bool
    True
    long_name :
    Use particulate organic carbon module
    units :
    unitless
    description :
    True/False use particulate organic carbon module
    array([[ True]])
  • use_DOC
    (x, y)
    bool
    True
    long_name :
    Use dissolved organic carbon module
    units :
    unitless
    description :
    True/False use dissolved organic carbon module
    array([[ True]])
  • use_DIC
    (x, y)
    bool
    True
    long_name :
    Use dissolved inorganic carbon module
    units :
    unitless
    description :
    True/False use dissolved inorganic carbon module
    array([[ True]])
  • use_N2
    (x, y)
    bool
    True
    long_name :
    Use dissolved N2 module
    units :
    unitless
    description :
    True/False use N2 module
    array([[ True]])
  • use_Pathogen
    (x, y)
    bool
    True
    long_name :
    Use pathogen module
    units :
    unitless
    description :
    True/False use pathogen module
    array([[ True]])
  • use_Alk
    (x, y)
    bool
    True
    long_name :
    Use alkalinity module
    units :
    unitless
    description :
    True/False use alkalinity module
    array([[ True]])
  • use_POM
    (x, y)
    bool
    True
    long_name :
    Use particulate organic matter module
    units :
    unitless
    description :
    True/False use particulate organic matter module
    array([[ True]])
  • dt
    (x, y)
    float64
    1.157e-05
    long_name :
    dt
    units :
    d
    description :
    calculation dt
    array([[1.15740741e-05]])
  • depth
    (x, y)
    float64
    1.5
    long_name :
    Depth of water in cell
    units :
    m
    description :
    Depth of water in cell
    array([[1.5]])
  • TwaterC
    (x, y)
    int32
    25
    long_name :
    Water temperature in celsius
    units :
    degrees C
    description :
    Water temperature in celsius
    array([[25]])
  • theta
    (x, y)
    float64
    1.047
    long_name :
    Water temperature theta adjustment factor
    units :
    unitless
    description :
    Water temperature theta adjustment factor
    array([[1.047]])
  • velocity
    (x, y)
    int32
    1
    long_name :
    velocity
    units :
    m/s
    description :
    Average water velocity in cell
    array([[1]])
  • flow
    (x, y)
    int32
    150
    long_name :
    flow
    units :
    m3/s
    description :
    Average flow rate in cell
    array([[150]])
  • topwidth
    (x, y)
    int32
    100
    long_name :
    topwidth
    units :
    m
    description :
    Average topwidth of cell
    array([[100]])
  • slope
    (x, y)
    float64
    0.0002
    long_name :
    slope
    units :
    TODO
    description :
    Average slope of bottom surface
    array([[0.0002]])
  • shear_velocity
    (x, y)
    float64
    0.05334
    long_name :
    shear_velocity
    units :
    TODO
    description :
    Average shear velocity on bottom surface
    array([[0.05334]])
  • pressure_mb
    (x, y)
    float64
    1.013e+03
    long_name :
    pressure_mb
    units :
    TODO
    description :
    atmospheric pressure in atm
    array([[1013.25]])
  • wind_speed
    (x, y)
    int32
    3
    long_name :
    Wind speed at 10 meters above the water surface
    units :
    m/s
    description :
    Wind speed at 10 meters above the water surface
    array([[3]])
  • q_solar
    (x, y)
    int32
    500
    long_name :
    Incident short-wave solar radiation
    units :
    W/m2
    description :
    Incident short-wave solar radiation
    array([[500]])
  • Solid
    (x, y)
    int32
    1
    long_name :
    Solid reaeration option
    units :
    Unknown
    description :
    Solid
    array([[1]])
  • AWd
    (x, y)
    int32
    100
    long_name :
    Algal Dry Weight
    units :
    mg
    description :
    Algal Dry Weight
    array([[100]])
  • AWc
    (x, y)
    int32
    40
    long_name :
    Carbon Weight
    units :
    mg
    description :
    Carbon Weight
    array([[40]])
  • AWn
    (x, y)
    float64
    7.2
    long_name :
    Nitrogen Weight
    units :
    mg
    description :
    Nitrogen Weight
    array([[7.2]])
  • AWp
    (x, y)
    int32
    1
    long_name :
    Phosphorus Weight
    units :
    mg
    description :
    Phosphorus Weight
    array([[1]])
  • AWa
    (x, y)
    int32
    1000
    long_name :
    Algal Chlorophyll
    units :
    ug Chla
    description :
    Algal Chlorophyll
    array([[1000]])
  • KL
    (x, y)
    int32
    10
    long_name :
    Light Limiting Constant for Algal Growth
    units :
    W/m^2
    description :
    Light Limiting Constant for Algal Growth
    array([[10]])
  • KsN
    (x, y)
    float64
    0.04
    long_name :
    Half-Saturation N Limiting Constant for Algal Growth
    units :
    mg-N/L
    description :
    Half-Saturation N Limiting Constant for Algal Growth
    array([[0.04]])
  • KsP
    (x, y)
    float64
    0.0012
    long_name :
    Half-Saturation P Limiting Constant for Algal Growth
    units :
    mg-P/L
    description :
    Half-Saturation P Limiting Constant for Algal Growth
    array([[0.0012]])
  • mu_max_20
    (x, y)
    int32
    1
    long_name :
    Max Algae Growth
    units :
    1/d
    description :
    Max Algae Growth at 20C
    array([[1]])
  • kdp_20
    (x, y)
    float64
    0.15
    long_name :
    Algal Mortality Rate
    units :
    1/d
    description :
    Algal Mortality Rate at 20C
    array([[0.15]])
  • krp_20
    (x, y)
    float64
    0.2
    long_name :
    Algal Respiration Rate
    units :
    1/d
    description :
    Algal Respiration Rate at 20C
    array([[0.2]])
  • vsap
    (x, y)
    float64
    0.15
    long_name :
    Algal Setting Velocity
    units :
    m/d
    description :
    Algal Setting Velocity
    array([[0.15]])
  • growth_rate_option
    (x, y)
    int32
    1
    long_name :
    Growth Rate Option
    units :
    1/d
    description :
    Algal growth rate option 1) multiplicative, 2) Limiting Nutrient, 3) Harmonic Mean Option
    array([[1]])
  • light_limitation_option
    (x, y)
    int32
    1
    long_name :
    Light Limitation Option
    units :
    1/d
    description :
    Algal light limitation 1) half-saturation, 2) Smith model, 3) Steele model
    array([[1]])
  • lambda0
    (x, y)
    float64
    0.1
    long_name :
    lambda0
    units :
    1/m
    description :
    background portion
    array([[0.1]])
  • lambda1
    (x, y)
    float64
    0.0098
    long_name :
    lambda1
    units :
    1/m/(ug Chla/L)
    description :
    linear self shading
    array([[0.0098]])
  • lambda2
    (x, y)
    float64
    0.064
    long_name :
    lambda2
    units :
    unitless
    description :
    nonlinear
    array([[0.064]])
  • lambdas
    (x, y)
    float64
    0.056
    long_name :
    lambdas
    units :
    L/mg/m
    description :
    ISS portion
    array([[0.056]])
  • lambdam
    (x, y)
    float64
    0.184
    long_name :
    lambdam
    units :
    L/mg/m
    description :
    POM portion
    array([[0.184]])
  • Fr_PAR
    (x, y)
    float64
    0.47
    long_name :
    fraction PAR
    units :
    unitless
    description :
    fraction of solar radiation within the PAR of the spectrum
    array([[0.47]])
  • Fw
    (x, y)
    float64
    0.9
    long_name :
    Fraction of benthic algae mortality into water column
    units :
    unitless
    description :
    Fraction of benthic algae mortality into water column
    array([[0.9]])
  • Fb
    (x, y)
    float64
    0.9
    long_name :
    Fraction of bottom area available for benthic algae
    units :
    unitless
    description :
    Fraction of bottom area available for benthic algae
    array([[0.9]])
  • BWd
    (x, y)
    int32
    100
    long_name :
    Benthic algae dry weight
    units :
    unitless
    description :
    Benthic algae dry weight
    array([[100]])
  • BWc
    (x, y)
    int32
    40
    long_name :
    Benthic algae carbon
    units :
    unitless
    description :
    Benthic algae carbon
    array([[40]])
  • BWn
    (x, y)
    float64
    7.2
    long_name :
    Benthic algae nitrogen
    units :
    unitless
    description :
    Benthic algae nitrogen
    array([[7.2]])
  • BWp
    (x, y)
    int32
    1
    long_name :
    Benthic algae phosphorus
    units :
    unitless
    description :
    Benthic algae phosphorus
    array([[1]])
  • BWa
    (x, y)
    int32
    5000
    long_name :
    Benthic algae Chla
    units :
    unitless
    description :
    Benthic algae Chla
    array([[5000]])
  • KLb
    (x, y)
    int32
    10
    long_name :
    Light limiting constant for benthic algae growth
    units :
    W/m^2
    description :
    Light limiting constant for benthic algae growth
    array([[10]])
  • KsNb
    (x, y)
    float64
    0.25
    long_name :
    Half-Saturation N limiting constant for Benthic algae
    units :
    mg-N/L
    description :
    Half-Saturation N limiting constant for Benthic algae
    array([[0.25]])
  • KsPb
    (x, y)
    float64
    0.125
    long_name :
    Half-Saturation P limiting constant for Benthic algae
    units :
    mg-P/L
    description :
    Half-Saturation P limiting constant for Benthic algae
    array([[0.125]])
  • Ksb
    (x, y)
    int32
    10
    long_name :
    Half-Saturation density constant for benthic algae growth
    units :
    g-D/m^2
    description :
    Half-Saturation density constant for benthic algae growth
    array([[10]])
  • mub_max_20
    (x, y)
    float64
    0.4
    long_name :
    Maximum benthic algal growth rate
    units :
    1/d
    description :
    maximum benthic algal growth rate
    array([[0.4]])
  • krb_20
    (x, y)
    float64
    0.2
    long_name :
    Benthic algal respiration rate
    units :
    1/d
    description :
    Benthic algal respiration rate
    array([[0.2]])
  • kdb_20
    (x, y)
    float64
    0.3
    long_name :
    Benthic algal mortality rate
    units :
    1/d
    description :
    Benthic algal mortality rate
    array([[0.3]])
  • b_growth_rate_option
    (x, y)
    int32
    1
    long_name :
    Benthic Algal growth rate options
    units :
    unitless
    description :
    Benthic Algal growth rate with two options: 1) Multiplicative, 2) Limiting Nutritent
    array([[1]])
  • b_light_limitation_option
    (x, y)
    int32
    1
    long_name :
    Benthic Algal light limitation rate options
    units :
    unitless
    description :
    Benthic Algal light limitation rate with three options: 1) Half-saturation formulation, 2) Smiths Model, 3) Steeles Model
    array([[1]])
  • KNR
    (x, y)
    float64
    0.6
    long_name :
    Oxygen inhabitation factor for nitrification
    units :
    mg-O2/L
    description :
    Oxygen inhabitation factor for nitrification
    array([[0.6]])
  • knit_20
    (x, y)
    float64
    0.1
    long_name :
    Nitrification Rate Ammonia decay at 20C
    units :
    1/d
    description :
    Nitrification Rate Ammonia NH4 -> NO3 decay at 20C
    array([[0.1]])
  • kon_20
    (x, y)
    float64
    0.1
    long_name :
    Decay Rate of OrgN to NH4 at 20C
    units :
    1/d
    description :
    Decay Rate of OrgN to NH4 at 20C
    array([[0.1]])
  • kdnit_20
    (x, y)
    float64
    0.002
    long_name :
    Denitrification rate at 20C
    units :
    1/d
    description :
    Denitrification rate at 20C
    array([[0.002]])
  • rnh4_20
    (x, y)
    int32
    0
    long_name :
    Sediment release rate of NH4 at 20C
    units :
    g-N/m^2/d
    description :
    Sediment release rate of NH4 at 20C
    array([[0]])
  • vno3_20
    (x, y)
    int32
    0
    long_name :
    Sediment denitrification velocity at 20C
    units :
    m/d
    description :
    Sediment denitrification velocity at 20C
    array([[0]])
  • KsOxdn
    (x, y)
    float64
    0.1
    long_name :
    Half-saturation oxygen inhibition constant for denitrification
    units :
    mg-O2/L
    description :
    Half-saturation oxygen inhibition constant for denitrification
    array([[0.1]])
  • PN
    (x, y)
    float64
    0.5
    long_name :
    NH4 preference factor algae
    units :
    unitless
    description :
    NH4 preference factor algae (1=full NH4, 0=full NO3)
    array([[0.5]])
  • PNb
    (x, y)
    float64
    0.5
    long_name :
    NH4 preference factor benthic algae
    units :
    unitless
    description :
    NH4 preference factor benthic algae (1=full NH4, 0=full NO3)
    array([[0.5]])
  • kop_20
    (x, y)
    float64
    0.1
    long_name :
    Decay rate of organic P to DIP
    units :
    1/d
    description :
    Decay rate of organic P to DIP
    array([[0.1]])
  • rpo4_20
    (x, y)
    int32
    0
    long_name :
    Benthic sediment release rate of DIP
    units :
    g-P/m^2/d
    description :
    Benthic sediment release rate of DIP
    array([[0]])
  • kdpo4
    (x, y)
    int32
    100
    long_name :
    solid partitioning coeff. of PO4
    units :
    L/kg
    description :
    solid partitioning coeff. of PO4
    array([[100]])
  • kpom_20
    (x, y)
    float64
    0.1
    long_name :
    POM dissolution rate at 20C
    units :
    1/d
    description :
    POM dissolution rate at 20C
    array([[0.1]])
  • kbod_20
    (x, y)
    float64
    0.12
    long_name :
    CBOD oxidation rate at 20C
    units :
    1/d
    description :
    CBOD oxidation rate at 20C
    array([[0.12]])
  • ksbod_20
    (x, y)
    int32
    0
    long_name :
    CBOD sedimentation rate at 20C
    units :
    m/d
    description :
    CBOD sedimentation rate at 20C
    array([[0]])
  • KsOxbod
    (x, y)
    float64
    0.5
    long_name :
    Half saturation oxygen attenuation constant for CBOD oxidation
    units :
    mg-O2/L
    description :
    Half saturation oxygen attenuation constant for CBOD oxidation
    array([[0.5]])
  • f_pocp
    (x, y)
    float64
    0.9
    long_name :
    Fraction of algal mortality into POC
    units :
    unitless
    description :
    Fraction of dead algae that converts to particulate organic carbon
    array([[0.9]])
  • kdoc_20
    (x, y)
    float64
    0.01
    long_name :
    Dissolved organic carbon oxidation rate
    units :
    1/d
    description :
    Dissolved organic carbon oxidation rate
    array([[0.01]])
  • f_pocb
    (x, y)
    float64
    0.9
    long_name :
    fraction of benthic algal mortality into POC
    units :
    unitless
    description :
    fraction of benthic algal mortality into POC
    array([[0.9]])
  • kpoc_20
    (x, y)
    float64
    0.005
    long_name :
    POC hydrolysis rate at 20 degrees Celsius
    units :
    1/d
    description :
    POC hydrolysis rate at 20 degrees Celsius
    array([[0.005]])
  • KsOxmc
    (x, y)
    float64
    1.0
    long_name :
    half saturation oxygen attenuation constant for DOC oxidation rate
    units :
    mg-O2/L
    description :
    half saturation oxygen attenuation constant for DOC oxidation rate
    array([[1.]])
  • pCO2
    (x, y)
    int32
    383
    long_name :
    partial atmospheric CO2 pressure
    units :
    ppm
    description :
    partial pressure of CO2 in the atmosphere
    array([[383]])
  • FCO2
    (x, y)
    float64
    0.2
    long_name :
    CO2 reaeration rate
    units :
    1/d
    description :
    CO2 reaeration rate
    array([[0.2]])
  • roc
    (x, y)
    float64
    2.667
    long_name :
    O2:C ratio for carbon oxidation
    units :
    mg-O2/mg-C
    description :
    O2:C ratio for carbon oxidation (32/12)
    array([[2.66666667]])
  • ron
    (x, y)
    float64
    4.571
    long_name :
    O2:N ratio for nitrification
    units :
    mg-O2/mg-N
    description :
    O2:N ratio for nitrification (2*32/14)
    array([[4.57142857]])
  • KsSOD
    (x, y)
    int32
    1
    long_name :
    half saturation oxygen attenuation constant for SOD
    units :
    mg/L
    description :
    half saturation oxygen attenuation constant for SOD
    array([[1]])
  • kdx_20
    (x, y)
    float64
    0.8
    long_name :
    Pathogen death rate at 20C
    units :
    1/d
    description :
    Pathogen death rate at 20C
    array([[0.8]])
  • apx
    (x, y)
    int32
    1
    long_name :
    Light efficiency factor for pathogen decay
    units :
    unitless
    description :
    Light efficiency factor for pathogen decay
    array([[1]])
  • vx
    (x, y)
    int32
    1
    long_name :
    Pathogen net settling velocity
    units :
    unitless
    description :
    Pathogen net settling velocity
    array([[1]])
  • r_alkaa
    (x, y)
    float64
    1.101e-05
    long_name :
    Ratio translating algal growth into Alk if NH4 is the N source
    units :
    eq/ug-Chla
    description :
    Ratio translating algal growth into Alk if NH4 is the N source
    array([[1.10062893e-05]])
  • r_alkan
    (x, y)
    float64
    1.415e-05
    long_name :
    Ratio translating algal growth into Alk if NO3 is the N source
    units :
    eq/ug-Chla
    description :
    Ratio translating algal growth into Alk if NO3 is the N source
    array([[1.41509434e-05]])
  • r_alkn
    (x, y)
    float64
    0.0001429
    long_name :
    Ratio translating NH4 nitrification into Alk
    units :
    eq/mg-N
    description :
    Ratio translating NH4 nitrification into Alk
    array([[0.00014286]])
  • r_alkden
    (x, y)
    float64
    0.0002857
    long_name :
    Ratio translating NO3 denitrification into Alk
    units :
    eq/mg-N
    description :
    Ratio translating NO3 denitrification into Alk
    array([[0.00028571]])
  • r_alkba
    (x, y)
    float64
    1.101e-05
    long_name :
    Ratio translating benthic algae growth into Alk if NH4 is the N source
    units :
    eq/mg-D
    description :
    Ratio translating benthic algae growth into Alk if NH4 is the N source
    array([[1.10062893e-05]])
  • r_alkbn
    (x, y)
    float64
    1.415e-05
    long_name :
    Ratio translating benthic algae growth into Alk if NO3 is the N source
    units :
    eq/mg-D
    description :
    Ratio translating benthic algae growth into Alk if NO3 is the N source
    array([[1.41509434e-05]])
  • TwaterK
    (year, x, y)
    float64
    nan 298.2 298.2 ... 298.2 298.2
    long_name :
    Water Temperature K
    units :
    K
    description :
    Water temperature degree kelvin
    array([[[   nan]],\n",
            "\n",
            "       [[298.16]],\n",
            "\n",
    @@ -9372,7 +9372,7 @@
            "\n",
            "       [[           nan]],\n",
            "\n",
    -       "       [[           nan]]])
  • vson
    (x, y)
    float64
    0.01
    long_name :
    Organic N settling velocity
    units :
    m/d
    description :
    Organic N settling velocity
    array([[0.01]])
  • vsoc
    (x, y)
    float64
    0.01
    long_name :
    POC settling velocity
    units :
    m/d
    description :
    POC settling velocity
    array([[0.01]])
  • vsop
    (x, y)
    int32
    999
    long_name :
    Organic phosphorus settling velocity
    units :
    m/d
    description :
    Organic phosphorus settling velocity
    array([[999]])
  • vs
    (x, y)
    int32
    999
    long_name :
    Sediment settling velocity
    units :
    m/d
    description :
    Sediment settling velocity
    array([[999]])
  • SOD_20
    (x, y)
    int32
    2
    long_name :
    Sediment oxygen demand at 20 degrees C
    units :
    g-O2/m/d
    description :
    Sediment oxygen demand at 20 degrees C
    array([[2]])
  • SOD_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for sediment oxygen demand
    units :
    unitless
    description :
    Arrhenius coefficient for sediment oxygen demand
    array([[1.047]])
  • fcom
    (x, y)
    float64
    0.4
    long_name :
    Fraction of carbon in organic matter
    units :
    mg-C/mg-D
    description :
    Fraction of carbon in organic matter
    array([[0.4]])
  • vb
    (x, y)
    float64
    0.01
    long_name :
    Burial velocity
    units :
    m/d
    description :
    Rate at which constituents are buried on the bottom
    array([[0.01]])
  • kaw_20_user
    (x, y)
    float64
    0.5
    long_name :
    Wind oxygen reaeration velocity at 20C
    units :
    m/d
    description :
    Wind oxygen reaeration velocity at 20C
    array([[0.5]])
  • kah_20_user
    (x, y)
    float64
    0.5
    long_name :
    Hydraulic oxygen reaeration rate at 20C
    units :
    1/d
    description :
    Hydraulic oxygen reaeration rate at 20C
    array([[0.5]])
  • hydraulic_reaeration_option
    (x, y)
    int32
    1
    long_name :
    Option for chosing the method by which O2 reaeration rate is calculated
    units :
    unitless
    description :
    Selects method for computing O2 reaeration rate
    array([[1]])
  • wind_reaeration_option
    (x, y)
    int32
    1
    long_name :
    Option for chosing the method by which wind reaeration is calculated
    units :
    unitless
    description :
    Selects method for computing O2 reaeration due to wind
    array([[1]])
  • use_NH4
    (x, y)
    bool
    True
    long_name :
    Use ammonium module
    units :
    unitless
    description :
    True/False use ammonium module
    array([[ True]])
  • use_NO3
    (x, y)
    bool
    True
    long_name :
    Use nitrate module
    units :
    unitless
    description :
    True/False use nitrate module
    array([[ True]])
  • use_OrgN
    (x, y)
    bool
    True
    long_name :
    Use organic nitrogen module
    units :
    unitless
    description :
    True/False use organic nitrogen module
    array([[ True]])
  • use_SedFlux
    (x, y)
    bool
    False
    long_name :
    Use sediment flux module
    units :
    unitless
    description :
    True/False use sediment flux module
    array([[False]])
  • use_DOX
    (x, y)
    bool
    True
    long_name :
    Use dissolved oxygen module
    units :
    unitless
    description :
    True/False use dissolved oxygen module
    array([[ True]])
  • use_Algae
    (x, y)
    bool
    True
    long_name :
    Use algae module
    units :
    unitless
    description :
    True/False use algae module
    array([[ True]])
  • use_Balgae
    (x, y)
    bool
    True
    long_name :
    Use benthic algae module
    units :
    unitless
    description :
    True/False use benthic algae module
    array([[ True]])
  • use_TIP
    (x, y)
    bool
    True
    long_name :
    Use total inorganic phosphorus module
    units :
    unitless
    description :
    True/False use total inorganic phosphorus module
    array([[ True]])
  • use_OrgP
    (x, y)
    bool
    True
    long_name :
    Use total organic phosphorus module
    units :
    unitless
    description :
    True/False use total organic phosphorus module
    array([[ True]])
  • use_POC
    (x, y)
    bool
    True
    long_name :
    Use particulate organic carbon module
    units :
    unitless
    description :
    True/False use particulate organic carbon module
    array([[ True]])
  • use_DOC
    (x, y)
    bool
    True
    long_name :
    Use dissolved organic carbon module
    units :
    unitless
    description :
    True/False use dissolved organic carbon module
    array([[ True]])
  • use_DIC
    (x, y)
    bool
    True
    long_name :
    Use dissolved inorganic carbon module
    units :
    unitless
    description :
    True/False use dissolved inorganic carbon module
    array([[ True]])
  • use_N2
    (x, y)
    bool
    True
    long_name :
    Use dissolved N2 module
    units :
    unitless
    description :
    True/False use N2 module
    array([[ True]])
  • use_Pathogen
    (x, y)
    bool
    True
    long_name :
    Use pathogen module
    units :
    unitless
    description :
    True/False use pathogen module
    array([[ True]])
  • use_Alk
    (x, y)
    bool
    True
    long_name :
    Use alkalinity module
    units :
    unitless
    description :
    True/False use alkalinity module
    array([[ True]])
  • use_POM
    (x, y)
    bool
    True
    long_name :
    Use particulate organic matter module
    units :
    unitless
    description :
    True/False use particulate organic matter module
    array([[ True]])
  • dt
    (x, y)
    int32
    86400
    long_name :
    dt
    units :
    d
    description :
    calculation dt
    array([[86400]])
  • depth
    (x, y)
    int32
    1
    long_name :
    Depth of water in cell
    units :
    m
    description :
    Depth of water in cell
    array([[1]])
  • TwaterC
    (x, y)
    int32
    20
    long_name :
    Water temperature in celsius
    units :
    degrees C
    description :
    Water temperature in celsius
    array([[20]])
  • theta
    (x, y)
    float64
    1.047
    long_name :
    Water temperature theta adjustment factor
    units :
    unitless
    description :
    Water temperature theta adjustment factor
    array([[1.047]])
  • velocity
    (x, y)
    int32
    1
    long_name :
    velocity
    units :
    m/s
    description :
    Average water velocity in cell
    array([[1]])
  • flow
    (x, y)
    int32
    2
    long_name :
    flow
    units :
    m3/s
    description :
    Average flow rate in cell
    array([[2]])
  • topwidth
    (x, y)
    int32
    1
    long_name :
    topwidth
    units :
    m
    description :
    Average topwidth of cell
    array([[1]])
  • slope
    (x, y)
    int32
    2
    long_name :
    slope
    units :
    TODO
    description :
    Average slope of bottom surface
    array([[2]])
  • shear_velocity
    (x, y)
    int32
    4
    long_name :
    shear_velocity
    units :
    TODO
    description :
    Average shear velocity on bottom surface
    array([[4]])
  • pressure_atm
    (x, y)
    int32
    2
    long_name :
    pressure_atm
    units :
    TODO
    description :
    atmospheric pressure in atm
    array([[2]])
  • wind_speed
    (x, y)
    int32
    4
    long_name :
    Wind speed at 10 meters above the water surface
    units :
    m/s
    description :
    Wind speed at 10 meters above the water surface
    array([[4]])
  • q_solar
    (x, y)
    int32
    4
    long_name :
    Incident short-wave solar radiation
    units :
    W/m2
    description :
    Incident short-wave solar radiation
    array([[4]])
  • Solid
    (x, y)
    int32
    1
    long_name :
    Solid reaeration option
    units :
    Unknown
    description :
    Solid
    array([[1]])
  • AWd
    (x, y)
    int32
    100
    long_name :
    Algal Dry Weight
    units :
    mg
    description :
    Algal Dry Weight
    array([[100]])
  • AWc
    (x, y)
    int32
    40
    long_name :
    Carbon Weight
    units :
    mg
    description :
    Carbon Weight
    array([[40]])
  • AWn
    (x, y)
    float64
    7.2
    long_name :
    Nitrogen Weight
    units :
    mg
    description :
    Nitrogen Weight
    array([[7.2]])
  • AWp
    (x, y)
    int32
    1
    long_name :
    Phosphorus Weight
    units :
    mg
    description :
    Phosphorus Weight
    array([[1]])
  • AWa
    (x, y)
    int32
    1000
    long_name :
    Algal Chlorophyll
    units :
    ug Chla
    description :
    Algal Chlorophyll
    array([[1000]])
  • KL
    (x, y)
    int32
    10
    long_name :
    Light Limiting Constant for Algal Growth
    units :
    W/m^2
    description :
    Light Limiting Constant for Algal Growth
    array([[10]])
  • KsN
    (x, y)
    float64
    0.04
    long_name :
    Half-Saturation N Limiting Constant for Algal Growth
    units :
    mg-N/L
    description :
    Half-Saturation N Limiting Constant for Algal Growth
    array([[0.04]])
  • KsP
    (x, y)
    float64
    0.0012
    long_name :
    Half-Saturation P Limiting Constant for Algal Growth
    units :
    mg-P/L
    description :
    Half-Saturation P Limiting Constant for Algal Growth
    array([[0.0012]])
  • mu_max_20
    (x, y)
    int32
    1
    long_name :
    Max Algae Growth
    units :
    1/d
    description :
    Max Algae Growth at 20C
    array([[1]])
  • kdp_20
    (x, y)
    float64
    0.15
    long_name :
    Algal Mortality Rate
    units :
    1/d
    description :
    Algal Mortality Rate at 20C
    array([[0.15]])
  • krp_20
    (x, y)
    float64
    0.2
    long_name :
    Algal Respiration Rate
    units :
    1/d
    description :
    Algal Respiration Rate at 20C
    array([[0.2]])
  • vsap
    (x, y)
    float64
    0.15
    long_name :
    Algal Setting Velocity
    units :
    m/d
    description :
    Algal Setting Velocity
    array([[0.15]])
  • growth_rate_option
    (x, y)
    int32
    1
    long_name :
    Growth Rate Option
    units :
    1/d
    description :
    Algal growth rate option 1) multiplicative, 2) Limiting Nutrient, 3) Harmonic Mean Option
    array([[1]])
  • light_limitation_option
    (x, y)
    int32
    1
    long_name :
    Light Limitation Option
    units :
    1/d
    description :
    Algal light limitation 1) half-saturation, 2) Smith model, 3) Steele model
    array([[1]])
  • lambda0
    (x, y)
    float64
    0.02
    long_name :
    lambda0
    units :
    1/m
    description :
    background portion
    array([[0.02]])
  • lambda1
    (x, y)
    float64
    0.0088
    long_name :
    lambda1
    units :
    1/m/(ug Chla/L)
    description :
    linear self shading
    array([[0.0088]])
  • lambda2
    (x, y)
    float64
    0.054
    long_name :
    lambda2
    units :
    unitless
    description :
    nonlinear
    array([[0.054]])
  • lambdas
    (x, y)
    float64
    0.052
    long_name :
    lambdas
    units :
    L/mg/m
    description :
    ISS portion
    array([[0.052]])
  • lambdam
    (x, y)
    float64
    0.0174
    long_name :
    lambdam
    units :
    L/mg/m
    description :
    POM portion
    array([[0.0174]])
  • Fr_PAR
    (x, y)
    float64
    0.47
    long_name :
    fraction PAR
    units :
    unitless
    description :
    fraction of solar radiation within the PAR of the spectrum
    array([[0.47]])
  • Fw
    (x, y)
    float64
    0.9
    long_name :
    Fraction of benthic algae mortality into water column
    units :
    unitless
    description :
    Fraction of benthic algae mortality into water column
    array([[0.9]])
  • Fb
    (x, y)
    float64
    0.9
    long_name :
    Fraction of bottom area available for benthic algae
    units :
    unitless
    description :
    Fraction of bottom area available for benthic algae
    array([[0.9]])
  • BWd
    (x, y)
    int32
    100
    long_name :
    Benthic algae dry weight
    units :
    unitless
    description :
    Benthic algae dry weight
    array([[100]])
  • BWc
    (x, y)
    int32
    40
    long_name :
    Benthic algae carbon
    units :
    unitless
    description :
    Benthic algae carbon
    array([[40]])
  • BWn
    (x, y)
    float64
    7.2
    long_name :
    Benthic algae nitrogen
    units :
    unitless
    description :
    Benthic algae nitrogen
    array([[7.2]])
  • BWp
    (x, y)
    int32
    1
    long_name :
    Benthic algae phosphorus
    units :
    unitless
    description :
    Benthic algae phosphorus
    array([[1]])
  • BWa
    (x, y)
    int32
    3500
    long_name :
    Benthic algae Chla
    units :
    unitless
    description :
    Benthic algae Chla
    array([[3500]])
  • KLb
    (x, y)
    int32
    10
    long_name :
    Light limiting constant for benthic algae growth
    units :
    W/m^2
    description :
    Light limiting constant for benthic algae growth
    array([[10]])
  • KsNb
    (x, y)
    float64
    0.25
    long_name :
    Half-Saturation N limiting constant for Benthic algae
    units :
    mg-N/L
    description :
    Half-Saturation N limiting constant for Benthic algae
    array([[0.25]])
  • KsPb
    (x, y)
    float64
    0.125
    long_name :
    Half-Saturation P limiting constant for Benthic algae
    units :
    mg-P/L
    description :
    Half-Saturation P limiting constant for Benthic algae
    array([[0.125]])
  • Ksb
    (x, y)
    int32
    10
    long_name :
    Half-Saturation density constant for benthic algae growth
    units :
    g-D/m^2
    description :
    Half-Saturation density constant for benthic algae growth
    array([[10]])
  • mub_max_20
    (x, y)
    float64
    0.4
    long_name :
    Maximum benthic algal growth rate
    units :
    1/d
    description :
    maximum benthic algal growth rate
    array([[0.4]])
  • krb_20
    (x, y)
    float64
    0.2
    long_name :
    Benthic algal respiration rate
    units :
    1/d
    description :
    Benthic algal respiration rate
    array([[0.2]])
  • kdb_20
    (x, y)
    float64
    0.3
    long_name :
    Benthic algal mortality rate
    units :
    1/d
    description :
    Benthic algal mortality rate
    array([[0.3]])
  • b_growth_rate_option
    (x, y)
    int32
    1
    long_name :
    Benthic Algal growth rate options
    units :
    unitless
    description :
    Benthic Algal growth rate with two options: 1) Multiplicative, 2) Limiting Nutritent
    array([[1]])
  • b_light_limitation_option
    (x, y)
    int32
    1
    long_name :
    Benthic Algal light limitation rate options
    units :
    unitless
    description :
    Benthic Algal light limitation rate with three options: 1) Half-saturation formulation, 2) Smiths Model, 3) Steeles Model
    array([[1]])
  • KNR
    (x, y)
    float64
    0.6
    long_name :
    Oxygen inhabitation factor for nitrification
    units :
    mg-O2/L
    description :
    Oxygen inhabitation factor for nitrification
    array([[0.6]])
  • knit_20
    (x, y)
    float64
    0.1
    long_name :
    Nitrification Rate Ammonia decay at 20C
    units :
    1/d
    description :
    Nitrification Rate Ammonia NH4 -> NO3 decay at 20C
    array([[0.1]])
  • kon_20
    (x, y)
    float64
    0.1
    long_name :
    Decay Rate of OrgN to NH4 at 20C
    units :
    1/d
    description :
    Decay Rate of OrgN to NH4 at 20C
    array([[0.1]])
  • kdnit_20
    (x, y)
    float64
    0.002
    long_name :
    Denitrification rate at 20C
    units :
    1/d
    description :
    Denitrification rate at 20C
    array([[0.002]])
  • rnh4_20
    (x, y)
    int32
    0
    long_name :
    Sediment release rate of NH4 at 20C
    units :
    g-N/m^2/d
    description :
    Sediment release rate of NH4 at 20C
    array([[0]])
  • vno3_20
    (x, y)
    int32
    0
    long_name :
    Sediment denitrification velocity at 20C
    units :
    m/d
    description :
    Sediment denitrification velocity at 20C
    array([[0]])
  • KsOxdn
    (x, y)
    float64
    0.1
    long_name :
    Half-saturation oxygen inhibition constant for denitrification
    units :
    mg-O2/L
    description :
    Half-saturation oxygen inhibition constant for denitrification
    array([[0.1]])
  • PN
    (x, y)
    float64
    0.5
    long_name :
    NH4 preference factor algae
    units :
    unitless
    description :
    NH4 preference factor algae (1=full NH4, 0=full NO3)
    array([[0.5]])
  • PNb
    (x, y)
    float64
    0.5
    long_name :
    NH4 preference factor benthic algae
    units :
    unitless
    description :
    NH4 preference factor benthic algae (1=full NH4, 0=full NO3)
    array([[0.5]])
  • kop_20
    (x, y)
    float64
    0.1
    long_name :
    Decay rate of organic P to DIP
    units :
    1/d
    description :
    Decay rate of organic P to DIP
    array([[0.1]])
  • rpo4_20
    (x, y)
    int32
    0
    long_name :
    Benthic sediment release rate of DIP
    units :
    g-P/m^2/d
    description :
    Benthic sediment release rate of DIP
    array([[0]])
  • kdpo4
    (x, y)
    float64
    0.0
    long_name :
    solid partitioning coeff. of PO4
    units :
    L/kg
    description :
    solid partitioning coeff. of PO4
    array([[0.]])
  • kpom_20
    (x, y)
    float64
    0.1
    long_name :
    POM dissolution rate at 20C
    units :
    1/d
    description :
    POM dissolution rate at 20C
    array([[0.1]])
  • kbod_20
    (x, y)
    float64
    0.12
    long_name :
    CBOD oxidation rate at 20C
    units :
    1/d
    description :
    CBOD oxidation rate at 20C
    array([[0.12]])
  • ksbod_20
    (x, y)
    int32
    0
    long_name :
    CBOD sedimentation rate at 20C
    units :
    m/d
    description :
    CBOD sedimentation rate at 20C
    array([[0]])
  • KsOxbod
    (x, y)
    float64
    0.5
    long_name :
    Half saturation oxygen attenuation constant for CBOD oxidation
    units :
    mg-O2/L
    description :
    Half saturation oxygen attenuation constant for CBOD oxidation
    array([[0.5]])
  • f_pocp
    (x, y)
    float64
    0.9
    long_name :
    Fraction of algal mortality into POC
    units :
    unitless
    description :
    Fraction of dead algae that converts to particulate organic carbon
    array([[0.9]])
  • kdoc_20
    (x, y)
    float64
    0.01
    long_name :
    Dissolved organic carbon oxidation rate
    units :
    1/d
    description :
    Dissolved organic carbon oxidation rate
    array([[0.01]])
  • f_pocb
    (x, y)
    float64
    0.9
    long_name :
    fraction of benthic algal mortality into POC
    units :
    unitless
    description :
    fraction of benthic algal mortality into POC
    array([[0.9]])
  • kpoc_20
    (x, y)
    float64
    0.005
    long_name :
    POC hydrolysis rate at 20 degrees Celsius
    units :
    1/d
    description :
    POC hydrolysis rate at 20 degrees Celsius
    array([[0.005]])
  • KsOxmc
    (x, y)
    float64
    1.0
    long_name :
    half saturation oxygen attenuation constant for DOC oxidation rate
    units :
    mg-O2/L
    description :
    half saturation oxygen attenuation constant for DOC oxidation rate
    array([[1.]])
  • pCO2
    (x, y)
    int32
    383
    long_name :
    partial atmospheric CO2 pressure
    units :
    ppm
    description :
    partial pressure of CO2 in the atmosphere
    array([[383]])
  • FCO2
    (x, y)
    float64
    0.2
    long_name :
    CO2 reaeration rate
    units :
    1/d
    description :
    CO2 reaeration rate
    array([[0.2]])
  • roc
    (x, y)
    float64
    2.667
    long_name :
    O2:C ratio for carbon oxidation
    units :
    mg-O2/mg-C
    description :
    O2:C ratio for carbon oxidation (32/12)
    array([[2.66666667]])
  • ron
    (x, y)
    float64
    4.571
    long_name :
    O2:N ratio for nitrification
    units :
    mg-O2/mg-N
    description :
    O2:N ratio for nitrification (2*32/14)
    array([[4.57142857]])
  • KsSOD
    (x, y)
    int32
    1
    long_name :
    half saturation oxygen attenuation constant for SOD
    units :
    mg/L
    description :
    half saturation oxygen attenuation constant for SOD
    array([[1]])
  • kdx_20
    (x, y)
    float64
    0.8
    long_name :
    Pathogen death rate at 20C
    units :
    1/d
    description :
    Pathogen death rate at 20C
    array([[0.8]])
  • apx
    (x, y)
    int32
    1
    long_name :
    Light efficiency factor for pathogen decay
    units :
    unitless
    description :
    Light efficiency factor for pathogen decay
    array([[1]])
  • vx
    (x, y)
    int32
    1
    long_name :
    Pathogen net settling velocity
    units :
    unitless
    description :
    Pathogen net settling velocity
    array([[1]])
  • r_alkaa
    (x, y)
    int32
    1
    long_name :
    Ratio translating algal growth into Alk if NH4 is the N source
    units :
    eq/ug-Chla
    description :
    Ratio translating algal growth into Alk if NH4 is the N source
    array([[1]])
  • r_alkan
    (x, y)
    int32
    1
    long_name :
    Ratio translating algal growth into Alk if NO3 is the N source
    units :
    eq/ug-Chla
    description :
    Ratio translating algal growth into Alk if NO3 is the N source
    array([[1]])
  • r_alkn
    (x, y)
    int32
    1
    long_name :
    Ratio translating NH4 nitrification into Alk
    units :
    eq/mg-N
    description :
    Ratio translating NH4 nitrification into Alk
    array([[1]])
  • r_alkden
    (x, y)
    int32
    1
    long_name :
    Ratio translating NO3 denitrification into Alk
    units :
    eq/mg-N
    description :
    Ratio translating NO3 denitrification into Alk
    array([[1]])
  • r_alkba
    (x, y)
    int32
    1
    long_name :
    Ratio translating benthic algae growth into Alk if NH4 is the N source
    units :
    eq/mg-D
    description :
    Ratio translating benthic algae growth into Alk if NH4 is the N source
    array([[1]])
  • r_alkbn
    (x, y)
    int32
    1
    long_name :
    Ratio translating benthic algae growth into Alk if NO3 is the N source
    units :
    eq/mg-D
    description :
    Ratio translating benthic algae growth into Alk if NO3 is the N source
    array([[1]])
  • TwaterK
    (year, x, y)
    float64
    nan 293.2 nan nan
    long_name :
    Water Temperature K
    units :
    K
    description :
    Water temperature degree kelvin
    array([[[   nan]],\n",
    +       "       [[           nan]]])
  • vson
    (x, y)
    float64
    0.01
    long_name :
    Organic N settling velocity
    units :
    m/d
    description :
    Organic N settling velocity
    array([[0.01]])
  • vsoc
    (x, y)
    float64
    0.01
    long_name :
    POC settling velocity
    units :
    m/d
    description :
    POC settling velocity
    array([[0.01]])
  • vsop
    (x, y)
    int32
    999
    long_name :
    Organic phosphorus settling velocity
    units :
    m/d
    description :
    Organic phosphorus settling velocity
    array([[999]])
  • vs
    (x, y)
    int32
    999
    long_name :
    Sediment settling velocity
    units :
    m/d
    description :
    Sediment settling velocity
    array([[999]])
  • SOD_20
    (x, y)
    int32
    2
    long_name :
    Sediment oxygen demand at 20 degrees C
    units :
    g-O2/m/d
    description :
    Sediment oxygen demand at 20 degrees C
    array([[2]])
  • SOD_theta
    (x, y)
    float64
    1.047
    long_name :
    Arrhenius coefficient for sediment oxygen demand
    units :
    unitless
    description :
    Arrhenius coefficient for sediment oxygen demand
    array([[1.047]])
  • fcom
    (x, y)
    float64
    0.4
    long_name :
    Fraction of carbon in organic matter
    units :
    mg-C/mg-D
    description :
    Fraction of carbon in organic matter
    array([[0.4]])
  • vb
    (x, y)
    float64
    0.01
    long_name :
    Burial velocity
    units :
    m/d
    description :
    Rate at which constituents are buried on the bottom
    array([[0.01]])
  • kaw_20_user
    (x, y)
    float64
    0.5
    long_name :
    Wind oxygen reaeration velocity at 20C
    units :
    m/d
    description :
    Wind oxygen reaeration velocity at 20C
    array([[0.5]])
  • kah_20_user
    (x, y)
    float64
    0.5
    long_name :
    Hydraulic oxygen reaeration rate at 20C
    units :
    1/d
    description :
    Hydraulic oxygen reaeration rate at 20C
    array([[0.5]])
  • hydraulic_reaeration_option
    (x, y)
    int32
    1
    long_name :
    Option for chosing the method by which O2 reaeration rate is calculated
    units :
    unitless
    description :
    Selects method for computing O2 reaeration rate
    array([[1]])
  • wind_reaeration_option
    (x, y)
    int32
    1
    long_name :
    Option for chosing the method by which wind reaeration is calculated
    units :
    unitless
    description :
    Selects method for computing O2 reaeration due to wind
    array([[1]])
  • use_NH4
    (x, y)
    bool
    True
    long_name :
    Use ammonium module
    units :
    unitless
    description :
    True/False use ammonium module
    array([[ True]])
  • use_NO3
    (x, y)
    bool
    True
    long_name :
    Use nitrate module
    units :
    unitless
    description :
    True/False use nitrate module
    array([[ True]])
  • use_OrgN
    (x, y)
    bool
    True
    long_name :
    Use organic nitrogen module
    units :
    unitless
    description :
    True/False use organic nitrogen module
    array([[ True]])
  • use_SedFlux
    (x, y)
    bool
    False
    long_name :
    Use sediment flux module
    units :
    unitless
    description :
    True/False use sediment flux module
    array([[False]])
  • use_DOX
    (x, y)
    bool
    True
    long_name :
    Use dissolved oxygen module
    units :
    unitless
    description :
    True/False use dissolved oxygen module
    array([[ True]])
  • use_Algae
    (x, y)
    bool
    True
    long_name :
    Use algae module
    units :
    unitless
    description :
    True/False use algae module
    array([[ True]])
  • use_Balgae
    (x, y)
    bool
    True
    long_name :
    Use benthic algae module
    units :
    unitless
    description :
    True/False use benthic algae module
    array([[ True]])
  • use_TIP
    (x, y)
    bool
    True
    long_name :
    Use total inorganic phosphorus module
    units :
    unitless
    description :
    True/False use total inorganic phosphorus module
    array([[ True]])
  • use_OrgP
    (x, y)
    bool
    True
    long_name :
    Use total organic phosphorus module
    units :
    unitless
    description :
    True/False use total organic phosphorus module
    array([[ True]])
  • use_POC
    (x, y)
    bool
    True
    long_name :
    Use particulate organic carbon module
    units :
    unitless
    description :
    True/False use particulate organic carbon module
    array([[ True]])
  • use_DOC
    (x, y)
    bool
    True
    long_name :
    Use dissolved organic carbon module
    units :
    unitless
    description :
    True/False use dissolved organic carbon module
    array([[ True]])
  • use_DIC
    (x, y)
    bool
    True
    long_name :
    Use dissolved inorganic carbon module
    units :
    unitless
    description :
    True/False use dissolved inorganic carbon module
    array([[ True]])
  • use_N2
    (x, y)
    bool
    True
    long_name :
    Use dissolved N2 module
    units :
    unitless
    description :
    True/False use N2 module
    array([[ True]])
  • use_Pathogen
    (x, y)
    bool
    True
    long_name :
    Use pathogen module
    units :
    unitless
    description :
    True/False use pathogen module
    array([[ True]])
  • use_Alk
    (x, y)
    bool
    True
    long_name :
    Use alkalinity module
    units :
    unitless
    description :
    True/False use alkalinity module
    array([[ True]])
  • use_POM
    (x, y)
    bool
    True
    long_name :
    Use particulate organic matter module
    units :
    unitless
    description :
    True/False use particulate organic matter module
    array([[ True]])
  • dt
    (x, y)
    int32
    86400
    long_name :
    dt
    units :
    d
    description :
    calculation dt
    array([[86400]])
  • depth
    (x, y)
    int32
    1
    long_name :
    Depth of water in cell
    units :
    m
    description :
    Depth of water in cell
    array([[1]])
  • TwaterC
    (x, y)
    int32
    20
    long_name :
    Water temperature in celsius
    units :
    degrees C
    description :
    Water temperature in celsius
    array([[20]])
  • theta
    (x, y)
    float64
    1.047
    long_name :
    Water temperature theta adjustment factor
    units :
    unitless
    description :
    Water temperature theta adjustment factor
    array([[1.047]])
  • velocity
    (x, y)
    int32
    1
    long_name :
    velocity
    units :
    m/s
    description :
    Average water velocity in cell
    array([[1]])
  • flow
    (x, y)
    int32
    2
    long_name :
    flow
    units :
    m3/s
    description :
    Average flow rate in cell
    array([[2]])
  • topwidth
    (x, y)
    int32
    1
    long_name :
    topwidth
    units :
    m
    description :
    Average topwidth of cell
    array([[1]])
  • slope
    (x, y)
    int32
    2
    long_name :
    slope
    units :
    TODO
    description :
    Average slope of bottom surface
    array([[2]])
  • shear_velocity
    (x, y)
    int32
    4
    long_name :
    shear_velocity
    units :
    TODO
    description :
    Average shear velocity on bottom surface
    array([[4]])
  • pressure_mb
    (x, y)
    int32
    2
    long_name :
    pressure_mb
    units :
    TODO
    description :
    atmospheric pressure in atm
    array([[2]])
  • wind_speed
    (x, y)
    int32
    4
    long_name :
    Wind speed at 10 meters above the water surface
    units :
    m/s
    description :
    Wind speed at 10 meters above the water surface
    array([[4]])
  • q_solar
    (x, y)
    int32
    4
    long_name :
    Incident short-wave solar radiation
    units :
    W/m2
    description :
    Incident short-wave solar radiation
    array([[4]])
  • Solid
    (x, y)
    int32
    1
    long_name :
    Solid reaeration option
    units :
    Unknown
    description :
    Solid
    array([[1]])
  • AWd
    (x, y)
    int32
    100
    long_name :
    Algal Dry Weight
    units :
    mg
    description :
    Algal Dry Weight
    array([[100]])
  • AWc
    (x, y)
    int32
    40
    long_name :
    Carbon Weight
    units :
    mg
    description :
    Carbon Weight
    array([[40]])
  • AWn
    (x, y)
    float64
    7.2
    long_name :
    Nitrogen Weight
    units :
    mg
    description :
    Nitrogen Weight
    array([[7.2]])
  • AWp
    (x, y)
    int32
    1
    long_name :
    Phosphorus Weight
    units :
    mg
    description :
    Phosphorus Weight
    array([[1]])
  • AWa
    (x, y)
    int32
    1000
    long_name :
    Algal Chlorophyll
    units :
    ug Chla
    description :
    Algal Chlorophyll
    array([[1000]])
  • KL
    (x, y)
    int32
    10
    long_name :
    Light Limiting Constant for Algal Growth
    units :
    W/m^2
    description :
    Light Limiting Constant for Algal Growth
    array([[10]])
  • KsN
    (x, y)
    float64
    0.04
    long_name :
    Half-Saturation N Limiting Constant for Algal Growth
    units :
    mg-N/L
    description :
    Half-Saturation N Limiting Constant for Algal Growth
    array([[0.04]])
  • KsP
    (x, y)
    float64
    0.0012
    long_name :
    Half-Saturation P Limiting Constant for Algal Growth
    units :
    mg-P/L
    description :
    Half-Saturation P Limiting Constant for Algal Growth
    array([[0.0012]])
  • mu_max_20
    (x, y)
    int32
    1
    long_name :
    Max Algae Growth
    units :
    1/d
    description :
    Max Algae Growth at 20C
    array([[1]])
  • kdp_20
    (x, y)
    float64
    0.15
    long_name :
    Algal Mortality Rate
    units :
    1/d
    description :
    Algal Mortality Rate at 20C
    array([[0.15]])
  • krp_20
    (x, y)
    float64
    0.2
    long_name :
    Algal Respiration Rate
    units :
    1/d
    description :
    Algal Respiration Rate at 20C
    array([[0.2]])
  • vsap
    (x, y)
    float64
    0.15
    long_name :
    Algal Setting Velocity
    units :
    m/d
    description :
    Algal Setting Velocity
    array([[0.15]])
  • growth_rate_option
    (x, y)
    int32
    1
    long_name :
    Growth Rate Option
    units :
    1/d
    description :
    Algal growth rate option 1) multiplicative, 2) Limiting Nutrient, 3) Harmonic Mean Option
    array([[1]])
  • light_limitation_option
    (x, y)
    int32
    1
    long_name :
    Light Limitation Option
    units :
    1/d
    description :
    Algal light limitation 1) half-saturation, 2) Smith model, 3) Steele model
    array([[1]])
  • lambda0
    (x, y)
    float64
    0.02
    long_name :
    lambda0
    units :
    1/m
    description :
    background portion
    array([[0.02]])
  • lambda1
    (x, y)
    float64
    0.0088
    long_name :
    lambda1
    units :
    1/m/(ug Chla/L)
    description :
    linear self shading
    array([[0.0088]])
  • lambda2
    (x, y)
    float64
    0.054
    long_name :
    lambda2
    units :
    unitless
    description :
    nonlinear
    array([[0.054]])
  • lambdas
    (x, y)
    float64
    0.052
    long_name :
    lambdas
    units :
    L/mg/m
    description :
    ISS portion
    array([[0.052]])
  • lambdam
    (x, y)
    float64
    0.0174
    long_name :
    lambdam
    units :
    L/mg/m
    description :
    POM portion
    array([[0.0174]])
  • Fr_PAR
    (x, y)
    float64
    0.47
    long_name :
    fraction PAR
    units :
    unitless
    description :
    fraction of solar radiation within the PAR of the spectrum
    array([[0.47]])
  • Fw
    (x, y)
    float64
    0.9
    long_name :
    Fraction of benthic algae mortality into water column
    units :
    unitless
    description :
    Fraction of benthic algae mortality into water column
    array([[0.9]])
  • Fb
    (x, y)
    float64
    0.9
    long_name :
    Fraction of bottom area available for benthic algae
    units :
    unitless
    description :
    Fraction of bottom area available for benthic algae
    array([[0.9]])
  • BWd
    (x, y)
    int32
    100
    long_name :
    Benthic algae dry weight
    units :
    unitless
    description :
    Benthic algae dry weight
    array([[100]])
  • BWc
    (x, y)
    int32
    40
    long_name :
    Benthic algae carbon
    units :
    unitless
    description :
    Benthic algae carbon
    array([[40]])
  • BWn
    (x, y)
    float64
    7.2
    long_name :
    Benthic algae nitrogen
    units :
    unitless
    description :
    Benthic algae nitrogen
    array([[7.2]])
  • BWp
    (x, y)
    int32
    1
    long_name :
    Benthic algae phosphorus
    units :
    unitless
    description :
    Benthic algae phosphorus
    array([[1]])
  • BWa
    (x, y)
    int32
    3500
    long_name :
    Benthic algae Chla
    units :
    unitless
    description :
    Benthic algae Chla
    array([[3500]])
  • KLb
    (x, y)
    int32
    10
    long_name :
    Light limiting constant for benthic algae growth
    units :
    W/m^2
    description :
    Light limiting constant for benthic algae growth
    array([[10]])
  • KsNb
    (x, y)
    float64
    0.25
    long_name :
    Half-Saturation N limiting constant for Benthic algae
    units :
    mg-N/L
    description :
    Half-Saturation N limiting constant for Benthic algae
    array([[0.25]])
  • KsPb
    (x, y)
    float64
    0.125
    long_name :
    Half-Saturation P limiting constant for Benthic algae
    units :
    mg-P/L
    description :
    Half-Saturation P limiting constant for Benthic algae
    array([[0.125]])
  • Ksb
    (x, y)
    int32
    10
    long_name :
    Half-Saturation density constant for benthic algae growth
    units :
    g-D/m^2
    description :
    Half-Saturation density constant for benthic algae growth
    array([[10]])
  • mub_max_20
    (x, y)
    float64
    0.4
    long_name :
    Maximum benthic algal growth rate
    units :
    1/d
    description :
    maximum benthic algal growth rate
    array([[0.4]])
  • krb_20
    (x, y)
    float64
    0.2
    long_name :
    Benthic algal respiration rate
    units :
    1/d
    description :
    Benthic algal respiration rate
    array([[0.2]])
  • kdb_20
    (x, y)
    float64
    0.3
    long_name :
    Benthic algal mortality rate
    units :
    1/d
    description :
    Benthic algal mortality rate
    array([[0.3]])
  • b_growth_rate_option
    (x, y)
    int32
    1
    long_name :
    Benthic Algal growth rate options
    units :
    unitless
    description :
    Benthic Algal growth rate with two options: 1) Multiplicative, 2) Limiting Nutritent
    array([[1]])
  • b_light_limitation_option
    (x, y)
    int32
    1
    long_name :
    Benthic Algal light limitation rate options
    units :
    unitless
    description :
    Benthic Algal light limitation rate with three options: 1) Half-saturation formulation, 2) Smiths Model, 3) Steeles Model
    array([[1]])
  • KNR
    (x, y)
    float64
    0.6
    long_name :
    Oxygen inhabitation factor for nitrification
    units :
    mg-O2/L
    description :
    Oxygen inhabitation factor for nitrification
    array([[0.6]])
  • knit_20
    (x, y)
    float64
    0.1
    long_name :
    Nitrification Rate Ammonia decay at 20C
    units :
    1/d
    description :
    Nitrification Rate Ammonia NH4 -> NO3 decay at 20C
    array([[0.1]])
  • kon_20
    (x, y)
    float64
    0.1
    long_name :
    Decay Rate of OrgN to NH4 at 20C
    units :
    1/d
    description :
    Decay Rate of OrgN to NH4 at 20C
    array([[0.1]])
  • kdnit_20
    (x, y)
    float64
    0.002
    long_name :
    Denitrification rate at 20C
    units :
    1/d
    description :
    Denitrification rate at 20C
    array([[0.002]])
  • rnh4_20
    (x, y)
    int32
    0
    long_name :
    Sediment release rate of NH4 at 20C
    units :
    g-N/m^2/d
    description :
    Sediment release rate of NH4 at 20C
    array([[0]])
  • vno3_20
    (x, y)
    int32
    0
    long_name :
    Sediment denitrification velocity at 20C
    units :
    m/d
    description :
    Sediment denitrification velocity at 20C
    array([[0]])
  • KsOxdn
    (x, y)
    float64
    0.1
    long_name :
    Half-saturation oxygen inhibition constant for denitrification
    units :
    mg-O2/L
    description :
    Half-saturation oxygen inhibition constant for denitrification
    array([[0.1]])
  • PN
    (x, y)
    float64
    0.5
    long_name :
    NH4 preference factor algae
    units :
    unitless
    description :
    NH4 preference factor algae (1=full NH4, 0=full NO3)
    array([[0.5]])
  • PNb
    (x, y)
    float64
    0.5
    long_name :
    NH4 preference factor benthic algae
    units :
    unitless
    description :
    NH4 preference factor benthic algae (1=full NH4, 0=full NO3)
    array([[0.5]])
  • kop_20
    (x, y)
    float64
    0.1
    long_name :
    Decay rate of organic P to DIP
    units :
    1/d
    description :
    Decay rate of organic P to DIP
    array([[0.1]])
  • rpo4_20
    (x, y)
    int32
    0
    long_name :
    Benthic sediment release rate of DIP
    units :
    g-P/m^2/d
    description :
    Benthic sediment release rate of DIP
    array([[0]])
  • kdpo4
    (x, y)
    float64
    0.0
    long_name :
    solid partitioning coeff. of PO4
    units :
    L/kg
    description :
    solid partitioning coeff. of PO4
    array([[0.]])
  • kpom_20
    (x, y)
    float64
    0.1
    long_name :
    POM dissolution rate at 20C
    units :
    1/d
    description :
    POM dissolution rate at 20C
    array([[0.1]])
  • kbod_20
    (x, y)
    float64
    0.12
    long_name :
    CBOD oxidation rate at 20C
    units :
    1/d
    description :
    CBOD oxidation rate at 20C
    array([[0.12]])
  • ksbod_20
    (x, y)
    int32
    0
    long_name :
    CBOD sedimentation rate at 20C
    units :
    m/d
    description :
    CBOD sedimentation rate at 20C
    array([[0]])
  • KsOxbod
    (x, y)
    float64
    0.5
    long_name :
    Half saturation oxygen attenuation constant for CBOD oxidation
    units :
    mg-O2/L
    description :
    Half saturation oxygen attenuation constant for CBOD oxidation
    array([[0.5]])
  • f_pocp
    (x, y)
    float64
    0.9
    long_name :
    Fraction of algal mortality into POC
    units :
    unitless
    description :
    Fraction of dead algae that converts to particulate organic carbon
    array([[0.9]])
  • kdoc_20
    (x, y)
    float64
    0.01
    long_name :
    Dissolved organic carbon oxidation rate
    units :
    1/d
    description :
    Dissolved organic carbon oxidation rate
    array([[0.01]])
  • f_pocb
    (x, y)
    float64
    0.9
    long_name :
    fraction of benthic algal mortality into POC
    units :
    unitless
    description :
    fraction of benthic algal mortality into POC
    array([[0.9]])
  • kpoc_20
    (x, y)
    float64
    0.005
    long_name :
    POC hydrolysis rate at 20 degrees Celsius
    units :
    1/d
    description :
    POC hydrolysis rate at 20 degrees Celsius
    array([[0.005]])
  • KsOxmc
    (x, y)
    float64
    1.0
    long_name :
    half saturation oxygen attenuation constant for DOC oxidation rate
    units :
    mg-O2/L
    description :
    half saturation oxygen attenuation constant for DOC oxidation rate
    array([[1.]])
  • pCO2
    (x, y)
    int32
    383
    long_name :
    partial atmospheric CO2 pressure
    units :
    ppm
    description :
    partial pressure of CO2 in the atmosphere
    array([[383]])
  • FCO2
    (x, y)
    float64
    0.2
    long_name :
    CO2 reaeration rate
    units :
    1/d
    description :
    CO2 reaeration rate
    array([[0.2]])
  • roc
    (x, y)
    float64
    2.667
    long_name :
    O2:C ratio for carbon oxidation
    units :
    mg-O2/mg-C
    description :
    O2:C ratio for carbon oxidation (32/12)
    array([[2.66666667]])
  • ron
    (x, y)
    float64
    4.571
    long_name :
    O2:N ratio for nitrification
    units :
    mg-O2/mg-N
    description :
    O2:N ratio for nitrification (2*32/14)
    array([[4.57142857]])
  • KsSOD
    (x, y)
    int32
    1
    long_name :
    half saturation oxygen attenuation constant for SOD
    units :
    mg/L
    description :
    half saturation oxygen attenuation constant for SOD
    array([[1]])
  • kdx_20
    (x, y)
    float64
    0.8
    long_name :
    Pathogen death rate at 20C
    units :
    1/d
    description :
    Pathogen death rate at 20C
    array([[0.8]])
  • apx
    (x, y)
    int32
    1
    long_name :
    Light efficiency factor for pathogen decay
    units :
    unitless
    description :
    Light efficiency factor for pathogen decay
    array([[1]])
  • vx
    (x, y)
    int32
    1
    long_name :
    Pathogen net settling velocity
    units :
    unitless
    description :
    Pathogen net settling velocity
    array([[1]])
  • r_alkaa
    (x, y)
    int32
    1
    long_name :
    Ratio translating algal growth into Alk if NH4 is the N source
    units :
    eq/ug-Chla
    description :
    Ratio translating algal growth into Alk if NH4 is the N source
    array([[1]])
  • r_alkan
    (x, y)
    int32
    1
    long_name :
    Ratio translating algal growth into Alk if NO3 is the N source
    units :
    eq/ug-Chla
    description :
    Ratio translating algal growth into Alk if NO3 is the N source
    array([[1]])
  • r_alkn
    (x, y)
    int32
    1
    long_name :
    Ratio translating NH4 nitrification into Alk
    units :
    eq/mg-N
    description :
    Ratio translating NH4 nitrification into Alk
    array([[1]])
  • r_alkden
    (x, y)
    int32
    1
    long_name :
    Ratio translating NO3 denitrification into Alk
    units :
    eq/mg-N
    description :
    Ratio translating NO3 denitrification into Alk
    array([[1]])
  • r_alkba
    (x, y)
    int32
    1
    long_name :
    Ratio translating benthic algae growth into Alk if NH4 is the N source
    units :
    eq/mg-D
    description :
    Ratio translating benthic algae growth into Alk if NH4 is the N source
    array([[1]])
  • r_alkbn
    (x, y)
    int32
    1
    long_name :
    Ratio translating benthic algae growth into Alk if NO3 is the N source
    units :
    eq/mg-D
    description :
    Ratio translating benthic algae growth into Alk if NO3 is the N source
    array([[1]])
  • TwaterK
    (year, x, y)
    float64
    nan 293.2 nan nan
    long_name :
    Water Temperature K
    units :
    K
    description :
    Water temperature degree kelvin
    array([[[   nan]],\n",
            "\n",
            "       [[293.16]],\n",
            "\n",
    diff --git a/examples/dev_sandbox/prof_nsm.py b/examples/dev_sandbox/prof_nsm.py
    index 68a85db..a6cb10c 100644
    --- a/examples/dev_sandbox/prof_nsm.py
    +++ b/examples/dev_sandbox/prof_nsm.py
    @@ -163,7 +163,7 @@
         'topwidth': 1,
         'slope': 2,
         'shear_velocity': 4,
    -    'pressure_atm': 2,
    +    'pressure_mb': 2026.5,
         'wind_speed': 4,
         'q_solar': 4,
         'Solid': 1, 
    diff --git a/src/clearwater_modules/nsm1/constants.py b/src/clearwater_modules/nsm1/constants.py
    index 28950c3..1412e49 100644
    --- a/src/clearwater_modules/nsm1/constants.py
    +++ b/src/clearwater_modules/nsm1/constants.py
    @@ -301,7 +301,7 @@ class GlobalVars(TypedDict):
         topwidth: float
         slope: float
         shear_velocity: float
    -    pressure_atm: float
    +    pressure_mb: float
         wind_speed: float
         q_solar: float
         Solid: int
    @@ -338,7 +338,7 @@ class GlobalVars(TypedDict):
         topwidth = 1,
         slope = 2,
         shear_velocity = 4,
    -    pressure_atm = 2,
    +    pressure_mb = 2026.5,
         wind_speed = 4,
         q_solar = 500,
         Solid = 1,
    diff --git a/src/clearwater_modules/nsm1/processes.py b/src/clearwater_modules/nsm1/processes.py
    index c43e1fb..4ba474e 100644
    --- a/src/clearwater_modules/nsm1/processes.py
    +++ b/src/clearwater_modules/nsm1/processes.py
    @@ -2906,7 +2906,7 @@ def DOs_atm_alpha(
     
     def DOX_sat(
         TwaterK: xr.DataArray,
    -    pressure_atm: xr.DataArray,
    +    pressure_mb: xr.DataArray,
         pwv: xr.DataArray,
         DOs_atm_alpha: xr.DataArray
     ) -> xr.DataArray:
    @@ -2914,11 +2914,11 @@ def DOX_sat(
     
         Args:
             TwaterK: Water temperature kelvin
    -        pressure_atm: Atmospheric pressure (atm)
    +        pressure_mb: Atmospheric pressure (mb)
             pwv: Patrial pressure of water vapor (atm)
             DOs_atm_alpha: DO saturation atmospheric correction coefficient
         """
    -    pressure_atm = pressure_atm * 0.000986923
    +    pressure_atm = pressure_mb * 0.000986923
         
         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) ))
     
    @@ -3475,7 +3475,7 @@ def KHN2_tc(
     
     def N2sat(
         KHN2_tc : xr.DataArray,
    -    pressure_atm: xr.DataArray,
    +    pressure_mb: xr.DataArray,
         pwv: xr.DataArray
     ) -> xr.DataArray:
         
    @@ -3483,11 +3483,11 @@ def N2sat(
     
         Args:
             KHN2_tc: Henry's law constant (mol/L/atm)
    -        pressure_atm: atmosphric pressure in atm (atm)
    +        pressure_mb: atmosphric pressure in mb (mb)
             pwv: Partial pressure of water vapor (atm)
         """
             
    -    N2sat = 2.8E+4 * KHN2_tc * 0.79 * (pressure_atm - pwv)  
    +    N2sat = 2.8E+4 * KHN2_tc * 0.79 * (pressure_mb*0.000986923 - pwv)  
         N2sat = xr.where(N2sat < 0.0,0.000001,N2sat) #Trap saturation concentration to ensure never negative
     
         return N2sat
    diff --git a/src/clearwater_modules/nsm1/static_variables.py b/src/clearwater_modules/nsm1/static_variables.py
    index df1a7a1..ba075fd 100644
    --- a/src/clearwater_modules/nsm1/static_variables.py
    +++ b/src/clearwater_modules/nsm1/static_variables.py
    @@ -473,10 +473,10 @@ class Variable(base.Variable):
     )
     
     Variable(
    -    name='pressure_atm',
    -    long_name='pressure_atm',
    -    units='TODO',
    -    description='atmospheric pressure in atm',
    +    name='pressure_mb',
    +    long_name='pressure_mb',
    +    units='mb',
    +    description='atmospheric pressure in mb',
         use='static',
     )
     
    diff --git a/tests/test_10_nsm_carbon_calculations.py b/tests/test_10_nsm_carbon_calculations.py
    index eee48ce..4e2ae95 100644
    --- a/tests/test_10_nsm_carbon_calculations.py
    +++ b/tests/test_10_nsm_carbon_calculations.py
    @@ -324,7 +324,7 @@ def default_gvars_params() -> GlobalVars:
             topwidth = 100,
             slope = 0.0002,
             shear_velocity = 0.05334,
    -        pressure_atm = 1013.25,
    +        pressure_mb = 1013.25,
             wind_speed = 3,
             q_solar = 500,
             Solid = 1,
    diff --git a/tests/test_11_nsm_DOX_calculations.py b/tests/test_11_nsm_DOX_calculations.py
    index 3e09dc5..bd89e34 100644
    --- a/tests/test_11_nsm_DOX_calculations.py
    +++ b/tests/test_11_nsm_DOX_calculations.py
    @@ -324,7 +324,7 @@ def default_gvars_params() -> GlobalVars:
             topwidth = 100,
             slope = 0.0002,
             shear_velocity = 0.05334,
    -        pressure_atm = 1013.25,
    +        pressure_mb = 1013.25,
             wind_speed = 3,
             q_solar = 500,
             Solid = 1,
    @@ -867,7 +867,7 @@ def test_changed_TwaterC(
         assert isinstance(DOX, float)
         assert pytest.approx(DOX, tolerance) == 10.39
         
    -def test_changed_pressure_atm(
    +def test_changed_pressure_mb(
         time_steps,
         initial_nsm1_state,
         default_algae_params,
    @@ -888,7 +888,7 @@ def test_changed_pressure_atm(
         """Test the model with default parameters."""
         # alter parameters as necessary
         default_gvars_dict = default_gvars_params
    -    default_gvars_dict['pressure_atm'] = 930
    +    default_gvars_dict['pressure_mb'] = 930
         
         # instantiate the model
         nsm1: NutrientBudget = get_nutrient_budget_instance(
    diff --git a/tests/test_12_nsm_alkalinity_calculations.py b/tests/test_12_nsm_alkalinity_calculations.py
    index ea913cf..e4e7a17 100644
    --- a/tests/test_12_nsm_alkalinity_calculations.py
    +++ b/tests/test_12_nsm_alkalinity_calculations.py
    @@ -324,7 +324,7 @@ def default_gvars_params() -> GlobalVars:
             topwidth = 100,
             slope = 0.0002,
             shear_velocity = 0.05334,
    -        pressure_atm = 1013.25,
    +        pressure_mb = 1013.25,
             wind_speed = 3,
             q_solar = 500,
             Solid = 1,
    diff --git a/tests/test_13_nsm_CBOD_calculations.py b/tests/test_13_nsm_CBOD_calculations.py
    index 8d7b6f1..5edc64b 100644
    --- a/tests/test_13_nsm_CBOD_calculations.py
    +++ b/tests/test_13_nsm_CBOD_calculations.py
    @@ -324,7 +324,7 @@ def default_gvars_params() -> GlobalVars:
             topwidth = 100,
             slope = 0.0002,
             shear_velocity = 0.05334,
    -        pressure_atm = 1013.25,
    +        pressure_mb = 1013.25,
             wind_speed = 3,
             q_solar = 500,
             Solid = 1,
    diff --git a/tests/test_14_nsm_phosphrous_calculations.py b/tests/test_14_nsm_phosphrous_calculations.py
    index 66a0d30..783d8e6 100644
    --- a/tests/test_14_nsm_phosphrous_calculations.py
    +++ b/tests/test_14_nsm_phosphrous_calculations.py
    @@ -328,7 +328,7 @@ def default_gvars_params() -> GlobalVars:
             topwidth = 100,
             slope = 0.0002,
             shear_velocity = 0.05334,
    -        pressure_atm = 1,
    +        pressure_mb = 1013.25,
             wind_speed = 3,
             q_solar = 500,
             Solid = 1,
    diff --git a/tests/test_15_nsm_POM_calculations.py b/tests/test_15_nsm_POM_calculations.py
    index 96f5565..ab92b9e 100644
    --- a/tests/test_15_nsm_POM_calculations.py
    +++ b/tests/test_15_nsm_POM_calculations.py
    @@ -327,7 +327,7 @@ def default_gvars_params() -> GlobalVars:
             topwidth = 100,
             slope = 0.0002,
             shear_velocity = 0.05334,
    -        pressure_atm = 1,
    +        pressure_mb = 1013.25,
             wind_speed = 3,
             q_solar = 500,
             Solid = 1,
    diff --git a/tests/test_16_nsm_PX_calculations.py b/tests/test_16_nsm_PX_calculations.py
    index f441373..6489614 100644
    --- a/tests/test_16_nsm_PX_calculations.py
    +++ b/tests/test_16_nsm_PX_calculations.py
    @@ -328,7 +328,7 @@ def default_gvars_params() -> GlobalVars:
             topwidth = 100,
             slope = 0.0002,
             shear_velocity = 0.05334,
    -        pressure_atm = 1,
    +        pressure_mb = 1013.25,
             wind_speed = 3,
             q_solar = 1,
             Solid = 1,
    diff --git a/tests/test_17_nsm_N2_calculations.py b/tests/test_17_nsm_N2_calculations.py
    index 31c46d5..6d493e8 100644
    --- a/tests/test_17_nsm_N2_calculations.py
    +++ b/tests/test_17_nsm_N2_calculations.py
    @@ -328,7 +328,7 @@ def default_gvars_params() -> GlobalVars:
             topwidth = 100,
             slope = 0.0002,
             shear_velocity = 0.05334,
    -        pressure_atm = 1,
    +        pressure_mb = 1013.25,
             wind_speed = 3,
             q_solar = 500,
             Solid = 1,
    @@ -623,7 +623,7 @@ def test_pressure_atm(
         """Test the model with default parameters."""
         # alter parameters as necessary
         initial_state_dict = initial_nsm1_state
    -    default_gvars_params['pressure_atm'] = 2
    +    default_gvars_params['pressure_mb'] = 2026.5
     
         # instantiate the model
         nsm1: NutrientBudget = get_nutrient_budget_instance(
    diff --git a/tests/test_7_nsm_algae_calculations.py b/tests/test_7_nsm_algae_calculations.py
    index a5e100e..543bb4e 100644
    --- a/tests/test_7_nsm_algae_calculations.py
    +++ b/tests/test_7_nsm_algae_calculations.py
    @@ -329,7 +329,7 @@ def default_gvars_params() -> GlobalVars:
             topwidth = 100,
             slope = 0.0002,
             shear_velocity = 0.05334,
    -        pressure_atm = 1,
    +        pressure_mb = 1013.25,
             wind_speed = 3,
             q_solar = 500,
             Solid = 1,
    diff --git a/tests/test_8_nsm_balgae_calculations.py b/tests/test_8_nsm_balgae_calculations.py
    index da8f37e..84f317d 100644
    --- a/tests/test_8_nsm_balgae_calculations.py
    +++ b/tests/test_8_nsm_balgae_calculations.py
    @@ -328,7 +328,7 @@ def default_gvars_params() -> GlobalVars:
             topwidth = 100,
             slope = 0.0002,
             shear_velocity = 0.05334,
    -        pressure_atm = 1,
    +        pressure_mb = 1013.25,
             wind_speed = 3,
             q_solar = 500,
             Solid = 1,
    diff --git a/tests/test_9_nsm_nitrogen_calculations.py b/tests/test_9_nsm_nitrogen_calculations.py
    index ebd9ac4..b4ee9a0 100644
    --- a/tests/test_9_nsm_nitrogen_calculations.py
    +++ b/tests/test_9_nsm_nitrogen_calculations.py
    @@ -328,7 +328,7 @@ def default_gvars_params() -> GlobalVars:
             topwidth = 100,
             slope = 0.0002,
             shear_velocity = 0.05334,
    -        pressure_atm = 1,
    +        pressure_mb = 1013.25,
             wind_speed = 3,
             q_solar = 500,
             Solid = 1,
    
    From 016b73d7678b7c883a6019fa562a98e762f7be57 Mon Sep 17 00:00:00 2001
    From: kewalak 
    Date: Tue, 24 Sep 2024 08:24:39 -0700
    Subject: [PATCH 8/9] Allow Negative Values
    
    All tests passing besides one test in Carbon and one in CBOD marked to fail with reason known issue with kbod 20 test TBA.
    ---
     src/clearwater_modules/nsm1/processes.py | 32 ++++++++++++------------
     1 file changed, 16 insertions(+), 16 deletions(-)
    
    diff --git a/src/clearwater_modules/nsm1/processes.py b/src/clearwater_modules/nsm1/processes.py
    index 4ba474e..c20d413 100644
    --- a/src/clearwater_modules/nsm1/processes.py
    +++ b/src/clearwater_modules/nsm1/processes.py
    @@ -700,7 +700,7 @@ def Ap(
             dApdt: Change in algae biomass concentration (ug-Chla/L/d)
             dt: current iteration dt (d)
         """
    -    return xr.where(Ap + dApdt * dt >0, Ap + dApdt * dt ,0)
    +    return Ap + dApdt * dt
     
     ############################################ From benthic algae
     
    @@ -1104,7 +1104,7 @@ def Ab(
     
         """
     
    -    return xr.where(Ab + dAbdt * dt > 0 , Ab + dAbdt * dt, 0)
    +    return Ab + dAbdt * dt
     
     
     def Chlb(
    @@ -1423,7 +1423,7 @@ def OrgN(
     
         """
     
    -    return xr.where(OrgN + dOrgNdt * dt > 0 , OrgN + dOrgNdt * dt , 0)
    +    return OrgN + dOrgNdt * dt
     
     def NitrificationInhibition(
         use_DOX: bool,
    @@ -1605,7 +1605,7 @@ def NH4(
     
         """
     
    -    return xr.where(NH4 + dNH4dt * dt > 0 , NH4 + dNH4dt * dt , 0)
    +    return NH4 + dNH4dt * dt
     
     def NO3_Denit(
         use_DOX: bool,
    @@ -1750,7 +1750,7 @@ def NO3(
     
         """
     
    -    return xr.where(NO3 + dNO3dt * dt > 0 , NO3 + dNO3dt * dt, 0)
    +    return NO3 + dNO3dt * dt
     
     
     def DIN(
    @@ -2111,7 +2111,7 @@ def TIP(
             TIP: Total inorganic phosphorus water concentration (mg-P/L),
             dt: current iteration dt (d)
         """     
    -    return xr.where(TIP + dTIPdt * dt > 0, TIP + dTIPdt * dt,0)
    +    return TIP + dTIPdt * dt
     
     
     def OrgP(
    @@ -2127,7 +2127,7 @@ def OrgP(
             OrgP: Total organic phosphorus water concentration (mg-P/L),
             dt: current iteration dt (d)
         """     
    -    return xr.where(OrgP + dOrgPdt * dt >0 , OrgP + dOrgPdt * dt,0)
    +    return OrgP + dOrgPdt * dt
     
     def TOP(
         use_OrgP: bool,
    @@ -2332,7 +2332,7 @@ def POM(
             POM: POM concentration from previous dt (mg/L)
             dt: Current iteration dt (d)
         """
    -    return xr.where(POM + dPOMdt * dt >0, POM + dPOMdt * dt, 0)
    +    return POM + dPOMdt * dt
     
     
     ################################## From CBOD
    @@ -2437,7 +2437,7 @@ def CBOD(
             dCBODdt: CBOD concentration change for current dt (mg/L/d)
             dt: current iteration dt (d)
         """
    -    return xr.where(CBOD + dCBODdt * dt >0, CBOD + dCBODdt * dt,0)
    +    return CBOD + dCBODdt * dt
     
     ############################### From Carbon
     
    @@ -2565,7 +2565,7 @@ def POC(
             dPOCdt: POC concentration change for current dt (mg/L/d)
             dt: current iteration dt (d)
         """
    -    return xr.where(POC + dPOCdt * dt>0, POC + dPOCdt * dt,0)
    +    return POC + dPOCdt * dt
     
     
     def DOC_algal_mortality(
    @@ -2686,7 +2686,7 @@ def DOC(
             dDOCdt: Dissolved organic carbon concentration change for current dt (mg/L/d)
             dt: current iteration dt (d)
         """
    -    return xr.where(DOC + dDOCdt * dt > 0, DOC + dDOCdt * dt, 0)
    +    return DOC + dDOCdt * dt
     
     
     
    @@ -2873,7 +2873,7 @@ def DIC(
             dDICdt: Change in concentration of DIC for current dt (mg/L/d)
             dt: Current iteration dt (d)
         """
    -    return xr.where(DIC + dDICdt * dt >0, DIC + dDICdt * dt,0)
    +    return DIC + dDICdt * dt
     
     
     ######################################## From DOX
    @@ -3138,7 +3138,7 @@ def DOX(
             dDOXdt: Change in dissolved oxygen concentration over dt
             dt: Current iteration dt (d)
         """
    -    return xr.where(DOX + dDOXdt * dt>0, DOX + dDOXdt * dt, 0)
    +    return DOX + dDOXdt * dt
     
     ######################################### From pathogen
     
    @@ -3244,7 +3244,7 @@ def PX(
           PX: Pathogen concentration (cfu/100mL)
           dt: Current iteration dt (d)
         """
    -    return xr.where(PX + dt * dPXdt >0, PX + dt * dPXdt , 0)
    +    return PX + dt * dPXdt
     
     
     ##################################### From alkalinity
    @@ -3450,7 +3450,7 @@ def Alk(
             dAlkdt: Change in concentration of alkalinity for current dt (mg/L/d)
             dt: Current iteration dt (d)
         """
    -    return xr.where(Alk + dAlkdt * dt > 0, Alk + dAlkdt * dt, 0)
    +    return Alk + dAlkdt * dt
     
     ##################################### From N2
     
    @@ -3524,7 +3524,7 @@ def N2(
             dt: Current iteration dt (d)
         """
             
    -    return xr.where(N2 + dN2dt * dt > 0 , N2 + dN2dt * dt , 0)
    +    return N2 + dN2dt * dt
     
     def TDG(
         N2: xr.DataArray,
    
    From b3ac9702261f7f392aba15b45166ea157acf9bf0 Mon Sep 17 00:00:00 2001
    From: kewalak 
    Date: Tue, 24 Sep 2024 11:39:03 -0700
    Subject: [PATCH 9/9] Remove kelvin_to_celsius
    
    ---
     src/clearwater_modules/nsm1/processes.py | 6 ------
     1 file changed, 6 deletions(-)
    
    diff --git a/src/clearwater_modules/nsm1/processes.py b/src/clearwater_modules/nsm1/processes.py
    index c20d413..1d39408 100644
    --- a/src/clearwater_modules/nsm1/processes.py
    +++ b/src/clearwater_modules/nsm1/processes.py
    @@ -9,12 +9,6 @@
     def celsius_to_kelvin(tempc: xr.DataArray) -> xr.DataArray:
         return tempc + 273.15
     
    -
    -
    -def kelvin_to_celsius(tempk: xr.DataArray) -> xr.DataArray:
    -    return tempk - 273.15
    -
    -
     def arrhenius_correction(
         TwaterC: xr.DataArray,
         rc20: xr.DataArray,