Commit 6914c303 authored by Marco De Lucia's avatar Marco De Lucia
Browse files

Added option "verbose" to splitMulti* to suppress some messages

parent a8bd1388
......@@ -8,4 +8,4 @@ Depends: R (>= 3.2.0), doParallel, plyr, data.table, phreeqc, caret, mgcv, rando
License: LGPL-2.1
Encoding: UTF-8
LLazyData: true
RoxygenNote: 6.0.1
RoxygenNote: 6.1.1
## Functions for dealing with simulations with kinetics
### 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
##' thereof - through \code{phreeqc}. Obviously it requires the
......@@ -131,10 +131,11 @@ DistributeKin <- function(input, prop=NULL, values, ident="-m0")
##' @param dt time step
##' @param ann optional annotation to be postponed to the values
##' @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
##' @author MDL
##' @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))
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
}
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
nsim <- ntot%/%procs
nlast <- nsim + ntot%%procs
......@@ -209,7 +211,8 @@ splitMultiKin <- function(data, procs, base, first, prop, minerals, kin, dt, ann
return(inputlist)
} else {
msg("won't parallelize... procs=", procs," ntot=", ntot)
if(verbose)
msg("won't parallelize... procs=", procs," ntot=", ntot)
BigInp <- RepSol(base, ntot)
tmp <- DistributeKinMatrix(input=BigInp, prop=prop, values=data, minerals=minerals, kin=kin, dt=dt, ann=ann)
input <- c(first, tmp)
......@@ -352,10 +355,11 @@ DistributeKinMatrix <- function(input, prop, values, minerals, kin, dt, ann)
##' @param prop vector containing the names of the properties
##' @param minerals indeces of EQUILIBRIUM minerals
##' @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
##' @author MDL
##' @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))
ntot <- dim(data)[1] ## the total number of pqc simulations
......@@ -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) ||
## 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)
namdis <- colnames(data)
indminer <- minerals
......@@ -385,7 +390,8 @@ splitMultiFix <- function(data, procs, base, first, prop, minerals, nmax=200)
}
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
nsim <- ntot%/%procs
nlong <- nsim + ntot%%procs
......
......@@ -15,6 +15,9 @@ logK}
\value{
The logK at wanted temperature
}
\description{
Calculates the logK of reaction for a given temperature
}
\author{
MDL
}
......@@ -16,6 +16,10 @@ defaults to c("C","Ca","Mg","Cl")}
\value{
a structure (list) containing the balance equations
}
\description{
Form the balance equations from a full stoichiometric
matrix
}
\author{
MDL
}
......@@ -21,6 +21,10 @@ mass balance check}
a matrix containing a mass balance error, one column for
each tested equation (=element)
}
\description{
Check mass balance between design and results for
surrogates
}
\author{
MDL
}
......@@ -20,6 +20,9 @@ DistributeMatrix(input, prop, values, minerals, SI = FALSE)
\value{
input buffer with the values in correct places
}
\description{
Distribute all values from a matrix into a buffer, EQUILIBRIUM case
}
\author{
MDL
}
......@@ -5,7 +5,8 @@
\title{Returns the composition of a mineral in terms of chemical
elements (not of species)}
\usage{
ElementalBalanceMin(pphase, stoichmat, elements = c("C", "Ca", "Mg", "Cl"))
ElementalBalanceMin(pphase, stoichmat, elements = c("C", "Ca", "Mg",
"Cl"))
}
\arguments{
\item{pphase}{name of the mineral to parse}
......@@ -19,6 +20,10 @@ defaults to c("C","Ca","Mg","Cl")}
named vector with stoichiometric coefficients of chemical
elements for the pphase mineral
}
\description{
Returns the composition of a mineral in terms of chemical
elements (not of species)
}
\author{
MDL
}
......@@ -15,6 +15,9 @@ for}
\value{
matix with one pphases per column
}
\description{
Extract all phases from a flatted Rphree list
}
\author{
MDL
}
......@@ -21,6 +21,10 @@ variables are selected}
\value{
a list with 2 elements: design and result
}
\description{
Extracts input/output tables from a list of Reactive
Transport Simulations
}
\author{
MDL
}
......@@ -15,6 +15,9 @@ search for}
\value{
matix with one species per column
}
\description{
Extract species from a flatted Rphree list
}
\author{
MDL
}
......@@ -16,6 +16,10 @@ search for}
\value{
Matrix with one element per column
}
\description{
Extract total element concentrations from a flatted Rphree
list
}
\author{
MDL
}
......@@ -12,6 +12,9 @@ FindAllMinNames(flatlist)
\value{
vector with unique occurrences of pphases names
}
\description{
Find all pphases occurring in the ensemble
}
\author{
MDL
}
......@@ -12,6 +12,9 @@ FindAllSpeciesNames(flatlist)
\value{
vector with unique occurrences of species names
}
\description{
Find all species occurring in the ensemble
}
\author{
MDL
}
......@@ -12,6 +12,9 @@ FindAllTotNames(flatlist)
\value{
vector with unique occurrences of element names
}
\description{
Find all totals occurring in the ensemble
}
\author{
MDL
}
......@@ -17,6 +17,10 @@ FindLogK(species, db, type = c("analytical"))
\value{
the requested logK
}
\description{
Finds the expression of a logK of a given compound/mineral
in a PHREEQC database
}
\author{
MDL
}
......@@ -16,6 +16,9 @@ a list with the components of the formula and the
stoichiometric coefficients, plus the corresponding line in
the db as attr(,"line")
}
\description{
Find a PURE_PHASE in a database and parses its formula
}
\author{
MDL
}
......@@ -14,6 +14,9 @@ minerals}
a named vector with the stoichiometric formula of the
minerals
}
\description{
Figures out the formula from a baleq structure
}
\author{
MDL
}
......@@ -5,8 +5,8 @@
\title{Display the profiles of some variables for 2 reactive
transport simulation (one using surrogates)}
\usage{
Matplot(sur, sim, sample = 1L, vars = c("Ca", "Mg", "Calcite", "Dolomite"),
...)
Matplot(sur, sim, sample = 1L, vars = c("Ca", "Mg", "Calcite",
"Dolomite"), ...)
}
\arguments{
\item{sur}{The simulation with surrogate}
......@@ -22,6 +22,10 @@ variables to display (up to 7)}
\item{...}{further parameters passed to \code{matplot}, such as
main, xlab, ylab...}
}
\description{
Display the profiles of some variables for 2 reactive
transport simulation (one using surrogates)
}
\author{
MDL
}
......@@ -5,8 +5,8 @@
\title{Display the profiles of some variables along a 1D reactive
transport simulation}
\usage{
MatplotSingle(sim, sample = 1L, vars = c("Ca", "Mg", "Calcite", "Dolomite"),
...)
MatplotSingle(sim, sample = 1L, vars = c("Ca", "Mg", "Calcite",
"Dolomite"), ...)
}
\arguments{
\item{sim}{The simulation to display}
......@@ -20,6 +20,10 @@ variables to display (up to 7)}
\item{...}{further parameters passed to \code{matplot}, such as
main, xlab, ylab...}
}
\description{
Display the profiles of some variables along a 1D reactive
transport simulation
}
\author{
MDL
}
......@@ -15,6 +15,9 @@ ParseFormula(line, type = "all")
a list containing components and coefficients.
Coefficients of left hand side are negated.
}
\description{
Parses a formula as it is written in a PHREEQC database
}
\author{
MDL
}
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