From c00fb8270f983277c2b2068aa90ce2739654e8b1 Mon Sep 17 00:00:00 2001 From: odunbar Date: Fri, 1 Nov 2024 14:00:05 -0700 Subject: [PATCH] stubs for structs/types/methods --- src/ClimaRivers.jl | 12 +++++++++++- src/Environments.jl | 16 ++++++++++++++++ src/MizurouteV1.jl | 28 ++++++++++++++++++++++++++++ src/RiverModels.jl | 19 +++++++++++++++++++ src/Routing.jl | 16 ++++++++++++++++ src/States.jl | 10 ++++++++++ 6 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 src/Environments.jl create mode 100644 src/MizurouteV1.jl create mode 100644 src/RiverModels.jl create mode 100644 src/Routing.jl create mode 100644 src/States.jl diff --git a/src/ClimaRivers.jl b/src/ClimaRivers.jl index f03b0a7..18af13c 100644 --- a/src/ClimaRivers.jl +++ b/src/ClimaRivers.jl @@ -1,5 +1,15 @@ module ClimaRivers -greet() = print("Hello World!") +#using deps: +using LinearAlgebra, + Distributions, + Statistics, + Random, + DocStringExtensions +# includes +include("Environments.jl") +include("States.jl") +include("RiverModels.jl") +include("Routing.jl") end # module ClimaRivers diff --git a/src/Environments.jl b/src/Environments.jl new file mode 100644 index 0000000..0071777 --- /dev/null +++ b/src/Environments.jl @@ -0,0 +1,16 @@ +# Contains the structs that define the static and dynamic environment that configures/forces the river model. + +struct StaticEnvironment + # static data objects +end +struct DynamicEnvironment + # timeseries objects + # date/time - index map +end +struct Environment{SE <: StaticEnvironment, DE <: DynamicEnvironment} + static_env::SE + dyn_env::DE + graph::Dict # river graph? +end +# get_static(env, :name) +# get_dynamic(env, :name, time=date/time) diff --git a/src/MizurouteV1.jl b/src/MizurouteV1.jl new file mode 100644 index 0000000..45d0e23 --- /dev/null +++ b/src/MizurouteV1.jl @@ -0,0 +1,28 @@ +# Contains the Mizuroute model +struct MizurouteHillslopeV1{FT <: AbstractFloat} <: AbstractHillslopeModel + "Shape factor, a (adjusted)" + shape::FT + "Timescale factor, θ [day]" + timescale::FT +end + +function MizurouteHillslope{FT}() where {FT <: AbstractFloat} + shape = FT(1.5) + timescale = FT(1.0) + return MizurouteHillslope(shape,timescale) +end + + +struct MizurouteChannelV1{FT <: AbstractFloat} <: AbstractChannelModel + "Wave velocity, C [m/day]" + wave_velocity::FT + "Diffusivity, D [m²/day] (adjusted)" + diffusivity::FT +end + +function MizurouteChannel{FT}() where {FT <: AbstractFloat} + wave_velocity = FT(1.5 * 86400) + diffusivity = FT(8000 * 86400 ) + return MizurouteHillslope(wave_velocity, diffusivity) +end + diff --git a/src/RiverModels.jl b/src/RiverModels.jl new file mode 100644 index 0000000..ac864f7 --- /dev/null +++ b/src/RiverModels.jl @@ -0,0 +1,19 @@ +# Contains the abstract river model types, structs and methods + + +#general model level +abstract type AbstractRiverModel end + +# hillslope-channel model +abstract type AbstractHillslopeModel end +abstract type AbstractChannelModel end + +struct HillslopeChannelRiverModel{HS <: AbstractHillslopeModel, CH <: AbstractChannelModel} <: RiverModel + hillslope_model::HS + channel_model::CH +end + +# Specific hillslope-channel models loaded here: +include("MizurouteV1.jl") + + diff --git a/src/Routing.jl b/src/Routing.jl new file mode 100644 index 0000000..af5c042 --- /dev/null +++ b/src/Routing.jl @@ -0,0 +1,16 @@ +# general methods for routing rivers + +# methods +function calculate_streamflow!( + river_state::RS, + river_model::RM, + environment::E, + ) where { + RS <:RiverState, + RM <: AbstractRiverModel, + E <: Environment, + } + # ...most general stub +end + + diff --git a/src/States.jl b/src/States.jl new file mode 100644 index 0000000..c7fede2 --- /dev/null +++ b/src/States.jl @@ -0,0 +1,10 @@ +# Contains the structs that are evolved by the river model, and methods to instantiate them + +struct RiverState{AM <: AbstractMatrix} + hillslope::AM # instantaneous + channel::AM # instantaneous + graph::Dict # river graph copy? +end + +# initialize method +# initialize_state(river_model::HCRM) where {HCRM <: HillslopChannelRiverModel} end