Skip to content

Commit

Permalink
Completed Testing Suite
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kewalak committed Aug 2, 2024
1 parent 78a59a9 commit a75305c
Show file tree
Hide file tree
Showing 5 changed files with 1,875 additions and 62 deletions.
32 changes: 16 additions & 16 deletions src/clearwater_modules/nsm1/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -1104,7 +1104,7 @@ def Ab(
"""

return Ab + dAbdt * dt
return xr.where(Ab + dAbdt * dt > 0 , Ab + dAbdt * dt, 0)


def Chlb(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1750,7 +1750,7 @@ def NO3(
"""

return NO3 + dNO3dt * dt
return xr.where(NO3 + dNO3dt * dt > 0 , NO3 + dNO3dt * dt, 0)


def DIN(
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)



Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit a75305c

Please sign in to comment.