Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RedModRphree
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marco De Lucia
RedModRphree
Commits
5e95b130
Commit
5e95b130
authored
6 years ago
by
Marco De Lucia
Browse files
Options
Downloads
Patches
Plain Diff
fixed RunPQC adding optional "second"
parent
17a22ea8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
R/Rphree_Kinetics.R
+8
-6
8 additions, 6 deletions
R/Rphree_Kinetics.R
man/RunPQC.Rd
+4
-2
4 additions, 2 deletions
man/RunPQC.Rd
with
12 additions
and
8 deletions
R/Rphree_Kinetics.R
+
8
−
6
View file @
5e95b130
## Functions for dealing with simulations with kinetics
## Functions for dealing with simulations with kinetics
### Marco De Lucia, delucia@gfz-potsdam.de, 2009-2018
### Marco De Lucia, delucia@gfz-potsdam.de, 2009-2018
### Time-stamp: "Last modified 2018-05-
17 15:52:34
delucia"
### Time-stamp: "Last modified 2018-05-
24 18:01:01
delucia"
##' This function just runs the generated input buffer - or a list
##' This function just runs the generated input buffer - or a list
##' thereof - through \code{phreeqc}. Obviously it requires the
##' thereof - through \code{phreeqc}. Obviously it requires the
...
@@ -17,14 +17,15 @@
...
@@ -17,14 +17,15 @@
##' @title Run the generated input buffer using phreeqc
##' @title Run the generated input buffer using phreeqc
##' @param input The input buffer, or list of inputs
##' @param input The input buffer, or list of inputs
##' @param procs the number of processes to employ
##' @param procs the number of processes to employ
##' @param second logical, if TRUE skips each odd row
##' @return a data.frame containing the SELECTED_OUTPUT, ordered if
##' @return a data.frame containing the SELECTED_OUTPUT, ordered if
##' multiple parallel simulations were called. Some manipulations
##' multiple parallel simulations were called. Some manipulations
##' of the colnames are also made.
##' of the colnames are also made.
##' @author MDL
##' @author MDL
##' @export
##' @export
RunPQC
<-
function
(
input
,
procs
=
1
)
{
RunPQC
<-
function
(
input
,
procs
=
1
,
second
=
TRUE
)
{
.runPQC
<-
function
(
input
)
{
.runPQC
<-
function
(
input
,
second
=
TRUE
)
{
require
(
phreeqc
)
require
(
phreeqc
)
phreeqc
::
phrRunString
(
input
)
phreeqc
::
phrRunString
(
input
)
out
<-
phreeqc
::
phrGetSelectedOutput
()[[
1
]]
out
<-
phreeqc
::
phrGetSelectedOutput
()[[
1
]]
...
@@ -33,7 +34,8 @@ RunPQC <- function(input, procs=1) {
...
@@ -33,7 +34,8 @@ RunPQC <- function(input, procs=1) {
nso
<-
sub
(
'.mol.kgw.'
,
''
,
nso
,
fixed
=
TRUE
)
nso
<-
sub
(
'.mol.kgw.'
,
''
,
nso
,
fixed
=
TRUE
)
nso
<-
sub
(
'^k_'
,
''
,
nso
)
nso
<-
sub
(
'^k_'
,
''
,
nso
)
nso
<-
sub
(
'.g.'
,
'(g)'
,
nso
,
fixed
=
TRUE
)
nso
<-
sub
(
'.g.'
,
'(g)'
,
nso
,
fixed
=
TRUE
)
out
<-
out
[
seq
(
2
,
nrow
(
out
),
by
=
2
),]
if
(
second
)
out
<-
out
[
seq
(
2
,
nrow
(
out
),
by
=
2
),]
colnames
(
out
)
<-
nso
colnames
(
out
)
<-
nso
return
(
data.matrix
(
out
))
return
(
data.matrix
(
out
))
}
}
...
@@ -41,7 +43,7 @@ RunPQC <- function(input, procs=1) {
...
@@ -41,7 +43,7 @@ RunPQC <- function(input, procs=1) {
## is lin a list of inputs?
## is lin a list of inputs?
if
(
!
is.list
(
input
))
{
if
(
!
is.list
(
input
))
{
if
(
is.character
(
input
))
{
## normal sequential run
if
(
is.character
(
input
))
{
## normal sequential run
res
<-
.runPQC
(
input
)
res
<-
.runPQC
(
input
,
second
=
second
)
}
else
{
}
else
{
stopmsg
(
"something wrong with the input, dying!"
)
stopmsg
(
"something wrong with the input, dying!"
)
}
}
...
@@ -51,7 +53,7 @@ RunPQC <- function(input, procs=1) {
...
@@ -51,7 +53,7 @@ RunPQC <- function(input, procs=1) {
## old one
## old one
## res <- parallel::mclapply(input, .runPQC, mc.silent=TRUE, mc.cores=procs)
## res <- parallel::mclapply(input, .runPQC, mc.silent=TRUE, mc.cores=procs)
## res <- parallel::parLapply(ThisRunCluster, input, .runPQC)
## res <- parallel::parLapply(ThisRunCluster, input, .runPQC)
res
<-
foreach
(
i
=
seq_along
(
input
),
.combine
=
rbind
)
%dopar%
.runPQC
(
input
[[
i
]])
res
<-
foreach
(
i
=
seq_along
(
input
),
.combine
=
rbind
)
%dopar%
.runPQC
(
input
[[
i
]]
,
second
=
second
)
## ## a is the string containing the rbind of each element of the list
## ## a is the string containing the rbind of each element of the list
## a <- paste("rbind(",paste("res[[",1:procs,"]]",sep="", collapse = ", "),")")
## a <- paste("rbind(",paste("res[[",1:procs,"]]",sep="", collapse = ", "),")")
...
...
This diff is collapsed.
Click to expand it.
man/RunPQC.Rd
+
4
−
2
View file @
5e95b130
...
@@ -4,12 +4,14 @@
...
@@ -4,12 +4,14 @@
\alias{RunPQC}
\alias{RunPQC}
\title{Run the generated input buffer using phreeqc}
\title{Run the generated input buffer using phreeqc}
\usage{
\usage{
RunPQC(input, procs = 1)
RunPQC(input, procs = 1
, second = TRUE
)
}
}
\arguments{
\arguments{
\item{input}{The input buffer, or list of inputs}
\item{input}{The input buffer, or list of inputs}
\item{procs}{the number of processes to employ}
\item{procs}{the number of processes to employ}
\item{second}{logical, if TRUE skips each odd row}
}
}
\value{
\value{
a data.frame containing the SELECTED_OUTPUT, ordered if
a data.frame containing the SELECTED_OUTPUT, ordered if
...
@@ -26,7 +28,7 @@ RPhreeFile("phreeqc.dat", is.db=TRUE ))}
...
@@ -26,7 +28,7 @@ RPhreeFile("phreeqc.dat", is.db=TRUE ))}
}
}
\details{
\details{
Currently parallelization is achieved using
Currently parallelization is achieved using
\code{parallel::
mcl
apply}, this can change in the future. At the
\code{parallel::
parL
apply}, this can change in the future. At the
moment the function doesn't check that the SELCTED_OUTPUT block is
moment the function doesn't check that the SELCTED_OUTPUT block is
well-formed, so this is responsibility of the user.
well-formed, so this is responsibility of the user.
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment