topic:start
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
topic:start [2022/08/04 12:07] – angelegt ckuells | topic:start [2024/04/10 10:02] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
====== Themen ====== | ====== Themen ====== | ||
+ | |||
+ | Programm zur Anwendung von TUW | ||
+ | |||
+ | <code S> | ||
+ | ## Load the data | ||
+ | data(example_TUWmodel) | ||
+ | |||
+ | ## Simulate runoff and plot observed vs simulated series | ||
+ | ## Lumped case (weighted means of the inputs) | ||
+ | simLump <- TUWmodel(prec=apply(P_Vils, | ||
+ | airt=apply(T_Vils, | ||
+ | ep=apply(PET_Vils, | ||
+ | area=sum(areas_Vils), | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | plot(as.Date(names(Q_Vils)), | ||
+ | | ||
+ | legend(" | ||
+ | |||
+ | plot(as.Date(rownames(SWE_Vils)), | ||
+ | | ||
+ | | ||
+ | |||
+ | ## Distribute input case (6 zones) | ||
+ | simDist <- TUWmodel(prec=P_Vils, | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | plot(as.Date(names(Q_Vils)), | ||
+ | | ||
+ | legend(" | ||
+ | |||
+ | plot(as.Date(rownames(SWE_Vils)), | ||
+ | | ||
+ | | ||
+ | |||
+ | ## Distributed input and parameters case | ||
+ | parametri <- matrix(rep(c(1.02, | ||
+ | 0.934, | ||
+ | 0.473, | ||
+ | 50.1, | ||
+ | parametri[2, | ||
+ | simDist2 <- TUWmodel(prec=P_Vils, | ||
+ | airt=T_Vils, | ||
+ | ep=PET_Vils, | ||
+ | area=areas_Vils/ | ||
+ | | ||
+ | |||
+ | plot(as.Date(names(Q_Vils)), | ||
+ | | ||
+ | legend(" | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Programm für numerische Berechnung eines Einzellinearspeichers, | ||
+ | |||
+ | <code S> | ||
+ | ```{r ELSnum} | ||
+ | |||
+ | Nt <- replicate(30, | ||
+ | Nt[7] <- 25 | ||
+ | Nt[18]<- 43 | ||
+ | |||
+ | # Parameter des ELSnum | ||
+ | k <- 0.35 | ||
+ | a <- 1/k # Einheiten, dies es braucht, bis der Speicher um eine log Einheit fällt | ||
+ | S0<- 0 | ||
+ | |||
+ | ELSnum <- function(a=10, | ||
+ | LN <- length(Nt) | ||
+ | St <- numeric(LN) | ||
+ | Qt <- numeric(LN) | ||
+ | | ||
+ | i=1 | ||
+ | while(i< | ||
+ | if(i==1){ | ||
+ | St[1] <- S0+Nt[1] | ||
+ | Qt[1] <- 0 | ||
+ | }else{ | ||
+ | Qt[i] <- St[i-1]*1/a | ||
+ | St[i] <- St[i-1]-Qt[i]+Nt[i] | ||
+ | } | ||
+ | i <- i+1 | ||
+ | } | ||
+ | Resultat <- data.frame(Nt, | ||
+ | return(Resultat) | ||
+ | } | ||
+ | ELSnum(5, | ||
+ | ``` | ||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
+ | |||
+ | ```{r ELS, echo=FALSE, fig.cap=" | ||
+ | ELS <- function(N=50, | ||
+ | errorflag <- FALSE | ||
+ | |||
+ | # Prüfe auf Fehler | ||
+ | if (N<0.0){ | ||
+ | error <- "N ist < 0.0" | ||
+ | errorflag <- TRUE | ||
+ | } | ||
+ | if(C < 0.0 | C > 1.0){ | ||
+ | error <- "C nicht zwischen 0.0 und 1.0" | ||
+ | errorflag <- TRUE | ||
+ | } | ||
+ | if(K <= 0.0){ | ||
+ | error <- "K nicht >= 0" | ||
+ | errorflag <- TRUE | ||
+ | } | ||
+ | if (ta< | ||
+ | error <- "ta ist < 0.0" | ||
+ | errorflag <- TRUE | ||
+ | } | ||
+ | if (ta> | ||
+ | error <- "ta ist > te" | ||
+ | errorflag <- TRUE | ||
+ | } | ||
+ | if (ta> | ||
+ | error <- "ta ist > tm" | ||
+ | errorflag <- TRUE | ||
+ | } | ||
+ | if (dt< | ||
+ | error <- "dt ist <= 0.0" | ||
+ | errorflag <- TRUE | ||
+ | } | ||
+ | if (dt>te){ | ||
+ | error <- "dt ist > te" | ||
+ | errorflag <- TRUE | ||
+ | } | ||
+ | |||
+ | # Erzeuge die Zeitreihe | ||
+ | tv <- seq(ta, | ||
+ | # Berechne die Länge in Tagen | ||
+ | Lt <- length(tv) | ||
+ | # Initialisiere die Abflussserie mit 0, Einheit mm | ||
+ | Qt <- replicate(Lt, | ||
+ | # Erzeuge Variable für letzten Wert der Schleife | ||
+ | QL <- 0.0 # last discharge | ||
+ | |||
+ | # i ist die Integer Laufvariable, | ||
+ | i <- 1 | ||
+ | t <- ta | ||
+ | while (i<=Lt) { | ||
+ | if(t< | ||
+ | # Anstieg (t < te) | ||
+ | Qt[i] <- (N*C)*(1-exp(-t/ | ||
+ | QL <- Qt[i] | ||
+ | } else { | ||
+ | # Rückgang | ||
+ | Qt[i] <- QL*exp(-(t-te)/ | ||
+ | } | ||
+ | # Gehe einen Zeitschritt dt weiter für t und setze Index i um +1 hoch | ||
+ | t <- t + dt | ||
+ | i <- i + 1 | ||
+ | } | ||
+ | |||
+ | # plot | ||
+ | if (errorflag){ | ||
+ | print(error) | ||
+ | } else{ | ||
+ | plot(tv,Qt, col=2, xlab=" | ||
+ | } | ||
+ | } | ||
+ | # Ausführen der Funktion ELS mit Standardparametern | ||
+ | ELS() | ||
+ | ``` | ||
+ | |||
+ | </ | ||
+ | |||
/usr/www/users/uhydro/doku/data/attic/topic/start.1659607667.txt.gz · Zuletzt geändert: 2024/04/10 10:12 (Externe Bearbeitung)