Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco De Lucia
RedModRphree
Commits
339592fe
Commit
339592fe
authored
Jun 26, 2021
by
Marco De Lucia
Browse files
Bumping to 0.3.6. Modified RepSol and AddProp
parent
8466b872
Changes
3
Hide whitespace changes
Inline
Side-by-side
DESCRIPTION
View file @
339592fe
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",
...
...
R/Rphree_Utils.R
View file @
339592fe
### Utility functions for RedModRphree
### Marco De Lucia, delucia@gfz-potsdam.de, 2009-2021
### Time-stamp: "Last modified 2021-0
5-06 16:05:40
delucia"
### Time-stamp: "Last modified 2021-0
6-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 insert
s
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
)
...
...
@@ -122,7 +150,7 @@ AddProp <- function(input, name, values, cat, kinpar=NULL, first=NULL)
newinp
<-
Distribute
(
tmp
,
reg
,
values
,
first
)
}
}
if
(
cat
==
"kin"
)
{
if
(
nsim
!=
1
)
stopmsg
(
" with KINETICS is able to handle only one simul at a time!"
)
...
...
man/RepSol.Rd
View file @
339592fe
...
...
@@ -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 insert
s
a
block (e.g: PUNCH
, or PHASES
) just once under the first SOLUTION.
}
\details{
Analogous to standard \code{rep} function.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment