Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kmdeck committed Jul 1, 2024
1 parent f0f1f05 commit e62c393
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
22 changes: 15 additions & 7 deletions experiments/integrated/soil_snow/met_drivers_fluxnet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,31 @@ esat =
)
e = @. esat - drivers.VPD.values
q = @. 0.622 * e ./ (drivers.PA.values - 0.378 * e)

RH = @. e/esat
function snowsplit(air_temp, hum)
air_temp_C = air_temp - 273.15
α = -10.04
β = 1.41
γ = 0.09
snow_frac = (1.0 / (1.0 + exp+ β * air_temp_C + γ * hum)))
return snow_frac
end
snow_frac = snowsplit.(drivers.TA.values[:], RH[:])
P_liq = -FT.(drivers.P.values[:] .* (1 .- snow_frac))
P_snow = -FT.(drivers.P.values[:] .* snow_frac)
# Create interpolators for each atmospheric driver needed for PrescribedAtmosphere and for
# PrescribedRadiation
seconds = FT.(0:DATA_DT:((length(UTC_DATETIME) - 1) * DATA_DT));

precip = TimeVaryingInput(seconds, -FT.(drivers.P.values[:]); context) # m/s
precip = TimeVaryingInput(seconds, P_liq; context) # m/s
atmos_q = TimeVaryingInput(seconds, FT.(q[:]); context)
atmos_T = TimeVaryingInput(seconds, FT.(drivers.TA.values[:]); context)
atmos_p = TimeVaryingInput(seconds, FT.(drivers.PA.values[:]); context)
atmos_co2 = TimeVaryingInput(seconds, FT.(drivers.CO2.values[:]); context)
atmos_u = TimeVaryingInput(seconds, FT.(drivers.WS.values[:]); context)
LW_IN = TimeVaryingInput(seconds, FT.(drivers.LW_IN.values[:]); context)
SW_IN = TimeVaryingInput(seconds, FT.(drivers.SW_IN.values[:]); context)
#NEEDED
snow_precip = TimeVaryingInput((t) -> FT(0))
snow_precip = TimeVaryingInput(seconds, P_snow; context) # m/s

# Construct the drivers. For the reference time we will use the UTC time at the
# start of the simulation
Expand All @@ -139,9 +149,7 @@ atmos = ClimaLand.PrescribedAtmosphere(
earth_param_set;
c_co2 = atmos_co2,
)
#NEEDED
lat = ;
lon = ;

function zenith_angle(
t,
ref_time;
Expand Down
9 changes: 9 additions & 0 deletions experiments/integrated/soil_snow/parameters_fluxnet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@
## And Forest Meteorology, 147(3-4), 157-171. https://doi.org/10.1016/j.agrformet.2007.07.008
## CLM 5.0 Tech Note: https://www2.cesm.ucar.edu/models/cesm2/land/CLM50_Tech_Note.pdf
# Bonan, G. Climate change and terrestrial ecosystem modeling. Cambridge University Press, 2019.
data_link = "https://caltech.box.com/shared/static/7r0ci9pacsnwyo0o9c25mhhcjhsu6d72.csv"
site_ID = "US-MOz"
# Timezone (offset from UTC in hrs)
time_offset = 7

# Height of sensor on flux tower
atmos_h = FT(32)

# Site latitude and longitude
lat = FT(38.7441) # degree
long = FT(-92.2000) # degree
# Soil parameters
soil_ν = FT(0.5) # m3/m3
soil_K_sat = FT(0.45 / 3600 / 100) # m/s,
Expand Down
2 changes: 1 addition & 1 deletion experiments/integrated/soil_snow/simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ snow_parameters = SnowParameters{FT}(
);
snow_args = (; domain = snow_domain, parameters = snow_parameters);
snow_model_type = Snow.SnowModel
land_input = (atmos = atmos, radiation = radiation)
land_input = (atmos = atmos, radiation = radiation, runoff = ClimaLand.Soil.SiteLevelSurfaceRunoff())
land = ClimaLand.LandHydrologyModel{FT}(;
land_args = land_input,
soil_model_type = soil_model_type,
Expand Down
10 changes: 7 additions & 3 deletions src/integrated/soil_snow_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ struct AtmosDrivenFluxBCwithSnow{
"The radiative fluxes driving the model"
radiation::B
"The runoff model. The default is no runoff."
runoff::R
runoff::R
end

function AtmosDrivenFluxBCwithSnow(atmos, radiation)
return AtmosDrivenFluxBCwithSnow{typeof(atmos), typeof(radiation), ClimaLand.Soil.Runoff.NoRunoff}(atmos, radiation, ClimaLand.Soil.Runoff.NoRunoff())
end

"""
Expand Down Expand Up @@ -72,14 +76,14 @@ function LandHydrologyModel{FT}(;
) where {FT, SnM <: Snow.SnowModel, SoM <: Soil.EnergyHydrology{FT}}
(; atmos, radiation) = land_args
if :runoff propertynames(land_args)
top_bc = ClimaLand.Soil.AtmosDrivenFluxBCwithSnow(
top_bc = ClimaLand.AtmosDrivenFluxBCwithSnow(
atmos,
radiation,
land_args.runoff,
)
else #no runoff model
top_bc =
ClimaLand.Soil.AtmosDrivenFluxBCwithSnow(atmos, radiation)
ClimaLand.AtmosDrivenFluxBCwithSnow(atmos, radiation)
end
sources = (Soil.PhaseChange{FT}(),)
zero_flux = Soil.HeatFluxBC((p, t) -> 0.0)
Expand Down

0 comments on commit e62c393

Please sign in to comment.