From e62c393e66571f3fe5d73f12741631c4e0bd0d52 Mon Sep 17 00:00:00 2001 From: kmdeck Date: Mon, 1 Jul 2024 15:18:08 -0700 Subject: [PATCH] wip --- .../soil_snow/met_drivers_fluxnet.jl | 22 +++++++++++++------ .../soil_snow/parameters_fluxnet.jl | 9 ++++++++ .../integrated/soil_snow/simulation.jl | 2 +- src/integrated/soil_snow_model.jl | 10 ++++++--- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/experiments/integrated/soil_snow/met_drivers_fluxnet.jl b/experiments/integrated/soil_snow/met_drivers_fluxnet.jl index 997663d187..4774c7ea76 100644 --- a/experiments/integrated/soil_snow/met_drivers_fluxnet.jl +++ b/experiments/integrated/soil_snow/met_drivers_fluxnet.jl @@ -109,12 +109,23 @@ 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) @@ -122,8 +133,7 @@ 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 @@ -139,9 +149,7 @@ atmos = ClimaLand.PrescribedAtmosphere( earth_param_set; c_co2 = atmos_co2, ) -#NEEDED -lat = ; -lon = ; + function zenith_angle( t, ref_time; diff --git a/experiments/integrated/soil_snow/parameters_fluxnet.jl b/experiments/integrated/soil_snow/parameters_fluxnet.jl index 7164b9172c..3abae047a6 100644 --- a/experiments/integrated/soil_snow/parameters_fluxnet.jl +++ b/experiments/integrated/soil_snow/parameters_fluxnet.jl @@ -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, diff --git a/experiments/integrated/soil_snow/simulation.jl b/experiments/integrated/soil_snow/simulation.jl index f8ab8f6883..56a592809d 100644 --- a/experiments/integrated/soil_snow/simulation.jl +++ b/experiments/integrated/soil_snow/simulation.jl @@ -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, diff --git a/src/integrated/soil_snow_model.jl b/src/integrated/soil_snow_model.jl index 3278f10e87..90320845ed 100644 --- a/src/integrated/soil_snow_model.jl +++ b/src/integrated/soil_snow_model.jl @@ -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 """ @@ -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)