Skip to content

Commit

Permalink
Rename vertical to land
Browse files Browse the repository at this point in the history
'land` refers to `AbstractLandModel`.
  • Loading branch information
vers-w committed Dec 19, 2024
1 parent c8805f1 commit 9d0c217
Show file tree
Hide file tree
Showing 40 changed files with 518 additions and 526 deletions.
48 changes: 22 additions & 26 deletions server/test/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ end
@test request((fn = "get_input_item_count",)) == Dict("input_item_count" => 202)
@test request((fn = "get_output_item_count",)) == Dict("output_item_count" => 202)
to_check = [
"vertical.soil.parameters.nlayers",
"vertical.soil.parameters.theta_r",
"land.soil.parameters.nlayers",
"land.soil.parameters.theta_r",
"lateral.river.variables.q",
"lateral.river.boundary_conditions.reservoir.variables.outflow",
]
Expand All @@ -51,28 +51,28 @@ vwc_1_size = 0
@testset "variable information and get and set functions" begin
@test request((fn = "get_var_itemsize", name = "lateral.subsurface.variables.ssf")) ==
Dict("var_itemsize" => sizeof(Wflow.Float))
@test request((fn = "get_var_type", name = "vertical.n"))["status"] == "ERROR"
@test request((fn = "get_var_units", name = "vertical.soil.parameters.theta_s")) ==
@test request((fn = "get_var_type", name = "land.n"))["status"] == "ERROR"
@test request((fn = "get_var_units", name = "land.soil.parameters.theta_s")) ==
Dict("var_units" => "-")
@test request((fn = "get_var_location", name = "lateral.river.variables.q")) ==
Dict("var_location" => "node")
zi_nbytes =
request((fn = "get_var_nbytes", name = "vertical.soil.variables.zi"))["var_nbytes"]
request((fn = "get_var_nbytes", name = "land.soil.variables.zi"))["var_nbytes"]
@test zi_nbytes == 400504
zi_itemsize =
request((fn = "get_var_itemsize", name = "vertical.soil.variables.zi"))["var_itemsize"]
request((fn = "get_var_itemsize", name = "land.soil.variables.zi"))["var_itemsize"]
zi_size = Int(zi_nbytes / zi_itemsize)
vwc_1_nbytes =
request((fn = "get_var_nbytes", name = "vertical.soil.variables.vwc[1]"))["var_nbytes"]
request((fn = "get_var_nbytes", name = "land.soil.variables.vwc[1]"))["var_nbytes"]
@test vwc_1_nbytes == 400504
vwc_1_itemsize =
request((fn = "get_var_itemsize", name = "vertical.soil.variables.vwc[1]"))["var_itemsize"]
request((fn = "get_var_itemsize", name = "land.soil.variables.vwc[1]"))["var_itemsize"]
vwc_1_size = Int(vwc_1_nbytes / vwc_1_itemsize)
@test request((fn = "get_var_grid", name = "lateral.river.variables.h")) ==
Dict("var_grid" => 3)
msg = (fn = "get_value", name = "vertical.soil.variables.zi", dest = fill(0.0, zi_size))
msg = (fn = "get_value", name = "land.soil.variables.zi", dest = fill(0.0, zi_size))
@test mean(request(msg)["value"]) 277.3620724821974
msg = (fn = "get_value_ptr", name = "vertical.soil.parameters.theta_s")
msg = (fn = "get_value_ptr", name = "land.soil.parameters.theta_s")
@test mean(request(msg)["value_ptr"]) 0.4409211971535584
msg = (
fn = "get_value_at_indices",
Expand All @@ -82,68 +82,64 @@ vwc_1_size = 0
)
@test request(msg)["value_at_indices"]
[2.1007361866518766, 2.5702292750107687, 3.2904803551115727]
msg =
(fn = "set_value", name = "vertical.soil.variables.zi", src = fill(300.0, zi_size))
msg = (fn = "set_value", name = "land.soil.variables.zi", src = fill(300.0, zi_size))
@test request(msg) == Dict("status" => "OK")
msg = (fn = "get_value", name = "vertical.soil.variables.zi", dest = fill(0.0, zi_size))
msg = (fn = "get_value", name = "land.soil.variables.zi", dest = fill(0.0, zi_size))
@test mean(request(msg)["value"]) == 300.0
msg = (
fn = "set_value_at_indices",
name = "vertical.soil.variables.zi",
name = "land.soil.variables.zi",
src = [250.0, 350.0],
inds = [1, 2],
)
@test request(msg) == Dict("status" => "OK")
msg = (
fn = "get_value_at_indices",
name = "vertical.soil.variables.zi",
name = "land.soil.variables.zi",
dest = [0.0, 0.0, 0.0],
inds = [1, 2, 3],
)
@test request(msg)["value_at_indices"] == [250.0, 350.0, 300.0]
msg = (
fn = "get_value",
name = "vertical.soil.variables.vwc[1]",
name = "land.soil.variables.vwc[1]",
dest = fill(0.0, vwc_1_size),
)
@test mean(request(msg)["value"]) 0.18600013563085036f0
msg = (
fn = "get_value_at_indices",
name = "vertical.soil.variables.vwc[1]",
name = "land.soil.variables.vwc[1]",
dest = [0.0, 0.0, 0.0],
inds = [1, 2, 3],
)
@test request(msg)["value_at_indices"]
[0.12089607119560242f0, 0.11968416924304527f0, 0.14602328618707333f0]
msg = (
fn = "set_value",
name = "vertical.soil.variables.vwc[1]",
src = fill(0.3, vwc_1_size),
)
msg =
(fn = "set_value", name = "land.soil.variables.vwc[1]", src = fill(0.3, vwc_1_size))
@test request(msg) == Dict("status" => "OK")
msg = (
fn = "get_value",
name = "vertical.soil.variables.vwc[1]",
name = "land.soil.variables.vwc[1]",
dest = fill(0.0, vwc_1_size),
)
@test mean(request(msg)["value"]) 0.3f0
msg = (
fn = "get_value_at_indices",
name = "vertical.soil.variables.vwc[1]",
name = "land.soil.variables.vwc[1]",
dest = [0.0, 0.0, 0.0],
inds = [1, 2, 3],
)
@test request(msg)["value_at_indices"] == [0.3, 0.3, 0.3]
msg = (
fn = "set_value_at_indices",
name = "vertical.soil.variables.vwc[1]",
name = "land.soil.variables.vwc[1]",
src = [0.1, 0.25],
inds = [1, 2],
)
@test request(msg) == Dict("status" => "OK")
msg = (
fn = "get_value_at_indices",
name = "vertical.soil.variables.vwc[1]",
name = "land.soil.variables.vwc[1]",
dest = [0.0, 0.0],
inds = [1, 2],
)
Expand Down
72 changes: 36 additions & 36 deletions server/test/sbm_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ path_output = "outstates-moselle.nc"
# if listed, the variable must be present in the NetCDF or error
# if not listed, the variable can get a default value if it has one

