Chemical.DB='phreeqc.dat';Chemical.CH={'Ca','Cl','K','N','Na','O(0)'}';PStr1=sprintf(['SOLUTION 1\n', ... '-units mol/L\n', ... 'pH 7 charge\n', ... 'Ca 0.0006\n', ... 'Cl 0.0012\n', ... 'O(0) 1e-5\n']);PStr2=sprintf(['SOLUTION_MODIFY 1\n',... '-totals\n',... 'Ca 0.005\n',... 'Cl 0.003\n',... 'K 0.02\n',... 'N 0\n',... 'Na 0\n',... 'O(0) 1.000066756e-05\n',... 'temp 32.400000\n']);STR = sprintf(['SELECTED_OUTPUT\n', ... '-reset false\n', ... '-time\n',... '-high_precision true\n', ... '-solution\n',... '-water\n',... '-pH\n',... '-pe\n',... '-charge_balance\n',... '-percent_error\n',... '-equilibrium_phases Calcite\n',... '-saturation_indices Calcite\n',... '-molalities NaX CaX X-\n',... 'USER_PUNCH\n', ... ['headings', ' density', cell2mat(strcat({' '},Chemical.CH')), '\n'], ... '-start\n', ... ['10 punch', ' rho,', cell2mat(strcat({' totmol("'},Chemical.CH',{'"),'})), '\n'], ... '-end\n', ... 'END\n']);[b]%% case1) using a single Iphreeqc obeject w/o INCLUDE$ dumpfile[/b]iphreeqc = actxserver('IPhreeqcCOM.Object');iphreeqc.LoadDatabase(fullfile(cd, 'Phreeqc_DB', Chemical.DB));iphreeqc.DumpFileOn = true;iphreeqc.RunString(PStr1); %SOLUTIONiphreeqc.RunString(STR); %SELECTED_OUTiphreeqc.AccumulateLine('RUN_CELLS');iphreeqc.AccumulateLine('-cells 1');iphreeqc.AccumulateLine('-time_step 0');iphreeqc.AccumulateLine('DUMP')iphreeqc.AccumulateLine('-file dump_initial')iphreeqc.AccumulateLine('-all')iphreeqc.RunAccumulated;output_inital=iphreeqc.GetSelectedOutputArray;iphreeqc.ClearAccumulatedLines;iphreeqc.AccumulateLine(PStr2); %SOLUTION_MODIFYiphreeqc.AccumulateLine('RUN_CELLS');iphreeqc.AccumulateLine('-cells 1');iphreeqc.AccumulateLine('DUMP')iphreeqc.AccumulateLine('-file dump_output1')iphreeqc.AccumulateLine('-all')iphreeqc.RunAccumulated;output1=iphreeqc.GetSelectedOutputArray;[b]%% case2) reset iphreeqc object w/ INCLUDE$ dumpfile[/b]iphreeqc.delete;iphreeqc = actxserver('IPhreeqcCOM.Object');iphreeqc.LoadDatabase(fullfile(cd, 'Phreeqc_DB', Chemical.DB));iphreeqc.DumpFileOn = true;iphreeqc.RunString('INCLUDE$ dump_initial') %INITIALIZE the solution compositions iphreeqc.AccumulateLine(PStr2); %SOLUTION_MODIFYiphreeqc.AccumulateLine(STR); %SELECTED_OUTiphreeqc.AccumulateLine('RUN_CELLS');iphreeqc.AccumulateLine('-cells 1');iphreeqc.AccumulateLine('DUMP')iphreeqc.AccumulateLine('-file dump_output2')iphreeqc.AccumulateLine('-all')iphreeqc.RunAccumulated;output2=iphreeqc.GetSelectedOutputArray;