-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
73 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-12-05T09:10:52","documenter_version":"1.8.0"}} | ||
{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-12-05T09:51:45","documenter_version":"1.8.0"}} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Run a Bucket Model · HydroModels.jl</title><meta name="title" content="Run a Bucket Model · HydroModels.jl"/><meta property="og:title" content="Run a Bucket Model · HydroModels.jl"/><meta property="twitter:title" content="Run a Bucket Model · HydroModels.jl"/><meta name="description" content="Documentation for HydroModels.jl."/><meta property="og:description" content="Documentation for HydroModels.jl."/><meta property="twitter:description" content="Documentation for HydroModels.jl."/><meta property="og:url" content="https://chooron.github.io/HydroModels.jl/tutorials\\run_a_bucket.html"/><meta property="twitter:url" content="https://chooron.github.io/HydroModels.jl/tutorials\\run_a_bucket.html"/><link rel="canonical" href="https://chooron.github.io/HydroModels.jl/tutorials\\run_a_bucket.html"/><script data-outdated-warner src="../assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../search_index.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/catppuccin-mocha.css" data-theme-name="catppuccin-mocha"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/catppuccin-macchiato.css" data-theme-name="catppuccin-macchiato"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/catppuccin-frappe.css" data-theme-name="catppuccin-frappe"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/catppuccin-latte.css" data-theme-name="catppuccin-latte"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script><link href="../assets/icons.ico" rel="icon" type="image/x-icon"/></head><body><div id="documenter"><nav class="docs-sidebar"><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li><a class="tocitem" href="../index.html">Home</a></li><li><span class="tocitem">Tutorials</span><ul><li class="is-active"><a class="tocitem" href="run_a_bucket.html">Run a Bucket Model</a><ul class="internal"><li><a class="tocitem" href="#Overview"><span>Overview</span></a></li><li><a class="tocitem" href="#Dependencies"><span>Dependencies</span></a></li><li><a class="tocitem" href="#Model-Configuration"><span>Model Configuration</span></a></li><li><a class="tocitem" href="#Data-Input"><span>Data Input</span></a></li><li><a class="tocitem" href="#Implementation-Examples"><span>Implementation Examples</span></a></li><li><a class="tocitem" href="#Model-Structure"><span>Model Structure</span></a></li><li><a class="tocitem" href="#Usage-Notes"><span>Usage Notes</span></a></li><li><a class="tocitem" href="#Time-Series-Processing"><span>Time Series Processing</span></a></li></ul></li><li><a class="tocitem" href="run_a_exphydro_model.html">Run ExpHydro Model</a></li></ul></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Tutorials</a></li><li class="is-active"><a href="run_a_bucket.html">Run a Bucket Model</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href="run_a_bucket.html">Run a Bucket Model</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/chooron/HydroModels.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/chooron/HydroModels.jl/blob/main/doc/src/tutorials/run_a_bucket.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h1 id="HydroModels-Bucket-Model-Implementation-Example"><a class="docs-heading-anchor" href="#HydroModels-Bucket-Model-Implementation-Example">HydroModels Bucket Model Implementation Example</a><a id="HydroModels-Bucket-Model-Implementation-Example-1"></a><a class="docs-heading-anchor-permalink" href="#HydroModels-Bucket-Model-Implementation-Example" title="Permalink"></a></h1><h2 id="Overview"><a class="docs-heading-anchor" href="#Overview">Overview</a><a id="Overview-1"></a><a class="docs-heading-anchor-permalink" href="#Overview" title="Permalink"></a></h2><p>This document demonstrates the implementation and usage of a hydrological bucket model using the HydroModels framework. The code showcases both single-node and multi-node simulations using the ExpHydro model structure.</p><h2 id="Dependencies"><a class="docs-heading-anchor" href="#Dependencies">Dependencies</a><a id="Dependencies-1"></a><a class="docs-heading-anchor-permalink" href="#Dependencies" title="Permalink"></a></h2><pre><code class="language-julia hljs">using CSV | ||
using DataFrames | ||
using ComponentArrays | ||
using BenchmarkTools | ||
using HydroModels | ||
using ModelingToolkit</code></pre><h2 id="Model-Configuration"><a class="docs-heading-anchor" href="#Model-Configuration">Model Configuration</a><a id="Model-Configuration-1"></a><a class="docs-heading-anchor-permalink" href="#Model-Configuration" title="Permalink"></a></h2><h3 id="Parameter-Setup"><a class="docs-heading-anchor" href="#Parameter-Setup">Parameter Setup</a><a id="Parameter-Setup-1"></a><a class="docs-heading-anchor-permalink" href="#Parameter-Setup" title="Permalink"></a></h3><p>The model uses the following parameters for the hydrological simulation:</p><ul><li><code>f</code>: 0.01674478 (Infiltration parameter)</li><li><code>Smax</code>: 1709.461015 (Maximum soil water storage)</li><li><code>Qmax</code>: 18.46996175 (Maximum discharge)</li><li><code>Df</code>: 2.674548848 (Degree-day factor)</li><li><code>Tmax</code>: 0.175739196 (Maximum temperature threshold)</li><li><code>Tmin</code>: -2.092959084 (Minimum temperature threshold)</li></ul><h3 id="Initial-States"><a class="docs-heading-anchor" href="#Initial-States">Initial States</a><a id="Initial-States-1"></a><a class="docs-heading-anchor-permalink" href="#Initial-States" title="Permalink"></a></h3><p>Initial conditions for the model:</p><ul><li><code>snowpack</code>: 0.0</li><li><code>soilwater</code>: 1303.004248</li></ul><h2 id="Data-Input"><a class="docs-heading-anchor" href="#Data-Input">Data Input</a><a id="Data-Input-1"></a><a class="docs-heading-anchor-permalink" href="#Data-Input" title="Permalink"></a></h2><p>The model uses time series data from a CSV file located at "data/exphydro/01013500.csv" containing:</p><ul><li>Day length (dayl)</li><li>Mean temperature (tmean)</li><li>Precipitation (prcp)</li></ul><h2 id="Implementation-Examples"><a class="docs-heading-anchor" href="#Implementation-Examples">Implementation Examples</a><a id="Implementation-Examples-1"></a><a class="docs-heading-anchor-permalink" href="#Implementation-Examples" title="Permalink"></a></h2><h3 id="1.-Single-Node-Simulation"><a class="docs-heading-anchor" href="#1.-Single-Node-Simulation">1. Single Node Simulation</a><a id="1.-Single-Node-Simulation-1"></a><a class="docs-heading-anchor-permalink" href="#1.-Single-Node-Simulation" title="Permalink"></a></h3><pre><code class="language-julia hljs"># Setup input data | ||
input = (lday=df[ts, "dayl(day)"], temp=df[ts, "tmean(C)"], prcp=df[ts, "prcp(mm/day)"]) | ||
solver = HydroModels.ManualSolver{true}() | ||
config = (solver=solver,) | ||
|
||
# Convert input to required format | ||
input_arr = Matrix(reduce(hcat, collect(input[ele.meta.inputs]))') | ||
|
||
# Run simulation | ||
results = ele(input_arr, pas, config=config, convert_to_ntp=true)</code></pre><h3 id="2.-Multi-Node-Simulation"><a class="docs-heading-anchor" href="#2.-Multi-Node-Simulation">2. Multi-Node Simulation</a><a id="2.-Multi-Node-Simulation-1"></a><a class="docs-heading-anchor-permalink" href="#2.-Multi-Node-Simulation" title="Permalink"></a></h3><pre><code class="language-julia hljs"># Setup for multiple nodes | ||
node_num = 10 | ||
node_names = [Symbol(:node, i) for i in 1:node_num] | ||
|
||
# Create parameter and state vectors for all nodes | ||
node_params = ComponentVector(NamedTuple{Tuple(node_names)}(repeat([params], length(node_names)))) | ||
node_initstates = ComponentVector(NamedTuple{Tuple(node_names)}(repeat([init_states], length(node_names)))) | ||
node_pas = ComponentVector(params=node_params, initstates=node_initstates) | ||
|
||
# Prepare input data for multiple nodes | ||
input_arr = reduce(hcat, collect(input[HydroModels.get_input_names(ele)])) | ||
node_input = reduce((m1, m2) -> cat(m1, m2, dims=3), repeat([input_arr], length(node_names))) | ||
node_input = permutedims(node_input, (2, 3, 1)) | ||
|
||
# Run simulation with multiple nodes | ||
run_kwgs = (ptypes=node_names, timeidx=ts) | ||
result = ele(node_input, node_pas, kwargs=run_kwgs)</code></pre><h2 id="Model-Structure"><a class="docs-heading-anchor" href="#Model-Structure">Model Structure</a><a id="Model-Structure-1"></a><a class="docs-heading-anchor-permalink" href="#Model-Structure" title="Permalink"></a></h2><p>The model uses a bucket structure defined in exphydro.jl with two main components:</p><ol><li><p>Surface water component (bucket_1):</p><ul><li>Handles precipitation partitioning (rainfall/snowfall)</li><li>Computes potential evapotranspiration</li><li>Manages snowmelt processes</li></ul></li><li><p>Soil water component:</p><ul><li>Manages soil water storage</li><li>Computes actual evaporation</li><li>Generates baseflow and surface flow</li></ul></li></ol><h2 id="Usage-Notes"><a class="docs-heading-anchor" href="#Usage-Notes">Usage Notes</a><a id="Usage-Notes-1"></a><a class="docs-heading-anchor-permalink" href="#Usage-Notes" title="Permalink"></a></h2><ol><li>The code demonstrates flexibility in handling both single-node and multi-node simulations</li><li>Input data should be properly formatted with required columns (dayl, tmean, prcp)</li><li>Parameters and initial states can be adjusted based on specific catchment characteristics</li><li>The model uses a manual solver for time-stepping</li></ol><h2 id="Time-Series-Processing"><a class="docs-heading-anchor" href="#Time-Series-Processing">Time Series Processing</a><a id="Time-Series-Processing-1"></a><a class="docs-heading-anchor-permalink" href="#Time-Series-Processing" title="Permalink"></a></h2><p>The example processes 10,000 time steps (ts = collect(1:10000)) and can be adjusted based on data availability and simulation requirements.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../index.html">« Home</a><a class="docs-footer-nextpage" href="run_a_exphydro_model.html">Run ExpHydro Model »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.8.0 on <span class="colophon-date" title="Thursday 5 December 2024 09:51">Thursday 5 December 2024</span>. Using Julia version 1.10.4.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
Oops, something went wrong.