[state.vertical.interception.variables]
[state.land.interception.variables]
canopy_storage = "canopystorage"

[state.vertical.soil.variables]
[state.land.soil.variables]
satwaterdepth = "satwaterdepth"
tsoil = "tsoil"
ustorelayerdepth = "ustorelayerdepth"

[state.vertical.snow.variables]
[state.land.snow.variables]
snow_storage = "snow"
snow_water = "snowwater"

Expand Down Expand Up @@ -60,32 +60,32 @@ subcatchment = "wflow_subcatch"
# specify the internal IDs of the parameters which vary over time
# the external name mapping needs to be below together with the other mappings
forcing = [
"vertical.atmospheric_forcing.precipitation",
"vertical.atmospheric_forcing.temperature",
"vertical.atmospheric_forcing.potential_evaporation",
"land.atmospheric_forcing.precipitation",
"land.atmospheric_forcing.temperature",
"land.atmospheric_forcing.potential_evaporation",
]

cyclic = ["vertical.vegetation_parameter_set.leaf_area_index"]
cyclic = ["land.vegetation_parameter_set.leaf_area_index"]

[input.vertical.vegetation_parameter_set]
[input.land.vegetation_parameter_set]
leaf_area_index = "LAI"
kext = "Kext"
storage_specific_leaf = "Sl"
storage_wood = "Swood"
rootingdepth = "RootingDepth"

[input.vertical.runoff.parameters]
[input.land.runoff.parameters]
waterfrac = "WaterFrac"

[input.vertical.interception.parameters]
[input.land.interception.parameters]
e_r = "EoverR"

[input.vertical.atmospheric_forcing]
[input.land.atmospheric_forcing]
potential_evaporation = "pet"
precipitation = "precip"
temperature = "temp"

[input.vertical.soil.parameters]
[input.land.soil.parameters]
c = "c"
cf_soil = "cf_soil"
f = "f"
Expand All @@ -99,13 +99,13 @@ pathfrac = "PathFrac"
rootdistpar = "rootdistpar"
soilthickness = "SoilThickness"

[input.vertical.snow.parameters]
[input.land.snow.parameters]
tt = "TT"
tti = "TTI"
ttm = "TTM"
cfmax = "Cfmax"

[input.vertical.soil.parameters.kv_0]
[input.land.soil.parameters.kv_0]
netcdf.variable.name = "KsatVer"
scale = 1.0
offset = 0.0
Expand Down Expand Up @@ -149,15 +149,15 @@ min_streamorder_land = 5
[output]
path = "output_moselle.nc"

