Skip to content

Commit 73795f6

Browse files
skfoggemorway-usgs
authored andcommitted
Abc lhf work (#23)
1 parent b1e012d commit 73795f6

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

autotest/test_gwe_sfe_abc_lhf00.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
]
5959
# sensible and latent heat flux parameter values
6060
wspd = 20.0
61-
tatm = 270.87556216 # unrealistically high to drive a -1C change in stream temperature
61+
tatm = 270.79111 # unrealistically high to drive a -1C change in stream temperature
6262
# shortwave radiation parameter values
6363
solr = 47880870.9 # unrealistically high to drive a 1 deg C rise in stream temperature
6464
shd = 1.0 # 100% shade "turns off" solar flux
@@ -90,7 +90,7 @@
9090
perlen = [1]
9191

9292
nouter, ninner = 1000, 300
93-
hclose, rclose, relax = 1e-3, 1e-4, 0.97
93+
hclose, rclose, relax = 1e-10, 1e-10, 0.97
9494

9595
#
9696
# MODFLOW 6 flopy GWF object
@@ -455,11 +455,12 @@ def check_output(idx, test):
455455

456456
# confirm that the energy added to the stream results in a -1C change in temp
457457
# temperature gradient
458+
458459
tgrad = tatm - strm_temp
459460
shf_ener_per_sqm = c_d * rhoa * Cpa * wspd * tgrad
460461
swr_ener_per_sqm = solr * (1 - shd) * (1 - swrefl)
461462
# latent calcs
462-
L = (2499.64 - 2.51 * strm_temp) * 1000
463+
L = (2499.64 - (2.51 * strm_temp)) * 1000
463464
e_w = 6.1275 * math.exp(17.2693882 * (strm_temp / (strm_temp + 273.16 - 35.86)))
464465
e_s = 6.1275 * math.exp(17.2693882 * (tatm / (tatm + 273.16 - 35.86)))
465466
e_a = rh / 100 * e_s
@@ -473,22 +474,25 @@ def check_output(idx, test):
473474
)
474475
# calculate expected temperature change based on energy transfer
475476
temp_change = ener_transfer / (surf_Q_in[idx][0] * Cpw * rhow)
477+
478+
print(str(strm_temp + temp_change))
479+
480+
#new_strm_temp = strm_temp + temp_change
476481

477482
fpth2 = os.path.join(test.workspace, gwename + ".sfe.obs.csv")
478483
assert os.path.isfile(fpth2)
479484
df2 = pd.read_csv(fpth2)
480485

481486
# confirm 1 deg C decrease in temp
482-
msg1 = (
483-
"The calculated temperature change \
484-
is: "
485-
+ str(temp_change)
487+
msg1 = "Python temperature change is = " + str(temp_change)
488+
msg2 = "MODFLOW temperature = " + str(df2.loc[0, "RCH1_OUTFTEMP"])
489+
msg3 = "MODFLOW temperature change is " + str(
490+
strm_temp - df2.loc[0, "RCH1_OUTFTEMP"]
486491
)
487-
msg2 = "The temperature is:" + str(df2.loc[0, "RCH1_OUTFTEMP"])
488492

489493
assert np.isclose(
490494
df2.loc[0, "RCH1_OUTFTEMP"], strm_temp + temp_change, atol=1e-6
491-
), msg2
495+
), msg2 + ". " + msg3 + ". " + msg1
492496

493497

494498
# - No need to change any code below

make/makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ $(OBJDIR)/tsp-obs.o \
425425
$(OBJDIR)/tsp-mvt.o \
426426
$(OBJDIR)/tsp-adv.o \
427427
$(OBJDIR)/gwf-uzf.o \
428+
$(OBJDIR)/tsp-apt_weird_chngs.o \
429+
$(OBJDIR)/gwt-mst_updates.o \
428430
$(OBJDIR)/GwtDspOptions.o \
429431
$(OBJDIR)/gwf-tvs.o \
430432
$(OBJDIR)/GwfStorageUtils.o \

src/Model/GroundWaterEnergy/gwe-lhf.f90

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,20 @@ subroutine lhf_cq(this, ifno, tstrm, rhow, lhflx)
139139
real(DP) :: sat_vap_ta
140140
real(DP) :: amb_vap_atm
141141
real(DP) :: evap_rate
142+
real(DP) :: test_mult
142143
!
143144
! -- calculate latent heat flux using mass transfer equation
144145
!! EQ BASED ON TEMPERATURES IN CELSIUS
145146
! -- temperature dependent latent heat of vaporization:
146-
latent_heat_vap = (2499.64 - (2.51*tstrm))*1000 ! tstrm in C
147+
!test_mult = 2.51*tstrm
147148

148-
sat_vap_tw = 6.1275*exp(17.2693882*((tstrm)/(tstrm + DCTOK - 35.86)))
149-
sat_vap_ta = 6.1275*exp(17.2693882*((this%tatm(ifno))/(this%tatm(ifno) + DCTOK - 35.86)))
149+
latent_heat_vap = (2499.64_DP - (2.51_DP*tstrm))*1000.0_DP ! tstrm in C
150+
!latent_heat_vap = 2449440.0
150151

151-
amb_vap_atm = (this%rh(ifno)/100)*sat_vap_ta
152+
sat_vap_tw = 6.1275_DP*exp(17.2693882_DP*((tstrm)/(tstrm + DCTOK - 35.86_DP)))
153+
sat_vap_ta = 6.1275_DP*exp(17.2693882_DP*((this%tatm(ifno))/(this%tatm(ifno) + DCTOK - 35.86_DP)))
154+
155+
amb_vap_atm = (this%rh(ifno)/100.0_DP)*sat_vap_ta
152156

153157
evap_rate = (this%wfint + this%wfslope*this%wspd(ifno))*(sat_vap_tw - amb_vap_atm)
154158

0 commit comments

Comments
 (0)