Commit fd43a43c authored by Dorchies David's avatar Dorchies David
Browse files

Merge branch '12-importation-of-stage-discharge-law-at-downstream-boundary-condition' into 'main'

Resolve "Importation of stage-discharge law at downstream boundary condition"

Closes #12

See merge request !9
1 merge request!9Resolve "Importation of stage-discharge law at downstream boundary condition"
Pipeline #34171 passed with stage
in 2 minutes and 16 seconds
Showing with 66 additions and 0 deletions
+66 -0
......@@ -21,6 +21,7 @@ export(get_section_centers)
export(loadConfig)
export(merge_reaches)
export(read_bin_result_matrix)
export(set_boundary_ZQ)
export(set_initial_conditions)
export(sic_import_reaches)
export(sic_run_export)
......
#' Set stage-discharge curve at an offtake of the model
#'
#' @description
#' Update the existing stage-discharge boundary condition.
#'
#' @inheritParams sic_run_mesh
#' @param nd [numeric], node number in SIC model
#' @param pr [numeric], offtake number in the node
#' @param mZQ [matrix], stage-discharge relation with first column the water elevation in meters
#' and the second column the discharge in cubic meters per seconds
#'
#' @return This function is only used for side effect on the XML file of the SIC project.
#' @export
#'
#' @examples
#' \dontrun{
#' cfg <- cfg_tmp_project()
#' z <- seq(5, 20, 1)
#' Q <- (z-5)^1.5
#' set_boundary_ZQ(cfg, scenario = 1, nd = 3, mZQ = matrix(c(z, Q), ncol = 2))
#' }
set_boundary_ZQ <- function(cfg, scenario, nd, pr = 1, mZQ) {
x <- read_xml(cfg$project$path)
xPath <- "/Reseau/Liste_Noeuds/Noeud[@Num=%d]/Flu[@nScenario=%d]/Prise[@Num=%d]/ConditionLim/TLoi"
xPath <- sprintf(xPath, nd, scenario, pr)
sZQ <- capture.output(write.table(t(mZQ), sep = "\t", quote = FALSE, col.names = FALSE, row.names = FALSE))
sZQ <- paste(sZQ, collapse = "\n")
xLoi <- x %>% xml_find_first(xPath)
xml_text(xLoi) <- sZQ
write_xml(x, cfg$project$path)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/set_boundary_ZQ.R
\name{set_boundary_ZQ}
\alias{set_boundary_ZQ}
\title{Set stage-discharge curve at an offtake of the model}
\usage{
set_boundary_ZQ(cfg, scenario, nd, pr = 1, mZQ)
}
\arguments{
\item{cfg}{a \link{config} object. Configuration to use. See \link{loadConfig} for details}
\item{scenario}{\link{numeric}, the scenario to use}
\item{nd}{\link{numeric}, node number in SIC model}
\item{pr}{\link{numeric}, offtake number in the node}
\item{mZQ}{\link{matrix}, stage-discharge relation with first column the water elevation in meters
and the second column the discharge in cubic meters per seconds}
}
\value{
This function is only used for side effect on the XML file of the SIC project.
}
\description{
Update the existing stage-discharge boundary condition.
}
\examples{
\dontrun{
cfg <- cfg_tmp_project()
z <- seq(5, 20, 1)
Q <- (z-5)^1.5
set_boundary_ZQ(cfg, scenario = 1, nd = 3, mZQ = matrix(c(z, Q), ncol = 2))
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment