...
 
Commits (2)
......@@ -5,6 +5,8 @@
*.Rprof
*.bak
.idea
venv*
2.17/*.o
2.17/*.so
*.rds
......@@ -2,7 +2,7 @@
### interface R/phreeqc (Parkhurst & Appelo)
###
### Marco De Lucia, delucia@gfz-potsdam.de, 2009-2012
### Time-stamp: "Last modified 2013-05-16 14:21:49 delucia"
### Time-stamp: "Last modified 2020-04-17 16:48:20 delucia"
dyn.load(paste("2.17/libRphree",.Platform$dynlib.ext,sep="")) # , local = TRUE, now = TRUE
......@@ -15,7 +15,7 @@ require(ggplot2) ## Viz
source("Rphree_Utils.R")
source("Rphree_Sim.R")
source("Rphree_Solub.R")
source("Rphree_Viz.R")
## source("Rphree_Viz.R")
source("Rphree_DataBase.R")
Rphree <- function( input = stop("No input specified.\n"), sel,
......
......@@ -148,20 +148,20 @@ class DataModel:
of each parameters
"""
def __init__(self,
Functions=['RunSims','Acquire','import_table','export_table','restore_session',
'save_session','setwd','uniq','RepeatInd','ParameterOrder'],#,'BatchSA','RPhreeFile'], # these are the functions exposed to Python from R (needed run the simulations)
BaseData=['combinations','Formulas','DBsequence'],#,'pls'], # base data structures
hard_limits_lo={ "pH":1.5, "temp":-40, "pe":-10, "density": 0 }, # These can be set manually and selectively while being passed as dictionary objects
hard_limits_hi={ "pH":9.5, "temp":200, "pe": 10, "density": 10 }, # while creating this object
TDBpath="db", # defult search path for thermodynamics databKetzin_initial_mod.phrqases
InitSolFilePath=os.curdir, # initial solution search path
InitSolFile="", # current directory is default for phrq files and if this is empty then the first one found is used
backend="rpb.R", # this can be set to different backend testing branch etc.
PureStates=["0.0 0", "0.0 1","EXCL"],
#Rsession="rpv_sessions/.RData"): # if this is set, then a previously saved session at this path is loaded for all variables,
Rsession="",
saved_sessions_path="sessions"
): # if not then it is created from the first PHRQ file in directory or another input solution specified at InitSolFilePath
Functions=['RunSims','Acquire','import_table','export_table','restore_session',
'save_session','setwd','uniq','RepeatInd','ParameterOrder'],#,'BatchSA','RPhreeFile'], # these are the functions exposed to Python from R (needed run the simulations)
BaseData=['combinations','Formulas','DBsequence'],#,'pls'], # base data structures
hard_limits_lo={ "pH":1.5, "temp":-40, "pe":-10, "density": 0 }, # These can be set manually and selectively while being passed as dictionary objects
hard_limits_hi={ "pH":9.5, "temp":200, "pe": 10, "density": 10 }, # while creating this object
TDBpath="db", # defult search path for thermodynamics databKetzin_initial_mod.phrqases
InitSolFilePath=os.curdir, # initial solution search path
InitSolFile="", # current directory is default for phrq files and if this is empty then the first one found is used
backend="rpb.R", # this can be set to different backend testing branch etc.
PureStates=["0.0 0", "0.0 1","EXCL"],
#Rsession="rpv_sessions/.RData"): # if this is set, then a previously saved session at this path is loaded for all variables,
Rsession="",
saved_sessions_path="sessions"
): # if not then it is created from the first PHRQ file in directory or another input solution specified at InitSolFilePath
# auto-create data structure names
# attach the speciefied "non-self" keyword arguments to the object. this allows addition to class parameter keywords that become object properties automatically
......@@ -480,7 +480,7 @@ class Interaction(Handler):
parseq.append( pline )
print(parseq)
# =========================== INVOKE BACKEND FOR SIMULATION BATCH =========================
dualecho(info.object.iface_status,"RPHREE GEOCHEMICAL SIMUALTION BATCH RUNNING ...")
dualecho(info.object.iface_status,"RPHREE GEOCHEMICAL SIMULATION BATCH RUNNING ...")
# first attempt using rpy interface. since we do not want the RunSims output to be useful directly on Python, we operate on R session generating code instead of using objects directly
plist=info.object.data.R('plist=list(\n\t'+',\n\t'.join( parseq ) + ')')
enclosedDBs='"'+l2s(info.object.Thermodynamics_DB,'","')+'"'
......
This diff is collapsed.
source("rpb_mdl.R")
## No parallelization
test1 <- RunSims(infile="Ketzin_CO2_batch_2.phrq",
TDB=c("db/llnl_ek2.dat"), ## path to thermodynamics database
mysel=c(kin=FALSE,tot=TRUE,desc=TRUE,species=TRUE,pphases=TRUE,SI=TRUE,punch=FALSE), ## output collection selector
set_cores=1, ## will attempt to use parallelization if basic checks are valid
min_sims_per_core=8, ## one of such checks is the minmal simulations to allocate per core
profiler = FALSE, ## get detailed profiler
paras=list( ## this is the most important thing - the parameterization list with all named parameter vectors
temp = seq(25,75,length=3),
Na = seq(2,4,length=10),
Cl = seq(2,4,length=10),
"CO2(g)" = paste("1.0",c(0,10)),
Calcite = paste("0.0",c(0,1)))
)
## New parallelization, set_cores=4
test2 <- RunSims(infile="Ketzin_CO2_batch_2.phrq",
TDB=c("db/llnl_ek2.dat"), ## path to thermodynamics database
mysel=c(kin=FALSE,tot=TRUE,desc=TRUE,species=TRUE,pphases=TRUE,SI=TRUE,punch=FALSE), ## output collection selector
set_cores=4, ## will attempt to use parallelization if basic checks are valid
min_sims_per_core=8, ## one of such checks is the minmal simulations to allocate per core
profiler = FALSE, ## get detailed profiler
paras=list( ## this is the most important thing - the parameterization list with all named parameter vectors
temp = seq(25,75,length=3),
Na = seq(2,4,length=10),
Cl = seq(2,4,length=10),
"CO2(g)" = paste("1.0",c(0,10)),
Calcite = paste("0.0",c(0,1)))
)
all.equal(test1, test2) ## TRUE
dd <- Acquire(rphree_out=test2, ## this is the usual Rphree output block
BatchSensitivity="_facts", ## if set then multifactor SA is run for all selected output blocks and stored in DFs with this sfx
AxisClust="_axcs", ## clusters for output axis similarity
data_list=blocks )
combinations ## parameter combinations
CONCs_facts ## Calculated sensitivity of the results (rownames) to inputs (colnames)
## The same with current Janis plyr/doMC dependency
## NB note that you should restart R
source("rpb.R")
## No parallelization
test1 <- RunSims(infile="Ketzin_CO2_batch_2.phrq",
TDB=c("db/llnl_ek2.dat"), ## path to thermodynamics database
mysel=c(kin=FALSE,tot=TRUE,desc=TRUE,species=TRUE,pphases=TRUE,SI=TRUE,punch=FALSE), ## output collection selector
set_cores=1, ## will attempt to use parallelization if basic checks are valid
min_sims_per_core=8, ## one of such checks is the minmal simulations to allocate per core
profiler = FALSE, ## get detailed profiler
paras=list( ## this is the most important thing - the parameterization list with all named parameter vectors
temp = seq(25,75,length=3),
Na = seq(2,4,length=10),
Cl = seq(2,4,length=10),
"CO2(g)" = paste("1.0",c(0,10)),
Calcite = paste("0.0",c(0,1)))
)
## New parallelization, set_cores=4
test2 <- RunSims(infile="Ketzin_CO2_batch_2.phrq",
TDB=c("db/llnl_ek2.dat"), ## path to thermodynamics database
mysel=c(kin=FALSE,tot=TRUE,desc=TRUE,species=TRUE,pphases=TRUE,SI=TRUE,punch=FALSE), ## output collection selector
set_cores=4, ## will attempt to use parallelization if basic checks are valid
min_sims_per_core=8, ## one of such checks is the minmal simulations to allocate per core
profiler = FALSE, ## get detailed profiler
paras=list( ## this is the most important thing - the parameterization list with all named parameter vectors
temp = seq(25,75,length=3),
Na = seq(2,4,length=10),
Cl = seq(2,4,length=10),
"CO2(g)" = paste("1.0",c(0,10)),
Calcite = paste("0.0",c(0,1)))
)
all.equal(test1, test2) ## TRUE
dd <- Acquire(rphree_out=test2, ## this is the usual Rphree output block
BatchSensitivity="_facts", ## if set then multifactor SA is run for all selected output blocks and stored in DFs with this sfx
AxisClust="_axcs", ## clusters for output axis similarity
data_list=blocks )
combinations ## parameter combinations
CONCs_facts ## Calculated sensitivity of the results (rownames) to inputs (colnames)