Commit 339592fe authored by Marco De Lucia's avatar Marco De Lucia
Browse files

Bumping to 0.3.6. Modified RepSol and AddProp

parent 8466b872
Package: RedModRphree
Title: Utilities Leveraging the R Interface to the PHREEQC Geochemical Solver
Version: 0.3.4
Version: 0.3.6
Authors@R: c(person(given = "Marco",
family = "De Lucia",
email = "delucia@gfz-potsdam.de",
......
### Utility functions for RedModRphree
### Marco De Lucia, delucia@gfz-potsdam.de, 2009-2021
### Time-stamp: "Last modified 2021-05-06 16:05:40 delucia"
### Time-stamp: "Last modified 2021-06-26 17:40:57 delucia"
##' Replicates an input buffer containing only one SOLUTION, taking
##' care of SOLUTION/KINETICS/PURE identifiers. Eventually insert a
##' block (e.g: PUNCH) just once under the first SOLUTION.
##' care of SOLUTION/KINETICS/PURE identifiers. Eventually inserts a
##' block (e.g: PUNCH, or PHASES) just once under the first SOLUTION.
##'
##' Analogous to standard \code{rep} function.
##' @title Replicate a SOLUTION
......@@ -81,9 +81,12 @@ AddProp <- function(input, name, values, cat, kinpar=NULL, first=NULL)
val <- as.character(values)
nval <- length(val)
nsim <- length(marksol <- grep("^SOLUTION",input))
nends <- length(marksend <- grep("^END",input))
if (nval != nsim && nsim != 1)
stopmsg("Lengths of simulation and values to add do not agree!")
if (nends != nsim)
stopmsg("Please explicitely add END at the bottom of your input script!")
if (cat == "tot") {
if (nsim == 1) {
......@@ -107,8 +110,33 @@ AddProp <- function(input, name, values, cat, kinpar=NULL, first=NULL)
}
if (cat == "pphases") {
markpure <- grep("PURE", input)
if (nsim == 1) {
markpure <- grep("^PURE|^EQUILIBRIUM", input)
## check if a line containing "PURE" or "EQUILIBRIUM_PHASE" is
## actually there, if not add it just before "END"
addKeyword <- ifelse(length(markpure)==0, TRUE, FALSE)
## create "space" in the solution vector and add keyword
## "PURE" if needed
if (addKeyword) {
## msg ("addKeyword TRUE")
if (nsim==1) {
markpure <- length(input)-1 ## the lines before "END"
## msg("markpure", markpure)
tmp <- c(input[1:markpure], "PURE 1",input[seq(markpure+1,length(input))])
## msg(tmp)
} else {
markpure <- marksend-1
tmp <- character(length(input) + nsim)
tmp[markpure] <- paste("PURE", seq_along(nsim))
rest <- seq_along(tmp)[-markpure]
tmp[rest] <- input
}
}
## now we are ensured that proper keywords are present
input <- tmp
## update markpure
markpure <- grep("^PURE", input)
if (nsim == 1) { ## we don't need to "RepSol"
tmp <- c(input[1:markpure], paste(name, val[1]), input[(markpure + 1):length(input)])
if (nval != 1)
newinp <- Distribute(tmp, reg, val, first)
......
......@@ -19,8 +19,8 @@ A buffer upon which RunPQC can be called
}
\description{
Replicates an input buffer containing only one SOLUTION, taking
care of SOLUTION/KINETICS/PURE identifiers. Eventually insert a
block (e.g: PUNCH) just once under the first SOLUTION.
care of SOLUTION/KINETICS/PURE identifiers. Eventually inserts a
block (e.g: PUNCH, or PHASES) just once under the first SOLUTION.
}
\details{
Analogous to standard \code{rep} function.
......
Markdown is supported
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