[output.vertical.interception.variables]
[output.land.interception.variables]
canopy_storage = "canopystorage"

[output.vertical.soil.variables]
[output.land.soil.variables]
satwaterdepth = "satwaterdepth"
tsoil = "tsoil"
ustorelayerdepth = "ustorelayerdepth"

[output.vertical.snow.variables]
[output.land.snow.variables]
snow_storage = "snow"
snow_water = "snowwater"

Expand Down Expand Up @@ -188,14 +188,14 @@ coordinate.x = 6.255
coordinate.y = 50.012
name = "temp_coord"
location = "temp_bycoord"
parameter = "vertical.atmospheric_forcing.temperature"
parameter = "land.atmospheric_forcing.temperature"

[[netcdf.variable]]
location = "temp_byindex"
name = "temp_index"
index.x = 100
index.y = 264
parameter = "vertical.atmospheric_forcing.temperature"
parameter = "land.atmospheric_forcing.temperature"

[csv]
path = "output_moselle.csv"
Expand All @@ -214,20 +214,20 @@ parameter = "lateral.river.boundary_conditions.reservoir.variables.volume"
coordinate.x = 6.255
coordinate.y = 50.012
header = "temp_bycoord"
parameter = "vertical.atmospheric_forcing.temperature"
parameter = "land.atmospheric_forcing.temperature"

[[csv.column]]
coordinate.x = 6.255
coordinate.y = 50.012
header = "vwc_layer2_bycoord"
parameter = "vertical.soil.variables.vwc"
parameter = "land.soil.variables.vwc"
layer = 2

[[csv.column]]
header = "temp_byindex"
index.x = 100
index.y = 264
parameter = "vertical.atmospheric_forcing.temperature"
parameter = "land.atmospheric_forcing.temperature"

[[csv.column]]
header = "Q"
Expand All @@ -237,24 +237,24 @@ parameter = "lateral.river.variables.q"
[[csv.column]]
header = "recharge"
map = "subcatchment"
parameter = "vertical.soil.variables.recharge"
parameter = "land.soil.variables.recharge"
reducer = "mean"

[API]
components = [
"vertical.atmospheric_forcing",
"vertical.vegetation_parameter_set",
"vertical.runoff.boundary_conditions",
"vertical.runoff.variables",
"vertical.runoff.parameters",
"vertical.soil.boundary_conditions",
"vertical.soil.variables",
"vertical.soil.parameters",
"vertical.interception.variables",
"vertical.interception.parameters",
"vertical.snow.boundary_conditions",
"vertical.snow.variables",
"vertical.snow.parameters",
"land.atmospheric_forcing",
"land.vegetation_parameter_set",
"land.runoff.boundary_conditions",
"land.runoff.variables",
"land.runoff.parameters",
"land.soil.boundary_conditions",
"land.soil.variables",
"land.soil.parameters",
"land.interception.variables",
"land.interception.parameters",
"land.snow.boundary_conditions",
"land.snow.variables",
"land.snow.parameters",
"lateral.subsurface.boundary_conditions",
"lateral.subsurface.variables",
"lateral.subsurface.parameters",
Expand Down
12 changes: 6 additions & 6 deletions src/Wflow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ include("io.jl")
include("network.jl")

abstract type AbstractModel{T} end
abstract type AbstractLandSurface end
abstract type AbstractLandModel end

# different model types (used for dispatch)
abstract type AbstractModelType end
Expand All @@ -127,23 +127,23 @@ struct SbmGwfModel <: AbstractModelType end # "sbm_gwf" type / sbm_gwf_mode
struct SedimentModel <: AbstractModelType end # "sediment" type / sediment_model.jl

"""
Model{L, V, R, W, T}
Model{L, LM, NR, W, T}
Composite type that represents all different aspects of a Wflow Model, such as the
network, parameters, clock, configuration and input and output.
"""
struct Model{
L <: Lateral,
V <: AbstractLandSurface,
R <: NCReader,
LM <: AbstractLandModel,
NR <: NCReader,
T <: AbstractModelType,
} <: AbstractModel{T}
config::Config # all configuration options
network::Network # connectivity information, directed graph
lateral::L # lateral model that holds lateral state, moves along network
vertical::V # vertical model that holds vertical state, independent of each other
land::LM # land model simulating vertical fluxes, independent of each other
clock::Clock # to keep track of simulation time
reader::R # provides the model with dynamic input
reader::NR # provides the model with dynamic input
writer::Writer # writes model output
type::T # model type
end
Expand Down
Loading

0 comments on commit 9d0c217

Please sign in to comment.