📄 hhwatqual.f
字号:
nh3con = (ammoin * wtrin + ammonian(jrch) * hrchwtr(ii)) &
& / wtrtot
no2con = (nitritin * wtrin + nitriten(jrch) * hrchwtr(ii)) &
& / wtrtot
no3con = (nitratin * wtrin + nitraten(jrch) * hrchwtr(ii)) &
& / wtrtot
orgpcon = (orgpin * wtrin + organicp(jrch) * hrchwtr(ii)) &
& / wtrtot
solpcon = (dispin * wtrin + disolvp(jrch) * hrchwtr(ii)) &
& / wtrtot
cbodcon = (cbodin * wtrin + rch_cbod(jrch) * hrchwtr(ii)) &
& / wtrtot
o2con = (disoxin * wtrin + rch_dox(jrch) * hrchwtr(ii)) &
& / wtrtot
else
algcon = (algin * wtrin + halgae(ii-1) * hrchwtr(ii)) / wtrtot
orgncon = (orgnin * wtrin + horgn(ii-1) * hrchwtr(ii)) / wtrtot
nh3con = (ammoin * wtrin + hnh4(ii-1) * hrchwtr(ii)) / wtrtot
no2con = (nitritin * wtrin + hno2(ii-1) * hrchwtr(ii)) / wtrtot
no3con = (nitratin * wtrin + hno3(ii-1) * hrchwtr(ii)) / wtrtot
orgpcon = (orgpin * wtrin + horgp(ii-1) * hrchwtr(ii)) / wtrtot
solpcon = (dispin * wtrin + hsolp(ii-1) * hrchwtr(ii)) / wtrtot
cbodcon = (cbodin * wtrin + hbod(ii-1) * hrchwtr(ii)) / wtrtot
o2con = (disoxin * wtrin + hdisox(ii-1) * hrchwtr(ii)) / wtrtot
end if
!! calculate temperature in stream
!! Stefan and Preudhomme. 1993. Stream temperature estimation
!! from air temperature. Water Res. Bull. p. 27-45
!! SWAT manual equation 2.3.13
wtmp = 0.
wtmp = 5.0 + 0.75 * tmpav(jrch)
if (wtmp <= 0.) wtmp = 0.1
!! calculate effective concentration of available nitrogen
!! QUAL2E equation III-15
cinn = nh3con + no3con
!! calculate saturation concentration for dissolved oxygen
!! QUAL2E section 3.6.1 equation III-29
ww = 0.
xx = 0.
yy = 0.
zz = 0.
ww = -139.34410 + (1.575701e05 / (wtmp + 273.15))
xx = 6.642308e07 / ((wtmp + 273.15)**2)
yy = 1.243800e10 / ((wtmp + 273.15)**3)
zz = 8.621949e11 / ((wtmp + 273.15)**4)
soxy = Exp(ww - xx + yy - zz)
if (soxy < 0.) soxy = 0.
!! end initialize concentrations
!! O2 impact calculations
!! calculate nitrification rate correction factor for low
!! oxygen QUAL2E equation III-21
cordo = 0.
cordo = 1.0 - Exp(-0.6 * o2con)
!! modify ammonia and nitrite oxidation rates to account for
!! low oxygen
bc1mod = 0.
bc2mod = 0.
bc1mod = bc1(jrch) * cordo
bc2mod = bc2(jrch) * cordo
!! end O2 impact calculations
!! calculate flow duration
thour = 0.
thour = hhtime(ii)
if (thour > 1.0) thour = 1.0
thour = 1.0
!! algal growth
!! calculate light extinction coefficient
!! (algal self shading) QUAL2E equation III-12
if (ai0 * algcon > 1.e-6) then
lambda = lambda0 + (lambda1 * ai0 * algcon) + lambda2 * &
& (ai0 * algcon) ** (.66667)
else
lambda = lambda0
endif
!! calculate algal growth limitation factors for nitrogen
!! and phosphorus QUAL2E equations III-13 & III-14
fnn = 0.
fpp = 0.
fnn = cinn / (cinn + k_n)
fpp = solpcon / (solpcon + k_p)
!! calculate hourly, photosynthetically active,
!! light intensity QUAL2E equation III-9c
!! Light Averaging Option # 3
algi = 0.
algi = frad(hru1(jrch),ii) * hru_ra(hru1(jrch)) * tfact
!! calculate growth attenuation factor for light, based on
!! hourly light intensity QUAL2E equation III-6a
fll = 0.
fll = (1. / (lambda * hdepth(ii))) * &
& Log((k_l + algi) / (k_l + algi * (Exp(-lambda * hdepth(ii)))))
!! calculcate local algal growth rate
gra = 0.
select case (igropt)
case (1)
!! multiplicative QUAL2E equation III-3a
gra = mumax * fll * fnn * fpp
case (2)
!! limiting nutrient QUAL2E equation III-3b
gra = mumax * fll * Min(fnn, fpp)
case (3)
!! harmonic mean QUAL2E equation III-3c
if (fnn > 1.e-6 .and. fpp > 1.e-6) then
gra = mumax * fll * 2. / ((1. / fnn) + (1. / fpp))
else
gra = 0.
endif
end select
!! calculate algal biomass concentration at end of day
!! (phytoplanktonic algae)
!! QUAL2E equation III-2
halgae(ii) = 0.
halgae(ii) = algcon + (Theta(gra,thgra,wtmp) * algcon - &
& Theta(rhoq,thrho,wtmp) * algcon - Theta(rs1(jrch),thrs1,wtmp) &
& / hdepth(ii) * algcon) * thour
if (halgae(ii) < 0.) halgae(ii) = 0.
!! calculate chlorophyll-a concentration at end of day
!! QUAL2E equation III-1
hchla(ii) = 0.
hchla(ii) = halgae(ii) * ai0 / 1000.
!! end algal growth
!! oxygen calculations
!! calculate carbonaceous biological oxygen demand at end
!! of day QUAL2E section 3.5 equation III-26
yy = 0.
zz = 0.
yy = Theta(rk1(jrch),thrk1,wtmp) * cbodcon
zz = Theta(rk3(jrch),thrk3,wtmp) * cbodcon
hbod(ii) = 0.
hbod(ii) = cbodcon - (yy + zz) * thour
if (hbod(ii) < 0.) hbod(ii) = 0.
!! calculate dissolved oxygen concentration if reach at
!! end of day QUAL2E section 3.6 equation III-28
uu = 0.
vv = 0.
ww = 0.
xx = 0.
yy = 0.
zz = 0.
uu = Theta(rk2(jrch),thrk2,wtmp) * (soxy - o2con)
vv = (ai3 * Theta(gra,thgra,wtmp) - ai4 * &
& Theta(rhoq,thrho,wtmp)) * algcon
ww = Theta(rk1(jrch),thrk1,wtmp) * cbodcon
xx = Theta(rk4(jrch),thrk4,wtmp) / (hdepth(ii) * 1000.)
yy = ai5 * Theta(bc1mod,thbc1,wtmp) * nh3con
zz = ai6 * Theta(bc2mod,thbc2,wtmp) * no2con
hdisox(ii) = 0.
hdisox(ii) = o2con + (uu + vv - ww - xx - yy - zz) * thour
if (hdisox(ii) < 0.) hdisox(ii) = 0.
!! end oxygen calculations
!! nitrogen calculations
!! calculate organic N concentration at end of day
!! QUAL2E section 3.3.1 equation III-16
xx = 0.
yy = 0.
zz = 0.
xx = ai1 * Theta(rhoq,thrho,wtmp) * algcon
yy = Theta(bc3(jrch),thbc3,wtmp) * orgncon
zz = Theta(rs4(jrch),thrs4,wtmp) * orgncon
horgn(ii) = 0.
horgn(ii) = orgncon + (xx - yy - zz) * thour
if (horgn(ii) < 0.) horgn(ii) = 0.
!! calculate fraction of algal nitrogen uptake from ammonia
!! pool QUAL2E equation III-18
f1 = 0.
f1 = p_n * nh3con / (p_n * nh3con + (1. - p_n) * no3con + &
& 1.e-6)
!! calculate ammonia nitrogen concentration at end of day
!! QUAL2E section 3.3.2 equation III-17
ww = 0.
xx = 0.
yy = 0.
zz = 0.
ww = Theta(bc3(jrch),thbc3,wtmp) * orgncon
xx = Theta(bc1mod,thbc1,wtmp) * nh3con
yy = Theta(rs3(jrch),thrs3,wtmp) / (hdepth(ii) * 1000.)
zz = f1 * ai1 * algcon * Theta(gra,thgra,wtmp)
hnh4(ii) = 0.
hnh4(ii) = nh3con + (ww - xx + yy - zz) * thour
if (hnh4(ii) < 0.) hnh4(ii) = 0.
!! calculate concentration of nitrite at end of day
!! QUAL2E section 3.3.3 equation III-19
yy = 0.
zz = 0.
yy = Theta(bc1mod,thbc1,wtmp) * nh3con
zz = Theta(bc2mod,thbc2,wtmp) * no2con
hno2(ii) = 0.
hno2(ii) = no2con + (yy - zz) * thour
if (hno2(ii) < 0.) hno2(ii) = 0.
!! calculate nitrate concentration at end of day
!! QUAL2E section 3.3.4 equation III-20
yy = 0.
zz = 0.
yy = Theta(bc2mod,thbc2,wtmp) * no2con
zz = (1. - f1) * ai1 * algcon * Theta(gra,thgra,wtmp)
hno3(ii) = 0.
hno3(ii) = no3con + (yy - zz) * thour
if (hno3(ii) < 0.) hno3(ii) = 0.
!! end nitrogen calculations
!! phosphorus calculations
!! calculate organic phosphorus concentration at end of
!! day QUAL2E section 3.3.6 equation III-24
xx = 0.
yy = 0.
zz = 0.
xx = ai2 * Theta(rhoq,thrho,wtmp) * algcon
yy = Theta(bc4(jrch),thbc4,wtmp) * orgpcon
zz = Theta(rs5(jrch),thrs5,wtmp) * orgpcon
horgp(ii) = 0.
horgp(ii) = orgpcon + (xx - yy - zz) * thour
if (horgp(ii) < 0.) horgp(ii) = 0.
!! calculate dissolved phosphorus concentration at end
!! of day QUAL2E section 3.4.2 equation III-25
xx = 0.
yy = 0.
zz = 0.
xx = Theta(bc4(jrch),thbc4,wtmp) * orgpcon
yy = Theta(rs2(jrch),thrs2,wtmp) / (hdepth(ii) * 1000.)
zz = ai2 * Theta(gra,thgra,wtmp) * algcon
hsolp(ii) = 0.
hsolp(ii) = solpcon + (xx + yy - zz) * thour
if (hsolp(ii) < 0.) hsolp(ii) = 0.
!! end phosphorus calculations
else
!! all water quality variables set to zero when no flow
algin = 0.0
chlin = 0.0
orgnin = 0.0
ammoin = 0.0
nitritin = 0.0
nitratin = 0.0
orgpin = 0.0
dispin = 0.0
cbodin = 0.0
disoxin = 0.0
halgae(ii) = 0.0
hchla(ii) = 0.0
horgn(ii) = 0.0
hnh4(ii) = 0.0
hno2(ii) = 0.0
hno3(ii) = 0.0
horgp(ii) = 0.0
hsolp(ii) = 0.0
hbod(ii) = 0.0
hdisox(ii) = 0.0
soxy = 0.0
endif
end do
!! end hourly loop
!! set end of day concentrations
algae(jrch) = halgae(24)
chlora(jrch) = hchla(24)
organicn(jrch) = horgn(24)
ammonian(jrch) = hnh4(24)
nitriten(jrch) = hno2(24)
nitraten(jrch) = hno3(24)
organicp(jrch) = horgp(24)
disolvp(jrch) = hsolp(24)
rch_cbod(jrch) = hbod(24)
rch_dox(jrch) = hdisox(24)
return
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -