Commit 1ffb5dcc authored by Marco De Lucia's avatar Marco De Lucia
Browse files

Re-added InputFromList. Reworked demo-validate.

parent 5683da32
......@@ -24,6 +24,7 @@ export(FlattenList)
export(FormSelectedOutput)
export(FormulaFromBal)
export(FormulaToExpression)
export(InputFromList)
export(Matplot)
export(MatplotSingle)
export(ParseFormula)
......
### Utility functions for RedModRphree
### Marco De Lucia, delucia@gfz-potsdam.de, 2009-2021
### Time-stamp: "Last modified 2021-06-26 17:40:57 delucia"
### Time-stamp: "Last modified 2021-06-30 16:33:18 delucia"
##' Replicates an input buffer containing only one SOLUTION, taking
##' care of SOLUTION/KINETICS/PURE identifiers. Eventually inserts a
......@@ -351,6 +351,55 @@ RGetPhases <- function(lin, which=NULL, delta=TRUE)
}
##' Transforms a parsed solution list in a new input buffer. Given the
##' large number of options offered by PHREEQC, this function must be
##' considered just a stub and the user should adapt it to his needs.
##' In particular, KINETIC blocks are programmatically disregarded.
##'
##' Since the function operates on lists formed from PHREEQC output
##' buffers, it automatically uses molality as unit and adds the line
##' "units mol/kgw" to the script.
##' @title Transform a parsed output list in a new input buffer
##' @param lin a list containing a parsed PHREEQC output, typically
##' resulting from \link{ReadOut}.
##' @param rem Optional, character vector containing the names of the
##' desc properties to include in the new input script. If
##' missing, pH, pe, temp and water are included by default.
##' @param title optional, character. TITLE to appear in the new input
##' buffer.
##' @param signif integer specifying how many significant digits will
##' be written in the buffer. Defaults to 10.
##' @return An input buffer ready for further manipulation and/or a
##' new Rphree call.
##' @author MDL
##' @export
InputFromList <- function(lin, rem, title=NULL, signif=10L)
{
## check that totals, phases, pH and pe are in the list
if (missing(rem))
rem <- c("pH","pe","temp","water")
if (!is.null(title))
title <- paste("TITLE",title)
## Desc
ind_desk <- match(rem,rownames(lin$desc))
desc <- c(paste(rownames(lin$desc)[ind_desk], signif(lin$desc[ind_desk,1],signif), sep=" " ), "units mol/kgw")
## totals
tot <- paste(rownames(lin$tot), signif(lin$tot[,"molal"],signif))
## Equilibrium phases
if ("pphases" %in% names(lin))
phases <- paste(rownames(lin$pphases), 0.0, signif(lin$pphases[,1]))
else
phases <- NULL
## All SOLUTION
buff <- c(title, "SOLUTION 1", desc, tot,"PURE 1", phases, "END")
## print(buff)
return(buff)
}
## ##' Workhorse function for extraction of results from a solution,
## ##' specifically equilibrium phases.
## ##'
......
This diff is collapsed.
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Rphree_Utils.R
\name{InputFromList}
\alias{InputFromList}
\title{Transform a parsed output list in a new input buffer}
\usage{
InputFromList(lin, rem, title = NULL, signif = 10L)
}
\arguments{
\item{lin}{a list containing a parsed PHREEQC output, typically
resulting from \link{ReadOut}.}
\item{rem}{Optional, character vector containing the names of the
desc properties to include in the new input script. If
missing, pH, pe, temp and water are included by default.}
\item{title}{optional, character. TITLE to appear in the new input
buffer.}
\item{signif}{integer specifying how many significant digits will
be written in the buffer. Defaults to 10.}
}
\value{
An input buffer ready for further manipulation and/or a
new Rphree call.
}
\description{
Transforms a parsed solution list in a new input buffer. Given the
large number of options offered by PHREEQC, this function must be
considered just a stub and the user should adapt it to his needs.
In particular, KINETIC blocks are programmatically disregarded.
}
\details{
Since the function operates on lists formed from PHREEQC output
buffers, it automatically uses molality as unit and adds the line
"units mol/kgw" to the script.
}
\author{
MDL
}
Supports Markdown
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