5757 [10.0 ],
5858]
5959# sensible and latent heat flux parameter values
60- wspd = 126005.19379436946474 # unrealistically high to drive a -1C change
61- tatm = 5.0
60+ wspd = 126005.30 # unrealistically high to drive a -1C change
61+ tatm = 5.0
6262# shortwave radiation parameter values
6363solr = 47880870.9 # unrealistically high to drive a 1 deg C rise in stream temperature
6464shd = 1.0 # 100% shade "turns off" solar flux
6868# Transport related parameters
6969porosity = sy # porosity (unitless)
7070K_therm = 2.0 # Thermal conductivity # ($W/m/C$)
71- rhow = 1000 # Density of water ($kg/m^3$)
72- rhos = 2650 # Density of the aquifer material ($kg/m^3$)
71+ rhow = 1000.0 # Density of water ($kg/m^3$)
72+ rhos = 2650.0 # Density of the aquifer material ($kg/m^3$)
7373rhoa = 1.225 # Density of the atmosphere ($kg/m^3$)
74- Cpw = 4180 # Heat capacity of water ($J/kg/C$)
75- Cps = 880 # Heat capacity of the solids ($J/kg/C$)
74+ Cpw = 4180.0 # Heat capacity of water ($J/kg/C$)
75+ Cps = 880.0 # Heat capacity of the solids ($J/kg/C$)
7676Cpa = 717.0 # Heat capacity of the atmosphere ($J/kg/C$)
7777lhv = 2454000.0 # Latent heat of vaporization ($J/kg$)
7878c_d = 0.0 # Drag coefficient ($unitless$) !!
@@ -435,6 +435,23 @@ def build_models(idx, test):
435435# sim.write_simulation()
436436
437437
438+ def calc_ener_transfer (updated_strm_temp , mf_strm_wid ):
439+ L = (2499.64 - (2.51 * updated_strm_temp )) * 1000
440+ e_w = 6.1275 * math .exp (
441+ 17.2693882 * (updated_strm_temp / (updated_strm_temp + 273.16 - 35.86 ))
442+ )
443+ e_s = 6.1275 * math .exp (17.2693882 * (tatm / (tatm + 273.16 - 35.86 )))
444+ e_a = (rh / 100 ) * e_s
445+ vap_press_deficit = e_w - e_a
446+ wind_function = wf_int + wf_slope * wspd
447+ Ev = wind_function * vap_press_deficit
448+ lhf_ener_per_sqm = Ev * L * rhow
449+
450+ ener_transfer = lhf_ener_per_sqm * delr * mf_strm_wid
451+
452+ return - ener_transfer
453+
454+
438455def check_output (idx , test ):
439456 print ("evaluating results..." )
440457 msg0 = "Stream channel width less than 1.0, should be 1.0 m"
@@ -449,35 +466,27 @@ def check_output(idx, test):
449466 fpth = os .path .join (test .workspace , gwfname + ".sfr.obs.csv" )
450467 assert os .path .isfile (fpth )
451468 df = pd .read_csv (fpth )
452- calc_strm_wid = df .loc [0 , "RCH1_WETWIDTH" ].copy ()
469+ mf_strm_wid = df .loc [0 , "RCH1_WETWIDTH" ].copy ()
453470 # confirm stream width is 1.0 m
454- assert np .isclose (calc_strm_wid , 1.0 , atol = 1e-9 ), msg0
471+ assert np .isclose (mf_strm_wid , 1.0 , atol = 1e-9 ), msg0
455472
456473 # confirm that the energy added to the stream results in a -1C change in temp
457474 # temperature gradient
458-
475+
459476 tgrad = tatm - strm_temp
460477 shf_ener_per_sqm = c_d * rhoa * Cpa * wspd * tgrad
461478 swr_ener_per_sqm = solr * (1 - shd ) * (1 - swrefl )
462- # latent calcs
463- L = (2499.64 - (2.51 * strm_temp )) * 1000
464- e_w = 6.1275 * math .exp (17.2693882 * (strm_temp / (strm_temp + 273.16 - 35.86 )))
465- e_s = 6.1275 * math .exp (17.2693882 * (tatm / (tatm + 273.16 - 35.86 )))
466- e_a = (rh / 100 ) * e_s
467- vap_press_deficit = e_w - e_a
468- wind_function = wf_int + wf_slope * wspd
469- Ev = wind_function * vap_press_deficit
470- lhf_ener_per_sqm = Ev * L * rhow
471479
472- ener_transfer = (shf_ener_per_sqm + swr_ener_per_sqm + lhf_ener_per_sqm ) * (
473- delr * calc_strm_wid
474- )
475- # calculate expected temperature change based on energy transfer
476- 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
480+ # latent calcs
481+ chng = 1
482+ strt_strm_temp = strm_temp
483+ updated_strm_temp = strm_temp
484+ while chng > hclose :
485+ ener_transfer = calc_ener_transfer (updated_strm_temp , mf_strm_wid )
486+ temp_change = ener_transfer / (surf_Q_in [idx ][0 ] * Cpw * rhow )
487+ updated_temp = strt_strm_temp + temp_change
488+ chng = abs (updated_strm_temp - updated_temp )
489+ updated_strm_temp = updated_temp
481490
482491 fpth2 = os .path .join (test .workspace , gwename + ".sfe.obs.csv" )
483492 assert os .path .isfile (fpth2 )
@@ -492,7 +501,7 @@ def check_output(idx, test):
492501 )
493502
494503 assert np .isclose (
495- df2 .loc [0 , "RCH1_OUTFTEMP" ], strm_temp + temp_change , atol = 1e-6
504+ df2 .loc [0 , "RCH1_OUTFTEMP" ], strt_strm_temp + temp_change , atol = 1e-6
496505 ), msg2 + ". " + msg3 + ". " + msg1
497506
498507
0 commit comments