character(len=:), dimension(:), allocatable :: components
clcclearnxyz = 40loadlibrary('./bin/PhreeqcRMd','./include/RM_interface_C.h')id = calllib('PhreeqcRMd','RM_Create',nxyz,1)libfunctionsview('PhreeqcRMd')%libfunctions('PhreeqcRMd')[x0,s] = calllib('PhreeqcRMd','RM_SetFilePrefix',id, 'Logfile')x1 = calllib('PhreeqcRMd','RM_OpenFiles',id)x2 = calllib('PhreeqcRMd','RM_LoadDatabase',id, 'LLNL.DAT')tt = calllib('PhreeqcRMd','RM_FindComponents',id) [x3,s] = calllib('PhreeqcRMd','RM_RunString',id,1,1,1,'END')[x4,s] = calllib('PhreeqcRMd','RM_RunFile',id,1,1,1,'./solution.pqi')ic = NaN(1,7*nxyz);for i = 1:nxyz ic(i) = i; ic(i+nxyz) = i; ic(i+2*nxyz) = -1; ic(i+3*nxyz) = -1; ic(i+4*nxyz) = -1; ic(i+5*nxyz) = -1; ic(i+6*nxyz) = -1;end[x5,s1,s2,s3] = calllib('PhreeqcRMd','RM_InitialPhreeqc2Module',id, ic, [], []);x6 = calllib('PhreeqcRMd','RM_SetComponentH2O',id, 0);ncomps = calllib('PhreeqcRMd','RM_FindComponents',id);% ParametersbufferSize = 200;% Preallocate a cell array to store componentscomponents = cell(1, ncomps);% Loop over componentsfor i = 1:ncomps disp(i); buffer = blanks(bufferSize); % Call the library function to get the component name [x6, buffer] = calllib('PhreeqcRMd', 'RM_GetComponent', id, i, buffer, bufferSize); disp(buffer) % Store the modified buffer in the ith cell components{i} = strtrim(buffer); % Remove trailing spaces disp(i);endx998 = calllib('PhreeqcRMd','RM_CloseFiles',id)x999 = calllib('PhreeqcRMd','RM_Destroy',id)unloadlibrary PhreeqcRMd
% Loop over componentsfor i = 1:ncomps disp(i); buffer = blanks(bufferSize); % Call the library function to get the component name [x6, buffer] = calllib('PhreeqcRMd', 'RM_GetComponent', id, i-1, buffer, bufferSize); disp(buffer) % Store the modified buffer in the ith cell components{i} = strtrim(buffer); % Remove trailing spaces disp(i);end
componentscomponents = 1?12 cell array Columns 1 through 11 {'H'} {'O'} {'Charge'} {'Al'} {'C'} {'Ca'} {'Charge'} {'Cl'} {'Fe'} {'Mg'} {'Na'} Column 12 {'Si'}
KNOBS-iterations 500-convergence_tolerance 1e-8-step_size 20ENDSOLUTION 0 formation water units mol/kgw Na 0.5 Cl 0.5EQUILIBRIUM_PHASES 0 CO2(g) 1.0 100SAVE solution 0ENDSOLUTION 1 formation water units mol/kgw #Na 0.00001 #Cl 0.00001EQUILIBRIUM_PHASES 1 Albite 0 1499 Anorthite 0 6347 Forsterite 0 12086 Fayalite 0 2746 Diopside 0 295SAVE SOLUTION 1ENDRATES############Fayalite###########Fayalite# from Palandri and Kharaka 2004# experimental condition range T=8-25C, pH=1.3-11-start1 rem unit should be mol,kgw-1 and second-12 rem parm(1) is surface area in the unit of m2/kgw3 rem calculation of surface area can be found in the note 4 rem M is current moles of minerals. M0 is the initial moles of minerals5 rem parm(2) is a correction factor10 rem acid solution parameters11 a1=5.48E+1112 E1=9440013 n1=020 rem neutral solution parameters21 a2=5.48E+0222 E2=9440030 rem base solution parameters31 a3=032 E3=033 n2=036 rem rate=0 if no minerals and undersaturated40 SR_mineral=SR("Fayalite")41 if (M<0) then goto 20042 if (M=0 and SR_mineral<1) then goto 20043 if (M0<=0) then SA=PARM(1) else SA=PARM(1)*(M/M0)^0.6750 if (SA<=0) then SA=160 R=8.3145175 Rate1=a1*EXP(-E1/R/TK)*ACT("H+")^n1 #acid rate expression80 Rate2=a2*EXP(-E2/R/TK) #neutral rate expression85 Rate3=a3*EXP(-E3/R/TK)*ACT("H+")^n2 #base rate expression90 Rate=(Rate1+Rate2+Rate3)*(1-Sr_mineral)*SA*parm(2)100 moles= rate*Time200 save moles-end#############forsterite############Forsterite# from Palandri and Kharaka 2004# experimental condition range T=25-65C, pH=2-12-start1 rem unit should be mol,kgw-1 and second-12 rem parm(1) is surface area in the unit of m2/kgw3 rem calculation of surface area can be found in the note 4 rem M is current moles of minerals. M0 is the initial moles of minerals5 rem parm(2) is a correction factor10 rem acid solution parameters11 a1=8.38E+04 12 E1=6720613 n1=0.47020 rem neutral solution parameters21 a2=1.58E+03 22 E2=7900030 rem base solution parameters31 a3=1.00E-07 32 E3=5663733 n2=-0.60036 rem rate=0 if no minerals and undersaturated40 SR_mineral=SR("forsterite")41 if (M<0) then goto 20042 if (M=0 and SR_mineral<1) then goto 20043 if (M0<=0) then SA=PARM(1) else SA=PARM(1)*(M/M0)^0.6750 if (SA<=0) then SA=160 R=8.3145175 Rate1=a1*EXP(-E1/R/TK)*ACT("H+")^n1 #acid rate expression80 Rate2=a2*EXP(-E2/R/TK) #neutral rate expression85 Rate3=a3*EXP(-E3/R/TK)*ACT("H+")^n2 #base rate expression90 Rate=(Rate1+Rate2+Rate3)*(1-Sr_mineral)*SA*parm(2)100 moles= rate*Time200 save moles-end###############diopside#############Diopside# from Palandri and Kharaka 2004# experimental condition range T=8-90C, pH=1-6-start1 rem unit should be mol,kgw-1 and second-12 rem parm(1) is surface area in the unit of m2/kgw3 rem calculation of surface area can be found in the note 4 rem M is current moles of minerals. M0 is the initial moles of minerals5 rem parm(2) is a correction factor10 rem acid solution parameters11 a1=3.00E+10 12 E1=9610013 n1=0.71020 rem neutral solution parameters21 a2=1.00E-04 22 E2=4060030 rem base solution parameters31 a3=032 E3=033 n2=036 rem rate=0 if no minerals and undersaturated40 SR_mineral=SR("diopside")41 if (M<0) then goto 20042 if (M=0 and SR_mineral<1) then goto 20043 if (M0<=0) then SA=PARM(1) else SA=PARM(1)*(M/M0)^0.6750 if (SA<=0) then SA=160 R=8.3145175 Rate1=a1*EXP(-E1/R/TK)*ACT("H+")^n1 #acid rate expression80 Rate2=a2*EXP(-E2/R/TK) #neutral rate expression85 Rate3=a3*EXP(-E3/R/TK)*ACT("H+")^n2 #base rate expression90 Rate=(Rate1+Rate2+Rate3)*(1-Sr_mineral)*SA*parm(2)100 moles= rate*Time200 save moles-end############Albite###########Albite-start1 rem unit should be mol,Liter-1 and second-12 rem parm(1) is surface area in the unit of m2/L 3 rem calculation of surface area can be found in the note 4 rem M is current moles of minerals M0 is the initial moles of minerals5 rem parm(2) is a correction factor for fields rate relative to lab rate10 rem acid solution parameters11 a1=1.45E+0 12 E1=5840013 n1=0.33520 rem neutral solution parameters21 a2=4.97E-1022 E2=5700030 rem base solution parameters31 a3=7.15E-01 32 E3=5550033 n2=0.31736 rem rate=0 if no minerals and undersaturated40 SR_mineral=SR("Albite")41 if (M<0) then goto 20042 if (M=0 and SR_mineral<1) then goto 20043 if (M0<=0) then SA=PARM(1) else SA=PARM(1)*(M/M0)^0.6750 if (SA<=0) then SA=160 R=8.3145175 Rate1=a1*EXP(-E1/R/TK)*ACT("H+")^n1 #acid rate expression80 Rate2=a2*EXP(-E2/R/TK) #neutral rate expression85 Rate3=a3*EXP(-E3/R/TK)*ACT("OH-")^n2 #base rate expression90 Rate=(Rate1+Rate2+Rate3)*(1-Sr_mineral)*SA*parm(2)100 moles= rate*Time110 rem do not dissolve more minerals than present115 if (moles>M) then moles=M200 save moles-end###############anorthite##############Anorthite# from Palandri and Kharaka 2004# experimental condition range T=25-95C, pH=2-10.2-start1 rem unit should be mol,kgw-1 and second-12 rem parm(1) is surface area in the unit of m2/kgw3 rem calculation of surface area can be found in the note 4 rem M is current moles of minerals. M0 is the initial moles of minerals5 rem parm(2) is a correction factor10 rem acid solution parameters11 a1=2.58E-01 12 E1=1660113 n1=1.41120 rem neutral solution parameters21 a2=1.00E-06 22 E2=1782130 rem base solution parameters31 a3=1.00E-22 32 E3=1815033 n2=-1.76736 rem rate=0 if no minerals and undersaturated40 SR_mineral=SR("anorthite")41 if (M<0) then goto 20042 if (M=0 and SR_mineral<1) then goto 20043 if (M0<=0) then SA=PARM(1) else SA=PARM(1)*(M/M0)^0.6750 if (SA<=0) then SA=160 R=8.3145175 Rate1=a1*EXP(-E1/R/TK)*ACT("H+")^n1 #acid rate expression80 Rate2=a2*EXP(-E2/R/TK) #neutral rate expression85 Rate3=a3*EXP(-E3/R/TK)*ACT("H+")^n2 #base rate expression90 Rate=(Rate1+Rate2+Rate3)*(1-Sr_mineral)*SA*parm(2)100 moles= rate*Time200 save moles-endKINETICS 0 define kinetic parametersFayalite -m 2.746#24.9 -m0 2.746#24.9 -parms 0.002 1Forsterite -m 12.086 -m0 12.086 -parms 0.002 1 Albite -m 14.99 -m0 14.99 -parms 0.002 1Anorthite -m 6.347 -m0 6.347 -parms 0.002 1 Diopside -m 29.5 -m0 29.5 -parms 0.002 1 ENDSELECTED_OUTPUT-reset false-high_precision true#-molalities Na+ Cl- H2OUSER_PUNCH -head rho pH molarity delta1 delta2 delta3 delta4 carbonates SI water 10 PUNCH RHO 20 PUNCH -LA("H+") 30 PUNCH MOL("Fe+2") 40 PUNCH MOL("Mg+2") 50 PUNCH MOL("Ca+2") 60 PUNCH KIN_DELTA("Fayalite") 70 PUNCH KIN_DELTA("Forsterite") 80 PUNCH KIN_DELTA("Diopside") 90 PUNCH KIN_DELTA("Anorthite") 100 PUNCH MOL("MgCO3")+MOL("FeCO3")+MOL("CaCO3") 110 PUNCH SI("Calcite") 120 PUNCH MOL("H2O")END
status = phreeqc_rm.SetComponentH2O(true); ncomps = phreeqc_rm.FindComponents(); status = phreeqc_rm.SetComponentH2O(false); ncomps = phreeqc_rm.FindComponents();
Warning: The function 'RM_BmiInitialize' was not found in the library > In loadlibraryIn li (line 4)