PhreeqcUsers Discussion Forum

Beginners => PHREEQC basics => Topic started by: DH1234 on October 01, 2018, 03:43:52 PM

Title: Errors with phrRunFile() IPHREEQC for R
Post by: DH1234 on October 01, 2018, 03:43:52 PM
Hello,

I'm trying to get IPHREEQC up and running in R. I've had some sucess following examples using the phrRunString() command and I'm now trying to use the phrRunFile() command to run a phreeqc script called "Aquil.txt". This script is in the same directory as the R script and runs fine in regular PHREEQC. When I run the R script I recieve the error message "Error in phrRunFile("Aquil.txt") : ERROR: RunFile: Unable to open:"Aquil.txt".".

Any help would be greatly appreciated.
 
Here's my R script:
Code: [Select]
library(phreeqc)

phrLoadDatabaseString(phreeqc.dat)
phrSetOutputStringsOn(TRUE)

phrRunFile("Aquil.txt")

phrGetOutputStrings()

Heres the contents of the file Aquil.txt:
Code: [Select]
SELECTED_OUTPUT
-file Aquil.xls
-reset false
-solution true
-charge_balance
USER_PUNCH
-headings pH ALK DIC(mmol) HCO3- CO3-2 SR(Cal)
20 PUNCH -LA("H+")
30 PUNCH ALK*1000
40 PUNCH TOTMOLE("C(4)")*1000
50 PUNCH MOL("HCO3-")*1000
60 PUNCH MOL("CO3-2")*1000
70 PUNCH SR("Calcite")

SOLUTION 1 #Define solution 1
REACTION 1 #Add the following moles of the following reagents to solution 1
NaCl 4.2e-1
Na2SO4 2.88e-2
KCl 9.39e-3
NaHCO3 2.38e-3
KBr 8.40e-4
HBO3 4.85e-5
NaF 7.15e-5
MgCl2 5.46e-2
CaCl2 1.05e-2
SrCl2 6.38e-5
NaH2PO4 1e-5
NaNO3 1e-4
Na2SiO3 1e-4
1.0 moles
END
Title: Re: Errors with phrRunFile() IPHREEQC for R
Post by: dlparkhurst on October 01, 2018, 04:40:37 PM
Try setting the working directory, setwd("c:/..."). Use forward slashes, even if you are using Windows.


Title: Re: Errors with phrRunFile() IPHREEQC for R
Post by: DH1234 on October 02, 2018, 08:42:58 AM
Thank you very much, thats the answer.