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
6914c303
Commit
6914c303
authored
Dec 12, 2018
by
Marco De Lucia
Browse files
Added option "verbose" to splitMulti* to suppress some messages
parent
a8bd1388
Changes
26
Hide whitespace changes
Inline
Side-by-side
DESCRIPTION
View file @
6914c303
...
@@ -8,4 +8,4 @@ Depends: R (>= 3.2.0), doParallel, plyr, data.table, phreeqc, caret, mgcv, rando
...
@@ -8,4 +8,4 @@ Depends: R (>= 3.2.0), doParallel, plyr, data.table, phreeqc, caret, mgcv, rando
License: LGPL-2.1
License: LGPL-2.1
Encoding: UTF-8
Encoding: UTF-8
LLazyData: true
LLazyData: true
RoxygenNote: 6.
0
.1
RoxygenNote: 6.
1
.1
R/Rphree_Kinetics.R
View file @
6914c303
## 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-
08-15 00:16:25
delucia"
### Time-stamp: "Last modified 2018-
12-12 14:25:38
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
...
@@ -131,10 +131,11 @@ DistributeKin <- function(input, prop=NULL, values, ident="-m0")
...
@@ -131,10 +131,11 @@ DistributeKin <- function(input, prop=NULL, values, ident="-m0")
##' @param dt time step
##' @param dt time step
##' @param ann optional annotation to be postponed to the values
##' @param ann optional annotation to be postponed to the values
##' @param nmax minimum number of simulations in one "split"
##' @param nmax minimum number of simulations in one "split"
##' @param verbose logical, defaulting to FALSE. If TRUE, some message are displayed
##' @return a list of length "procs" with the inputs, ready to be run in parallel
##' @return a list of length "procs" with the inputs, ready to be run in parallel
##' @author MDL
##' @author MDL
##' @export
##' @export
splitMultiKin
<-
function
(
data
,
procs
,
base
,
first
,
prop
,
minerals
,
kin
,
dt
,
ann
,
nmax
=
200
)
splitMultiKin
<-
function
(
data
,
procs
,
base
,
first
,
prop
,
minerals
,
kin
,
dt
,
ann
,
nmax
=
200
,
verbose
=
FALSE
)
{
{
if
(
is.matrix
(
data
))
if
(
is.matrix
(
data
))
ntot
<-
dim
(
data
)[
1
]
## the total number of pqc simulations
ntot
<-
dim
(
data
)[
1
]
## the total number of pqc simulations
...
@@ -182,7 +183,8 @@ splitMultiKin <- function(data, procs, base, first, prop, minerals, kin, dt, ann
...
@@ -182,7 +183,8 @@ splitMultiKin <- function(data, procs, base, first, prop, minerals, kin, dt, ann
}
}
if
(
ntot
>
max
(
nmax
,
procs
*
2
)
&&
procs
>
1
)
{
if
(
ntot
>
max
(
nmax
,
procs
*
2
)
&&
procs
>
1
)
{
msg
(
" Splitting up "
,
ntot
,
"simulations to"
,
procs
,
"processes..."
)
if
(
verbose
)
msg
(
" Splitting up "
,
ntot
,
"simulations to"
,
procs
,
"processes..."
)
## find best division in n
## find best division in n
nsim
<-
ntot
%/%
procs
nsim
<-
ntot
%/%
procs
nlast
<-
nsim
+
ntot
%%
procs
nlast
<-
nsim
+
ntot
%%
procs
...
@@ -209,7 +211,8 @@ splitMultiKin <- function(data, procs, base, first, prop, minerals, kin, dt, ann
...
@@ -209,7 +211,8 @@ splitMultiKin <- function(data, procs, base, first, prop, minerals, kin, dt, ann
return
(
inputlist
)
return
(
inputlist
)
}
else
{
}
else
{
msg
(
"won't parallelize... procs="
,
procs
,
" ntot="
,
ntot
)
if
(
verbose
)
msg
(
"won't parallelize... procs="
,
procs
,
" ntot="
,
ntot
)
BigInp
<-
RepSol
(
base
,
ntot
)
BigInp
<-
RepSol
(
base
,
ntot
)
tmp
<-
DistributeKinMatrix
(
input
=
BigInp
,
prop
=
prop
,
values
=
data
,
minerals
=
minerals
,
kin
=
kin
,
dt
=
dt
,
ann
=
ann
)
tmp
<-
DistributeKinMatrix
(
input
=
BigInp
,
prop
=
prop
,
values
=
data
,
minerals
=
minerals
,
kin
=
kin
,
dt
=
dt
,
ann
=
ann
)
input
<-
c
(
first
,
tmp
)
input
<-
c
(
first
,
tmp
)
...
@@ -352,10 +355,11 @@ DistributeKinMatrix <- function(input, prop, values, minerals, kin, dt, ann)
...
@@ -352,10 +355,11 @@ DistributeKinMatrix <- function(input, prop, values, minerals, kin, dt, ann)
##' @param prop vector containing the names of the properties
##' @param prop vector containing the names of the properties
##' @param minerals indeces of EQUILIBRIUM minerals
##' @param minerals indeces of EQUILIBRIUM minerals
##' @param nmax max number of simulations in each input
##' @param nmax max number of simulations in each input
##' @param verbose logical, defaulting to FALSE. If TRUE, some message are displayed
##' @return a list with n=procs inputs
##' @return a list with n=procs inputs
##' @author MDL
##' @author MDL
##' @export
##' @export
splitMultiFix
<-
function
(
data
,
procs
,
base
,
first
,
prop
,
minerals
,
nmax
=
200
)
splitMultiFix
<-
function
(
data
,
procs
,
base
,
first
,
prop
,
minerals
,
nmax
=
200
,
verbose
=
FALSE
)
{
{
if
(
is.matrix
(
data
))
if
(
is.matrix
(
data
))
ntot
<-
dim
(
data
)[
1
]
## the total number of pqc simulations
ntot
<-
dim
(
data
)[
1
]
## the total number of pqc simulations
...
@@ -369,7 +373,8 @@ splitMultiFix <- function(data, procs, base, first, prop, minerals, nmax=200)
...
@@ -369,7 +373,8 @@ splitMultiFix <- function(data, procs, base, first, prop, minerals, nmax=200)
if
(
ntot
==
1
)
## try and call normal Distribute (i.e., ##!is.matrix(data) ||
if
(
ntot
==
1
)
## try and call normal Distribute (i.e., ##!is.matrix(data) ||
## just 1 simulation!)
## just 1 simulation!)
{
{
msg
(
"just 1 simulation, reverting back to normal Distribute"
)
if
(
verbose
)
msg
(
"just 1 simulation, reverting back to normal Distribute"
)
BigInp
<-
RepSol
(
base
,
1
,
first
=
first
)
BigInp
<-
RepSol
(
base
,
1
,
first
=
first
)
namdis
<-
colnames
(
data
)
namdis
<-
colnames
(
data
)
indminer
<-
minerals
indminer
<-
minerals
...
@@ -385,7 +390,8 @@ splitMultiFix <- function(data, procs, base, first, prop, minerals, nmax=200)
...
@@ -385,7 +390,8 @@ splitMultiFix <- function(data, procs, base, first, prop, minerals, nmax=200)
}
}
if
(
ntot
>
nmax
&&
procs
>
1
)
{
if
(
ntot
>
nmax
&&
procs
>
1
)
{
msg
(
"Splitting up "
,
ntot
,
"simulations to"
,
procs
,
"processes..."
)
if
(
verbose
)
msg
(
"Splitting up "
,
ntot
,
"simulations to"
,
procs
,
"processes..."
)
## find best division in n
## find best division in n
nsim
<-
ntot
%/%
procs
nsim
<-
ntot
%/%
procs
nlong
<-
nsim
+
ntot
%%
procs
nlong
<-
nsim
+
ntot
%%
procs
...
...
man/AnalyticalLogK.Rd
View file @
6914c303
...
@@ -15,6 +15,9 @@ logK}
...
@@ -15,6 +15,9 @@ logK}
\value{
\value{
The logK at wanted temperature
The logK at wanted temperature
}
}
\description{
Calculates the logK of reaction for a given temperature
}
\author{
\author{
MDL
MDL
}
}
man/BalanceEquations.Rd
View file @
6914c303
...
@@ -16,6 +16,10 @@ defaults to c("C","Ca","Mg","Cl")}
...
@@ -16,6 +16,10 @@ defaults to c("C","Ca","Mg","Cl")}
\value{
\value{
a structure (list) containing the balance equations
a structure (list) containing the balance equations
}
}
\description{
Form the balance equations from a full stoichiometric
matrix
}
\author{
\author{
MDL
MDL
}
}
man/CheckBalance.Rd
View file @
6914c303
...
@@ -21,6 +21,10 @@ mass balance check}
...
@@ -21,6 +21,10 @@ mass balance check}
a matrix containing a mass balance error, one column for
a matrix containing a mass balance error, one column for
each tested equation (=element)
each tested equation (=element)
}
}
\description{
Check mass balance between design and results for
surrogates
}
\author{
\author{
MDL
MDL
}
}
man/DistributeMatrix.Rd
View file @
6914c303
...
@@ -20,6 +20,9 @@ DistributeMatrix(input, prop, values, minerals, SI = FALSE)
...
@@ -20,6 +20,9 @@ DistributeMatrix(input, prop, values, minerals, SI = FALSE)
\value{
\value{
input buffer with the values in correct places
input buffer with the values in correct places
}
}
\description{
Distribute all values from a matrix into a buffer, EQUILIBRIUM case
}
\author{
\author{
MDL
MDL
}
}
man/ElementalBalanceMin.Rd
View file @
6914c303
...
@@ -5,7 +5,8 @@
...
@@ -5,7 +5,8 @@
\title{Returns the composition of a mineral in terms of chemical
\title{Returns the composition of a mineral in terms of chemical
elements (not of species)}
elements (not of species)}
\usage{
\usage{
ElementalBalanceMin(pphase, stoichmat, elements = c("C", "Ca", "Mg", "Cl"))
ElementalBalanceMin(pphase, stoichmat, elements = c("C", "Ca", "Mg",
"Cl"))
}
}
\arguments{
\arguments{
\item{pphase}{name of the mineral to parse}
\item{pphase}{name of the mineral to parse}
...
@@ -19,6 +20,10 @@ defaults to c("C","Ca","Mg","Cl")}
...
@@ -19,6 +20,10 @@ defaults to c("C","Ca","Mg","Cl")}
named vector with stoichiometric coefficients of chemical
named vector with stoichiometric coefficients of chemical
elements for the pphase mineral
elements for the pphase mineral
}
}
\description{
Returns the composition of a mineral in terms of chemical
elements (not of species)
}
\author{
\author{
MDL
MDL
}
}
man/ExtractPphases.Rd
View file @
6914c303
...
@@ -15,6 +15,9 @@ for}
...
@@ -15,6 +15,9 @@ for}
\value{
\value{
matix with one pphases per column
matix with one pphases per column
}
}
\description{
Extract all phases from a flatted Rphree list
}
\author{
\author{
MDL
MDL
}
}
man/ExtractSamples.Rd
View file @
6914c303
...
@@ -21,6 +21,10 @@ variables are selected}
...
@@ -21,6 +21,10 @@ variables are selected}
\value{
\value{
a list with 2 elements: design and result
a list with 2 elements: design and result
}
}
\description{
Extracts input/output tables from a list of Reactive
Transport Simulations
}
\author{
\author{
MDL
MDL
}
}
man/ExtractSpecies.Rd
View file @
6914c303
...
@@ -15,6 +15,9 @@ search for}
...
@@ -15,6 +15,9 @@ search for}
\value{
\value{
matix with one species per column
matix with one species per column
}
}
\description{
Extract species from a flatted Rphree list
}
\author{
\author{
MDL
MDL
}
}
man/ExtractTotals.Rd
View file @
6914c303
...
@@ -16,6 +16,10 @@ search for}
...
@@ -16,6 +16,10 @@ search for}
\value{
\value{
Matrix with one element per column
Matrix with one element per column
}
}
\description{
Extract total element concentrations from a flatted Rphree
list
}
\author{
\author{
MDL
MDL
}
}
man/FindAllMinNames.Rd
View file @
6914c303
...
@@ -12,6 +12,9 @@ FindAllMinNames(flatlist)
...
@@ -12,6 +12,9 @@ FindAllMinNames(flatlist)
\value{
\value{
vector with unique occurrences of pphases names
vector with unique occurrences of pphases names
}
}
\description{
Find all pphases occurring in the ensemble
}
\author{
\author{
MDL
MDL
}
}
man/FindAllSpeciesNames.Rd
View file @
6914c303
...
@@ -12,6 +12,9 @@ FindAllSpeciesNames(flatlist)
...
@@ -12,6 +12,9 @@ FindAllSpeciesNames(flatlist)
\value{
\value{
vector with unique occurrences of species names
vector with unique occurrences of species names
}
}
\description{
Find all species occurring in the ensemble
}
\author{
\author{
MDL
MDL
}
}
man/FindAllTotNames.Rd
View file @
6914c303
...
@@ -12,6 +12,9 @@ FindAllTotNames(flatlist)
...
@@ -12,6 +12,9 @@ FindAllTotNames(flatlist)
\value{
\value{
vector with unique occurrences of element names
vector with unique occurrences of element names
}
}
\description{
Find all totals occurring in the ensemble
}
\author{
\author{
MDL
MDL
}
}
man/FindLogK.Rd
View file @
6914c303
...
@@ -17,6 +17,10 @@ FindLogK(species, db, type = c("analytical"))
...
@@ -17,6 +17,10 @@ FindLogK(species, db, type = c("analytical"))
\value{
\value{
the requested logK
the requested logK
}
}
\description{
Finds the expression of a logK of a given compound/mineral
in a PHREEQC database
}
\author{
\author{
MDL
MDL
}
}
man/FindPhase.Rd
View file @
6914c303
...
@@ -16,6 +16,9 @@ a list with the components of the formula and the
...
@@ -16,6 +16,9 @@ a list with the components of the formula and the
stoichiometric coefficients, plus the corresponding line in
stoichiometric coefficients, plus the corresponding line in
the db as attr(,"line")
the db as attr(,"line")
}
}
\description{
Find a PURE_PHASE in a database and parses its formula
}
\author{
\author{
MDL
MDL
}
}
man/FormulaFromBal.Rd
View file @
6914c303
...
@@ -14,6 +14,9 @@ minerals}
...
@@ -14,6 +14,9 @@ minerals}
a named vector with the stoichiometric formula of the
a named vector with the stoichiometric formula of the
minerals
minerals
}
}
\description{
Figures out the formula from a baleq structure
}
\author{
\author{
MDL
MDL
}
}
man/Matplot.Rd
View file @
6914c303
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
\title{Display the profiles of some variables for 2 reactive
\title{Display the profiles of some variables for 2 reactive
transport simulation (one using surrogates)}
transport simulation (one using surrogates)}
\usage{
\usage{
Matplot(sur, sim, sample = 1L, vars = c("Ca", "Mg", "Calcite",
"Dolomite"),
Matplot(sur, sim, sample = 1L, vars = c("Ca", "Mg", "Calcite",
...)
"Dolomite"),
...)
}
}
\arguments{
\arguments{
\item{sur}{The simulation with surrogate}
\item{sur}{The simulation with surrogate}
...
@@ -22,6 +22,10 @@ variables to display (up to 7)}
...
@@ -22,6 +22,10 @@ variables to display (up to 7)}
\item{...}{further parameters passed to \code{matplot}, such as
\item{...}{further parameters passed to \code{matplot}, such as
main, xlab, ylab...}
main, xlab, ylab...}
}
}
\description{
Display the profiles of some variables for 2 reactive
transport simulation (one using surrogates)
}
\author{
\author{
MDL
MDL
}
}
man/MatplotSingle.Rd
View file @
6914c303
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
\title{Display the profiles of some variables along a 1D reactive
\title{Display the profiles of some variables along a 1D reactive
transport simulation}
transport simulation}
\usage{
\usage{
MatplotSingle(sim, sample = 1L, vars = c("Ca", "Mg", "Calcite",
"Dolomite"),
MatplotSingle(sim, sample = 1L, vars = c("Ca", "Mg", "Calcite",
...)
"Dolomite"),
...)
}
}
\arguments{
\arguments{
\item{sim}{The simulation to display}
\item{sim}{The simulation to display}
...
@@ -20,6 +20,10 @@ variables to display (up to 7)}
...
@@ -20,6 +20,10 @@ variables to display (up to 7)}
\item{...}{further parameters passed to \code{matplot}, such as
\item{...}{further parameters passed to \code{matplot}, such as
main, xlab, ylab...}
main, xlab, ylab...}
}
}
\description{
Display the profiles of some variables along a 1D reactive
transport simulation
}
\author{
\author{
MDL
MDL
}
}
man/ParseFormula.Rd
View file @
6914c303
...
@@ -15,6 +15,9 @@ ParseFormula(line, type = "all")
...
@@ -15,6 +15,9 @@ ParseFormula(line, type = "all")
a list containing components and coefficients.
a list containing components and coefficients.
Coefficients of left hand side are negated.
Coefficients of left hand side are negated.
}
}
\description{
Parses a formula as it is written in a PHREEQC database
}
\author{
\author{
MDL
MDL
}
}
Prev
1
2
Next
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