Skip to content

Commit

Permalink
fix open water evaporation
Browse files Browse the repository at this point in the history
  • Loading branch information
JoostBuitink committed Oct 24, 2024
1 parent 26f5004 commit dd921b7
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/sbm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,18 @@ function update_until_recharge(sbm::SBM, config)
ustoredepth = sum(@view sbm.ustorelayerdepth[i][1:sbm.nlayers[i]])

runoff_river = min(1.0, sbm.riverfrac[i]) * avail_forinfilt
runoff_land = min(1.0, sbm.waterfrac[i]) * avail_forinfilt

# Calculate the initial capacity of the unsaturated store
ustorecapacity = sbm.soilwatercapacity[i] - sbm.satwaterdepth[i] - ustoredepth
# Add a flag if the soil is saturated
check_saturated = ustorecapacity < 0.1

if check_saturated
runoff_land = min(1.0, 1.0 - sbm.riverfrac[i]) * avail_forinfilt
else
runoff_land = min(1.0, sbm.waterfrac[i]) * avail_forinfilt
end

if !isnothing(sbm.paddy) || !isnothing(sbm.nonpaddy)
avail_forinfilt = avail_forinfilt + sbm.allocation.irri_alloc[i]
end
Expand All @@ -928,10 +939,17 @@ function update_until_recharge(sbm::SBM, config)
surface_water = sbm.waterlevel_land[i] * (1.0 - sbm.riverfrac[i])

# Calculate open water evaporation
ae_openw_l = min(
surface_water,
sbm.potential_evaporation[i] * soilevap_fraction,
)
if check_saturated
ae_openw_l = min(
surface_water,
sbm.potential_evaporation[i] * soilevap_fraction,
)
else
ae_openw_l = min(
surface_water,
sbm.potential_evaporation[i] * sbm.waterfrac[i],
)
end

# Update land waterlevel and scale to part of cell not covered by rivers
if do_surface_water_infiltration
Expand All @@ -954,9 +972,6 @@ function update_until_recharge(sbm::SBM, config)
evap_paddy_water = 0.0
end

# Calculate the initial capacity of the unsaturated store
ustorecapacity = sbm.soilwatercapacity[i] - sbm.satwaterdepth[i] - ustoredepth

# Calculate the infiltration flux into the soil column
infiltsoilpath,
infiltsoil,
Expand Down

0 comments on commit dd921b7

Please sign in to comment.