Skip to content
Snippets Groups Projects
Commit 74799e61 authored by wactbprot's avatar wactbprot
Browse files

start with ssmp scripts

parent 9392f737
No related branches found
No related tags found
No related merge requests found
## -- ## --
## wactbprot/2014-03-25 ## wactbprot/2014-03-25
## -- ## --
#library(xlsx, quietly =TRUE)
library(knitr, quietly =TRUE) library(knitr, quietly =TRUE)
library(methods, quietly =TRUE) library(methods, quietly =TRUE)
library(bitops, quietly =TRUE) library(bitops, quietly =TRUE)
......
#'
#' Function mediates
#'
#' @author wactbprot (thsteinbock@web.de)
#' @export
#' @keywords yamp
#'
setwd("/usr/local/lib/r4vl")
source("load.R")
args <- commandArgs(TRUE)
pressure.target <- as.numeric(args[1])
gas <- "N2" # as.numeric(args[2])
maxIter <- 10
cdb <- cdbIni()
cdb$DBName <- "vl_db"
cdb$id <- "std-ce3"
ce3doc <- cdbGetDoc(cdb)$res
cdb$id <- "constants"
constdoc <- cdbGetDoc(cdb)$res
molLw <- getConstVal(ce3doc,"dv2MolCIntercept")
cf <- list()
if(pressure.target < 2e-4){
lw <- "lw1"
}
if(pressure.target < 9e-7){
lw <- "lw0"
}
if(pressure.target < 1e-10){
lw <- "lwc"
}
NOMC1 <- getSubList(ce3doc,"nomC1")
conv <- getConstVal(constdoc, paste0(NOMC1$Unit, "_2_l/s"))
Cp <- getConstVal(NA, NA, NOMC1) * conv # f. l/s
if(lw == "lw0" ){
## Parameter
## kleiner Leitwert
##
cf$a <- getConstVal(ce3doc, paste("klLw_",gas,"_A", sep=""))
cf$b <- getConstVal(ce3doc, paste("klLw_",gas,"_B", sep=""))
cf$c <- getConstVal(ce3doc, paste("klLw_",gas,"_C", sep=""))
cf$d <- getConstVal(ce3doc, paste("klLw_",gas,"_D", sep=""))
pressure.fill <- 0.0001 ## start pfill
}
if(lw == "lw1" ){
## Parameter
## großer Leitwert
##
cf$a <- getConstVal(ce3doc, paste("grLw_",gas,"_A", sep=""))
cf$b <- getConstVal(ce3doc, paste("grLw_",gas,"_B", sep=""))
cf$c <- getConstVal(ce3doc, paste("grLw_",gas,"_C", sep=""))
cf$d <- getConstVal(ce3doc, paste("grLw_",gas,"_D", sep=""))
pressure.fill <- 8.1 ## start pfill
}
if(lw == "lwc"){
pressure.fill <- Cp / molLw * pressure.target
cat(toJSON(list(value=pressure.fill)))
}
if(lw == "lw0" | lw == "lw1"){
##
## Berechnen des pfill aus der Leitwertkurve
## und der Differenz zum Zieldruck
##
pressure.target.pred <- fn.2162(cf, pressure.fill)/Cp * pressure.fill
e <- pressure.target.pred/pressure.target - 1
iter <- 1
while((abs(e) > 1e-4) | iter == maxIter ){
e <- pressure.target.pred/pressure.target - 1
pressure.fill <- pressure.fill * (1 - e)
if(pressure.target < 9e-10){
pressure.target.pred <- molLw/Cp * pressure.fill
}else{
pressure.target.pred <- fn.2162(cf, pressure.fill)/Cp * pressure.fill
}
iter <- iter + 1
}
cat(toJSON(list(value=pressure.fill)))
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment