pyEQL 1.4.0rc9__cp311-cp311-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (491) hide show
  1. pyEQL/__init__.py +50 -0
  2. pyEQL/_phreeqc.cpython-311-darwin.so +0 -0
  3. pyEQL/activity_correction.py +879 -0
  4. pyEQL/database/geothermal.dat +5693 -0
  5. pyEQL/database/llnl.dat +19305 -0
  6. pyEQL/database/phreeqc_license.txt +54 -0
  7. pyEQL/database/pyeql_db.json +35607 -0
  8. pyEQL/engines.py +1153 -0
  9. pyEQL/equilibrium.py +227 -0
  10. pyEQL/functions.py +281 -0
  11. pyEQL/phreeqc/__init__.py +5 -0
  12. pyEQL/phreeqc/bindings.cpp +84 -0
  13. pyEQL/phreeqc/core.py +239 -0
  14. pyEQL/phreeqc/database/Amm.dat +1968 -0
  15. pyEQL/phreeqc/database/CMakeLists.txt +32 -0
  16. pyEQL/phreeqc/database/ColdChem.dat +267 -0
  17. pyEQL/phreeqc/database/Concrete_PHR.dat +158 -0
  18. pyEQL/phreeqc/database/Concrete_PZ.dat +195 -0
  19. pyEQL/phreeqc/database/Kinec.v2.dat +12039 -0
  20. pyEQL/phreeqc/database/Kinec_v3.dat +12159 -0
  21. pyEQL/phreeqc/database/Makefile.am +28 -0
  22. pyEQL/phreeqc/database/Makefile.in +530 -0
  23. pyEQL/phreeqc/database/PHREEQC_ThermoddemV1.10_15Dec2020.dat +12965 -0
  24. pyEQL/phreeqc/database/Tipping_Hurley.dat +4137 -0
  25. pyEQL/phreeqc/database/__init__.py +0 -0
  26. pyEQL/phreeqc/database/core10.dat +6824 -0
  27. pyEQL/phreeqc/database/frezchem.dat +634 -0
  28. pyEQL/phreeqc/database/iso.dat +7235 -0
  29. pyEQL/phreeqc/database/llnl.dat +19310 -0
  30. pyEQL/phreeqc/database/minteq.dat +5654 -0
  31. pyEQL/phreeqc/database/minteq.v4.dat +13212 -0
  32. pyEQL/phreeqc/database/phreeqc.dat +1972 -0
  33. pyEQL/phreeqc/database/phreeqc_rates.dat +3158 -0
  34. pyEQL/phreeqc/database/pitzer.dat +1044 -0
  35. pyEQL/phreeqc/database/sit.dat +14348 -0
  36. pyEQL/phreeqc/database/wateq4f.dat +4036 -0
  37. pyEQL/phreeqc/ext/README.md +10 -0
  38. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/CMakeLists.txt +476 -0
  39. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/INSTALL +302 -0
  40. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/IPhreeqc.rc +61 -0
  41. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/IPhreeqcConfig.cmake.in +4 -0
  42. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/Makefile.am +8 -0
  43. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/Makefile.in +816 -0
  44. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/aclocal.m4 +1217 -0
  45. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/CTestScript.cmake +167 -0
  46. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/CSelectedOutput.cpp.o +0 -0
  47. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/IPhreeqc.cpp.o +0 -0
  48. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/IPhreeqcLib.cpp.o +0 -0
  49. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/IPhreeqc_interface_F.cpp.o +0 -0
  50. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/Var.c.o +0 -0
  51. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/Dictionary.cpp.o +0 -0
  52. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/ExchComp.cxx.o +0 -0
  53. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/Exchange.cxx.o +0 -0
  54. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/GasComp.cxx.o +0 -0
  55. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/GasPhase.cxx.o +0 -0
  56. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/ISolution.cxx.o +0 -0
  57. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/ISolutionComp.cxx.o +0 -0
  58. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/KineticsComp.cxx.o +0 -0
  59. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/NameDouble.cxx.o +0 -0
  60. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/NumKeyword.cxx.o +0 -0
  61. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/PBasic.cpp.o +0 -0
  62. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/PHRQ_io_output.cpp.o +0 -0
  63. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/PPassemblage.cxx.o +0 -0
  64. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/PPassemblageComp.cxx.o +0 -0
  65. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/Phreeqc.cpp.o +0 -0
  66. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/PhreeqcKeywords/Keywords.cpp.o +0 -0
  67. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/Pressure.cxx.o +0 -0
  68. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/Reaction.cxx.o +0 -0
  69. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/ReadClass.cxx.o +0 -0
  70. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/SS.cxx.o +0 -0
  71. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/SSassemblage.cxx.o +0 -0
  72. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/SScomp.cxx.o +0 -0
  73. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/SelectedOutput.cpp.o +0 -0
  74. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/Serializer.cxx.o +0 -0
  75. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/Solution.cxx.o +0 -0
  76. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/SolutionIsotope.cxx.o +0 -0
  77. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/StorageBin.cxx.o +0 -0
  78. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/StorageBinList.cpp.o +0 -0
  79. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/Surface.cxx.o +0 -0
  80. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/SurfaceCharge.cxx.o +0 -0
  81. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/SurfaceComp.cxx.o +0 -0
  82. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/System.cxx.o +0 -0
  83. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/Temperature.cxx.o +0 -0
  84. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/Use.cpp.o +0 -0
  85. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/UserPunch.cpp.o +0 -0
  86. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/advection.cpp.o +0 -0
  87. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/basicsubs.cpp.o +0 -0
  88. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/cl1.cpp.o +0 -0
  89. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/common/PHRQ_base.cxx.o +0 -0
  90. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/common/PHRQ_io.cpp.o +0 -0
  91. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/common/Parser.cxx.o +0 -0
  92. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/common/Utils.cxx.o +0 -0
  93. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/cvdense.cpp.o +0 -0
  94. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/cvode.cpp.o +0 -0
  95. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/cxxKinetics.cxx.o +0 -0
  96. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/cxxMix.cxx.o +0 -0
  97. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/dense.cpp.o +0 -0
  98. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/dumper.cpp.o +0 -0
  99. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/gases.cpp.o +0 -0
  100. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/input.cpp.o +0 -0
  101. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/integrate.cpp.o +0 -0
  102. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/inverse.cpp.o +0 -0
  103. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/isotopes.cpp.o +0 -0
  104. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/kinetics.cpp.o +0 -0
  105. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/mainsubs.cpp.o +0 -0
  106. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/model.cpp.o +0 -0
  107. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/nvector.cpp.o +0 -0
  108. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/nvector_serial.cpp.o +0 -0
  109. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/parse.cpp.o +0 -0
  110. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/phqalloc.cpp.o +0 -0
  111. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/pitzer.cpp.o +0 -0
  112. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/pitzer_structures.cpp.o +0 -0
  113. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/prep.cpp.o +0 -0
  114. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/print.cpp.o +0 -0
  115. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/read.cpp.o +0 -0
  116. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/readtr.cpp.o +0 -0
  117. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/runner.cpp.o +0 -0
  118. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/sit.cpp.o +0 -0
  119. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/smalldense.cpp.o +0 -0
  120. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/spread.cpp.o +0 -0
  121. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/step.cpp.o +0 -0
  122. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/structures.cpp.o +0 -0
  123. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/sundialsmath.cpp.o +0 -0
  124. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/tally.cpp.o +0 -0
  125. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/tidy.cpp.o +0 -0
  126. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/transport.cpp.o +0 -0
  127. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CMakeFiles/IPhreeqc.dir/src/phreeqcpp/utilities.cpp.o +0 -0
  128. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/CTestTestfile.cmake +6 -0
  129. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/DartConfiguration.tcl +109 -0
  130. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/cmake_install.cmake +45 -0
  131. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/build/libIPhreeqc.a +0 -0
  132. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/config/ar-lib +270 -0
  133. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/config/compile +347 -0
  134. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/config/config.guess +1441 -0
  135. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/config/config.sub +1813 -0
  136. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/config/depcomp +791 -0
  137. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/config/install-sh +508 -0
  138. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/config/ltmain.sh +11156 -0
  139. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/config/missing +215 -0
  140. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/config/test-driver +148 -0
  141. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/configure +23867 -0
  142. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/configure.ac +136 -0
  143. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/Amm.dat +1968 -0
  144. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/CMakeLists.txt +32 -0
  145. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/ColdChem.dat +267 -0
  146. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/Concrete_PHR.dat +158 -0
  147. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/Concrete_PZ.dat +195 -0
  148. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/Kinec.v2.dat +12039 -0
  149. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/Kinec_v3.dat +12159 -0
  150. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/Makefile.am +28 -0
  151. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/Makefile.in +530 -0
  152. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/PHREEQC_ThermoddemV1.10_15Dec2020.dat +12965 -0
  153. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/Tipping_Hurley.dat +4137 -0
  154. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/core10.dat +6824 -0
  155. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/frezchem.dat +634 -0
  156. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/iso.dat +7235 -0
  157. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/llnl.dat +19310 -0
  158. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/minteq.dat +5654 -0
  159. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/minteq.v4.dat +13212 -0
  160. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/phreeqc.dat +1972 -0
  161. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/phreeqc_rates.dat +3158 -0
  162. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/pitzer.dat +1044 -0
  163. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/sit.dat +14348 -0
  164. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/database/wateq4f.dat +4036 -0
  165. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/CMakeLists.txt +35 -0
  166. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/IPhreeqc.pdf +0 -0
  167. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/Makefile.am +24 -0
  168. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/Makefile.in +545 -0
  169. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/NOTICE +51 -0
  170. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/Phreeqc_2_1999_manual.pdf +0 -0
  171. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/Phreeqc_3_2013_manual.pdf +0 -0
  172. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/README +428 -0
  173. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/RELEASE +7294 -0
  174. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/IPhreeqc_8h.html +5096 -0
  175. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/IPhreeqc_8h_source.html +389 -0
  176. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/IPhreeqc_8hpp.html +83 -0
  177. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/IPhreeqc_8hpp_source.html +478 -0
  178. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/Var_8h.html +318 -0
  179. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/Var_8h_source.html +200 -0
  180. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/bc_s.png +0 -0
  181. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/bdwn.png +0 -0
  182. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/classIPhreeqc.html +2274 -0
  183. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/classIPhreeqc.png +0 -0
  184. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/classIPhreeqcStop.html +69 -0
  185. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/classIPhreeqcStop.png +0 -0
  186. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/closed.png +0 -0
  187. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html +68 -0
  188. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/doxygen.css +1440 -0
  189. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/doxygen.png +0 -0
  190. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/dynsections.js +97 -0
  191. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2blank.png +0 -0
  192. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2doc.png +0 -0
  193. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2folderclosed.png +0 -0
  194. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2folderopen.png +0 -0
  195. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2lastnode.png +0 -0
  196. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2link.png +0 -0
  197. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2mlastnode.png +0 -0
  198. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2mnode.png +0 -0
  199. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2node.png +0 -0
  200. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2plastnode.png +0 -0
  201. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2pnode.png +0 -0
  202. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2splitbar.png +0 -0
  203. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/ftv2vertline.png +0 -0
  204. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/index.html +58 -0
  205. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/jquery.js +31 -0
  206. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/nav_f.png +0 -0
  207. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/nav_g.png +0 -0
  208. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/nav_h.png +0 -0
  209. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/open.png +0 -0
  210. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/structVAR.html +143 -0
  211. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/sync_off.png +0 -0
  212. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/sync_on.png +0 -0
  213. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/tab_a.png +0 -0
  214. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/tab_b.png +0 -0
  215. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/tab_h.png +0 -0
  216. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/tab_s.png +0 -0
  217. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/html/tabs.css +60 -0
  218. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/doc/phreeqc3.chm +0 -0
  219. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/CMakeLists.txt +11 -0
  220. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/Makefile.am +88 -0
  221. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/Makefile.in +696 -0
  222. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/c/CMakeLists.txt +1 -0
  223. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/c/advect/CMakeLists.txt +35 -0
  224. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/c/advect/CMakeLists.txt.in +21 -0
  225. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/c/advect/README.txt +44 -0
  226. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/c/advect/advect.c +101 -0
  227. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/c/advect/ic +17 -0
  228. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/c/advect/phreeqc.dat +1579 -0
  229. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/com/CMakeLists.txt +10 -0
  230. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/com/README.txt +3 -0
  231. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/com/excel/CMakeLists.txt +9 -0
  232. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/com/excel/phreeqc.dat +1582 -0
  233. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/com/excel/runphreeqc.xls +0 -0
  234. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/com/excel/withcallback.xls +0 -0
  235. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/com/python/CMakeLists.txt +11 -0
  236. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/com/python/Gypsum.py +52 -0
  237. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/com/python/parallel_advect.py +465 -0
  238. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/com/python/phreeqc.dat +1582 -0
  239. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/com/python/pitzer.dat +790 -0
  240. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/com/python/wateq4f.dat +3846 -0
  241. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/cpp/CMakeLists.txt +1 -0
  242. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/cpp/advect/CMakeLists.txt +35 -0
  243. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/cpp/advect/CMakeLists.txt.in +20 -0
  244. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/cpp/advect/README.txt +45 -0
  245. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/cpp/advect/advect.cpp +110 -0
  246. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/cpp/advect/ic +17 -0
  247. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/cpp/advect/phreeqc.dat +1579 -0
  248. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/fortran/CMakeLists.txt +1 -0
  249. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/fortran/advect/CMakeLists.txt +44 -0
  250. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/fortran/advect/CMakeLists.txt.in +24 -0
  251. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/fortran/advect/README.txt +45 -0
  252. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/fortran/advect/advect.F90 +102 -0
  253. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/fortran/advect/ic +17 -0
  254. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/fortran/advect/phreeqc.dat +1579 -0
  255. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/using-cmake/CMakeLists.txt +26 -0
  256. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/using-cmake/CMakeLists.txt.in +20 -0
  257. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/using-cmake/README.txt +37 -0
  258. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/using-cmake/ex2 +26 -0
  259. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/using-cmake/main.cpp +20 -0
  260. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/using-cmake/phreeqc.dat +1837 -0
  261. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/examples/using-cmake/post-install.cmake.in +7 -0
  262. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/CMakeLists.txt +185 -0
  263. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/FileTest.cpp +171 -0
  264. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/FileTest.h +34 -0
  265. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/Makefile.am +18 -0
  266. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/Makefile.in +466 -0
  267. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/TestCVar.cpp +9 -0
  268. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/TestIPhreeqc.cpp +4901 -0
  269. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/TestIPhreeqcLib.cpp +4644 -0
  270. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/TestSelectedOutput.cpp +669 -0
  271. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/TestVar.cpp +10 -0
  272. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/conv_fail.in +11 -0
  273. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/dump +42 -0
  274. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/iso.dat +7231 -0
  275. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/kinn20140218 +349 -0
  276. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/missing_e.dat +1556 -0
  277. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/multi_punch +105 -0
  278. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/multi_punch_no_set +102 -0
  279. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/phreeqc.dat.90a6449 +1935 -0
  280. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/gtest/phreeqc.dat.old +1556 -0
  281. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/m4/libtool.m4 +8388 -0
  282. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/m4/ltoptions.m4 +437 -0
  283. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/m4/ltsugar.m4 +124 -0
  284. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/m4/ltversion.m4 +23 -0
  285. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/m4/lt~obsolete.m4 +99 -0
  286. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/resource.h +14 -0
  287. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/CSelectedOutput.cpp +401 -0
  288. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/CSelectedOutput.hxx +77 -0
  289. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/CVar.hxx +162 -0
  290. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/Debug.h +12 -0
  291. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/ErrorReporter.hxx +70 -0
  292. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/IPhreeqc.cpp +1889 -0
  293. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/IPhreeqc.f.inc +91 -0
  294. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/IPhreeqc.f90.inc +603 -0
  295. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/IPhreeqc.h +2182 -0
  296. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/IPhreeqc.hpp +1027 -0
  297. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/IPhreeqcCallbacks.h +19 -0
  298. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/IPhreeqcF.f +653 -0
  299. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/IPhreeqcLib.cpp +1098 -0
  300. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/IPhreeqc_interface.F90 +1283 -0
  301. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/IPhreeqc_interface_F.cpp +535 -0
  302. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/IPhreeqc_interface_F.h +162 -0
  303. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/Makefile.am +210 -0
  304. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/Makefile.in +1294 -0
  305. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/README.Fortran +17 -0
  306. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/Var.c +84 -0
  307. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/Var.h +152 -0
  308. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/Version.h +36 -0
  309. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/fimpl.h +282 -0
  310. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/fwrap.cpp +646 -0
  311. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/fwrap.h +163 -0
  312. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/fwrap1.cpp +24 -0
  313. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/fwrap2.cpp +24 -0
  314. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/fwrap3.cpp +24 -0
  315. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/fwrap4.cpp +24 -0
  316. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/fwrap5.cpp +24 -0
  317. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/fwrap6.cpp +25 -0
  318. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/fwrap7.cpp +25 -0
  319. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/fwrap8.cpp +24 -0
  320. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/ChartHandler.cpp +225 -0
  321. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/ChartHandler.h +59 -0
  322. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/ChartObject.cpp +1382 -0
  323. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/ChartObject.h +444 -0
  324. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/CurveObject.cpp +42 -0
  325. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/CurveObject.h +79 -0
  326. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Dictionary.cpp +41 -0
  327. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Dictionary.h +28 -0
  328. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/ExchComp.cxx +398 -0
  329. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/ExchComp.h +117 -0
  330. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Exchange.cxx +466 -0
  331. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Exchange.h +74 -0
  332. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Form1.h +1184 -0
  333. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Form1.resX +36 -0
  334. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/GasComp.cxx +265 -0
  335. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/GasComp.h +59 -0
  336. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/GasPhase.cxx +659 -0
  337. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/GasPhase.h +103 -0
  338. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/ISolution.cxx +40 -0
  339. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/ISolution.h +53 -0
  340. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/ISolutionComp.cxx +202 -0
  341. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/ISolutionComp.h +138 -0
  342. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/KineticsComp.cxx +318 -0
  343. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/KineticsComp.h +81 -0
  344. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/NA.h +1 -0
  345. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/NameDouble.cxx +537 -0
  346. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/NameDouble.h +66 -0
  347. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/NumKeyword.cxx +190 -0
  348. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/NumKeyword.h +67 -0
  349. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/PBasic.cpp +8350 -0
  350. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/PBasic.h +572 -0
  351. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/PHRQ_io_output.cpp +411 -0
  352. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/PPassemblage.cxx +375 -0
  353. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/PPassemblage.h +70 -0
  354. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/PPassemblageComp.cxx +441 -0
  355. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/PPassemblageComp.h +83 -0
  356. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Phreeqc.cpp +2087 -0
  357. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Phreeqc.h +2164 -0
  358. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/PhreeqcKeywords/Keywords.cpp +242 -0
  359. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/PhreeqcKeywords/Keywords.h +104 -0
  360. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Pressure.cxx +417 -0
  361. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Pressure.h +43 -0
  362. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Reaction.cxx +284 -0
  363. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Reaction.h +57 -0
  364. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/ReadClass.cxx +1150 -0
  365. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SS.cxx +609 -0
  366. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SS.h +128 -0
  367. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SSassemblage.cxx +317 -0
  368. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SSassemblage.h +59 -0
  369. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SScomp.cxx +297 -0
  370. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SScomp.h +66 -0
  371. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SelectedOutput.cpp +115 -0
  372. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SelectedOutput.h +209 -0
  373. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Serializer.cxx +213 -0
  374. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Serializer.h +42 -0
  375. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Solution.cxx +1795 -0
  376. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Solution.h +154 -0
  377. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SolutionIsotope.cxx +333 -0
  378. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SolutionIsotope.h +85 -0
  379. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/StorageBin.cxx +1507 -0
  380. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/StorageBin.h +141 -0
  381. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/StorageBinList.cpp +358 -0
  382. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/StorageBinList.h +81 -0
  383. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Surface.cxx +837 -0
  384. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Surface.h +108 -0
  385. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SurfaceCharge.cxx +617 -0
  386. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SurfaceCharge.h +137 -0
  387. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SurfaceComp.cxx +509 -0
  388. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/SurfaceComp.h +70 -0
  389. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/System.cxx +103 -0
  390. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/System.h +89 -0
  391. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Temperature.cxx +423 -0
  392. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Temperature.h +42 -0
  393. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Use.cpp +78 -0
  394. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/Use.h +159 -0
  395. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/UserPunch.cpp +32 -0
  396. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/UserPunch.h +39 -0
  397. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/ZedGraph.dll +0 -0
  398. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/advection.cpp +140 -0
  399. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/basicsubs.cpp +4333 -0
  400. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/cl1.cpp +881 -0
  401. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/common/PHRQ_base.cxx +117 -0
  402. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/common/PHRQ_base.h +48 -0
  403. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/common/PHRQ_exports.h +20 -0
  404. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/common/PHRQ_io.cpp +914 -0
  405. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/common/PHRQ_io.h +207 -0
  406. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/common/Parser.cxx +1331 -0
  407. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/common/Parser.h +310 -0
  408. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/common/Utils.cxx +263 -0
  409. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/common/Utils.h +29 -0
  410. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/common/phrqtype.h +18 -0
  411. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/cvdense.cpp +566 -0
  412. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/cvdense.h +267 -0
  413. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/cvode.cpp +3939 -0
  414. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/cvode.h +940 -0
  415. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/cxxKinetics.cxx +617 -0
  416. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/cxxKinetics.h +78 -0
  417. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/cxxMix.cxx +154 -0
  418. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/cxxMix.h +58 -0
  419. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/dense.cpp +175 -0
  420. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/dense.h +341 -0
  421. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/dumper.cpp +277 -0
  422. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/dumper.h +60 -0
  423. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/gases.cpp +748 -0
  424. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/global_structures.h +1672 -0
  425. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/input.cpp +133 -0
  426. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/integrate.cpp +1219 -0
  427. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/inverse.cpp +5135 -0
  428. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/isotopes.cpp +1813 -0
  429. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/kinetics.cpp +3180 -0
  430. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/mainsubs.cpp +2320 -0
  431. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/model.cpp +5843 -0
  432. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/nvector.cpp +272 -0
  433. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/nvector.h +485 -0
  434. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/nvector_serial.cpp +1032 -0
  435. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/nvector_serial.h +369 -0
  436. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/parse.cpp +1044 -0
  437. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/phqalloc.cpp +316 -0
  438. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/phqalloc.h +47 -0
  439. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/pitzer.cpp +2709 -0
  440. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/pitzer_structures.cpp +225 -0
  441. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/prep.cpp +6267 -0
  442. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/print.cpp +3673 -0
  443. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/read.cpp +10245 -0
  444. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/readtr.cpp +1495 -0
  445. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/runner.cpp +158 -0
  446. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/runner.h +33 -0
  447. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/sit.cpp +1684 -0
  448. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/smalldense.cpp +324 -0
  449. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/smalldense.h +261 -0
  450. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/spread.cpp +1309 -0
  451. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/step.cpp +1566 -0
  452. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/structures.cpp +3381 -0
  453. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/sundialsmath.cpp +133 -0
  454. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/sundialsmath.h +162 -0
  455. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/sundialstypes.h +183 -0
  456. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/tally.cpp +1288 -0
  457. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/tidy.cpp +5600 -0
  458. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/transport.cpp +6403 -0
  459. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/phreeqcpp/utilities.cpp +1339 -0
  460. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/src/thread.h +64 -0
  461. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/tests/CMakeLists.txt +133 -0
  462. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/tests/Makefile.am +45 -0
  463. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/tests/Makefile.in +1128 -0
  464. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/tests/ex2.in +26 -0
  465. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/tests/main.f90 +31 -0
  466. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/tests/main77.f +6 -0
  467. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/tests/main_fortran.cxx +8 -0
  468. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/tests/phreeqc.dat.in +1556 -0
  469. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/tests/test_c.c +148 -0
  470. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/tests/test_cxx.cxx +152 -0
  471. pyEQL/phreeqc/ext/iphreeqc-3.8.6-17100/tests/test_f90.F90 +328 -0
  472. pyEQL/phreeqc/iphreeqc_wrapper.cpp +75 -0
  473. pyEQL/phreeqc/solution.py +74 -0
  474. pyEQL/phreeqc/var.py +50 -0
  475. pyEQL/presets/Ringers lactate.yaml +20 -0
  476. pyEQL/presets/__init__.py +17 -0
  477. pyEQL/presets/normal saline.yaml +17 -0
  478. pyEQL/presets/rainwater.yaml +17 -0
  479. pyEQL/presets/seawater.yaml +29 -0
  480. pyEQL/presets/urine.yaml +26 -0
  481. pyEQL/presets/wastewater.yaml +21 -0
  482. pyEQL/py.typed +0 -0
  483. pyEQL/salt_ion_match.py +112 -0
  484. pyEQL/solute.py +163 -0
  485. pyEQL/solution.py +2714 -0
  486. pyEQL/utils.py +237 -0
  487. pyeql-1.4.0rc9.dist-info/METADATA +130 -0
  488. pyeql-1.4.0rc9.dist-info/RECORD +491 -0
  489. pyeql-1.4.0rc9.dist-info/WHEEL +6 -0
  490. pyeql-1.4.0rc9.dist-info/licenses/AUTHORS.md +21 -0
  491. pyeql-1.4.0rc9.dist-info/licenses/LICENSE.txt +20 -0
@@ -0,0 +1,4333 @@
1
+ #include "Phreeqc.h"
2
+ #include "phqalloc.h"
3
+
4
+ #include "Utils.h"
5
+ #include "NameDouble.h"
6
+ #include "PBasic.h"
7
+ #include "Exchange.h"
8
+ #include "GasPhase.h"
9
+ #include "PPassemblage.h"
10
+ #include "SSassemblage.h"
11
+ #include "cxxKinetics.h"
12
+ #include "Solution.h"
13
+ #include "Parser.h"
14
+
15
+ #if defined(_MSC_VER) && (_MSC_VER <= 1400) // VS2005
16
+ # define nullptr NULL
17
+ #endif
18
+
19
+ #if __cplusplus < 201103L // Check if C++ standard is pre-C++11
20
+ # ifndef nullptr
21
+ # define nullptr NULL
22
+ # endif
23
+ #endif
24
+
25
+ #if defined(PHREEQCI_GUI)
26
+ #ifdef _DEBUG
27
+ #define new DEBUG_NEW
28
+ #undef THIS_FILE
29
+ static char THIS_FILE[] = __FILE__;
30
+ #endif
31
+ #endif
32
+
33
+ /* ---------------------------------------------------------------------- */
34
+ LDBLE Phreeqc::
35
+ activity(const char *species_name)
36
+ /* ---------------------------------------------------------------------- */
37
+ {
38
+ class species *s_ptr;
39
+ LDBLE a;
40
+
41
+ s_ptr = s_search(species_name);
42
+ if (s_ptr == s_h2o)
43
+ {
44
+ a = pow((LDBLE) 10., s_h2o->la);
45
+ }
46
+ else if (s_ptr == s_eminus)
47
+ {
48
+ a = pow((LDBLE) 10., s_eminus->la);
49
+ }
50
+ else if (s_ptr == NULL || s_ptr->in == FALSE)
51
+ {
52
+ a = 1e-99;
53
+ }
54
+ else
55
+ {
56
+ a = pow((LDBLE) 10., s_ptr->lm + s_ptr->lg);
57
+ }
58
+ return (a);
59
+ }
60
+
61
+ /* ---------------------------------------------------------------------- */
62
+ LDBLE Phreeqc::
63
+ activity_coefficient(const char *species_name)
64
+ /* ---------------------------------------------------------------------- */
65
+ {
66
+ class species *s_ptr;
67
+ LDBLE g, dum = 0.0;
68
+
69
+ s_ptr = s_search(species_name);
70
+ if (s_ptr != NULL && s_ptr->in != FALSE && ((s_ptr->type < EMINUS) || (s_ptr->type == EX) || (s_ptr->type == SURF)))
71
+ {
72
+ if (s_ptr->type == EX && s_ptr->equiv && s_ptr->alk)
73
+ dum = log10(s_ptr->equiv / s_ptr->alk);
74
+ g = pow((LDBLE) 10., s_ptr->lg - dum);
75
+ }
76
+ else
77
+ {
78
+ g = 0;
79
+ }
80
+ return (g);
81
+ }
82
+
83
+ /* ---------------------------------------------------------------------- */
84
+ LDBLE Phreeqc::
85
+ log_activity_coefficient(const char *species_name)
86
+ /* ---------------------------------------------------------------------- */
87
+ {
88
+ class species *s_ptr;
89
+ LDBLE g, dum = 0.0;
90
+
91
+ s_ptr = s_search(species_name);
92
+ if (s_ptr != NULL && s_ptr->in != FALSE && ((s_ptr->type < EMINUS) || (s_ptr->type == EX) || (s_ptr->type == SURF)))
93
+ {
94
+ if (s_ptr->type == EX && s_ptr->equiv && s_ptr->alk)
95
+ dum = log10(s_ptr->equiv / s_ptr->alk);
96
+ g = s_ptr->lg - dum;
97
+ }
98
+ else
99
+ {
100
+ g = 0;
101
+ }
102
+ return (g);
103
+ }
104
+
105
+ /* ---------------------------------------------------------------------- */
106
+ LDBLE Phreeqc::
107
+ aqueous_vm(const char *species_name)
108
+ /* ---------------------------------------------------------------------- */
109
+ {
110
+ class species *s_ptr;
111
+ LDBLE g;
112
+
113
+ s_ptr = s_search(species_name);
114
+ if (s_ptr != NULL && s_ptr->in != FALSE && s_ptr->type < EMINUS)
115
+ {
116
+ g = s_ptr->logk[vm_tc];
117
+ }
118
+ else
119
+ {
120
+ g = 0;
121
+ }
122
+ return (g);
123
+ }
124
+ /* ---------------------------------------------------------------------- */
125
+ LDBLE Phreeqc::
126
+ phase_vm(const char *phase_name)
127
+ /* ---------------------------------------------------------------------- */
128
+ {
129
+ class phase *phase_ptr;
130
+ int l;
131
+ LDBLE g;
132
+
133
+ phase_ptr = phase_bsearch(phase_name, &l, FALSE);
134
+ if (phase_ptr == NULL)
135
+ {
136
+ g = 0.0;
137
+ }
138
+ else
139
+ {
140
+ g = phase_ptr->logk[vm0];
141
+ }
142
+ return (g);
143
+ }
144
+ /* ---------------------------------------------------------------------- */
145
+ LDBLE Phreeqc::
146
+ sa_declercq(double sa_type, double Sa, double d, double m, double m0, double gfw)
147
+ /* ---------------------------------------------------------------------- */
148
+ {
149
+ if (sa_type == 0)
150
+ {
151
+ // surface-area-calculation-Fixed_Surface
152
+ return Sa;
153
+ }
154
+ else if (sa_type == 1)
155
+ // surface-area-calculation-Square
156
+ {
157
+ double mass0 = m0 * gfw;
158
+ double V0 = mass0 / d;
159
+ double St0 = mass0 * Sa; // total surface
160
+ double a0 = pow(V0, 1.0/3.0); // side length
161
+ double Sp0 = 6.0 * a0*a0; // surface particle
162
+ double np = St0 / Sp0; // number of particles
163
+ double RATS = Sa / St0;
164
+ double mass = m * gfw;
165
+ double V = mass / d;
166
+ double a = pow(V, 1.0/3.0);
167
+ double St = 6.0 * a*a*np;
168
+ return St * RATS; // total current surface
169
+ }
170
+ else if (sa_type == 2)
171
+ {
172
+ //double pi = 3.14159265359;
173
+ double mass0 = m0 * gfw;
174
+ double V0 = mass0 / d; // volume
175
+ double St0 = mass0 * Sa; // total surface
176
+ double a0 = pow(3.0 * V0/(4.0 * pi), 1.0/3.0); // ((3*V0)/(4 * 3.14159265359))^(1/3)
177
+ double Sp0 = (4.0 * pi) * a0 * a0; // surface particle
178
+ double np = St0 / Sp0; // number of particles
179
+ double RATS = Sa / St0;
180
+
181
+ double mass = m * gfw;
182
+ double V = mass / d;
183
+ double a = pow(3.0 * V/(4.0 * pi), 1.0/3.0); //((3*V)/(4 * 3.14159265359))^(1/3)
184
+ double St = 4.0 * pi * a * a * np;
185
+ return St * RATS; // total current surface
186
+ }
187
+ error_string = sformatf( "Unknown surface area type in SA_DECLERCQ %d.", (int) sa_type);
188
+ error_msg(error_string, CONTINUE);
189
+ input_error++;
190
+ return (MISSING);
191
+ }
192
+
193
+ /* ---------------------------------------------------------------------- */
194
+ LDBLE Phreeqc::
195
+ diff_c(const char *species_name)
196
+ /* ---------------------------------------------------------------------- */
197
+ {
198
+ class species *s_ptr;
199
+ LDBLE Dw;
200
+
201
+ s_ptr = s_search(species_name);
202
+ if (s_ptr == NULL)
203
+ return(0);
204
+ if ((Dw = s_ptr->dw) == 0)
205
+ return(0);
206
+ if (correct_Dw)
207
+ {
208
+ calc_SC();
209
+ Dw = s_ptr->dw_corr;
210
+ }
211
+ else
212
+ {
213
+ if (tk_x != 298.15 && s_ptr->dw_t)
214
+ Dw *= exp(s_ptr->dw_t / tk_x - s_ptr->dw_t / 298.15);
215
+
216
+ Dw *= viscos_0_25 / viscos_0;
217
+ }
218
+ if (s_ptr->dw_a_v_dif && print_viscosity)
219
+ {
220
+ viscosity(nullptr);
221
+ Dw *= pow(viscos_0 / viscos, s_ptr->dw_a_v_dif);
222
+ }
223
+ return Dw;
224
+ }
225
+
226
+ /* ---------------------------------------------------------------------- */
227
+ LDBLE Phreeqc::
228
+ setdiff_c(const char *species_name, double d, double d_v_d)
229
+ /* ---------------------------------------------------------------------- */
230
+ {
231
+ class species *s_ptr;
232
+ LDBLE Dw;
233
+
234
+ s_ptr = s_search(species_name);
235
+ if (s_ptr == NULL)
236
+ return(0);
237
+ Dw = s_ptr->dw = d;
238
+ s_ptr->dw_a_v_dif = d_v_d;
239
+ if (correct_Dw)
240
+ {
241
+ calc_SC();
242
+ Dw = s_ptr->dw_corr;
243
+ }
244
+ else
245
+ {
246
+ if (tk_x != 298.15 && s_ptr->dw_t)
247
+ Dw *= exp(s_ptr->dw_t / tk_x - s_ptr->dw_t / 298.15);
248
+
249
+ Dw *= viscos_0_25 / viscos_0;
250
+ }
251
+ if (d_v_d && print_viscosity)
252
+ {
253
+ viscosity(nullptr);
254
+ Dw *= pow(viscos_0 / viscos, s_ptr->dw_a_v_dif);
255
+ }
256
+ return Dw;
257
+ }
258
+ /* ---------------------------------------------------------------------- */
259
+ LDBLE Phreeqc::
260
+ calc_SC(void)
261
+ /* ---------------------------------------------------------------------- */
262
+ {
263
+ class species *s_ptr;
264
+ int i;
265
+ LDBLE ka, l_z, Dw, ff, sqrt_mu, a, a2, a3, av, v_Cl = 1;
266
+ SC = 0;
267
+ sqrt_mu = sqrt(mu_x);
268
+ bool Falk = false;
269
+ s_ptr = s_search("H+");
270
+ if (s_ptr == NULL)
271
+ return(0);
272
+ else if (s_ptr->dw_a3 > 24) Falk = true;
273
+
274
+ //LDBLE ta1, ta2, ta3, ta4;
275
+ //for (i = 0; i < (int)this->s_x.size(); i++)
276
+ //{
277
+ // // ** for optimizing, get numbers from -analyt for H+ = H+...
278
+ // if (!strcmp(s_x[i]->name, "H+"))
279
+ // {
280
+ // ta1 = s_x[i]->logk[2] * 1e15;
281
+ // ta2 = s_x[i]->logk[3] * 1e15;
282
+ // ta3 = s_x[i]->logk[4] * 1e15;
283
+ // ta4 = s_x[i]->logk[5] * 1e15;
284
+ // break;
285
+ // }
286
+ //}
287
+ av = 0;
288
+ if (print_viscosity)
289
+ viscosity(nullptr);
290
+ if (!Falk)
291
+ {
292
+ for (i = 0; i < (int)this->s_x.size(); i++)
293
+ {
294
+ if (s_x[i]->type != AQ && s_x[i]->type != HPLUS)
295
+ continue;
296
+ if ((Dw = s_x[i]->dw) == 0)
297
+ {
298
+ if (correct_Dw)
299
+ Dw = default_Dw;
300
+ else
301
+ {
302
+ s_x[i]->dw_corr = 0;
303
+ continue;
304
+ }
305
+ }
306
+ if (s_x[i]->lm < min_dif_LM)
307
+ continue;
308
+ if (tk_x != 298.15)
309
+ {
310
+ if (s_x[i]->dw_t)
311
+ Dw *= exp(s_x[i]->dw_t / tk_x - s_x[i]->dw_t / 298.15);
312
+ //else
313
+ //{
314
+ // Dw *= exp(ta1 / tk_x - ta1 / 298.15);
315
+ //}
316
+ }
317
+ // correct for temperature dependent viscosity of pure water...
318
+ Dw *= viscos_0_25 / viscos_0;
319
+ s_x[i]->dw_corr = Dw;
320
+ if ((l_z = fabs(s_x[i]->z)) == 0)
321
+ {
322
+ //l_z = 1; // only a 1st approximation for correct_Dw in electrical field
323
+ continue;
324
+ }
325
+ else
326
+ {
327
+ s_ptr = s_x[i];
328
+ if (print_viscosity)
329
+ {
330
+ a = (s_ptr->dw_a ? s_ptr->dw_a : 1.6);
331
+ a2 = (s_ptr->dw_a2 ? s_ptr->dw_a2 : 4.73);
332
+ av = (s_ptr->dw_a_visc ? pow((viscos_0 / viscos), s_ptr->dw_a_visc) : 1);
333
+ a3 = (s_ptr->dw_a3 ? pow(mu_x, s_ptr->dw_a3) : s_ptr->dw_a_visc ? 1 : pow(mu_x, 0.75));
334
+ }
335
+ else
336
+ {
337
+ a = (s_ptr->dw_a ? s_ptr->dw_a : 1.6);
338
+ a2 = (s_ptr->dw_a2 ? s_ptr->dw_a2 : 4.73);
339
+ av = 1.0;
340
+ a3 = (s_ptr->dw_a3 ? pow(mu_x, s_ptr->dw_a3) : pow(mu_x, 0.75));
341
+ }
342
+ ka = DH_B * a2 * sqrt_mu / (1 + a3);
343
+ ff = av * exp(-a * DH_A * l_z * sqrt_mu / (1 + ka));
344
+ }
345
+
346
+ Dw *= ff;
347
+ if (correct_Dw)
348
+ s_x[i]->dw_corr = Dw;
349
+ s_x[i]->dw_t_SC = s_x[i]->moles / mass_water_aq_x * l_z * l_z * Dw;
350
+ SC += s_x[i]->dw_t_SC;
351
+ }
352
+ SC *= 1e7 * F_C_MOL * F_C_MOL / (R_KJ_DEG_MOL * 298150.0);
353
+ return (SC);
354
+ }
355
+ else
356
+ {
357
+ /* the phreeqc equation from Appelo, 2017, CCR 101, 102 with viscosity correction, e.g. for SO4-2 and its complexes:
358
+ Dw dw_t a a2 visc -5< a3 <5
359
+ -dw 1.07e-9 236 0.7281 3.452 -0.1515 -3.043 # obsolete
360
+ or
361
+ Debye-Onsager with (1 + ka)^2 in the denominator,
362
+ for the individual ions according to their contribution to mu, with sqrt charge multiplier for B2 and
363
+ a in ka corrected by volume (or mu^a2, if a3 = -10), and * (viscos_0 / viscos)^av
364
+ Dw dw_t a a2 visc a3 = (0) or >5
365
+ -dw 1.03e-9 -14 4.03 0.8341 1.679 # Li+, ka = DH_B * a * (1 + (vm - v0))^a2 * mu^0.5
366
+ */
367
+ LDBLE q, sqrt_q, B1, B2, m_plus, m_min, eq_plus, eq_min, eq_dw_plus, eq_dw_min, z_plus, z_min, t1, Dw_SC;
368
+
369
+ m_plus = m_min = eq_plus = eq_min = eq_dw_plus = eq_dw_min = z_plus = z_min = 0;
370
+ SC = 0;
371
+ LDBLE eps_c = eps_r; // Cl concentration corrected eps_r
372
+ // average z and Dw for transport numbers t1_0 and t2_0 at zero conc's, and q of the solution...
373
+ for (i = 0; i < (int)this->s_x.size(); i++)
374
+ {
375
+ if (s_x[i]->type != AQ && s_x[i]->type != HPLUS)
376
+ continue;
377
+ if (s_x[i]->lm < min_dif_LM)
378
+ continue;
379
+ if ((Dw = s_x[i]->dw) == 0)
380
+ {
381
+ if (correct_Dw)
382
+ Dw = default_Dw; // or charge based...Dw = l_z > 0 ? 1.6e-9 / l_z : 2e-9 / -l_z;
383
+ else
384
+ {
385
+ s_x[i]->dw_corr = 0;
386
+ continue;
387
+ }
388
+ }
389
+ if (tk_x != 298.15 && s_x[i]->dw_t)
390
+ Dw *= exp(s_x[i]->dw_t / tk_x - s_x[i]->dw_t / 298.15);
391
+ Dw *= viscos_0_25 / viscos_0;
392
+ s_x[i]->dw_corr = Dw;
393
+
394
+ if ((l_z = s_x[i]->z) == 0)
395
+ continue;
396
+
397
+ if (l_z > 0)
398
+ {
399
+ m_plus += s_x[i]->moles;
400
+ a = s_x[i]->moles * l_z;
401
+ eq_plus += a;
402
+ eq_dw_plus += a * Dw;
403
+ }
404
+ else
405
+ {
406
+ m_min += s_x[i]->moles;
407
+ a = s_x[i]->moles * l_z;
408
+ eq_min -= a;
409
+ eq_dw_min -= a * Dw;
410
+ }
411
+ }
412
+ // q = z1 * z2 / ((z2 * t1_0 + z1 * t2_0) * (z1 + z2));
413
+ // z1 = z_plus, z2 = z_min, t1_0 = (eq_dw_plus / m_plus) / (eq_dw_plus / m_plus + eq_dw_min / m_min)
414
+ //a = (eq_plus - eq_min) / 2;
415
+ //eq_min += a;
416
+ //eq_plus -= a;
417
+ z_plus = eq_plus / m_plus; // |av_z1|
418
+ z_min = eq_min / m_min; // |av_z2|
419
+ t1 = (eq_dw_plus / m_plus) / (eq_dw_plus / m_plus + eq_dw_min / m_min);
420
+ q = 1 / ((t1 / z_plus + (1 - t1) / z_min) * (z_min + z_plus));
421
+ sqrt_q = sqrt(q);
422
+
423
+ // B1 = relaxation, B2 = electrophoresis in ll = (ll0 - B2 * sqrt(mu) / f2(1 + ka)) * (1 - B1 * sqrt(mu) / f1(1 + ka))
424
+ a = 1.60218e-19 * 1.60218e-19 / (6 * pi);
425
+ B1 = a / (2 * 8.8542e-12 * eps_r * 1.38066e-23 * tk_x) * q / (1 + sqrt_q) * DH_B * 1e10 * z_plus * z_min; // DH_B is per Angstrom (*1e10)
426
+ B2 = a * AVOGADRO / viscos_0 * DH_B * 1e17; // DH_B per Angstrom (*1e10), viscos in mPa.s (*1e3), B2 in cm2 (*1e4)
427
+ //B1 = a / (2 * 8.8542e-12 * eps_c * 1.38066e-23 * tk_x) * q / (1 + sqrt_q) * DH_B * 1e10 * z_plus * z_min; // DH_B is per Angstrom (*1e10)
428
+ //B2 = a * AVOGADRO / viscos * DH_B * 1e17; // DH_B per Angstrom (*1e10), viscos in mPa.s (*1e3), B2 in cm2 (*1e4)
429
+
430
+ LDBLE mu_plus, mu_min, lz, ll_SC, v0;
431
+ // the + and - contributions to mu, assuming -2, -1, 1, 2 charge numbers...
432
+ mu_min = 3 * m_min * (z_min - 1) + m_min;
433
+ mu_plus = 3 * m_plus * (z_plus - 1) + m_plus;
434
+
435
+ Dw_SC = 1e4 * F_C_MOL * F_C_MOL / (R_KJ_DEG_MOL * 298.15e3); // for recalculating Dw to ll0
436
+ t1 = calc_solution_volume();
437
+ ll_SC = 0.5e3 * (eq_plus + eq_min) / t1 * mass_water_aq_x / t1; // recalculates ll to SC in uS/cm, with mu in mol/kgw
438
+
439
+ for (i = 0; i < (int)this->s_x.size(); i++)
440
+ {
441
+ if (s_x[i]->type != AQ && s_x[i]->type != HPLUS)
442
+ continue;
443
+ if ((lz = s_x[i]->z) == 0)
444
+ continue;
445
+ if (s_x[i]->lm < min_dif_LM)
446
+ continue;
447
+ if ((Dw = s_x[i]->dw_corr) == 0)
448
+ continue;
449
+ l_z = fabs(lz);
450
+ a3 = s_x[i]->dw_a3;
451
+ if (a3 != 0 && a3 > -5.01 && a3 < 4.99)
452
+ {
453
+ // with the phreeqc equation...
454
+ s_ptr = s_x[i];
455
+ a = (s_ptr->dw_a ? s_ptr->dw_a : 1.6);
456
+ a2 = (s_ptr->dw_a2 ? s_ptr->dw_a2 : 4.73);
457
+ a3 = pow(mu_x, a3);
458
+ if (print_viscosity)
459
+ av = (s_ptr->dw_a_visc ? pow((viscos_0 / viscos), s_ptr->dw_a_visc) : 1);
460
+ else
461
+ av = 1.0;
462
+ ka = DH_B * a2 * sqrt_mu / (1 + a3);
463
+ ff = av * exp(-a * DH_A * l_z * sqrt_mu / (1 + ka));
464
+
465
+ Dw *= ff;
466
+ if (correct_Dw)
467
+ s_x[i]->dw_corr = Dw;
468
+ s_x[i]->dw_t_SC = s_x[i]->moles / mass_water_aq_x * l_z * l_z * Dw;
469
+ SC += s_x[i]->dw_t_SC * 1e3 * Dw_SC;
470
+ }
471
+ else
472
+ {
473
+ // Falkenhagen...
474
+ if (!a3) a3 = 10;
475
+ a = (s_x[i]->dw_a ? s_x[i]->dw_a : 3.5);
476
+ a2 = (s_x[i]->dw_a2);// ? s_x[i]->dw_a2 : 0.5);
477
+ av = (s_x[i]->dw_a_visc);// ? s_x[i]->dw_a_visc : 0.8);
478
+ if (lz < -0.5/* && lz > -1.5*/)
479
+ {
480
+ // Mg and Ca give different numbers than H+, Li+, Na+ and K for anions...
481
+ t1 = (z_plus - 1);
482
+ //a -= a3 / 1000 * l_z * t1;
483
+ //a2 += a3 / 1000 * l_z * t1;
484
+ a -= 0.126 * l_z * t1;
485
+ a2 += 0.126 * l_z * t1;
486
+ //av += 0 * t1;
487
+ }
488
+ Dw *= Dw_SC * l_z;
489
+ if (!a2)
490
+ t1 = 1;
491
+ else if (!strcmp(s_x[i]->name, "H+"))
492
+ t1 = pow(1 + mu_x, a2);
493
+ else
494
+ {
495
+ v0 = calc_vm0(s_x[i]->name, tc_x, 1, 0);
496
+ t1 = 1 + (s_x[i]->rxn_x.logk[vm_tc] - v0);
497
+ if (a2 && t1 > 0)
498
+ t1 = pow(t1, a2);
499
+ //t1 = (t1 <= a3 / 10 ? a3 / 10 : t1);
500
+ t1 = (t1 < 1 ? 1 : t1);
501
+ }
502
+ if (a3 >= 5)
503
+ // with the vm correction of a in ka..
504
+ ka = DH_B * a * t1 * sqrt_mu;
505
+ else
506
+ // with a mu^dw_a2 correction of a..
507
+ ka = DH_B * a * pow((double)mu_x, a2);
508
+
509
+ t1 = (Dw - B2 * l_z * sqrt_mu / (1 + ka)) *
510
+ (1 - B1 * sqrt_mu / ((1 + ka) * (1 + ka)));// +ka * ka / 6))); // S.cm2/eq / (kgw/L)
511
+ //t1 = (Dw - B2 * l_z * sqrt_mu / (1 + ka)) *
512
+ // (1 - B1 * sqrt_mu / ((1 + ka) *(1 + ka * sqrt_q + ka * ka / 6))); // S.cm2/eq / (kgw/L)
513
+ if (av)
514
+ t1 *= pow(viscos_0 / viscos, av);
515
+ if (correct_Dw)
516
+ s_x[i]->dw_corr *= t1 / Dw * pow(mass_water_aq_x / calc_solution_volume(), 2);
517
+
518
+ // fractional contribution in mu, and correct for charge imbalance
519
+ a2 = 2 / (eq_plus + eq_min);
520
+ a = (lz > 0 ? mu_plus / (eq_plus * a2) : mu_min / (eq_min * a2));
521
+ t1 *= s_x[i]->moles * l_z * l_z / a;
522
+ t1 *= ll_SC;
523
+ s_x[i]->dw_t_SC = t1 / (1e3 * Dw_SC);
524
+ SC += t1;
525
+ }
526
+ }
527
+ return SC;
528
+ }
529
+ }
530
+
531
+ /* VP: Density Start */
532
+ /* ---------------------------------------------------------------------- */
533
+ LDBLE Phreeqc::
534
+ calc_dens(void)
535
+ /* ---------------------------------------------------------------------- */
536
+ {
537
+ /*
538
+ * Calculates density based on the formulas and parameters from Millero,
539
+ * 2000.
540
+ *
541
+ * Millero, F.J. (2000) The equation of state of lakes. Aquatic geochemistry
542
+ * volume 6, pages 1-17
543
+ */
544
+ int i;
545
+ LDBLE M_T, /*rho_new,*/ gfw;
546
+ /* 2 options: original VP, assign the volumes of species with zero molar volume to their master species,
547
+ but this doubles counts of complexes with -Vm defined. And, cation-OH and H-anion
548
+ complexes are counted once. Also, must add H+ and OH-... */
549
+ //class species *s_ptr;
550
+
551
+ //V_solutes = M_T = 0.0;
552
+ //for (i = 0; i < count_species_list; i++)
553
+ //{
554
+ // if (species_list[i].s->type != AQ && species_list[i].s->type != HPLUS)
555
+ // continue;
556
+
557
+ // //if (species_list[i].master_s->secondary != NULL)
558
+ // // gfw = species_list[i].master_s->secondary->gfw;
559
+ // //else
560
+ // // gfw = species_list[i].master_s->primary->gfw;
561
+
562
+ // /* OH-... */
563
+ // if (!strcmp(species_list[i].s->name, "OH-"))
564
+ // s_ptr = s_search("OH-");
565
+ // else if (species_list[i].s->logk[vm_tc] == 0)
566
+ // {
567
+ // s_ptr = species_list[i].master_s;
568
+ // if (s_ptr->secondary)
569
+ // gfw = s_ptr->secondary->gfw;
570
+ // else
571
+ // gfw = s_ptr->primary->gfw;
572
+ // }
573
+ // else
574
+ // {
575
+ // s_ptr = species_list[i].s;
576
+ // compute_gfw(species_list[i].s->name, &gfw);
577
+ // }
578
+
579
+ // /* Special case: CO3-2 species */
580
+ // if (strcmp(s_ptr->name, "CO3-2") == 0)
581
+ // {
582
+ // if (strstr(species_list[i].s->name, "HCO3") != NULL)
583
+ // {
584
+ // s_ptr = s_search("HCO3-");
585
+ // } else if (strstr(species_list[i].s->name, "CO3") != NULL)
586
+ // {
587
+ // compute_gfw("CO3-2", &gfw);
588
+ // }
589
+ // }
590
+ // if (!gfw || !strcmp(species_list[i].s->name, "CO2")) /* CO2, H+ and OH- */
591
+ // compute_gfw(species_list[i].s->name, &gfw);
592
+
593
+ // M_T += (species_list[i].s->moles * gfw);
594
+ // V_solutes += species_list[i].s->moles * s_ptr->logk[vm_tc];
595
+ //}
596
+
597
+ /* 2nd option, use species_x, vm = 0 for complexes with undefined volume... */
598
+ V_solutes = M_T = 0.0;
599
+ for (i = 0; i < (int)this->s_x.size(); i++)
600
+ {
601
+ if (s_x[i]->type != AQ && s_x[i]->type != HPLUS)
602
+ continue;
603
+
604
+ //compute_gfw(s_x[i]->name, &gfw);
605
+ gfw = s_x[i]->gfw;
606
+ M_T += s_x[i]->moles * gfw;
607
+ V_solutes += s_x[i]->moles * s_x[i]->logk[vm_tc];
608
+ }
609
+ /* If pure water then return rho_0 */
610
+ density_x = rho_0;
611
+ if (M_T > 0.0)
612
+ {
613
+ density_x = rho_0 * (1e3 + M_T / mass_water_aq_x) / (rho_0 * V_solutes / mass_water_aq_x + 1e3);
614
+ }
615
+ solution_mass_x = 1e-3*(M_T + s_h2o->moles * s_h2o->gfw);
616
+ solution_volume_x = solution_mass_x / density_x;
617
+ return density_x;
618
+ //M_T /= 1e3;
619
+ //solution_mass = mass_water_aq_x + M_T;
620
+ //V_solutes = M_T - rho_0 * V_solutes / 1e3;
621
+
622
+ //rho_new = halve(f_rho, 0.5, 2.0, 1e-7);
623
+ //if (!PHR_ISFINITE(rho_new) || rho_new > 1.99999) rho_new = 1.99999;
624
+
625
+ //return rho_new;
626
+ }
627
+ /* VP: Density End */
628
+ /* DP: Function for interval halving */
629
+ #ifdef NOT_USED
630
+ LDBLE Phreeqc::
631
+ f_rho(LDBLE rho_old, void* cookie)
632
+ /* ---------------------------------------------------------------------- */
633
+ {
634
+ LDBLE rho = 1.0;
635
+ Phreeqc* pThis;
636
+
637
+ pThis = (Phreeqc*)cookie;
638
+
639
+ pThis->solution_volume = pThis->solution_mass / rho_old;
640
+ if (pThis->solution_volume != 0)
641
+ {
642
+ rho = pThis->V_solutes / pThis->solution_volume;
643
+ }
644
+ rho = rho + pThis->rho_0;
645
+ return (rho - rho_old);
646
+ }
647
+ #endif
648
+ #ifdef original
649
+ /* ---------------------------------------------------------------------- */
650
+ LDBLE Phreeqc::
651
+ calc_solution_volume(void)
652
+ /* ---------------------------------------------------------------------- */
653
+ {
654
+ /*
655
+ * Calculates solution volume based on sum of mass of element plus density
656
+ */
657
+ LDBLE total_mass = 0;
658
+ LDBLE gfw;
659
+ //compute_gfw("H", &gfw);
660
+ gfw = s_hplus->primary->gfw;
661
+ total_mass = total_h_x * gfw;
662
+ //compute_gfw("O", &gfw);
663
+ gfw = s_h2o->primary->gfw;
664
+ total_mass += total_o_x * gfw;
665
+
666
+ for (int i = 0; i < (int)master.size(); i++)
667
+ {
668
+ if (master[i]->s->type != AQ) continue;
669
+ class master* master_ptr = master[i];
670
+ if (master_ptr->primary == TRUE && strcmp(master_ptr->elt->name, "Alkalinity"))
671
+ {
672
+ total_mass += master_ptr->total_primary * master_ptr->elt->gfw;
673
+ }
674
+ }
675
+ LDBLE rho = calc_dens();
676
+ LDBLE vol = 1e-3 * total_mass / rho;
677
+ return (vol);
678
+ }
679
+ #endif
680
+ /* ---------------------------------------------------------------------- */
681
+ LDBLE Phreeqc::
682
+ calc_solution_volume(void)
683
+ /* ---------------------------------------------------------------------- */
684
+ {
685
+ /*
686
+ * Calculates solution volume based on sum of mass of element plus density
687
+ */
688
+ LDBLE rho = calc_dens();
689
+ LDBLE vol = solution_volume_x;
690
+ return (vol);
691
+ }
692
+ /* ---------------------------------------------------------------------- */
693
+ LDBLE Phreeqc::
694
+ calc_logk_n(const char* name)
695
+ /* ---------------------------------------------------------------------- */
696
+ {
697
+ char token[MAX_LENGTH];
698
+ int i;
699
+ LDBLE lk;
700
+ class logk* logk_ptr;
701
+ LDBLE l_logk[MAX_LOG_K_INDICES];
702
+ class name_coef add_logk;
703
+ std::vector<class name_coef> add_logk_v;
704
+
705
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
706
+ {
707
+ l_logk[i] = 0.0;
708
+ }
709
+ Utilities::strcpy_safe(token, MAX_LENGTH, name);
710
+ logk_ptr = logk_search(token);
711
+ if (logk_ptr != NULL)
712
+ {
713
+ add_logk.name = token;
714
+ add_logk.coef = 1.0;
715
+ add_logk_v.push_back(add_logk);
716
+ add_other_logk(l_logk, add_logk_v);
717
+ lk = k_calc(l_logk, tk_x, patm_x * PASCAL_PER_ATM);
718
+ return (lk);
719
+ }
720
+ return (-999.99);
721
+ }
722
+
723
+ /* ---------------------------------------------------------------------- */
724
+ LDBLE Phreeqc::
725
+ calc_logk_p(const char* name)
726
+ /* ---------------------------------------------------------------------- */
727
+ {
728
+ int i, j;
729
+ char token[MAX_LENGTH];
730
+ class phase* phase_ptr;
731
+ LDBLE lk = -999.9;
732
+ LDBLE l_logk[MAX_LOG_K_INDICES];
733
+
734
+ Utilities::strcpy_safe(token, MAX_LENGTH, name);
735
+ phase_ptr = phase_bsearch(token, &j, FALSE);
736
+
737
+ if (phase_ptr != NULL)
738
+ {
739
+ CReaction* reaction_ptr;
740
+ if (phase_ptr->replaced)
741
+ reaction_ptr = &phase_ptr->rxn_s;
742
+ else
743
+ reaction_ptr = &phase_ptr->rxn;
744
+ /*
745
+ * Print saturation index
746
+ */
747
+ reaction_ptr->logk[delta_v] = calc_delta_v(*reaction_ptr, true) -
748
+ phase_ptr->logk[vm0];
749
+ if (reaction_ptr->logk[delta_v])
750
+ mu_terms_in_logk = true;
751
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
752
+ {
753
+ l_logk[i] = 0.0;
754
+ }
755
+ //lk = k_calc(reaction_ptr->logk, tk_x, patm_x * PASCAL_PER_ATM);
756
+ select_log_k_expression(reaction_ptr->logk, l_logk);
757
+ add_other_logk(l_logk, phase_ptr->add_logk);
758
+ lk = k_calc(l_logk, tk_x, patm_x * PASCAL_PER_ATM);
759
+ }
760
+ return (lk);
761
+ }
762
+
763
+ /* ---------------------------------------------------------------------- */
764
+ LDBLE Phreeqc::
765
+ calc_logk_s(const char* name)
766
+ /* ---------------------------------------------------------------------- */
767
+ {
768
+ int i;
769
+ char token[MAX_LENGTH];
770
+ class species* s_ptr;
771
+ LDBLE lk, l_logk[MAX_LOG_K_INDICES];
772
+
773
+ Utilities::strcpy_safe(token, MAX_LENGTH, name);
774
+ s_ptr = s_search(token);
775
+ if (s_ptr != NULL)
776
+ {
777
+ //if (s_ptr->logk[vm_tc])
778
+ /* calculate delta_v for the reaction... */
779
+ s_ptr->logk[delta_v] = calc_delta_v(*&s_ptr->rxn, false);
780
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
781
+ {
782
+ l_logk[i] = 0.0;
783
+ }
784
+ select_log_k_expression(s_ptr->logk, l_logk);
785
+ mu_terms_in_logk = true;
786
+ add_other_logk(l_logk, s_ptr->add_logk);
787
+ lk = k_calc(l_logk, tk_x, patm_x * PASCAL_PER_ATM);
788
+ return (lk);
789
+ }
790
+ return (-999.99);
791
+ }
792
+ /* ---------------------------------------------------------------------- */
793
+ LDBLE Phreeqc::
794
+ dh_a0(const char* name)
795
+ /* ---------------------------------------------------------------------- */
796
+ {
797
+ char token[MAX_LENGTH];
798
+ class species* s_ptr;
799
+ double a = -999.99;
800
+
801
+ Utilities::strcpy_safe(token, MAX_LENGTH, name);
802
+ s_ptr = s_search(token);
803
+ if (s_ptr != NULL)
804
+ {
805
+ a = s_ptr->dha;
806
+ }
807
+ return (a);
808
+ }
809
+ /* ---------------------------------------------------------------------- */
810
+ LDBLE Phreeqc::
811
+ dh_bdot(const char* name)
812
+ /* ---------------------------------------------------------------------- */
813
+ {
814
+ char token[MAX_LENGTH];
815
+ class species* s_ptr;
816
+ double b = -999.99;
817
+ if (llnl_temp.size() > 0)
818
+ {
819
+ b = bdot_llnl;
820
+ }
821
+ else
822
+ {
823
+ Utilities::strcpy_safe(token, MAX_LENGTH, name);
824
+ s_ptr = s_search(token);
825
+ if (s_ptr != NULL)
826
+ {
827
+ b = s_ptr->dhb;
828
+ }
829
+ }
830
+ return (b);
831
+ }
832
+ /* ---------------------------------------------------------------------- */
833
+ LDBLE Phreeqc::
834
+ calc_deltah_p(const char* name)
835
+ /* ---------------------------------------------------------------------- */
836
+ {
837
+ int i, j;
838
+ char token[MAX_LENGTH];
839
+ class phase* phase_ptr;
840
+ LDBLE lkm, lkp;
841
+ LDBLE l_logk[MAX_LOG_K_INDICES];
842
+ double dh = -999.99;
843
+ Utilities::strcpy_safe(token, MAX_LENGTH, name);
844
+ phase_ptr = phase_bsearch(token, &j, FALSE);
845
+
846
+ if (phase_ptr != NULL)
847
+ {
848
+ CReaction* reaction_ptr;
849
+ if (phase_ptr->replaced)
850
+ reaction_ptr = &phase_ptr->rxn_s;
851
+ else
852
+ reaction_ptr = &phase_ptr->rxn;
853
+ /*
854
+ * Print saturation index
855
+ */
856
+ reaction_ptr->logk[delta_v] = calc_delta_v(*reaction_ptr, true) -
857
+ phase_ptr->logk[vm0];
858
+ if (reaction_ptr->logk[delta_v])
859
+ mu_terms_in_logk = true;
860
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
861
+ {
862
+ l_logk[i] = 0.0;
863
+ }
864
+ //lk = k_calc(reaction_ptr->logk, tk_x, patm_x * PASCAL_PER_ATM);
865
+ select_log_k_expression(reaction_ptr->logk, l_logk);
866
+ add_other_logk(l_logk, phase_ptr->add_logk);
867
+ lkm = k_calc(l_logk, tk_x - 1.0, patm_x * PASCAL_PER_ATM);
868
+ lkp = k_calc(l_logk, tk_x + 1.0, patm_x * PASCAL_PER_ATM);
869
+ dh = (lkp - lkm) / 2.0 * LOG_10 * R_KJ_DEG_MOL * pow(tk_x, 2.0);
870
+ }
871
+ return (dh);
872
+ }
873
+ /* ---------------------------------------------------------------------- */
874
+ LDBLE Phreeqc::
875
+ calc_deltah_s(const char* name)
876
+ /* ---------------------------------------------------------------------- */
877
+ {
878
+ int i;
879
+ char token[MAX_LENGTH];
880
+ class species* s_ptr;
881
+ LDBLE lkm, lkp, l_logk[MAX_LOG_K_INDICES];
882
+ double dh = -999.99;
883
+ Utilities::strcpy_safe(token, MAX_LENGTH, name);
884
+ s_ptr = s_search(token);
885
+ if (s_ptr != NULL)
886
+ {
887
+ /* calculate delta_v for the reaction... */
888
+ s_ptr->logk[delta_v] = calc_delta_v(*&s_ptr->rxn, false);
889
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
890
+ {
891
+ l_logk[i] = 0.0;
892
+ }
893
+ select_log_k_expression(s_ptr->logk, l_logk);
894
+ mu_terms_in_logk = true;
895
+ add_other_logk(l_logk, s_ptr->add_logk);
896
+ lkm = k_calc(l_logk, tk_x - 1.0, patm_x * PASCAL_PER_ATM);
897
+ lkp = k_calc(l_logk, tk_x + 1.0, patm_x * PASCAL_PER_ATM);
898
+ dh = (lkp - lkm) / 2.0 * LOG_10 * R_KJ_DEG_MOL * pow(tk_x, 2.0);
899
+ return (dh);
900
+ }
901
+ return (0.0);
902
+ }
903
+ /* ---------------------------------------------------------------------- */
904
+ LDBLE Phreeqc::
905
+ calc_surface_charge(const char* surface_name)
906
+ /* ---------------------------------------------------------------------- */
907
+ {
908
+ char token[MAX_LENGTH], token1[MAX_LENGTH];
909
+ const char* cptr;
910
+ int i, j, k;
911
+ LDBLE charge;
912
+ class rxn_token_temp* token_ptr;
913
+ class master* master_ptr;
914
+ /*
915
+ * Go through species, sum charge
916
+ */
917
+ charge = 0;
918
+ for (k = 0; k < (int)this->s_x.size(); k++)
919
+ {
920
+ if (s_x[k]->type != SURF)
921
+ continue;
922
+ /*
923
+ * Match surface_name
924
+ */
925
+ count_trxn = 0;
926
+ trxn_add(s_x[k]->rxn_s, 1.0, false); /* rxn_s is set in tidy_model */
927
+ for (i = 1; i < count_trxn; i++)
928
+ {
929
+ token_ptr = &(trxn.token[i]);
930
+ if (token_ptr->s->type != SURF)
931
+ continue;
932
+ master_ptr = trxn.token[i].s->primary;
933
+ Utilities::strcpy_safe(token, MAX_LENGTH, master_ptr->elt->name);
934
+ replace("_", " ", token);
935
+ cptr = token;
936
+ copy_token(token1, &cptr, &j);
937
+ if (strcmp(surface_name, token1) == 0)
938
+ {
939
+ charge += s_x[k]->moles * s_x[k]->z;
940
+ }
941
+ }
942
+ }
943
+ return (charge);
944
+ }
945
+ /* ---------------------------------------------------------------------- */
946
+ LDBLE Phreeqc::
947
+ diff_layer_total(const char* total_name, const char* surface_name)
948
+ /* ---------------------------------------------------------------------- */
949
+ {
950
+ /*
951
+ * Provides total moles in DDL layer
952
+ */
953
+ cxxSurfaceCharge* surface_charge_ptr1;
954
+ std::string name, token, surface_name_local;
955
+ class master* master_ptr;
956
+
957
+ LDBLE mass_water_surface;
958
+ LDBLE molality, moles_excess, moles_surface, charge;
959
+
960
+ if (use.Get_surface_ptr() == NULL || (dl_type_x == cxxSurface::NO_DL &&
961
+ strcmp_nocase("psi", total_name) != 0 &&
962
+ strcmp_nocase("psi1", total_name) != 0 &&
963
+ strcmp_nocase("psi2", total_name) != 0 &&
964
+ strcmp_nocase("charge", total_name) != 0
965
+ && strcmp_nocase("charge1",
966
+ total_name) != 0
967
+ && strcmp_nocase("charge2",
968
+ total_name) != 0
969
+ && strcmp_nocase("sigma",
970
+ total_name) != 0
971
+ && strcmp_nocase("sigma1",
972
+ total_name) != 0
973
+ && strcmp_nocase("sigma2",
974
+ total_name) != 0))
975
+ return (0);
976
+
977
+ /*
978
+ * Find surface...
979
+ */
980
+ int j;
981
+ for (j = 0; j < count_unknowns; j++)
982
+ {
983
+ if (use.Get_surface_ptr()->Get_type() == cxxSurface::DDL || use.Get_surface_ptr()->Get_type() == cxxSurface::CCM)
984
+ {
985
+ if (x[j]->type != SURFACE_CB)
986
+ continue;
987
+ name = x[j]->master[0]->elt->name;
988
+ Utilities::replace("_psi", "", name);
989
+ }
990
+ else if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
991
+ {
992
+ if (x[j]->type != SURFACE_CB)
993
+ continue;
994
+ name = x[j]->master[0]->elt->name;
995
+ Utilities::replace("_psi", "", name);
996
+ }
997
+ else
998
+ {
999
+ if (x[j]->type != SURFACE)
1000
+ continue;
1001
+ token = x[j]->master[0]->elt->name;
1002
+ Utilities::replace("_", " ", token);
1003
+ std::string::iterator b = token.begin();
1004
+ std::string::iterator e = token.end();
1005
+ CParser::copy_token(name, b, e);
1006
+ }
1007
+ if (surface_name != NULL)
1008
+ {
1009
+ if (strcmp(name.c_str(), surface_name) == 0)
1010
+ break;
1011
+ }
1012
+ else
1013
+ {
1014
+ break;
1015
+ }
1016
+ }
1017
+ if (j >= count_unknowns)
1018
+ return (0);
1019
+ surface_name_local = name;
1020
+ /*
1021
+ * Psi, charge, sigma
1022
+ */
1023
+ if (strcmp_nocase("psi", total_name) == 0)
1024
+ {
1025
+ if (use.Get_surface_ptr()->Get_type() == cxxSurface::DDL || use.Get_surface_ptr()->Get_type() == cxxSurface::CCM)
1026
+ {
1027
+ return ((LDBLE)(x[j]->master[0]->s->la * 2 * R_KJ_DEG_MOL *
1028
+ tk_x * LOG_10 / F_KJ_V_EQ));
1029
+ }
1030
+ else if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
1031
+ {
1032
+ master_ptr = surface_get_psi_master(surface_name, SURF_PSI);
1033
+ if (master_ptr != NULL)
1034
+ {
1035
+ return ((LDBLE)
1036
+ (-master_ptr->s->la * R_KJ_DEG_MOL * tk_x * LOG_10 /
1037
+ F_KJ_V_EQ));
1038
+ }
1039
+ else
1040
+ {
1041
+ return (0.0);
1042
+ }
1043
+ }
1044
+ else
1045
+ {
1046
+ return (0);
1047
+ }
1048
+ }
1049
+ else if (strcmp_nocase("psi1", total_name) == 0)
1050
+ {
1051
+ master_ptr = surface_get_psi_master(surface_name, SURF_PSI1);
1052
+ if (master_ptr != NULL)
1053
+ {
1054
+ return ((LDBLE)
1055
+ (-master_ptr->s->la * R_KJ_DEG_MOL * tk_x * LOG_10 /
1056
+ F_KJ_V_EQ));
1057
+ }
1058
+ else
1059
+ {
1060
+ return (0.0);
1061
+ }
1062
+ }
1063
+ else if (strcmp_nocase("psi2", total_name) == 0)
1064
+ {
1065
+ master_ptr = surface_get_psi_master(surface_name, SURF_PSI2);
1066
+ if (master_ptr != NULL)
1067
+ {
1068
+ return ((LDBLE)
1069
+ (-master_ptr->s->la * R_KJ_DEG_MOL * tk_x * LOG_10 /
1070
+ F_KJ_V_EQ));
1071
+ }
1072
+ else
1073
+ {
1074
+ return (0.0);
1075
+ }
1076
+ }
1077
+ else if (strcmp_nocase("charge", total_name) == 0)
1078
+ {
1079
+ if ((use.Get_surface_ptr()->Get_type() == cxxSurface::DDL || use.Get_surface_ptr()->Get_type() == cxxSurface::CCM) && dl_type_x == cxxSurface::NO_DL)
1080
+ {
1081
+ return ((LDBLE)(x[j]->f));
1082
+ }
1083
+ else if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
1084
+ {
1085
+ cxxSurfaceCharge* charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
1086
+ return ((charge_ptr->Get_sigma0() *
1087
+ (charge_ptr->Get_specific_area() *
1088
+ charge_ptr->Get_grams()) / F_C_MOL));
1089
+ }
1090
+ else
1091
+ {
1092
+ return (calc_surface_charge(surface_name_local.c_str()));
1093
+ }
1094
+ }
1095
+ else if (strcmp_nocase("charge1", total_name) == 0)
1096
+ {
1097
+ if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
1098
+ {
1099
+ cxxSurfaceCharge* charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
1100
+ return ((charge_ptr->Get_sigma1() *
1101
+ (charge_ptr->Get_specific_area() *
1102
+ charge_ptr->Get_grams()) / F_C_MOL));
1103
+ }
1104
+ else
1105
+ {
1106
+ return (0);
1107
+ }
1108
+ }
1109
+ else if (strcmp_nocase("charge2", total_name) == 0)
1110
+ {
1111
+ if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
1112
+ {
1113
+ cxxSurfaceCharge* charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
1114
+ return ((charge_ptr->Get_sigma2() *
1115
+ (charge_ptr->Get_specific_area() *
1116
+ charge_ptr->Get_grams()) / F_C_MOL));
1117
+ }
1118
+ else
1119
+ {
1120
+ return (0);
1121
+ }
1122
+ }
1123
+ else if (strcmp_nocase("sigma", total_name) == 0)
1124
+ {
1125
+ if (use.Get_surface_ptr()->Get_type() == cxxSurface::DDL || use.Get_surface_ptr()->Get_type() == cxxSurface::CCM)
1126
+ {
1127
+ cxxSurfaceCharge* charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
1128
+ if (dl_type_x != cxxSurface::NO_DL)
1129
+ {
1130
+ charge = calc_surface_charge(surface_name_local.c_str());
1131
+ }
1132
+ else
1133
+ {
1134
+ charge = x[j]->f;
1135
+ }
1136
+ if ((charge_ptr->Get_specific_area() *
1137
+ charge_ptr->Get_grams()) > 0)
1138
+ {
1139
+ return ((charge * F_C_MOL /
1140
+ (charge_ptr->Get_specific_area() *
1141
+ charge_ptr->Get_grams())));
1142
+ }
1143
+ else
1144
+ {
1145
+ return (0);
1146
+ }
1147
+ }
1148
+ else if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
1149
+ {
1150
+ cxxSurfaceCharge* charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
1151
+ return ((LDBLE)(charge_ptr->Get_sigma0()));
1152
+ }
1153
+ else
1154
+ {
1155
+ return (0);
1156
+ }
1157
+ }
1158
+ else if (strcmp_nocase("sigma1", total_name) == 0)
1159
+ {
1160
+ if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
1161
+ {
1162
+ cxxSurfaceCharge* charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
1163
+ return ((LDBLE)(charge_ptr->Get_sigma1()));
1164
+ }
1165
+ else
1166
+ {
1167
+ return (0);
1168
+ }
1169
+ }
1170
+ else if (strcmp_nocase("sigma2", total_name) == 0)
1171
+ {
1172
+ if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
1173
+ {
1174
+ cxxSurfaceCharge* charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
1175
+ return ((LDBLE)(charge_ptr->Get_sigma2()));
1176
+ }
1177
+ else
1178
+ {
1179
+ return (0);
1180
+ }
1181
+ }
1182
+ else if (strcmp_nocase("water", total_name) == 0)
1183
+ {
1184
+ if (dl_type_x != cxxSurface::NO_DL)
1185
+ {
1186
+ cxxSurfaceCharge* charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
1187
+ return (charge_ptr->Get_mass_water());
1188
+ }
1189
+ else
1190
+ {
1191
+ return (0);
1192
+ }
1193
+ }
1194
+ else if (strcmp_nocase("viscos_ddl", total_name) == 0)
1195
+ {
1196
+ if (dl_type_x != cxxSurface::NO_DL)
1197
+ {
1198
+ cxxSurfaceCharge* charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
1199
+ if (charge_ptr->Get_mass_water() > 0)
1200
+ {
1201
+ cxxSurface * surf_ptr = use.Get_surface_ptr();
1202
+ if (surf_ptr->Get_calc_viscosity())
1203
+ {
1204
+ viscosity(surf_ptr);
1205
+ viscosity(nullptr);
1206
+ return charge_ptr->Get_DDL_viscosity();
1207
+ }
1208
+ else
1209
+ return charge_ptr->Get_DDL_viscosity() * viscos;
1210
+ }
1211
+ }
1212
+ else
1213
+ {
1214
+ return (0);
1215
+ }
1216
+ }
1217
+ /*
1218
+ * find total moles of each element in diffuse layer...
1219
+ */
1220
+ surface_charge_ptr1 = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
1221
+ if (surface_charge_ptr1)
1222
+ {
1223
+ mass_water_surface = surface_charge_ptr1->Get_mass_water();
1224
+ count_elts = 0;
1225
+ paren_count = 0;
1226
+ for (j = 0; j < (int)this->s_x.size(); j++)
1227
+ {
1228
+ if (s_x[j]->type > HPLUS)
1229
+ continue;
1230
+ molality = under(s_x[j]->lm);
1231
+ LDBLE g = surface_charge_ptr1->Get_g_map()[s_x[j]->z].Get_g();
1232
+
1233
+ moles_excess = mass_water_aq_x * molality * (g * s_x[j]->erm_ddl +
1234
+ mass_water_surface /
1235
+ mass_water_aq_x * (s_x[j]->erm_ddl - 1));
1236
+ moles_surface = mass_water_surface * molality + moles_excess;
1237
+ /*
1238
+ * Accumulate elements in diffuse layer
1239
+ */
1240
+ add_elt_list(s_x[j]->next_elt, moles_surface);
1241
+ }
1242
+ elt_list_combine();
1243
+ /*
1244
+ * Return totals
1245
+ */
1246
+ for (j = 0; j < count_elts; j++)
1247
+ {
1248
+ if (strcmp(elt_list[j].elt->name, total_name) == 0)
1249
+ {
1250
+ return ((LDBLE)elt_list[j].coef);
1251
+ }
1252
+ }
1253
+ }
1254
+ return (0);
1255
+ }
1256
+ /* ---------------------------------------------------------------------- */
1257
+ LDBLE Phreeqc::
1258
+ calc_t_sc(const char* name)
1259
+ /* ---------------------------------------------------------------------- */
1260
+ {
1261
+ char token[MAX_LENGTH];
1262
+ class species* s_ptr;
1263
+
1264
+ Utilities::strcpy_safe(token, MAX_LENGTH, name);
1265
+ s_ptr = s_search(token);
1266
+ if (s_ptr != NULL && s_ptr->in)
1267
+ {
1268
+ if (!s_ptr->z)
1269
+ return (0);
1270
+ calc_SC();
1271
+ if (!SC)
1272
+ return (0);
1273
+ LDBLE t = s_ptr->dw_t_SC * 1e7 * F_C_MOL * F_C_MOL / (R_KJ_DEG_MOL * 298150.0);
1274
+ return (t / SC);
1275
+ }
1276
+ return (0);
1277
+ }
1278
+
1279
+ /* ---------------------------------------------------------------------- */
1280
+ LDBLE Phreeqc::
1281
+ calc_f_visc(const char* name)
1282
+ /* ---------------------------------------------------------------------- */
1283
+ {
1284
+ char token[MAX_LENGTH];
1285
+ class species* s_ptr;
1286
+
1287
+ if (print_viscosity)
1288
+ {
1289
+ Utilities::strcpy_safe(token, MAX_LENGTH, name);
1290
+ s_ptr = s_search(token);
1291
+ if (s_ptr != NULL && s_ptr->in)
1292
+ return s_ptr->dw_t_visc;
1293
+ }
1294
+ return 0;
1295
+ }
1296
+
1297
+ /* ---------------------------------------------------------------------- */
1298
+ LDBLE Phreeqc::
1299
+ equi_phase(const char* phase_name)
1300
+ /* ---------------------------------------------------------------------- */
1301
+ {
1302
+ int j;
1303
+
1304
+ if (use.Get_pp_assemblage_in() == FALSE || use.Get_pp_assemblage_ptr() == NULL)
1305
+ return (0);
1306
+ for (j = 0; j < count_unknowns; j++)
1307
+ {
1308
+ if (x[j]->type != PP)
1309
+ continue;
1310
+ if (strcmp_nocase(x[j]->pp_assemblage_comp_name, phase_name) == 0)
1311
+ {
1312
+ break;
1313
+ }
1314
+ }
1315
+ /*
1316
+ * Print pure phase assemblage data
1317
+ */
1318
+ cxxPPassemblage* pp_assemblage_ptr = use.Get_pp_assemblage_ptr();
1319
+ if (j == count_unknowns)
1320
+ {
1321
+ /* if not an unknown */
1322
+ std::map<std::string, cxxPPassemblageComp>::iterator it;
1323
+ it = pp_assemblage_ptr->Get_pp_assemblage_comps().begin();
1324
+ for (; it != pp_assemblage_ptr->Get_pp_assemblage_comps().end(); it++)
1325
+ {
1326
+ if (strcmp_nocase
1327
+ (it->second.Get_name().c_str(), phase_name) == 0)
1328
+ {
1329
+ return (it->second.Get_moles());
1330
+ }
1331
+ }
1332
+ }
1333
+ else
1334
+ {
1335
+ /* if an unknown */
1336
+ if (x[j]->moles < 0.0)
1337
+ x[j]->moles = 0.0;
1338
+ return (x[j]->moles);
1339
+ }
1340
+ return (0);
1341
+ }
1342
+ /* ---------------------------------------------------------------------- */
1343
+ LDBLE Phreeqc::
1344
+ equi_phase_delta(const char* phase_name)
1345
+ /* ---------------------------------------------------------------------- */
1346
+ {
1347
+ int j;
1348
+
1349
+ if (use.Get_pp_assemblage_in() == FALSE || use.Get_pp_assemblage_ptr() == NULL)
1350
+ return (0);
1351
+ for (j = 0; j < count_unknowns; j++)
1352
+ {
1353
+ if (x[j]->type != PP)
1354
+ continue;
1355
+ if (strcmp_nocase(x[j]->pp_assemblage_comp_name, phase_name) == 0)
1356
+ {
1357
+ break;
1358
+ }
1359
+ }
1360
+ /*
1361
+ * Print pure phase assemblage data
1362
+ */
1363
+ cxxPPassemblage* pp_assemblage_ptr = use.Get_pp_assemblage_ptr();
1364
+ if (j == count_unknowns)
1365
+ {
1366
+ /* if not an unknown */
1367
+ std::map<std::string, cxxPPassemblageComp>::iterator it;
1368
+ it = pp_assemblage_ptr->Get_pp_assemblage_comps().begin();
1369
+ for (; it != pp_assemblage_ptr->Get_pp_assemblage_comps().end(); it++)
1370
+ {
1371
+ if (strcmp_nocase
1372
+ (it->second.Get_name().c_str(), phase_name) == 0)
1373
+ {
1374
+ cxxPPassemblageComp* comp_ptr = &(it->second);
1375
+ if (state != TRANSPORT && state != PHAST)
1376
+ {
1377
+ //LDBLE moles = it->second.Get_moles();
1378
+ //LDBLE delta_moles = moles - comp_ptr->Get_moles() -
1379
+ // comp_ptr->Get_delta();
1380
+ return(0);
1381
+ }
1382
+ else
1383
+ {
1384
+ LDBLE moles = it->second.Get_moles();
1385
+ LDBLE delta_moles = moles - comp_ptr->Get_initial_moles();
1386
+ return(delta_moles);
1387
+ }
1388
+ }
1389
+ }
1390
+ }
1391
+ else
1392
+ {
1393
+ //cxxPPassemblageComp * comp_ptr = pp_assemblage_ptr->Find(x[j]->pp_assemblage_comp_name);
1394
+ cxxPPassemblageComp* comp_ptr = (cxxPPassemblageComp*)x[j]->pp_assemblage_comp_ptr;
1395
+ if (state != TRANSPORT && state != PHAST)
1396
+ {
1397
+ LDBLE delta_moles =
1398
+ x[j]->moles - comp_ptr->Get_moles() -
1399
+ comp_ptr->Get_delta();
1400
+ return(delta_moles);
1401
+ }
1402
+ else
1403
+ {
1404
+ LDBLE delta_moles =
1405
+ x[j]->moles - comp_ptr->Get_initial_moles();
1406
+ return(delta_moles);
1407
+ }
1408
+ }
1409
+ return (0);
1410
+ }
1411
+
1412
+ /* ---------------------------------------------------------------------- */
1413
+ LDBLE Phreeqc::
1414
+ equivalent_fraction(const char* name, LDBLE* eq, std::string& elt_name)
1415
+ /* ---------------------------------------------------------------------- */
1416
+ {
1417
+ class species* s_ptr = s_search(name);
1418
+ *eq = 0;
1419
+ elt_name.clear();
1420
+ LDBLE f = 0;
1421
+ if (s_ptr != NULL && (s_ptr->type == EX || s_ptr->type == SURF))
1422
+ {
1423
+ *eq = s_ptr->equiv;
1424
+ const class elt_list* next_elt;
1425
+ LDBLE tot = 0.0;
1426
+ for (next_elt = &s_ptr->next_elt[0]; next_elt->elt != NULL; next_elt++)
1427
+ {
1428
+ if (next_elt->elt->master->s->type == SURF ||
1429
+ next_elt->elt->master->s->type == EX)
1430
+ {
1431
+ tot = total_mole(next_elt->elt->name);
1432
+ elt_name = next_elt->elt->name;
1433
+ }
1434
+ }
1435
+ if (s_ptr->in == TRUE && tot > 0.0)
1436
+ {
1437
+ f = s_ptr->moles * s_ptr->equiv / tot;
1438
+ }
1439
+ }
1440
+ return f;
1441
+ }
1442
+ /* ---------------------------------------------------------------------- */
1443
+ LDBLE Phreeqc::
1444
+ find_gas_comp(const char* gas_comp_name)
1445
+ /* ---------------------------------------------------------------------- */
1446
+ {
1447
+ int i;
1448
+
1449
+ if (use.Get_gas_phase_in() == FALSE || use.Get_gas_phase_ptr() == NULL)
1450
+ return (0);
1451
+ cxxGasPhase* gas_phase_ptr = use.Get_gas_phase_ptr();
1452
+ for (size_t j = 0; j < gas_phase_ptr->Get_gas_comps().size(); j++)
1453
+ {
1454
+ if (strcmp_nocase(gas_phase_ptr->Get_gas_comps()[j].Get_phase_name().c_str(), gas_comp_name) == 0)
1455
+ {
1456
+ class phase* phase_ptr = phase_bsearch(gas_comp_name, &i, false);
1457
+ if (phase_ptr)
1458
+ {
1459
+ return (phase_ptr->moles_x);
1460
+ }
1461
+ }
1462
+ }
1463
+ return (0);
1464
+ }
1465
+ /* ---------------------------------------------------------------------- */
1466
+ LDBLE Phreeqc::
1467
+ find_gas_p(void)
1468
+ /* ---------------------------------------------------------------------- */
1469
+ {
1470
+ if (use.Get_gas_phase_in() == FALSE || use.Get_gas_phase_ptr() == NULL)
1471
+ return (0);
1472
+ cxxGasPhase* gas_phase_ptr = use.Get_gas_phase_ptr();
1473
+ if (gas_phase_ptr->Get_type() == cxxGasPhase::GP_PRESSURE)
1474
+ {
1475
+ if (gas_unknown == NULL)
1476
+ return (0);
1477
+ if (gas_unknown->moles < 1e-12)
1478
+ return (0);
1479
+ }
1480
+ return (gas_phase_ptr->Get_total_p());
1481
+ }
1482
+ /* ---------------------------------------------------------------------- */
1483
+ LDBLE Phreeqc::
1484
+ find_gas_vm(void)
1485
+ /* ---------------------------------------------------------------------- */
1486
+ {
1487
+ if (use.Get_gas_phase_in() == FALSE || use.Get_gas_phase_ptr() == NULL)
1488
+ return (0);
1489
+ cxxGasPhase* gas_phase_ptr = use.Get_gas_phase_ptr();
1490
+ if (gas_phase_ptr->Get_type() == cxxGasPhase::GP_PRESSURE)
1491
+ {
1492
+ if (gas_unknown == NULL)
1493
+ return (0);
1494
+ if (gas_unknown->moles < 1e-12)
1495
+ return (0);
1496
+ gas_phase_ptr->Set_total_moles(gas_unknown->moles);
1497
+ gas_phase_ptr->Set_volume(gas_phase_ptr->Get_total_moles() * R_LITER_ATM * tk_x /
1498
+ gas_phase_ptr->Get_total_p());
1499
+ if (gas_phase_ptr->Get_v_m() >= 0.01)
1500
+ gas_phase_ptr->Set_volume(gas_phase_ptr->Get_v_m() * gas_unknown->moles);
1501
+ }
1502
+ return gas_phase_ptr->Get_volume() / gas_phase_ptr->Get_total_moles();
1503
+ }
1504
+
1505
+ /* ---------------------------------------------------------------------- */
1506
+ LDBLE Phreeqc::
1507
+ find_misc1(const char* ss_name)
1508
+ /* ---------------------------------------------------------------------- */
1509
+ {
1510
+ if (use.Get_ss_assemblage_in() == FALSE || use.Get_ss_assemblage_ptr() == NULL)
1511
+ return (0.0);
1512
+ std::vector<cxxSS*> ss_ptrs = use.Get_ss_assemblage_ptr()->Vectorize();
1513
+ for (size_t j = 0; j < ss_ptrs.size(); j++)
1514
+ {
1515
+ cxxSS* ss_ptr = ss_ptrs[j];
1516
+ if (strcmp_nocase(ss_ptr->Get_name().c_str(), ss_name) == 0)
1517
+ {
1518
+ if (ss_ptr->Get_miscibility())
1519
+ {
1520
+ return (ss_ptr->Get_xb1());
1521
+ }
1522
+ else
1523
+ {
1524
+ return (1.0);
1525
+ }
1526
+ }
1527
+ }
1528
+ return (0);
1529
+ }
1530
+
1531
+ /* ---------------------------------------------------------------------- */
1532
+ LDBLE Phreeqc::
1533
+ find_misc2(const char* ss_name)
1534
+ /* ---------------------------------------------------------------------- */
1535
+ {
1536
+ if (use.Get_ss_assemblage_in() == FALSE || use.Get_ss_assemblage_ptr() == NULL)
1537
+ return (0.0);
1538
+ std::vector<cxxSS*> ss_ptrs = use.Get_ss_assemblage_ptr()->Vectorize();
1539
+ for (size_t j = 0; j < ss_ptrs.size(); j++)
1540
+ {
1541
+ cxxSS* ss_ptr = ss_ptrs[j];
1542
+ if (strcmp_nocase(ss_ptr->Get_name().c_str(), ss_name) == 0)
1543
+ {
1544
+ if (ss_ptr->Get_miscibility())
1545
+ {
1546
+ return (ss_ptr->Get_xb2());
1547
+ }
1548
+ else
1549
+ {
1550
+ return (1.0);
1551
+ }
1552
+ }
1553
+ }
1554
+ return (0);
1555
+ }
1556
+
1557
+ /* ---------------------------------------------------------------------- */
1558
+ LDBLE Phreeqc::
1559
+ find_ss_comp(const char* ss_comp_name)
1560
+ /* ---------------------------------------------------------------------- */
1561
+ {
1562
+ if (use.Get_ss_assemblage_in() == FALSE || use.Get_ss_assemblage_ptr() == NULL)
1563
+ return (0);
1564
+
1565
+ std::vector<cxxSS*> ss_ptrs = use.Get_ss_assemblage_ptr()->Vectorize();
1566
+ for (size_t j = 0; j < ss_ptrs.size(); j++)
1567
+ {
1568
+ cxxSS* ss_ptr = ss_ptrs[j];
1569
+ for (size_t i = 0; i < ss_ptr->Get_ss_comps().size(); i++)
1570
+ {
1571
+ cxxSScomp* comp_ptr = &(ss_ptr->Get_ss_comps()[i]);
1572
+ if (strcmp_nocase(comp_ptr->Get_name().c_str(), ss_comp_name) == 0)
1573
+ {
1574
+ if (ss_ptr->Get_ss_in())
1575
+ {
1576
+ return (comp_ptr->Get_moles());
1577
+ }
1578
+ else
1579
+ {
1580
+ return (0.0);
1581
+ }
1582
+ }
1583
+ }
1584
+ }
1585
+ return (0);
1586
+ }
1587
+ /* ---------------------------------------------------------------------- */
1588
+ LDBLE Phreeqc::
1589
+ get_calculate_value(const char* name)
1590
+ /* ---------------------------------------------------------------------- */
1591
+ /*
1592
+ * Gets value from a calclate_value structure
1593
+ * arguments: name
1594
+ * return: LDBLE of value
1595
+ */
1596
+ {
1597
+ class calculate_value* calculate_value_ptr;
1598
+ calculate_value_ptr = calculate_value_search(name);
1599
+ if (calculate_value_ptr == NULL)
1600
+ {
1601
+ error_string = sformatf("CALC_VALUE Basic function, %s not found.",
1602
+ name);
1603
+ //error_msg(error_string, CONTINUE);
1604
+ //input_error++;
1605
+ warning_msg(error_string);
1606
+ return (MISSING);
1607
+ }
1608
+ if (name == NULL)
1609
+ {
1610
+ error_string = sformatf(
1611
+ "Definition for calculated value not found, %s", name);
1612
+ input_error++;
1613
+ error_msg(error_string, CONTINUE);
1614
+ return (MISSING);
1615
+ }
1616
+
1617
+ char l_command[] = "run";
1618
+ PBasic interp(this, this->phrq_io);
1619
+ if (calculate_value_ptr->new_def == TRUE)
1620
+ {
1621
+ if (interp.basic_compile
1622
+ (calculate_value_ptr->commands.c_str(),
1623
+ &calculate_value_ptr->linebase,
1624
+ &calculate_value_ptr->varbase,
1625
+ &calculate_value_ptr->loopbase) != 0)
1626
+ {
1627
+ error_string = sformatf(
1628
+ "Fatal Basic error in CALCULATE_VALUES %s.",
1629
+ calculate_value_ptr->name);
1630
+ error_msg(error_string, STOP);
1631
+ }
1632
+ calculate_value_ptr->new_def = FALSE;
1633
+ }
1634
+
1635
+ if (interp.basic_run(l_command,
1636
+ calculate_value_ptr->linebase,
1637
+ calculate_value_ptr->varbase,
1638
+ calculate_value_ptr->loopbase) != 0)
1639
+ {
1640
+ error_string = sformatf("Fatal Basic error in calculate_value %s.",
1641
+ calculate_value_ptr->name);
1642
+ error_msg(error_string, STOP);
1643
+ }
1644
+ if (std::isnan(rate_moles))
1645
+ {
1646
+ error_string = sformatf("Calculated value not SAVEed for %s.",
1647
+ calculate_value_ptr->name);
1648
+ error_msg(error_string, STOP);
1649
+ }
1650
+ else
1651
+ {
1652
+ calculate_value_ptr->calculated = TRUE;
1653
+ calculate_value_ptr->value = rate_moles;
1654
+ }
1655
+ return (calculate_value_ptr->value);
1656
+ }
1657
+ /* ---------------------------------------------------------------------- */
1658
+ LDBLE Phreeqc::
1659
+ kinetics_moles(const char* kinetics_name)
1660
+ /* ---------------------------------------------------------------------- */
1661
+ {
1662
+
1663
+ if (use.Get_kinetics_in() == FALSE || use.Get_kinetics_ptr() == NULL)
1664
+ return (0);
1665
+ for (size_t i = 0; i < use.Get_kinetics_ptr()->Get_kinetics_comps().size(); i++)
1666
+ {
1667
+ cxxKineticsComp* kinetics_comp_ptr = &(use.Get_kinetics_ptr()->Get_kinetics_comps()[i]);
1668
+ if (strcmp_nocase
1669
+ (kinetics_comp_ptr->Get_rate_name().c_str(), kinetics_name) == 0)
1670
+ {
1671
+ return (kinetics_comp_ptr->Get_m());
1672
+ }
1673
+ }
1674
+
1675
+ error_string = sformatf("No data for rate %s in KINETICS keyword.",
1676
+ kinetics_name);
1677
+ //if (count_warnings >= 0) // appt debug cvode
1678
+ // warning_msg(error_string);
1679
+ return (0);
1680
+ }
1681
+ /* ---------------------------------------------------------------------- */
1682
+ LDBLE Phreeqc::
1683
+ kinetics_moles_delta(const char* kinetics_name)
1684
+ /* ---------------------------------------------------------------------- */
1685
+ {
1686
+
1687
+ if (use.Get_kinetics_in() == FALSE || use.Get_kinetics_ptr() == NULL)
1688
+ return (0);
1689
+ for (size_t i = 0; i < use.Get_kinetics_ptr()->Get_kinetics_comps().size(); i++)
1690
+ {
1691
+ cxxKineticsComp* kinetics_comp_ptr = &(use.Get_kinetics_ptr()->Get_kinetics_comps()[i]);
1692
+ if (strcmp_nocase
1693
+ (kinetics_comp_ptr->Get_rate_name().c_str(), kinetics_name) == 0)
1694
+ {
1695
+ //return (kinetics_comp_ptr->Get_m());
1696
+
1697
+ if (state != TRANSPORT && state != PHAST)
1698
+ {
1699
+ //LDBLE moles = kinetics_comp_ptr->Get_m();
1700
+ LDBLE delta_moles = -kinetics_comp_ptr->Get_moles();
1701
+ return delta_moles;
1702
+ }
1703
+ else
1704
+ {
1705
+ //moles = kinetics_comp_ptr->Get_m();
1706
+ LDBLE delta_moles =
1707
+ kinetics_comp_ptr->Get_m() -
1708
+ kinetics_comp_ptr->Get_initial_moles();
1709
+ return delta_moles;
1710
+ }
1711
+ }
1712
+ }
1713
+
1714
+ //error_string = sformatf( "No data for rate %s in KINETICS keyword.",
1715
+ // kinetics_name);
1716
+ //warning_msg(error_string);
1717
+ return (0);
1718
+ }
1719
+ /* ---------------------------------------------------------------------- */
1720
+ LDBLE Phreeqc::
1721
+ log_activity(const char* species_name)
1722
+ /* ---------------------------------------------------------------------- */
1723
+ {
1724
+ class species* s_ptr;
1725
+ LDBLE la;
1726
+
1727
+ s_ptr = s_search(species_name);
1728
+
1729
+ if (s_ptr == s_eminus)
1730
+ {
1731
+ la = s_eminus->la;
1732
+ }
1733
+ else if (s_ptr == NULL || s_ptr->in == FALSE)
1734
+ {
1735
+ la = -99.99;
1736
+ }
1737
+ else if (s_ptr == s_h2o)
1738
+ {
1739
+ la = s_h2o->la;
1740
+ }
1741
+ else
1742
+ {
1743
+ la = s_ptr->lm + s_ptr->lg;
1744
+ }
1745
+ return (la);
1746
+ }
1747
+
1748
+ /* ---------------------------------------------------------------------- */
1749
+ LDBLE Phreeqc::
1750
+ log_molality(const char* species_name)
1751
+ /* ---------------------------------------------------------------------- */
1752
+ {
1753
+ class species* s_ptr;
1754
+ LDBLE lm;
1755
+
1756
+ s_ptr = s_search(species_name);
1757
+
1758
+ if (s_ptr == s_eminus)
1759
+ {
1760
+ lm = -99.99;
1761
+ }
1762
+ else if (s_ptr == NULL || s_ptr->in == FALSE)
1763
+ {
1764
+ lm = -99.99;
1765
+ }
1766
+ else if (s_ptr == s_h2o)
1767
+ {
1768
+ lm = log10(s_ptr->moles / mass_water_aq_x);
1769
+ }
1770
+ else
1771
+ {
1772
+ lm = s_ptr->lm;
1773
+ }
1774
+ return (lm);
1775
+ }
1776
+
1777
+ /* ---------------------------------------------------------------------- */
1778
+ LDBLE Phreeqc::
1779
+ molality(const char* species_name)
1780
+ /* ---------------------------------------------------------------------- */
1781
+ {
1782
+ class species* s_ptr;
1783
+ LDBLE m;
1784
+
1785
+ s_ptr = s_search(species_name);
1786
+ if (s_ptr == NULL || s_ptr == s_eminus || s_ptr->in == FALSE)
1787
+ {
1788
+ m = 1e-99;
1789
+ }
1790
+ else
1791
+ {
1792
+ /* m = pow(10., s_ptr->lm); */
1793
+ m = s_ptr->moles / mass_water_aq_x;
1794
+ }
1795
+ return (m);
1796
+ }
1797
+ /* ---------------------------------------------------------------------- */
1798
+ LDBLE Phreeqc::
1799
+ pr_pressure(const char* phase_name)
1800
+ /* ---------------------------------------------------------------------- */
1801
+ {
1802
+ int l;
1803
+ class phase* phase_ptr = phase_bsearch(phase_name, &l, FALSE);
1804
+ if (phase_ptr == NULL)
1805
+ {
1806
+ error_string = sformatf("Gas %s, not found.", phase_name);
1807
+ warning_msg(error_string);
1808
+ return (1e-99);
1809
+ }
1810
+ cxxGasPhase* gas_phase_ptr = use.Get_gas_phase_ptr();
1811
+ if (gas_phase_ptr != NULL)
1812
+ {
1813
+ for (size_t i = 0; i < gas_phase_ptr->Get_gas_comps().size(); i++)
1814
+ {
1815
+ const cxxGasComp* gas_comp_ptr = &(gas_phase_ptr->Get_gas_comps()[i]);
1816
+ int j;
1817
+ class phase* phase_ptr_gas = phase_bsearch(gas_comp_ptr->Get_phase_name().c_str(), &j, FALSE);
1818
+ if (phase_ptr == phase_ptr_gas)
1819
+ {
1820
+ if (gas_phase_ptr->Get_pr_in() && phase_ptr->moles_x)
1821
+ {
1822
+ return phase_ptr->pr_p;
1823
+ }
1824
+ else
1825
+ {
1826
+ return gas_comp_ptr->Get_p();
1827
+ }
1828
+ }
1829
+ }
1830
+ }
1831
+ else if (phase_ptr->in != FALSE && phase_ptr->pr_in)
1832
+ {
1833
+ return phase_ptr->pr_p;
1834
+ }
1835
+ return(0.0);
1836
+ }
1837
+ /* ---------------------------------------------------------------------- */
1838
+ LDBLE Phreeqc::
1839
+ pressure(void)
1840
+ /* ---------------------------------------------------------------------- */
1841
+ {
1842
+ return (patm_x);
1843
+ }
1844
+
1845
+ /* ---------------------------------------------------------------------- */
1846
+ LDBLE Phreeqc::
1847
+ pr_phi(const char* phase_name)
1848
+ /* ---------------------------------------------------------------------- */
1849
+ {
1850
+ int l;
1851
+ class phase* phase_ptr = phase_bsearch(phase_name, &l, FALSE);
1852
+ if (phase_ptr == NULL)
1853
+ {
1854
+ error_string = sformatf("Gas %s, not found.", phase_name);
1855
+ warning_msg(error_string);
1856
+ return (1e-99);
1857
+ }
1858
+ cxxGasPhase* gas_phase_ptr = use.Get_gas_phase_ptr();
1859
+ if (gas_phase_ptr != NULL)
1860
+ {
1861
+ for (size_t i = 0; i < gas_phase_ptr->Get_gas_comps().size(); i++)
1862
+ {
1863
+ const cxxGasComp* gas_comp_ptr = &(gas_phase_ptr->Get_gas_comps()[i]);
1864
+ int j;
1865
+ class phase* phase_ptr_gas = phase_bsearch(gas_comp_ptr->Get_phase_name().c_str(), &j, FALSE);
1866
+ if (phase_ptr == phase_ptr_gas)
1867
+ {
1868
+ if (gas_phase_ptr->Get_pr_in() && phase_ptr->moles_x)
1869
+ return phase_ptr->pr_phi;
1870
+ else
1871
+ return gas_comp_ptr->Get_phi();
1872
+ }
1873
+ }
1874
+ }
1875
+ else if (phase_ptr->in != FALSE && phase_ptr->pr_in)
1876
+ {
1877
+ return phase_ptr->pr_phi;
1878
+ }
1879
+ return (1.0);
1880
+ }
1881
+ /* ---------------------------------------------------------------------- */
1882
+ LDBLE Phreeqc::
1883
+ saturation_ratio(const char* phase_name)
1884
+ /* ---------------------------------------------------------------------- */
1885
+ {
1886
+ class rxn_token* rxn_ptr;
1887
+ class phase* phase_ptr;
1888
+ int l;
1889
+ LDBLE si, iap;
1890
+
1891
+ iap = 0.0;
1892
+ phase_ptr = phase_bsearch(phase_name, &l, FALSE);
1893
+ if (phase_ptr == NULL)
1894
+ {
1895
+ error_string = sformatf("Mineral %s, not found.", phase_name);
1896
+ warning_msg(error_string);
1897
+ return (1e-99);
1898
+ }
1899
+ else if (phase_ptr->in != FALSE)
1900
+ {
1901
+ for (rxn_ptr = &phase_ptr->rxn_x.token[0] + 1; rxn_ptr->s != NULL;
1902
+ rxn_ptr++)
1903
+ {
1904
+ iap += rxn_ptr->s->la * rxn_ptr->coef;
1905
+ }
1906
+ si = iap - phase_ptr->lk;
1907
+ return (pow((LDBLE)10.0, si));
1908
+ }
1909
+ return (0.0);
1910
+
1911
+ }
1912
+
1913
+ /* ---------------------------------------------------------------------- */
1914
+ int Phreeqc::
1915
+ saturation_index(const char* phase_name, LDBLE* iap, LDBLE* si)
1916
+ /* ---------------------------------------------------------------------- */
1917
+ {
1918
+ class rxn_token* rxn_ptr;
1919
+ class phase* phase_ptr;
1920
+ int l;
1921
+
1922
+ *si = -99.99;
1923
+ *iap = 0.0;
1924
+ phase_ptr = phase_bsearch(phase_name, &l, FALSE);
1925
+ if (phase_ptr == NULL)
1926
+ {
1927
+ error_string = sformatf("Mineral %s, not found.", phase_name);
1928
+ warning_msg(error_string);
1929
+ *si = -99;
1930
+ }
1931
+ else if (phase_ptr->in != FALSE)
1932
+ {
1933
+ for (rxn_ptr = &phase_ptr->rxn_x.token[0] + 1; rxn_ptr->s != NULL;
1934
+ rxn_ptr++)
1935
+ {
1936
+ *iap += rxn_ptr->s->la * rxn_ptr->coef;
1937
+ }
1938
+ *si = *iap - phase_ptr->lk;
1939
+ }
1940
+ else
1941
+ {
1942
+ return (ERROR);
1943
+ }
1944
+ return (OK);
1945
+ }
1946
+ /* ---------------------------------------------------------------------- */
1947
+ LDBLE Phreeqc::
1948
+ sum_match_gases(const char* mytemplate, const char* name)
1949
+ /* ---------------------------------------------------------------------- */
1950
+ {
1951
+ int i;
1952
+ LDBLE tot;
1953
+ const class elt_list* next_elt;
1954
+
1955
+ if (use.Get_gas_phase_in() == FALSE || use.Get_gas_phase_ptr() == NULL)
1956
+ return (0);
1957
+ cxxGasPhase* gas_phase_ptr = use.Get_gas_phase_ptr();
1958
+ tot = 0;
1959
+ for (size_t j = 0; j < gas_phase_ptr->Get_gas_comps().size(); j++)
1960
+ {
1961
+ class phase* phase_ptr = phase_bsearch(gas_phase_ptr->Get_gas_comps()[j].Get_phase_name().c_str(),
1962
+ &i, FALSE);
1963
+ if (match_elts_in_species(phase_ptr->formula, mytemplate) == TRUE)
1964
+ {
1965
+ if (name == NULL)
1966
+ {
1967
+ tot += phase_ptr->moles_x;
1968
+ }
1969
+ else
1970
+ {
1971
+ for (next_elt = &phase_ptr->next_elt[0];
1972
+ next_elt->elt != NULL; next_elt++)
1973
+ {
1974
+ if (strcmp(next_elt->elt->name, name) == 0)
1975
+ {
1976
+ tot += next_elt->coef * phase_ptr->moles_x;
1977
+ break;
1978
+ }
1979
+ }
1980
+ }
1981
+ }
1982
+ }
1983
+ return (tot);
1984
+ }
1985
+
1986
+ /* ---------------------------------------------------------------------- */
1987
+ LDBLE Phreeqc::
1988
+ sum_match_species(const char* mytemplate, const char* name)
1989
+ /* ---------------------------------------------------------------------- */
1990
+ {
1991
+ int i;
1992
+ LDBLE tot;
1993
+ const class elt_list* next_elt;
1994
+
1995
+ count_elts = 0;
1996
+ paren_count = 0;
1997
+ tot = 0;
1998
+ if (sum_species_map.find(mytemplate) == sum_species_map.end())
1999
+ {
2000
+ std::vector<std::string> species_list;
2001
+ for (i = 0; i < (int)this->s_x.size(); i++)
2002
+ {
2003
+ class species* s_ptr = s_x[i];
2004
+ if (match_elts_in_species(s_ptr->name, mytemplate) == TRUE)
2005
+ {
2006
+ species_list.push_back(s_ptr->name);
2007
+ }
2008
+ }
2009
+ sum_species_map[mytemplate] = species_list;
2010
+ }
2011
+ std::vector<std::string>& species_list = (sum_species_map.find(mytemplate))->second;
2012
+ for (size_t i = 0; i < species_list.size(); i++)
2013
+ {
2014
+ class species* s_ptr = s_search(species_list[i].c_str());
2015
+ if (s_ptr->in == FALSE) continue;
2016
+ if (name == NULL)
2017
+ {
2018
+ tot += s_ptr->moles;
2019
+ }
2020
+ else
2021
+ {
2022
+ for (next_elt = &s_ptr->next_elt[0]; next_elt->elt != NULL;
2023
+ next_elt++)
2024
+ {
2025
+ if (strcmp(next_elt->elt->name, name) == 0)
2026
+ {
2027
+ tot += next_elt->coef * s_ptr->moles;
2028
+ break;
2029
+ }
2030
+ }
2031
+ }
2032
+ }
2033
+ return (tot);
2034
+ }
2035
+
2036
+
2037
+
2038
+ /* ---------------------------------------------------------------------- */
2039
+ LDBLE Phreeqc::
2040
+ sum_match_ss(const char* mytemplate, const char* name)
2041
+ /* ---------------------------------------------------------------------- */
2042
+ {
2043
+ LDBLE tot;
2044
+ const class elt_list* next_elt;
2045
+
2046
+ if (use.Get_ss_assemblage_in() == FALSE || use.Get_ss_assemblage_ptr() == NULL)
2047
+ return (0);
2048
+ tot = 0;
2049
+ std::vector<cxxSS*> ss_ptrs = use.Get_ss_assemblage_ptr()->Vectorize();
2050
+ for (size_t j = 0; j < ss_ptrs.size(); j++)
2051
+ {
2052
+ cxxSS* ss_ptr = ss_ptrs[j];
2053
+ if (strcmp_nocase(ss_ptr->Get_name().c_str(), mytemplate) == 0)
2054
+ {
2055
+ if (!ss_ptr->Get_ss_in())
2056
+ {
2057
+ tot = 0;
2058
+ break;
2059
+ }
2060
+ for (size_t i = 0; i < ss_ptr->Get_ss_comps().size(); i++)
2061
+ {
2062
+ cxxSScomp* comp_ptr = &(ss_ptr->Get_ss_comps()[i]);
2063
+ if (name == NULL)
2064
+ {
2065
+ tot += comp_ptr->Get_moles();
2066
+ }
2067
+ else
2068
+ {
2069
+ int l;
2070
+ class phase* phase_ptr = phase_bsearch(comp_ptr->Get_name().c_str(), &l, FALSE);
2071
+ for (next_elt = &phase_ptr->next_elt[0]; next_elt->elt != NULL; next_elt++)
2072
+ {
2073
+ if (strcmp(next_elt->elt->name, name) == 0)
2074
+ {
2075
+ tot += next_elt->coef * comp_ptr->Get_moles();
2076
+ break;
2077
+ }
2078
+ }
2079
+ }
2080
+ }
2081
+ break;
2082
+ }
2083
+ }
2084
+ return (tot);
2085
+ }
2086
+
2087
+ /* ---------------------------------------------------------------------- */
2088
+ LDBLE Phreeqc::
2089
+ list_ss(std::string ss_name, cxxNameDouble& composition)
2090
+ /* ---------------------------------------------------------------------- */
2091
+ {
2092
+ LDBLE tot = 0;
2093
+ composition.clear();
2094
+ if (use.Get_ss_assemblage_in() == FALSE || use.Get_ss_assemblage_ptr() == NULL)
2095
+ return (0);
2096
+
2097
+ std::vector<cxxSS*> ss_ptrs = use.Get_ss_assemblage_ptr()->Vectorize();
2098
+ for (size_t j = 0; j < ss_ptrs.size(); j++)
2099
+ {
2100
+ cxxSS* ss_ptr = ss_ptrs[j];
2101
+ if (strcmp_nocase(ss_ptr->Get_name().c_str(), ss_name.c_str()) == 0)
2102
+ {
2103
+ for (size_t i = 0; i < ss_ptr->Get_ss_comps().size(); i++)
2104
+ {
2105
+ cxxSScomp* comp_ptr = &(ss_ptr->Get_ss_comps()[i]);
2106
+ composition.add(comp_ptr->Get_name().c_str(), comp_ptr->Get_moles());
2107
+ tot += comp_ptr->Get_moles();
2108
+ }
2109
+ break;
2110
+ }
2111
+ }
2112
+ return (tot);
2113
+ }
2114
+ /* ---------------------------------------------------------------------- */
2115
+ int Phreeqc::
2116
+ match_elts_in_species(const char* name, const char* mytemplate)
2117
+ /* ---------------------------------------------------------------------- */
2118
+ {
2119
+ /*
2120
+ * Makes a list of elements with their coefficients, stores elements
2121
+ * in elt_list at position count_elts. Global variable count_elts is
2122
+ * updated with each stored element. Also uses static global variable
2123
+ * paren_count.
2124
+ *
2125
+ * Arguments:
2126
+ * **t_ptr input, point in token string to start looking
2127
+ * output, is next position to start looking
2128
+ * coef input, coefficient to multiply subscripts by
2129
+ */
2130
+ int i, i1, l, case_no, match;
2131
+ char c, c1;
2132
+ const char* cptr, * ptr1;
2133
+ LDBLE d;
2134
+ char token[MAX_LENGTH], equal_list[MAX_LENGTH];
2135
+ char token1[MAX_LENGTH], template1[MAX_LENGTH], equal_list1[MAX_LENGTH];
2136
+ char str[2];
2137
+
2138
+ Utilities::strcpy_safe(token, MAX_LENGTH, name);
2139
+ squeeze_white(token);
2140
+ replace("(+", "(", token);
2141
+ if (strstr("token", "++") != NULL)
2142
+ {
2143
+ replace("++++++", "+6", token);
2144
+ replace("+++++", "+5", token);
2145
+ replace("++++", "+4", token);
2146
+ replace("+++", "+3", token);
2147
+ replace("++", "+2", token);
2148
+ }
2149
+ if (strstr("token", "--") != NULL)
2150
+ {
2151
+ replace("------", "-6", token);
2152
+ replace("-----", "-5", token);
2153
+ replace("----", "-4", token);
2154
+ replace("---", "-3", token);
2155
+ replace("--", "-2", token);
2156
+ }
2157
+
2158
+ cptr = token;
2159
+ std::vector< std::pair<std::string, LDBLE> > match_vector;
2160
+ while ((c = *cptr) != '\0')
2161
+ {
2162
+ c1 = *(cptr + 1);
2163
+ str[0] = c;
2164
+ str[1] = '\0';
2165
+ /*
2166
+ * New element
2167
+ */
2168
+ if (isupper((int)c) || (c == 'e' && c1 == '-') || (c == '['))
2169
+ {
2170
+ /*
2171
+ * Get new element and subscript
2172
+ */
2173
+ std::string element;
2174
+ if (get_elt(&cptr, element, &l) == ERROR)
2175
+ {
2176
+ return (ERROR);
2177
+ }
2178
+ if (get_num(&cptr, &d) == ERROR)
2179
+ {
2180
+ return (ERROR);
2181
+ }
2182
+ std::pair<std::string, LDBLE> pr(element, d);
2183
+ match_vector.push_back(pr);
2184
+ }
2185
+ else
2186
+ {
2187
+ std::pair<std::string, LDBLE> pr(str, 1.0);
2188
+ match_vector.push_back(pr);
2189
+ cptr += 1;
2190
+ }
2191
+ }
2192
+ /*
2193
+ * Replace elements with first of equivalent elements
2194
+ */
2195
+ Utilities::strcpy_safe(template1, MAX_LENGTH, mytemplate);
2196
+ squeeze_white(template1);
2197
+ cptr = template1;
2198
+ while (extract_bracket(&cptr, equal_list) == TRUE)
2199
+ {
2200
+ replace("{", "", equal_list);
2201
+ replace("}", "", equal_list);
2202
+ while (replace(",", " ", equal_list) == TRUE);
2203
+ ptr1 = equal_list;
2204
+ /*
2205
+ * Get first name in a list from template
2206
+ */
2207
+ std::string elt_name;
2208
+ if (copy_token(elt_name, &ptr1) == EMPTY)
2209
+ {
2210
+ error_string = sformatf(
2211
+ "Expecting a nonempty list of element names in isotope sum. %s",
2212
+ mytemplate);
2213
+ error_msg(error_string, CONTINUE);
2214
+ return (ERROR);
2215
+ }
2216
+ std::string replace_name = elt_name;
2217
+ /*
2218
+ * Replace in species all equivalent names from template
2219
+ */
2220
+ while (copy_token(elt_name, &ptr1) != EMPTY)
2221
+ {
2222
+ for (i = 0; i < (int)match_vector.size(); i++)
2223
+ {
2224
+ if (elt_name == match_vector[i].first)
2225
+ {
2226
+ match_vector[i].first = replace_name;
2227
+ }
2228
+ }
2229
+ }
2230
+ }
2231
+ /*
2232
+ * Combine contiguous elements
2233
+ */
2234
+ i1 = 0;
2235
+ for (i = 1; i < (int)match_vector.size(); i++)
2236
+ {
2237
+ if ((isupper((int)(match_vector[i].first[0])) != FALSE)
2238
+ && (match_vector[i].first == match_vector[i1].first))
2239
+ {
2240
+ match_vector[i1].second += match_vector[i].second;
2241
+ }
2242
+ else
2243
+ {
2244
+ i1++;
2245
+ match_vector[i1].first = match_vector[i].first;
2246
+ match_vector[i1].second = match_vector[i].second;
2247
+ }
2248
+ }
2249
+ int count_match_tokens = i1 + 1;
2250
+ /*
2251
+ * write out string
2252
+ */
2253
+ token[0] = '\0';
2254
+ for (i = 0; i < count_match_tokens; i++)
2255
+ {
2256
+ Utilities::strcat_safe(token, MAX_LENGTH, match_vector[i].first.c_str());
2257
+ if (match_vector[i].second != 1.0)
2258
+ {
2259
+ snprintf(token1, sizeof(token1), "%g", (double)match_vector[i].second);
2260
+ Utilities::strcat_safe(token, MAX_LENGTH, token1);
2261
+ }
2262
+ }
2263
+ /*
2264
+ * Write a template name using first of equivalent elements
2265
+ */
2266
+ Utilities::strcpy_safe(template1, MAX_LENGTH, mytemplate);
2267
+ squeeze_white(template1);
2268
+ cptr = template1;
2269
+ while (extract_bracket(&cptr, equal_list) == TRUE)
2270
+ {
2271
+ Utilities::strcpy_safe(equal_list1, MAX_LENGTH, equal_list);
2272
+ replace("{", "", equal_list);
2273
+ replace("}", "", equal_list);
2274
+ while (replace(",", " ", equal_list) == TRUE);
2275
+ ptr1 = equal_list;
2276
+ /*
2277
+ * Get first name in a list
2278
+ */
2279
+ std::string elt_name;
2280
+ if (copy_token(elt_name, &ptr1) == EMPTY)
2281
+ {
2282
+ error_string = sformatf(
2283
+ "Expecting a nonempty list of element names in isotope sum. %s",
2284
+ mytemplate);
2285
+ error_msg(error_string, CONTINUE);
2286
+ return (ERROR);
2287
+ }
2288
+ replace(equal_list1, elt_name.c_str(), template1);
2289
+ squeeze_white(template1);
2290
+ cptr = template1;
2291
+ }
2292
+ /*
2293
+ * Compare string
2294
+ */
2295
+ /* Cases: 0 exact match
2296
+ * 1 leading wild card
2297
+ * 2 trailing wild card
2298
+ * 3 leading and trailing wild card
2299
+ */
2300
+ case_no = 0;
2301
+ if (template1[0] == '*')
2302
+ case_no = 1;
2303
+ l = (int)strlen(template1);
2304
+ if (template1[l - 1] == '*')
2305
+ {
2306
+ if (case_no != 1)
2307
+ {
2308
+ case_no = 2;
2309
+ }
2310
+ else
2311
+ {
2312
+ case_no = 3;
2313
+ }
2314
+ }
2315
+ while (replace("*", "", template1));
2316
+ match = FALSE;
2317
+ switch (case_no)
2318
+ {
2319
+ case 0:
2320
+ /* exact match */
2321
+ if (strcmp(token, template1) == 0)
2322
+ match = TRUE;
2323
+ break;
2324
+ case 1:
2325
+ /* leading wild card */
2326
+ if ((cptr = strstr(token, template1)) == NULL)
2327
+ {
2328
+ match = FALSE;
2329
+ }
2330
+ else
2331
+ {
2332
+ if (strcmp(cptr, template1) == 0)
2333
+ match = TRUE;
2334
+ }
2335
+ break;
2336
+ case 2:
2337
+ /* trailing wild card */
2338
+ if (strstr(token, template1) == token)
2339
+ match = TRUE;
2340
+ break;
2341
+ case 3:
2342
+ /* trailing wild card */
2343
+ if (strstr(token, template1) != NULL)
2344
+ match = TRUE;
2345
+ break;
2346
+ }
2347
+ return (match);
2348
+ }
2349
+
2350
+ /* ---------------------------------------------------------------------- */
2351
+ int Phreeqc::
2352
+ extract_bracket(const char** string, char* bracket_string)
2353
+ /* ---------------------------------------------------------------------- */
2354
+ {
2355
+ const char* cptr;
2356
+ char* ptr1;
2357
+
2358
+ if ((cptr = strstr(*string, "{")) == NULL)
2359
+ return (FALSE);
2360
+ strcpy(bracket_string, cptr);
2361
+ if ((ptr1 = strstr(bracket_string, "}")) == NULL)
2362
+ {
2363
+ error_string = sformatf(
2364
+ "No matching bracket (}) in isotope template string %s",
2365
+ *string);
2366
+ error_msg(error_string, CONTINUE);
2367
+ input_error++;
2368
+ return (FALSE);
2369
+ }
2370
+ ptr1[1] = '\0';
2371
+ *string = strstr(*string, "}");
2372
+ *string += 1;
2373
+ return (TRUE);
2374
+ }
2375
+ /* ---------------------------------------------------------------------- */
2376
+ LDBLE Phreeqc::
2377
+ surf_total(const char* total_name, const char* surface_name)
2378
+ /* ---------------------------------------------------------------------- */
2379
+ {
2380
+ /*
2381
+ * Provides total moles in LDBLE layer
2382
+ */
2383
+ int j;
2384
+
2385
+ if (use.Get_surface_ptr() == NULL || surface_name == NULL || total_name == NULL)
2386
+ return (0);
2387
+
2388
+ bool redox = false;
2389
+ if (strstr(total_name, "(") != NULL)
2390
+ {
2391
+ redox = true;
2392
+ }
2393
+ if (!redox)
2394
+ {
2395
+ if (strcmp(total_name, "H") == 0 || strcmp(total_name, "O") == 0)
2396
+ {
2397
+ return surf_total_no_redox(total_name, surface_name);
2398
+ }
2399
+ }
2400
+ /*
2401
+ * Find surface...
2402
+ */
2403
+ for (j = 0; j < count_unknowns; j++)
2404
+ {
2405
+ if (x[j]->type != SURFACE)
2406
+ continue;
2407
+
2408
+ std::string token;
2409
+ token = x[j]->master[0]->elt->name;
2410
+ replace("_", " ", token);
2411
+ std::string::iterator b = token.begin();
2412
+ std::string::iterator e = token.end();
2413
+ std::string name;
2414
+ CParser::copy_token(name, b, e);
2415
+ if (strcmp(name.c_str(), surface_name) == 0)
2416
+ break;
2417
+ }
2418
+ if (j >= count_unknowns)
2419
+ return (0);
2420
+ /*
2421
+ * find total moles for redox state
2422
+ */
2423
+ LDBLE t = 0;
2424
+ for (j = 0; j < (int)this->s_x.size(); j++)
2425
+ {
2426
+ if (s_x[j]->type != SURF)
2427
+ continue;
2428
+
2429
+ std::string token;
2430
+ bool match = false;
2431
+
2432
+ // find if surface matches
2433
+ for (int i = 0; s_x[j]->next_elt[i].elt != NULL; i++)
2434
+ {
2435
+ if (s_x[j]->next_elt[i].elt->master->type != SURF) continue;
2436
+
2437
+ token = s_x[j]->next_elt[i].elt->name;
2438
+ replace("_", " ", token);
2439
+ std::string::iterator b = token.begin();
2440
+ std::string::iterator e = token.end();
2441
+ std::string name;
2442
+ CParser::copy_token(name, b, e);
2443
+ if (strcmp(name.c_str(), surface_name) == 0)
2444
+ {
2445
+ match = true;
2446
+ break;
2447
+ }
2448
+ }
2449
+ if (!match) continue;
2450
+
2451
+ // surface matches, now match element or redox state
2452
+ class rxn_token* rxn_ptr;
2453
+ if (s_x[j]->mole_balance == NULL)
2454
+ {
2455
+ for (rxn_ptr = &s_x[j]->rxn_s.token[0] + 1; rxn_ptr->s != NULL; rxn_ptr++)
2456
+ {
2457
+ if (redox && rxn_ptr->s->secondary)
2458
+ {
2459
+ token = rxn_ptr->s->secondary->elt->name;
2460
+ }
2461
+ else if (!redox && rxn_ptr->s->secondary)
2462
+ {
2463
+ token = rxn_ptr->s->secondary->elt->primary->elt->name;
2464
+ }
2465
+ else if (!redox && rxn_ptr->s->primary)
2466
+ {
2467
+ token = rxn_ptr->s->primary->elt->name;
2468
+ }
2469
+ else
2470
+ {
2471
+ continue;
2472
+ }
2473
+ if (strcmp(token.c_str(), total_name) == 0)
2474
+ {
2475
+ t += rxn_ptr->coef * s_x[j]->moles;
2476
+ break;
2477
+ }
2478
+ else
2479
+ // sum all sites in case total_name is a surface name without underscore surf ("Hfo_w", "Hfo")
2480
+ {
2481
+ if (rxn_ptr->s->type == SURF)
2482
+ {
2483
+ if (token.find("_") != std::string::npos)
2484
+ {
2485
+ token = token.substr(0, token.find("_"));
2486
+ }
2487
+ if (strcmp(token.c_str(), total_name) == 0)
2488
+ {
2489
+ t += rxn_ptr->coef * s_x[j]->moles;
2490
+ break;
2491
+ }
2492
+ }
2493
+ }
2494
+ }
2495
+ }
2496
+ else
2497
+ {
2498
+ for (int i = 0; s_x[j]->next_secondary[i].elt != NULL; i++)
2499
+ {
2500
+ token = s_x[j]->next_secondary[i].elt->name;
2501
+ if (strcmp(token.c_str(), total_name) == 0)
2502
+ {
2503
+ t += s_x[j]->next_secondary[i].coef * s_x[j]->moles;
2504
+ break;
2505
+ }
2506
+ }
2507
+ }
2508
+ }
2509
+ return t;
2510
+ }
2511
+
2512
+ /* ---------------------------------------------------------------------- */
2513
+ LDBLE Phreeqc::
2514
+ surf_total_no_redox(const char* total_name, const char* surface_name)
2515
+ /* ---------------------------------------------------------------------- */
2516
+ {
2517
+ /*
2518
+ * Provides total moles in LDBLE layer
2519
+ */
2520
+ int i, j, k;
2521
+ char name[MAX_LENGTH], token[MAX_LENGTH];
2522
+ char surface_name_local[MAX_LENGTH];
2523
+ const char* cptr;
2524
+
2525
+ if (use.Get_surface_ptr() == NULL)
2526
+ return (0);
2527
+
2528
+ /*
2529
+ * Find surface...
2530
+ */
2531
+ for (j = 0; j < count_unknowns; j++)
2532
+ {
2533
+ if (x[j]->type != SURFACE)
2534
+ continue;
2535
+ Utilities::strcpy_safe(token, MAX_LENGTH, x[j]->master[0]->elt->name);
2536
+ replace("_", " ", token);
2537
+ cptr = token;
2538
+ copy_token(name, &cptr, &k);
2539
+ if (surface_name != NULL)
2540
+ {
2541
+ if (strcmp(name, surface_name) == 0)
2542
+ break;
2543
+ }
2544
+ else
2545
+ {
2546
+ break;
2547
+ }
2548
+ }
2549
+ if (j >= count_unknowns)
2550
+ return (0);
2551
+ Utilities::strcpy_safe(surface_name_local, MAX_LENGTH, name);
2552
+ /*
2553
+ * find total moles of each element in diffuse layer...
2554
+ */
2555
+ count_elts = 0;
2556
+ paren_count = 0;
2557
+ for (j = 0; j < (int)this->s_x.size(); j++)
2558
+ {
2559
+ if (s_x[j]->type != SURF)
2560
+ continue;
2561
+ for (i = 0; s_x[j]->next_elt[i].elt != NULL; i++)
2562
+ {
2563
+ if (s_x[j]->next_elt[i].elt->master->type != SURF) continue;
2564
+
2565
+ Utilities::strcpy_safe(token, MAX_LENGTH, s_x[j]->next_elt[i].elt->name);
2566
+ replace("_", " ", token);
2567
+ cptr = token;
2568
+ copy_token(name, &cptr, &k);
2569
+ if (strcmp(name, surface_name_local) == 0)
2570
+ {
2571
+ /*
2572
+ * Accumulate elements in diffuse layer
2573
+ */
2574
+ add_elt_list(s_x[j]->next_elt, s_x[j]->moles);
2575
+ //fprintf(stderr, "%15s\t%e\t%s\t%s\n", s_x[j]->name, s_x[j]->moles, name, surface_name_local );
2576
+ break;
2577
+ }
2578
+ }
2579
+ }
2580
+ elt_list_combine();
2581
+ /*
2582
+ * Return totals
2583
+ */
2584
+ for (j = 0; j < count_elts; j++)
2585
+ {
2586
+ if (strcmp(elt_list[j].elt->name, total_name) == 0)
2587
+ {
2588
+ return ((LDBLE)elt_list[j].coef);
2589
+ }
2590
+ }
2591
+ return (0);
2592
+ }
2593
+ /* ---------------------------------------------------------------------- */
2594
+ LDBLE Phreeqc::
2595
+ total(const char* total_name)
2596
+ /* ---------------------------------------------------------------------- */
2597
+ {
2598
+ class master* master_ptr;
2599
+ LDBLE t;
2600
+
2601
+ if (strcmp(total_name, "H") == 0)
2602
+ {
2603
+ return (total_h_x / mass_water_aq_x);
2604
+ }
2605
+ if (strcmp(total_name, "O") == 0)
2606
+ {
2607
+ return (total_o_x / mass_water_aq_x);
2608
+ }
2609
+ std::string noplus = total_name;
2610
+ replace(noplus, "(+", "(");
2611
+ master_ptr = master_bsearch(noplus.c_str());
2612
+ t = 0.0;
2613
+ if (master_ptr == NULL)
2614
+ {
2615
+ if (strcmp_nocase(total_name, "water") == 0)
2616
+ {
2617
+ return (mass_water_aq_x);
2618
+ }
2619
+ else if (strcmp_nocase(total_name, "charge") == 0)
2620
+ {
2621
+ return (cb_x / mass_water_aq_x);
2622
+ }
2623
+ /*
2624
+ sprintf (error_string, "Cannot find definition for master species, %s.",
2625
+ total_name);
2626
+ warning_msg (error_string);
2627
+ */
2628
+ }
2629
+ /*
2630
+ * Primary master species
2631
+ */
2632
+ else if (master_ptr->primary == TRUE)
2633
+ {
2634
+ /*
2635
+ * Not a redox element
2636
+ */
2637
+ if (master_ptr->s->secondary == NULL)
2638
+ {
2639
+ t = master_ptr->total / mass_water_aq_x;
2640
+ /*
2641
+ * Redox element, need to sum totals of all redox states
2642
+ */
2643
+ }
2644
+ else
2645
+ {
2646
+ t = 0;
2647
+ for (size_t i = master_ptr->number + 1;
2648
+ (i < (int)master.size() && master[i]->elt->primary == master_ptr);
2649
+ i++)
2650
+ {
2651
+ t += master[i]->total / mass_water_aq_x;
2652
+ }
2653
+ }
2654
+ }
2655
+ /*
2656
+ * Secondary master species
2657
+ */
2658
+ else
2659
+ {
2660
+ t = master_ptr->total / mass_water_aq_x;
2661
+ }
2662
+ return (t);
2663
+ }
2664
+ /* ---------------------------------------------------------------------- */
2665
+ LDBLE Phreeqc::
2666
+ total_mole(const char* total_name)
2667
+ /* ---------------------------------------------------------------------- */
2668
+ {
2669
+ class master* master_ptr;
2670
+ LDBLE t;
2671
+
2672
+ if (strcmp(total_name, "H") == 0)
2673
+ {
2674
+ return (total_h_x);
2675
+ }
2676
+ if (strcmp(total_name, "O") == 0)
2677
+ {
2678
+ return (total_o_x);
2679
+ }
2680
+ std::string noplus = total_name;
2681
+ replace(noplus, "(+", "(");
2682
+ master_ptr = master_bsearch(noplus.c_str());
2683
+ t = 0.0;
2684
+ if (master_ptr == NULL)
2685
+ {
2686
+ if (strcmp_nocase(total_name, "water") == 0)
2687
+ {
2688
+ return (mass_water_aq_x / gfw_water);
2689
+ }
2690
+ else if (strcmp_nocase(total_name, "charge") == 0)
2691
+ {
2692
+ return (cb_x);
2693
+ }
2694
+ /*
2695
+ sprintf (error_string, "Cannot find definition for master species, %s.",
2696
+ total_name);
2697
+ warning_msg (error_string);
2698
+ */
2699
+ }
2700
+ /*
2701
+ * Primary master species
2702
+ */
2703
+ else if (master_ptr->primary == TRUE)
2704
+ {
2705
+ /*
2706
+ * Not a redox element
2707
+ */
2708
+ if (master_ptr->s->secondary == NULL)
2709
+ {
2710
+ t = master_ptr->total;
2711
+ /*
2712
+ * Redox element, need to sum totals of all redox states
2713
+ */
2714
+ }
2715
+ else
2716
+ {
2717
+ t = 0;
2718
+ for (size_t i = master_ptr->number + 1;
2719
+ (i < master.size() && master[i]->elt->primary == master_ptr);
2720
+ i++)
2721
+ {
2722
+ t += master[i]->total;
2723
+ }
2724
+ }
2725
+ }
2726
+ /*
2727
+ * Secondary master species
2728
+ */
2729
+ else
2730
+ {
2731
+ t = master_ptr->total;
2732
+ }
2733
+ return (t);
2734
+ }
2735
+
2736
+ /* ---------------------------------------------------------------------- */
2737
+ int Phreeqc::
2738
+ get_edl_species(cxxSurfaceCharge& charge_ref)
2739
+ /* ---------------------------------------------------------------------- */
2740
+ {
2741
+
2742
+ double mass_water_surface = charge_ref.Get_mass_water();
2743
+ sys.clear();
2744
+ for (int j = 0; j < (int)this->s_x.size(); j++)
2745
+ {
2746
+ if (s_x[j]->type == H2O)
2747
+ {
2748
+ size_t count_sys = sys.size();
2749
+ sys.resize(count_sys + 1);
2750
+ sys[count_sys].name = string_duplicate(s_x[j]->name);
2751
+ sys[count_sys].moles = mass_water_surface / gfw_water;
2752
+ sys_tot += sys[count_sys].moles;
2753
+ count_sys++;
2754
+ }
2755
+ else if (s_x[j]->type < H2O)
2756
+ {
2757
+ size_t count_sys = sys.size();
2758
+ sys.resize(count_sys + 1);
2759
+ double molality = under(s_x[j]->lm);
2760
+ double moles_excess = mass_water_aq_x * molality * charge_ref.Get_g_map()[s_x[j]->z].Get_g();
2761
+ double moles_surface = mass_water_surface * molality + moles_excess;
2762
+ sys[count_sys].name = string_duplicate(s_x[j]->name);
2763
+ sys[count_sys].moles = moles_surface;
2764
+ sys_tot += sys[count_sys].moles;
2765
+ count_sys++;
2766
+ }
2767
+ else
2768
+ {
2769
+ continue;
2770
+ }
2771
+ }
2772
+ return (OK);
2773
+ }
2774
+ /* ---------------------------------------------------------------------- */
2775
+ LDBLE Phreeqc::
2776
+ edl_species(const char* surf_name, LDBLE* count, char*** names, LDBLE** moles, LDBLE* area, LDBLE* thickness)
2777
+ /* ---------------------------------------------------------------------- */
2778
+ {
2779
+ /*
2780
+ * Provides total moles in system and lists of species/phases in sort order
2781
+ */
2782
+ int i;
2783
+ sys_tot = 0;
2784
+ sys.clear();
2785
+ if (!(dl_type_x == cxxSurface::NO_DL))
2786
+ {
2787
+ cxxSurface* surface_ptr = use.Get_surface_ptr();
2788
+ for (size_t i = 0; i < surface_ptr->Get_surface_charges().size(); i++)
2789
+ {
2790
+ cxxSurfaceCharge& charge_ref = surface_ptr->Get_surface_charges()[i];
2791
+ if (strcmp(charge_ref.Get_name().c_str(), surf_name) == 0)
2792
+ {
2793
+ get_edl_species(charge_ref);
2794
+ *area = charge_ref.Get_specific_area() * charge_ref.Get_grams();
2795
+ *thickness = surface_ptr->Get_thickness();
2796
+ break;
2797
+ }
2798
+ }
2799
+ }
2800
+ /*
2801
+ * Sort system species
2802
+ */
2803
+ if (sys.size() > 1)
2804
+ {
2805
+ qsort(&sys[0], sys.size(),
2806
+ sizeof(class system_species), system_species_compare);
2807
+ }
2808
+ /*
2809
+ * malloc space
2810
+ */
2811
+ *names = (char**)PHRQ_malloc((sys.size() + 1) * sizeof(char*));
2812
+ if (names == NULL)
2813
+ malloc_error();
2814
+ *moles = (LDBLE*)PHRQ_malloc((sys.size() + 1) * sizeof(LDBLE));
2815
+ if (*moles == NULL)
2816
+ malloc_error();
2817
+
2818
+ (*names)[0] = NULL;
2819
+ (*moles)[0] = 0;
2820
+ for (i = 0; i < (int)sys.size(); i++)
2821
+ {
2822
+ (*names)[i + 1] = sys[i].name;
2823
+ (*moles)[i + 1] = sys[i].moles;
2824
+ }
2825
+ *count = (LDBLE)sys.size();
2826
+
2827
+ //PHRQ_free(sys);
2828
+ sys.clear();
2829
+ return (sys_tot);
2830
+ }
2831
+ /* ---------------------------------------------------------------------- */
2832
+ LDBLE Phreeqc::
2833
+ system_total(const char* total_name, LDBLE* count, char*** names,
2834
+ char*** types, LDBLE** moles, int isort)
2835
+ /* ---------------------------------------------------------------------- */
2836
+ {
2837
+ /*
2838
+ * Provides total moles in system and lists of species/phases in sort order
2839
+ */
2840
+ int i;
2841
+
2842
+ sys_tot = 0;
2843
+ sys.clear();
2844
+ if (strcmp_nocase(total_name, "elements") == 0)
2845
+ {
2846
+ system_total_elements();
2847
+ }
2848
+ else if (strcmp_nocase(total_name, "phases") == 0)
2849
+ {
2850
+ system_total_si();
2851
+ }
2852
+ else if (strcmp_nocase(total_name, "aq") == 0)
2853
+ {
2854
+ system_total_aq();
2855
+ }
2856
+ else if (strcmp_nocase(total_name, "ex") == 0)
2857
+ {
2858
+ system_total_ex();
2859
+ }
2860
+ else if (strcmp_nocase(total_name, "surf") == 0)
2861
+ {
2862
+ system_total_surf();
2863
+ }
2864
+ else if (strcmp_nocase(total_name, "s_s") == 0)
2865
+ {
2866
+ system_total_ss();
2867
+ }
2868
+ else if (strcmp_nocase(total_name, "gas") == 0)
2869
+ {
2870
+ system_total_gas();
2871
+ }
2872
+ else if (strcmp_nocase(total_name, "equi") == 0)
2873
+ {
2874
+ system_total_equi();
2875
+ }
2876
+ else if (strcmp_nocase(total_name, "kin") == 0)
2877
+ {
2878
+ system_total_kin();
2879
+ }
2880
+ else
2881
+ {
2882
+ if (strstr(total_name, "(") == NULL)
2883
+ {
2884
+ system_total_elt(total_name);
2885
+ }
2886
+ else
2887
+ {
2888
+ system_total_elt_secondary(total_name);
2889
+ }
2890
+ }
2891
+ /*
2892
+ * Sort system species
2893
+ */
2894
+ if (sys.size() > 1 && isort == 0)
2895
+ {
2896
+ qsort(&sys[0], sys.size(),
2897
+ sizeof(class system_species), system_species_compare);
2898
+ }
2899
+ else if (sys.size() > 1)
2900
+ {
2901
+ qsort(&sys[0], sys.size(),
2902
+ sizeof(class system_species), system_species_compare_name);
2903
+ }
2904
+ /*
2905
+ * malloc space
2906
+ */
2907
+ size_t count_sys = sys.size();
2908
+ *names = (char**)PHRQ_malloc((count_sys + 1) * sizeof(char*));
2909
+ if (*names == NULL)
2910
+ malloc_error();
2911
+ *types = (char**)PHRQ_malloc((count_sys + 1) * sizeof(char*));
2912
+ if (*types == NULL)
2913
+ malloc_error();
2914
+ *moles = (LDBLE*)PHRQ_malloc((count_sys + 1) * sizeof(LDBLE));
2915
+ if (*moles == NULL)
2916
+ malloc_error();
2917
+
2918
+ (*names)[0] = NULL;
2919
+ (*types)[0] = NULL;
2920
+ (*moles)[0] = 0;
2921
+ for (i = 0; i < (int)count_sys; i++)
2922
+ {
2923
+ (*names)[i + 1] = sys[i].name;
2924
+ (*types)[i + 1] = sys[i].type;
2925
+ (*moles)[i + 1] = sys[i].moles;
2926
+ }
2927
+ *count = (LDBLE)count_sys;
2928
+ if (strcmp_nocase(total_name, "elements") == 0)
2929
+ {
2930
+ sys_tot = 0;;
2931
+ for (i = 0; i < (int)count_sys; i++)
2932
+ {
2933
+ if (strcmp(sys[i].type, "dis") == 0 &&
2934
+ strstr(sys[i].name, "(") == NULL &&
2935
+ strcmp(sys[i].name, "H") != 0
2936
+ && strcmp(sys[i].name, "O") != 0)
2937
+ {
2938
+ sys_tot += sys[i].moles;
2939
+ }
2940
+ }
2941
+ }
2942
+ //PHRQ_free(sys);
2943
+ sys.clear();
2944
+ return (sys_tot);
2945
+ }
2946
+
2947
+ /* ---------------------------------------------------------------------- */
2948
+ std::string Phreeqc::
2949
+ kinetics_formula(std::string kin_name, cxxNameDouble& stoichiometry)
2950
+ /* ---------------------------------------------------------------------- */
2951
+ {
2952
+ /*
2953
+ * Returns formula of kinetic reactant
2954
+ * Also returns arrays of elements and stoichiometry in stoichiometry
2955
+ */
2956
+ stoichiometry.clear();
2957
+ std::string formula;
2958
+
2959
+ if (use.Get_kinetics_ptr() == NULL)
2960
+ return (formula);
2961
+ std::vector <cxxKineticsComp> comps = use.Get_kinetics_ptr()->Get_kinetics_comps();
2962
+ count_elts = 0;
2963
+ paren_count = 0;
2964
+ for (size_t i = 0; i < comps.size(); i++)
2965
+ {
2966
+ cxxKineticsComp* comp_ptr = &comps[i];
2967
+ if (kin_name == comp_ptr->Get_rate_name().c_str())
2968
+ {
2969
+ cxxNameDouble nd = comp_ptr->Get_namecoef();
2970
+ cxxNameDouble::iterator it = nd.begin();
2971
+ for (; it != nd.end(); it++)
2972
+ {
2973
+ // Try Phases
2974
+ int l;
2975
+ class phase* phase_ptr = phase_bsearch(it->first.c_str(), &l, FALSE);
2976
+ if (phase_ptr != NULL)
2977
+ {
2978
+ add_elt_list(phase_ptr->next_elt, it->second);
2979
+ }
2980
+ else
2981
+ {
2982
+ // add formula
2983
+ std::string name = it->first;
2984
+ LDBLE coef = it->second;
2985
+ const char* cptr = &name[0];
2986
+ get_elts_in_species(&cptr, coef);
2987
+ }
2988
+ }
2989
+ formula.append(kin_name);
2990
+ //elt_list[count_elts].elt = NULL;
2991
+ elt_list_combine();
2992
+ stoichiometry = elt_list_NameDouble();
2993
+ break;
2994
+ }
2995
+ }
2996
+ return (formula);
2997
+ }
2998
+ /* ---------------------------------------------------------------------- */
2999
+ std::string Phreeqc::
3000
+ phase_formula(std::string phase_name, cxxNameDouble& stoichiometry)
3001
+ /* ---------------------------------------------------------------------- */
3002
+ {
3003
+ /*
3004
+ * Returns formula of mineral
3005
+ * Also returns arrays of elements and stoichiometry in elts_arg and coef_arg
3006
+ */
3007
+ stoichiometry.clear();
3008
+ std::string formula;
3009
+
3010
+ int j;
3011
+ class phase* phase_ptr = phase_bsearch(phase_name.c_str(), &j, FALSE);
3012
+ if (phase_ptr != NULL)
3013
+ {
3014
+ formula.append(phase_ptr->formula);
3015
+ cxxNameDouble nd(phase_ptr->next_elt);
3016
+ stoichiometry = nd;
3017
+ }
3018
+
3019
+ return (formula);
3020
+ }
3021
+ /* ---------------------------------------------------------------------- */
3022
+ std::string Phreeqc::
3023
+ species_formula(std::string phase_name, cxxNameDouble& stoichiometry)
3024
+ /* ---------------------------------------------------------------------- */
3025
+ {
3026
+ /*
3027
+ * Returns formula of mineral
3028
+ * Also returns arrays of elements and stoichiometry in elts_arg and coef_arg
3029
+ */
3030
+ stoichiometry.clear();
3031
+ std::string formula;
3032
+ formula = "none";
3033
+ class species* s_ptr = s_search(phase_name.c_str());
3034
+ if (s_ptr != NULL)
3035
+ {
3036
+ cxxNameDouble nd(s_ptr->next_elt);
3037
+ stoichiometry = nd;
3038
+ stoichiometry["charge"] = s_ptr->z;
3039
+ if (s_ptr->type == EX)
3040
+ {
3041
+ formula = "ex";
3042
+ }
3043
+ else if (s_ptr->type == SURF)
3044
+ {
3045
+ formula = "surf";
3046
+ }
3047
+ else
3048
+ {
3049
+ formula = "aq";
3050
+ }
3051
+ }
3052
+ return (formula);
3053
+ }
3054
+
3055
+ /* ---------------------------------------------------------------------- */
3056
+ std::string Phreeqc::
3057
+ phase_equation(std::string phase_name, std::vector<std::pair<std::string, double> >& stoichiometry)
3058
+ /* ---------------------------------------------------------------------- */
3059
+ {
3060
+ /*
3061
+ * Returns equation
3062
+ * Also returns arrays of species and stoichiometry in stoichiometry
3063
+ */
3064
+ stoichiometry.clear();
3065
+ std::ostringstream eq, lhs, rhs;
3066
+ int j = -1;
3067
+ class phase* phase_ptr = phase_bsearch(phase_name.c_str(), &j, FALSE);
3068
+ bool rhs_started = false;
3069
+ bool lhs_started = false;
3070
+ if (phase_ptr != NULL)
3071
+ {
3072
+ std::vector<rxn_token>::iterator it = phase_ptr->rxn.Get_tokens().begin();
3073
+ for (; it->name != NULL; it++)
3074
+ {
3075
+ if (!lhs_started)
3076
+ {
3077
+ std::pair<std::string, double> item(phase_ptr->formula, it->coef);
3078
+ stoichiometry.push_back(item);
3079
+ }
3080
+ else
3081
+ {
3082
+ std::pair<std::string, double> item(it->name, it->coef);
3083
+ stoichiometry.push_back(item);
3084
+ }
3085
+ if (it->coef < 0.0)
3086
+ {
3087
+ if (lhs_started) lhs << "+ ";
3088
+ if (it->coef != -1.0)
3089
+ {
3090
+ lhs << -it->coef;
3091
+ }
3092
+ lhs << it->name << " ";
3093
+ lhs_started = true;
3094
+ }
3095
+ else if (it->coef > 0.0)
3096
+ {
3097
+ if (rhs_started) rhs << "+ ";
3098
+ if (it->coef != 1.0)
3099
+ {
3100
+ rhs << it->coef;
3101
+ }
3102
+ rhs << it->name << " ";
3103
+ rhs_started = true;
3104
+ }
3105
+ }
3106
+ }
3107
+ eq << lhs.str() << "= " << rhs.str();
3108
+ return (eq.str());
3109
+ }
3110
+
3111
+ /* ---------------------------------------------------------------------- */
3112
+ std::string Phreeqc::
3113
+ species_equation(std::string species_name, std::vector<std::pair<std::string, double> >& stoichiometry)
3114
+ /* ---------------------------------------------------------------------- */
3115
+ {
3116
+ /*
3117
+ * Returns equation
3118
+ * Also returns arrays of species and stoichiometry in stoichiometry
3119
+ */
3120
+ stoichiometry.clear();
3121
+ std::ostringstream eq, lhs, rhs;;
3122
+ class species* s_ptr = s_search(species_name.c_str());
3123
+ bool rhs_started = false;
3124
+ bool lhs_started = false;
3125
+ if (s_ptr != NULL)
3126
+ {
3127
+ std::vector<rxn_token>::iterator it = s_ptr->rxn.Get_tokens().begin();
3128
+ for ( ; it->name != NULL; it++)
3129
+ {
3130
+ std::pair<std::string, double> item(it->name, it->coef);
3131
+ stoichiometry.push_back(item);
3132
+ if (it->coef > 0.0)
3133
+ {
3134
+ if (lhs_started) lhs << "+ ";
3135
+ if (it->coef != 1.0)
3136
+ {
3137
+ lhs << it->coef;
3138
+ }
3139
+ lhs << it->name << " ";
3140
+ lhs_started = true;
3141
+ }
3142
+ else if (it->coef < 0.0)
3143
+ {
3144
+ if (rhs_started) rhs << "+ ";
3145
+ if (it->coef != -1.0)
3146
+ {
3147
+ rhs << -it->coef;
3148
+ }
3149
+ rhs << it->name << " ";
3150
+ rhs_started = true;
3151
+ }
3152
+ }
3153
+ }
3154
+ eq << lhs.str() << "= " << rhs.str();
3155
+ return (eq.str());
3156
+ }
3157
+
3158
+ /* ---------------------------------------------------------------------- */
3159
+ int Phreeqc::
3160
+ system_total_elements(void)
3161
+ /* ---------------------------------------------------------------------- */
3162
+ {
3163
+ int i;
3164
+ LDBLE t;
3165
+ char name[MAX_LENGTH];
3166
+ class master* master_ptr;
3167
+
3168
+ /*
3169
+ * Include H and O
3170
+ */
3171
+ size_t count_sys = sys.size();
3172
+ sys.resize(count_sys + 1);
3173
+ sys[count_sys].name = string_duplicate("H");
3174
+ sys[count_sys].moles = total_h_x;
3175
+ sys_tot += sys[count_sys].moles;
3176
+ sys[count_sys].type = string_duplicate("dis");
3177
+ count_sys++;
3178
+ sys.resize(count_sys + 1);
3179
+ sys[count_sys].name = string_duplicate("O");
3180
+ sys[count_sys].moles = total_o_x;
3181
+ sys_tot += sys[count_sys].moles;
3182
+ sys[count_sys].type = string_duplicate("dis");
3183
+ count_sys++;;
3184
+ /*
3185
+ * Include H(1) and O(-2)
3186
+ */
3187
+ sys.resize(count_sys + 1);
3188
+ sys[count_sys].name = string_duplicate("H(1)");
3189
+ sys[count_sys].moles = solution_sum_secondary("H(1)");
3190
+ sys_tot += sys[count_sys].moles;
3191
+ sys[count_sys].type = string_duplicate("dis");
3192
+ count_sys++;
3193
+ sys.resize(count_sys + 1);
3194
+ sys[count_sys].name = string_duplicate("O(-2)");
3195
+ sys[count_sys].moles = solution_sum_secondary("O(-2)");
3196
+ sys_tot += sys[count_sys].moles;
3197
+ sys[count_sys].type = string_duplicate("dis");
3198
+ count_sys++;
3199
+ for (i = 0; i < (int)master.size(); i++)
3200
+ {
3201
+ master_ptr = master[i];
3202
+ if (master_ptr->primary == TRUE && master_ptr->total_primary <= 0)
3203
+ continue;
3204
+ if (master_ptr->in == FALSE
3205
+ && (master_ptr->primary == FALSE
3206
+ || master_ptr->total_primary == 0))
3207
+ continue;
3208
+ /*
3209
+ * H and O
3210
+ */
3211
+ if (master_ptr->s == s_hplus)
3212
+ {
3213
+ continue;
3214
+ }
3215
+ else if (master_ptr->s == s_h2o)
3216
+ {
3217
+ continue;
3218
+ }
3219
+ if (master_ptr->primary == TRUE)
3220
+ {
3221
+ if (master_ptr->total_primary > 0)
3222
+ {
3223
+ t = master_ptr->total_primary;
3224
+ /*
3225
+ * Not a redox element
3226
+ */
3227
+ }
3228
+ else if (master_ptr->s->secondary == NULL)
3229
+ {
3230
+ t = master_ptr->total;
3231
+ /*
3232
+ * Redox element, need to sum totals of all redox states
3233
+ */
3234
+ }
3235
+ else
3236
+ {
3237
+ t = 0;
3238
+ for (size_t j = master_ptr->number + 1;
3239
+ master[j]->elt->primary == master_ptr; j++)
3240
+ {
3241
+ t += master[j]->total;
3242
+ }
3243
+ }
3244
+ /*
3245
+ * Secondary master species
3246
+ */
3247
+ }
3248
+ else
3249
+ {
3250
+ t = master_ptr->total;
3251
+ }
3252
+ Utilities::strcpy_safe(name, MAX_LENGTH, master[i]->elt->name);
3253
+ count_sys = sys.size();
3254
+ sys.resize(count_sys + 1);
3255
+ sys[count_sys].name = string_duplicate(name);
3256
+ sys[count_sys].moles = t;
3257
+ sys_tot += sys[count_sys].moles;
3258
+ if (master[i]->s->type <= SOLID)
3259
+ {
3260
+ sys[count_sys].type = string_duplicate("dis");
3261
+ }
3262
+ else if (master[i]->s->type == EX)
3263
+ {
3264
+ sys[count_sys].type = string_duplicate("ex");
3265
+ }
3266
+ else if (master[i]->s->type == SURF || master[i]->s->type == SURF_PSI)
3267
+ {
3268
+ sys[count_sys].type = string_duplicate("surf");
3269
+ }
3270
+ }
3271
+ return (OK);
3272
+ }
3273
+
3274
+ /* ---------------------------------------------------------------------- */
3275
+ int Phreeqc::
3276
+ system_total_si(void)
3277
+ /* ---------------------------------------------------------------------- */
3278
+ {
3279
+ int i;
3280
+ LDBLE si, iap;
3281
+ class rxn_token* rxn_ptr;
3282
+ char name[MAX_LENGTH];
3283
+
3284
+ sys_tot = -999.9;
3285
+ for (i = 0; i < (int)phases.size(); i++)
3286
+ {
3287
+ if (phases[i]->in == FALSE || phases[i]->type != SOLID)
3288
+ continue;
3289
+ /*
3290
+ * Print saturation index
3291
+ */
3292
+ iap = 0.0;
3293
+ for (rxn_ptr = &phases[i]->rxn_x.token[0] + 1; rxn_ptr->s != NULL;
3294
+ rxn_ptr++)
3295
+ {
3296
+ iap += rxn_ptr->s->la * rxn_ptr->coef;
3297
+ }
3298
+ si = -phases[i]->lk + iap;
3299
+ Utilities::strcpy_safe(name, MAX_LENGTH, phases[i]->name);
3300
+ size_t count_sys = sys.size();
3301
+ sys.resize(count_sys + 1);
3302
+ sys[count_sys].name = string_duplicate(name);
3303
+ sys[count_sys].moles = si;
3304
+ if (si > sys_tot)
3305
+ sys_tot = si;
3306
+ sys[count_sys].type = string_duplicate("phase");
3307
+ }
3308
+ return (OK);
3309
+ }
3310
+
3311
+ /* ---------------------------------------------------------------------- */
3312
+ int Phreeqc::
3313
+ system_total_aq(void)
3314
+ /* ---------------------------------------------------------------------- */
3315
+ {
3316
+ /*
3317
+ * Provides total moles in system and lists of species/phases in sort order
3318
+ */
3319
+ int i;
3320
+ /*
3321
+ * find total moles in aq, surface, and exchange
3322
+ */
3323
+ for (i = 0; i < (int)this->s_x.size(); i++)
3324
+ {
3325
+ //if (s_x[i]->type != AQ)
3326
+ if (s_x[i]->type > HPLUS)
3327
+ continue;
3328
+ size_t count_sys = sys.size();
3329
+ sys.resize(count_sys + 1);
3330
+ sys[count_sys].name = string_duplicate(s_x[i]->name);
3331
+ sys[count_sys].moles = s_x[i]->moles;
3332
+ sys_tot += sys[count_sys].moles;
3333
+ sys[count_sys].type = string_duplicate("aq");
3334
+ }
3335
+ return (OK);
3336
+ }
3337
+
3338
+ /* ---------------------------------------------------------------------- */
3339
+ int Phreeqc::
3340
+ system_total_ex(void)
3341
+ /* ---------------------------------------------------------------------- */
3342
+ {
3343
+ /*
3344
+ * Provides total moles in system and lists of species/phases in sort order
3345
+ */
3346
+ int i;
3347
+ /*
3348
+ * find total moles in aq, surface, and exchange
3349
+ */
3350
+ for (i = 0; i < (int)this->s_x.size(); i++)
3351
+ {
3352
+ if (s_x[i]->type != EX)
3353
+ continue;
3354
+ if (s_x[i]->primary != NULL)
3355
+ continue;
3356
+ size_t count_sys = sys.size();
3357
+ sys.resize(count_sys + 1);
3358
+ sys[count_sys].name = string_duplicate(s_x[i]->name);
3359
+ sys[count_sys].moles = s_x[i]->moles;
3360
+ sys_tot += sys[count_sys].moles;
3361
+ sys[count_sys].type = string_duplicate("ex");
3362
+ }
3363
+ return (OK);
3364
+ }
3365
+
3366
+ /* ---------------------------------------------------------------------- */
3367
+ int Phreeqc::
3368
+ system_total_surf(void)
3369
+ /* ---------------------------------------------------------------------- */
3370
+ {
3371
+ /*
3372
+ * Provides total moles in system and lists of species/phases in sort order
3373
+ */
3374
+ int i;
3375
+ /*
3376
+ * find total moles in aq, surface, and exchange
3377
+ */
3378
+ for (i = 0; i < (int)this->s_x.size(); i++)
3379
+ {
3380
+ if (s_x[i]->type != SURF)
3381
+ continue;
3382
+ size_t count_sys = sys.size();
3383
+ sys.resize(count_sys + 1);
3384
+ sys[count_sys].name = string_duplicate(s_x[i]->name);
3385
+ sys[count_sys].moles = s_x[i]->moles;
3386
+ sys_tot += sys[count_sys].moles;
3387
+ sys[count_sys].type = string_duplicate("surf");
3388
+ }
3389
+ return (OK);
3390
+ }
3391
+ /* ---------------------------------------------------------------------- */
3392
+ int Phreeqc::
3393
+ system_total_gas(void)
3394
+ /* ---------------------------------------------------------------------- */
3395
+ {
3396
+ /*
3397
+ * Provides total moles in system and lists of species/phases in sort order
3398
+ */
3399
+ int i;
3400
+
3401
+ /*
3402
+ * find total in gas phase
3403
+ */
3404
+ if (use.Get_gas_phase_ptr() == NULL)
3405
+ return (OK);
3406
+ cxxGasPhase *gas_phase_ptr = use.Get_gas_phase_ptr();
3407
+ for (size_t j = 0; j < gas_phase_ptr->Get_gas_comps().size(); j++)
3408
+ {
3409
+ class phase *phase_ptr = phase_bsearch(gas_phase_ptr->Get_gas_comps()[j].Get_phase_name().c_str(),
3410
+ &i, FALSE);
3411
+ assert(phase_ptr);
3412
+ size_t count_sys = sys.size();
3413
+ sys.resize(count_sys + 1);
3414
+ sys[count_sys].name = string_duplicate(phase_ptr->name);
3415
+ sys[count_sys].moles = phase_ptr->moles_x;
3416
+ sys_tot += sys[count_sys].moles;
3417
+ sys[count_sys].type = string_duplicate("gas");
3418
+ }
3419
+ return (OK);
3420
+ }
3421
+ /* ---------------------------------------------------------------------- */
3422
+ int Phreeqc::
3423
+ system_total_equi(void)
3424
+ /* ---------------------------------------------------------------------- */
3425
+ {
3426
+ /*
3427
+ * Equilibrium phases
3428
+ */
3429
+ if (use.Get_pp_assemblage_ptr() == NULL)
3430
+ return (OK);
3431
+ std::map <std::string, cxxPPassemblageComp > comps = use.Get_pp_assemblage_ptr()->Get_pp_assemblage_comps();
3432
+ std::map <std::string, cxxPPassemblageComp >::iterator it = comps.begin();
3433
+ for ( ; it != comps.end(); it++)
3434
+ {
3435
+ cxxPPassemblageComp *comp_ptr = &(it->second);
3436
+ int l;
3437
+ class phase *phase_ptr = phase_bsearch(comp_ptr->Get_name().c_str(), &l, FALSE);
3438
+ size_t count_sys = sys.size();
3439
+ sys.resize(count_sys + 1);
3440
+ sys[count_sys].name = string_duplicate(phase_ptr->name);
3441
+ sys[count_sys].moles = equi_phase(sys[count_sys].name);
3442
+ sys_tot += sys[count_sys].moles;
3443
+ sys[count_sys].type = string_duplicate("equi");
3444
+ }
3445
+ return (OK);
3446
+ }
3447
+ /* ---------------------------------------------------------------------- */
3448
+ int Phreeqc::
3449
+ system_total_kin(void)
3450
+ /* ---------------------------------------------------------------------- */
3451
+ {
3452
+ /*
3453
+ * Equilibrium phases
3454
+ */
3455
+ if (use.Get_kinetics_ptr() == NULL)
3456
+ return (OK);
3457
+ std::vector <cxxKineticsComp> comps = use.Get_kinetics_ptr()->Get_kinetics_comps();
3458
+ for (size_t i=0 ; i < comps.size(); i++)
3459
+ {
3460
+ cxxKineticsComp *comp_ptr = &comps[i];
3461
+ size_t count_sys = sys.size();
3462
+ sys.resize(count_sys + 1);
3463
+ sys[count_sys].name = string_duplicate(comp_ptr->Get_rate_name().c_str());
3464
+ sys[count_sys].moles = comp_ptr->Get_m();
3465
+ sys_tot += sys[count_sys].moles;
3466
+ sys[count_sys].type = string_duplicate("kin");
3467
+ }
3468
+ return (OK);
3469
+ }
3470
+ /* ---------------------------------------------------------------------- */
3471
+ int Phreeqc::
3472
+ system_total_ss(void)
3473
+ /* ---------------------------------------------------------------------- */
3474
+ {
3475
+ /*
3476
+ * Provides total moles in system and lists of species/phases in sort order
3477
+ */
3478
+
3479
+ /*
3480
+ * Solid solutions
3481
+ */
3482
+ if (use.Get_ss_assemblage_ptr() == NULL)
3483
+ return (OK);
3484
+ std::vector<cxxSS *> ss_ptrs = use.Get_ss_assemblage_ptr()->Vectorize();
3485
+ for (size_t k = 0; k < ss_ptrs.size(); k++)
3486
+ {
3487
+ cxxSS *ss_ptr = ss_ptrs[k];
3488
+ for (size_t i = 0; i < ss_ptr->Get_ss_comps().size(); i++)
3489
+ {
3490
+ cxxSScomp *comp_ptr = &(ss_ptr->Get_ss_comps()[i]);
3491
+ int l;
3492
+ class phase *phase_ptr = phase_bsearch(comp_ptr->Get_name().c_str(), &l, FALSE);
3493
+ size_t count_sys = sys.size();
3494
+ sys.resize(count_sys + 1);
3495
+ sys[count_sys].name = string_duplicate(phase_ptr->name);
3496
+ sys[count_sys].moles = comp_ptr->Get_moles();
3497
+ sys_tot += sys[count_sys].moles;
3498
+ sys[count_sys].type = string_duplicate("s_s");
3499
+ }
3500
+ }
3501
+ return (OK);
3502
+ }
3503
+ /* ---------------------------------------------------------------------- */
3504
+ int Phreeqc::
3505
+ system_total_elt(const char *total_name)
3506
+ /* ---------------------------------------------------------------------- */
3507
+ {
3508
+ /*
3509
+ * Provides total moles in system and lists of species/phases in sort order
3510
+ */
3511
+ int i, j, k;
3512
+ LDBLE molality, moles_excess, moles_surface, mass_water_surface;
3513
+ char name[MAX_LENGTH];
3514
+
3515
+ /*
3516
+ * find total moles in aq, surface, and exchange
3517
+ */
3518
+ for (i = 0; i < (int)this->s_x.size(); i++)
3519
+ {
3520
+ count_elts = 0;
3521
+ paren_count = 0;
3522
+ add_elt_list(s_x[i]->next_elt, s_x[i]->moles);
3523
+
3524
+ elt_list_combine();
3525
+ /*
3526
+ * Look for element
3527
+ */
3528
+ for (j = 0; j < count_elts; j++)
3529
+ {
3530
+ if (strcmp(elt_list[j].elt->name, total_name) == 0)
3531
+ {
3532
+ size_t count_sys = sys.size();
3533
+ sys.resize(count_sys + 1);
3534
+ sys[count_sys].name = string_duplicate(s_x[i]->name);
3535
+ sys[count_sys].moles = elt_list[j].coef;
3536
+ sys_tot += sys[count_sys].moles;
3537
+ if (s_x[i]->type == AQ)
3538
+ {
3539
+ sys[count_sys].type = string_duplicate("aq");
3540
+ }
3541
+ else if (s_x[i]->type == EX)
3542
+ {
3543
+ sys[count_sys].type = string_duplicate("ex");
3544
+ /* subtract again the dummy moles of primary exchange species... */
3545
+ if (s_x[i]->primary != NULL)
3546
+ {
3547
+ sys_tot -= elt_list[j].coef;
3548
+ }
3549
+ }
3550
+ else if (s_x[i]->type == SURF)
3551
+ {
3552
+ sys[count_sys].type = string_duplicate("surf");
3553
+ }
3554
+ else if (s_x[i]->type == HPLUS)
3555
+ {
3556
+ sys[count_sys].type = string_duplicate("aq");
3557
+ /* sys[count_sys].moles = total_h_x; */
3558
+ }
3559
+ else if (s_x[i]->type == H2O)
3560
+ {
3561
+ sys[count_sys].type = string_duplicate("aq");
3562
+ /* sys[count_sys].moles = total_o_x; */
3563
+ }
3564
+ else
3565
+ {
3566
+ error_msg("System_total", STOP);
3567
+ }
3568
+ break;
3569
+ }
3570
+ }
3571
+ }
3572
+ if (use.Get_surface_ptr() != NULL && dl_type_x != cxxSurface::NO_DL)
3573
+ {
3574
+ /*
3575
+ * Find position of component in surface charge data
3576
+ */
3577
+ i = -1;
3578
+ for (k = 0; k < count_unknowns; k++)
3579
+ {
3580
+ if (x[k]->type != SURFACE_CB)
3581
+ continue;
3582
+ cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[k]->surface_charge);
3583
+ i++;
3584
+ /*
3585
+ * Loop through all surface components, calculate each H2O surface (diffuse layer),
3586
+ * H2O aq, and H2O bulk (diffuse layers plus aqueous).
3587
+ */
3588
+ mass_water_surface = charge_ptr->Get_mass_water();
3589
+ count_elts = 0;
3590
+ paren_count = 0;
3591
+ for (j = 0; j < (int)this->s_x.size(); j++)
3592
+ {
3593
+ if (s_x[j]->type > HPLUS)
3594
+ continue;
3595
+ molality = under(s_x[j]->lm);
3596
+ moles_excess =
3597
+ mass_water_aq_x * molality *
3598
+ (charge_ptr->Get_g_map()[s_x[j]->z].Get_g() * s_x[j]->erm_ddl +
3599
+ mass_water_surface / mass_water_aq_x * (s_x[j]->erm_ddl -
3600
+ 1));
3601
+ moles_surface = mass_water_surface * molality + moles_excess;
3602
+ /*
3603
+ * Accumulate elements in diffuse layer
3604
+ */
3605
+ add_elt_list(s_x[j]->next_elt, moles_surface);
3606
+ }
3607
+ elt_list_combine();
3608
+ /*
3609
+ * Print totals
3610
+ */
3611
+ for (j = 0; j < count_elts; j++)
3612
+ {
3613
+ if (strcmp(elt_list[j].elt->name, total_name) == 0)
3614
+ {
3615
+ size_t count_sys = sys.size();
3616
+ sys.resize(count_sys + 1);
3617
+ Utilities::strcpy_safe(name, MAX_LENGTH, x[k]->master[0]->elt->name);
3618
+ replace("_psi", "", name);
3619
+ sys[count_sys].name = string_duplicate(name);
3620
+ sys[count_sys].moles = elt_list[j].coef;
3621
+ sys_tot += sys[count_sys].moles;
3622
+ sys[count_sys].type = string_duplicate("diff");
3623
+ break;
3624
+ }
3625
+ }
3626
+ }
3627
+ }
3628
+ /*
3629
+ * find total moles in mineral phases
3630
+ */
3631
+ if (use.Get_pp_assemblage_in() == TRUE && use.Get_pp_assemblage_ptr() != NULL)
3632
+ {
3633
+ for (i = 0; i < count_unknowns; i++)
3634
+ {
3635
+ if (x[i]->type != PP)
3636
+ continue;
3637
+ //std::map<std::string, cxxPPassemblageComp>::iterator it;
3638
+ //it = pp_assemblage_ptr->Get_pp_assemblage_comps().find(x[i]->pp_assemblage_comp_name);
3639
+ cxxPPassemblageComp * comp_ptr = (cxxPPassemblageComp * ) x[i]->pp_assemblage_comp_ptr;
3640
+ //if (it->second.Get_add_formula().size() > 0)
3641
+ if (comp_ptr->Get_add_formula().size() > 0)
3642
+ continue;
3643
+ count_elts = 0;
3644
+ paren_count = 0;
3645
+ int j;
3646
+ //class phase * phase_ptr = phase_bsearch(x[i]->pp_assemblage_comp_name, &j, FALSE);
3647
+ class phase * phase_ptr = x[i]->phase;
3648
+ add_elt_list(phase_ptr->next_elt, x[i]->moles);
3649
+ elt_list_combine();
3650
+ for (j = 0; j < count_elts; j++)
3651
+ {
3652
+ if (strcmp(elt_list[j].elt->name, total_name) == 0)
3653
+ {
3654
+ size_t count_sys = sys.size();
3655
+ sys.resize(count_sys + 1);
3656
+ sys[count_sys].name = string_duplicate(phase_ptr->name);
3657
+ sys[count_sys].moles = elt_list[j].coef;
3658
+ sys_tot += sys[count_sys].moles;
3659
+ sys[count_sys].type = string_duplicate("equi");
3660
+ break;
3661
+ }
3662
+ }
3663
+ }
3664
+ }
3665
+ /*
3666
+ * Solid solutions
3667
+ */
3668
+ if (use.Get_ss_assemblage_ptr() != NULL)
3669
+ {
3670
+ std::vector<cxxSS *> ss_ptrs = use.Get_ss_assemblage_ptr()->Vectorize();
3671
+ for (size_t k = 0; k < ss_ptrs.size(); k++)
3672
+ {
3673
+ cxxSS *ss_ptr = ss_ptrs[k];
3674
+ if (ss_ptr->Get_ss_in())
3675
+ {
3676
+ for (size_t i = 0; i < ss_ptr->Get_ss_comps().size(); i++)
3677
+ {
3678
+ cxxSScomp *comp_ptr = &(ss_ptr->Get_ss_comps()[i]);
3679
+ int l;
3680
+ class phase *phase_ptr = phase_bsearch(comp_ptr->Get_name().c_str(), &l, FALSE);
3681
+ count_elts = 0;
3682
+ paren_count = 0;
3683
+ add_elt_list(phase_ptr->next_elt,
3684
+ comp_ptr->Get_moles());
3685
+ elt_list_combine();
3686
+ for (j = 0; j < count_elts; j++)
3687
+ {
3688
+ if (strcmp(elt_list[j].elt->name, total_name) == 0)
3689
+ {
3690
+ size_t count_sys = sys.size();
3691
+ sys.resize(count_sys + 1);
3692
+ sys[count_sys].name =
3693
+ string_duplicate(phase_ptr->name);
3694
+ sys[count_sys].moles = elt_list[j].coef;
3695
+ sys_tot += sys[count_sys].moles;
3696
+ sys[count_sys].type = string_duplicate("s_s");
3697
+ break;
3698
+ }
3699
+ }
3700
+ }
3701
+ }
3702
+ }
3703
+ }
3704
+ /*
3705
+ * find total in gas phase
3706
+ */
3707
+ if (use.Get_gas_phase_ptr() != NULL)
3708
+ {
3709
+ cxxGasPhase *gas_phase_ptr = use.Get_gas_phase_ptr();
3710
+ for (size_t i = 0; i < gas_phase_ptr->Get_gas_comps().size(); i++)
3711
+ {
3712
+ class phase *phase_ptr =
3713
+ phase_bsearch(gas_phase_ptr->Get_gas_comps()[i].Get_phase_name().c_str(), &k, FALSE);
3714
+ assert(phase_ptr);
3715
+ if (phase_ptr->in == TRUE)
3716
+ {
3717
+ count_elts = 0;
3718
+ paren_count = 0;
3719
+ add_elt_list(phase_ptr->next_elt, phase_ptr->moles_x);
3720
+ elt_list_combine();
3721
+ /*
3722
+ * Look for element
3723
+ */
3724
+ for (j = 0; j < count_elts; j++)
3725
+ {
3726
+ if (strcmp(elt_list[j].elt->name, total_name) == 0)
3727
+ {
3728
+ size_t count_sys = sys.size();
3729
+ sys.resize(count_sys + 1);
3730
+ sys[count_sys].name = string_duplicate(phase_ptr->name);
3731
+ sys[count_sys].moles = elt_list[j].coef;
3732
+ sys_tot += sys[count_sys].moles;
3733
+ sys[count_sys].type = string_duplicate("gas");
3734
+ break;
3735
+ }
3736
+ }
3737
+ }
3738
+ }
3739
+ }
3740
+ return (OK);
3741
+ }
3742
+
3743
+ /* ---------------------------------------------------------------------- */
3744
+ int Phreeqc::
3745
+ system_total_elt_secondary(const char *total_name)
3746
+ /* ---------------------------------------------------------------------- */
3747
+ {
3748
+ /*
3749
+ * Provides total moles in system and lists of species/phases in sort order
3750
+ */
3751
+ int i, j, k, l;
3752
+ LDBLE molality, moles_excess, moles_surface, mass_water_surface, sum,
3753
+ coef;
3754
+ char name[MAX_LENGTH];
3755
+ /*
3756
+ * find total moles in aq, surface, and exchange
3757
+ */
3758
+ for (i = 0; i < (int)this->s_x.size(); i++)
3759
+ {
3760
+ count_elts = 0;
3761
+ paren_count = 0;
3762
+ if (s_x[i]->next_secondary.size() != 0)
3763
+ {
3764
+ add_elt_list(s_x[i]->next_secondary, s_x[i]->moles);
3765
+ }
3766
+ else
3767
+ {
3768
+ add_elt_list(s_x[i]->next_sys_total, s_x[i]->moles);
3769
+ }
3770
+ elt_list_combine();
3771
+ /*
3772
+ * Look for element
3773
+ */
3774
+ for (j = 0; j < count_elts; j++)
3775
+ {
3776
+ if (strcmp(elt_list[j].elt->name, total_name) == 0)
3777
+ {
3778
+ size_t count_sys = sys.size();
3779
+ sys.resize(count_sys + 1);
3780
+ sys[count_sys].name = string_duplicate(s_x[i]->name);
3781
+ sys[count_sys].moles = elt_list[j].coef;
3782
+ sys_tot += sys[count_sys].moles;
3783
+ if (s_x[i]->type == AQ)
3784
+ {
3785
+ sys[count_sys].type = string_duplicate("aq");
3786
+ }
3787
+ else if (s_x[i]->type == EX)
3788
+ {
3789
+ sys[count_sys].type = string_duplicate("ex");
3790
+ }
3791
+ else if (s_x[i]->type == SURF)
3792
+ {
3793
+ sys[count_sys].type = string_duplicate("surf");
3794
+ }
3795
+ else if (s_x[i]->type == HPLUS)
3796
+ {
3797
+ sys[count_sys].type = string_duplicate("aq");
3798
+ /* sys[count_sys].moles = total_h_x; */
3799
+ }
3800
+ else if (s_x[i]->type == H2O)
3801
+ {
3802
+ sys[count_sys].type = string_duplicate("aq");
3803
+ /* sys[count_sys].moles = total_o_x; */
3804
+ }
3805
+ else
3806
+ {
3807
+ error_msg("System_total", STOP);
3808
+ }
3809
+ break;
3810
+ }
3811
+ }
3812
+ }
3813
+ if (use.Get_surface_ptr() != NULL && dl_type_x != cxxSurface::NO_DL)
3814
+ {
3815
+ /*
3816
+ * Find position of component in surface charge data
3817
+ */
3818
+ i = -1;
3819
+ for (k = 0; k < count_unknowns; k++)
3820
+ {
3821
+ if (x[k]->type != SURFACE_CB)
3822
+ continue;
3823
+ cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[k]->surface_charge);
3824
+ i++;
3825
+ /*
3826
+ * Loop through all surface components, calculate each H2O surface (diffuse layer),
3827
+ * H2O aq, and H2O bulk (diffuse layers plus aqueous).
3828
+ */
3829
+ mass_water_surface = charge_ptr->Get_mass_water();
3830
+ sum = 0;
3831
+ for (j = 0; j < (int)this->s_x.size(); j++)
3832
+ {
3833
+ count_elts = 0;
3834
+ paren_count = 0;
3835
+ if (s_x[i]->next_secondary.size() != 0)
3836
+ {
3837
+ add_elt_list(s_x[i]->next_secondary, 1);
3838
+ }
3839
+ else
3840
+ {
3841
+ add_elt_list(s_x[i]->next_sys_total, 1);
3842
+ }
3843
+ for (l = 0; l < count_elts; l++)
3844
+ {
3845
+ if (strcmp(elt_list[l].elt->name, total_name) == 0)
3846
+ {
3847
+ coef = elt_list[l].coef;
3848
+ if (s_x[j]->type > H2O)
3849
+ continue;
3850
+ molality = under(s_x[j]->lm);
3851
+ moles_excess =
3852
+ mass_water_aq_x * molality *
3853
+ charge_ptr->Get_g_map()[s_x[j]->z].Get_g();
3854
+ moles_surface =
3855
+ mass_water_surface * molality + moles_excess;
3856
+ sum += moles_surface * coef;
3857
+ break;
3858
+ }
3859
+ }
3860
+ if (l >= count_elts)
3861
+ continue;
3862
+ Utilities::strcpy_safe(name, MAX_LENGTH, x[k]->master[0]->elt->name);
3863
+ replace("_psi", "", name);
3864
+ size_t count_sys = sys.size();
3865
+ sys.resize(count_sys + 1);
3866
+ sys[count_sys].name = string_duplicate(name);
3867
+ sys[count_sys].moles = sum;
3868
+ sys_tot += sys[count_sys].moles;
3869
+ sys[count_sys].type = string_duplicate("diff");
3870
+ break;
3871
+ }
3872
+ }
3873
+ }
3874
+ /*
3875
+ * find total moles in mineral phases
3876
+ */
3877
+ if (use.Get_pp_assemblage_in() == TRUE && use.Get_pp_assemblage_ptr() != NULL)
3878
+ {
3879
+ for (i = 0; i < count_unknowns; i++)
3880
+ {
3881
+ if (x[i]->type != PP)
3882
+ continue;
3883
+ //std::map<std::string, cxxPPassemblageComp>::iterator it;
3884
+ //it = pp_assemblage_ptr->Get_pp_assemblage_comps().find(x[i]->pp_assemblage_comp_name);
3885
+ cxxPPassemblageComp * comp_ptr = (cxxPPassemblageComp * ) x[i]->pp_assemblage_comp_ptr;
3886
+ //if (it->second.Get_add_formula().size() > 0)
3887
+ if (comp_ptr->Get_add_formula().size() > 0)
3888
+ continue;
3889
+ count_elts = 0;
3890
+ paren_count = 0;
3891
+ int j;
3892
+ //class phase * phase_ptr = phase_bsearch(x[i]->pp_assemblage_comp_name, &j, FALSE);
3893
+ class phase * phase_ptr = x[i]->phase;
3894
+ add_elt_list(phase_ptr->next_sys_total, x[i]->moles);
3895
+ elt_list_combine();
3896
+ for (j = 0; j < count_elts; j++)
3897
+ {
3898
+ if (strcmp(elt_list[j].elt->name, total_name) == 0)
3899
+ {
3900
+ size_t count_sys = sys.size();
3901
+ sys.resize(count_sys + 1);
3902
+ sys[count_sys].name =
3903
+ string_duplicate(phase_ptr->name);
3904
+ sys[count_sys].moles = elt_list[j].coef;
3905
+ sys_tot += sys[count_sys].moles;
3906
+ sys[count_sys].type = string_duplicate("equi");
3907
+ break;
3908
+ }
3909
+ }
3910
+ }
3911
+ }
3912
+ /*
3913
+ * Solid solutions
3914
+ */
3915
+ if (use.Get_ss_assemblage_ptr() != NULL)
3916
+ {
3917
+ std::vector<cxxSS *> ss_ptrs = use.Get_ss_assemblage_ptr()->Vectorize();
3918
+ for (size_t i = 0; i < ss_ptrs.size(); i++)
3919
+ {
3920
+ cxxSS *ss_ptr = ss_ptrs[i];
3921
+ if (ss_ptr->Get_ss_in())
3922
+ {
3923
+ for (size_t k = 0; k < ss_ptr->Get_ss_comps().size(); k++)
3924
+ {
3925
+ cxxSScomp *comp_ptr = &(ss_ptr->Get_ss_comps()[k]);
3926
+ int l;
3927
+ class phase *phase_ptr = phase_bsearch(comp_ptr->Get_name().c_str(), &l, FALSE);
3928
+ count_elts = 0;
3929
+ paren_count = 0;
3930
+ add_elt_list(phase_ptr->next_sys_total,
3931
+ comp_ptr->Get_moles());
3932
+ elt_list_combine();
3933
+ for (j = 0; j < count_elts; j++)
3934
+ {
3935
+ if (strcmp(elt_list[j].elt->name, total_name) == 0)
3936
+ {
3937
+ size_t count_sys = sys.size();
3938
+ sys.resize(count_sys + 1);
3939
+ sys[count_sys].name =
3940
+ string_duplicate(phase_ptr->name);
3941
+ sys[count_sys].moles = elt_list[j].coef;
3942
+ sys_tot += sys[count_sys].moles;
3943
+ sys[count_sys].type = string_duplicate("s_s");
3944
+ break;
3945
+ }
3946
+ }
3947
+ }
3948
+ }
3949
+ }
3950
+ }
3951
+ /*
3952
+ * find total in gas phase
3953
+ */
3954
+ if (use.Get_gas_phase_ptr() != NULL)
3955
+ {
3956
+ cxxGasPhase *gas_phase_ptr = use.Get_gas_phase_ptr();
3957
+ for (size_t j = 0; j < gas_phase_ptr->Get_gas_comps().size(); j++)
3958
+ {
3959
+ class phase *phase_ptr =
3960
+ phase_bsearch(gas_phase_ptr->Get_gas_comps()[j].Get_phase_name().c_str(), &i, FALSE);
3961
+ assert(phase_ptr);
3962
+ if (phase_ptr->in == TRUE)
3963
+ {
3964
+ count_elts = 0;
3965
+ paren_count = 0;
3966
+ add_elt_list(phase_ptr->next_sys_total,
3967
+ phase_ptr->moles_x);
3968
+
3969
+ elt_list_combine();
3970
+ /*
3971
+ * Look for element
3972
+ */
3973
+ for (size_t j1 = 0; j1 < (size_t) count_elts; j1++)
3974
+ {
3975
+ if (strcmp(elt_list[j1].elt->name, total_name) == 0)
3976
+ {
3977
+ size_t count_sys = sys.size();
3978
+ sys.resize(count_sys + 1);
3979
+ sys[count_sys].name =
3980
+ string_duplicate(phase_ptr->name);
3981
+ sys[count_sys].moles = elt_list[j1].coef;
3982
+ sys_tot += sys[count_sys].moles;
3983
+ sys[count_sys].type = string_duplicate("gas");
3984
+ break;
3985
+ }
3986
+ }
3987
+ }
3988
+ }
3989
+ }
3990
+ return (OK);
3991
+ }
3992
+ /* ---------------------------------------------------------------------- */
3993
+ int Phreeqc::
3994
+ solution_number(void)
3995
+ /* ---------------------------------------------------------------------- */
3996
+ {
3997
+ Phreeqc * PhreeqcPtr = this;
3998
+ int soln_no = -999;
3999
+ if (PhreeqcPtr->state == TRANSPORT)
4000
+ {
4001
+ soln_no = PhreeqcPtr->cell_no;
4002
+ }
4003
+ else if (PhreeqcPtr->state == PHAST)
4004
+ {
4005
+ soln_no = PhreeqcPtr->cell_no;
4006
+ }
4007
+ else if (PhreeqcPtr->state == ADVECTION)
4008
+ {
4009
+ soln_no = PhreeqcPtr->cell_no;
4010
+ }
4011
+ else if (PhreeqcPtr->state < REACTION)
4012
+ {
4013
+ soln_no = PhreeqcPtr->use.Get_solution_ptr()->Get_n_user();
4014
+ }
4015
+ else
4016
+ {
4017
+ if (PhreeqcPtr->use.Get_mix_in())
4018
+ {
4019
+ soln_no = PhreeqcPtr->use.Get_n_mix_user();
4020
+ }
4021
+ else
4022
+ {
4023
+ soln_no = PhreeqcPtr->use.Get_n_solution_user();
4024
+ }
4025
+ }
4026
+ return soln_no;
4027
+ }
4028
+ /* ---------------------------------------------------------------------- */
4029
+ LDBLE Phreeqc::
4030
+ solution_sum_secondary(const char *total_name)
4031
+ /* ---------------------------------------------------------------------- */
4032
+ {
4033
+ /*
4034
+ * Provides total moles in system and lists of species/phases in sort order
4035
+ */
4036
+ int i, j;
4037
+ LDBLE sum;
4038
+ /*
4039
+ * find total moles in aq, surface, and exchange
4040
+ */
4041
+ sum = 0;
4042
+ for (i = 0; i < (int)this->s_x.size(); i++)
4043
+ {
4044
+ if (s_x[i]->type > H2O)
4045
+ continue;
4046
+ count_elts = 0;
4047
+ paren_count = 0;
4048
+ if (s_x[i]->next_secondary.size() != 0)
4049
+ {
4050
+ add_elt_list(s_x[i]->next_secondary, s_x[i]->moles);
4051
+ }
4052
+ else
4053
+ {
4054
+ add_elt_list(s_x[i]->next_sys_total, s_x[i]->moles);
4055
+ }
4056
+ elt_list_combine();
4057
+ /*
4058
+ * Look for element
4059
+ */
4060
+ for (j = 0; j < count_elts; j++)
4061
+ {
4062
+ if (strcmp(elt_list[j].elt->name, total_name) == 0)
4063
+ {
4064
+ sum += elt_list[j].coef;
4065
+ break;
4066
+ }
4067
+ }
4068
+ }
4069
+ return (sum);
4070
+ }
4071
+
4072
+ /* ---------------------------------------------------------------------- */
4073
+ int Phreeqc::
4074
+ system_species_compare(const void *ptr1, const void *ptr2)
4075
+ /* ---------------------------------------------------------------------- */
4076
+ {
4077
+ const class system_species *a, *b;
4078
+
4079
+ a = (const class system_species *) ptr1;
4080
+ b = (const class system_species *) ptr2;
4081
+ if (a->moles < b->moles)
4082
+ return (1);
4083
+ if (a->moles > b->moles)
4084
+ return (-1);
4085
+ return (0);
4086
+ }
4087
+ int Phreeqc::
4088
+ system_species_compare_name(const void* ptr1, const void* ptr2)
4089
+ /* ---------------------------------------------------------------------- */
4090
+ {
4091
+ const class system_species* a, * b;
4092
+
4093
+ a = (const class system_species*)ptr1;
4094
+ b = (const class system_species*)ptr2;
4095
+ return (strncmp(a->name, b->name, MAX_LENGTH));
4096
+ }
4097
+
4098
+ /* ---------------------------------------------------------------------- */
4099
+ int Phreeqc::
4100
+ system_total_solids(cxxExchange *exchange_ptr,
4101
+ cxxPPassemblage *pp_assemblage_ptr,
4102
+ cxxGasPhase *gas_phase_ptr,
4103
+ cxxSSassemblage *ss_assemblage_ptr,
4104
+ cxxSurface *surface_ptr)
4105
+ /* ---------------------------------------------------------------------- */
4106
+ {
4107
+ /*
4108
+ * Provides total moles in solid phases
4109
+ */
4110
+ count_elts = 0;
4111
+ paren_count = 0;
4112
+ /*
4113
+ * find total moles in exchanger
4114
+ */
4115
+ if (exchange_ptr != NULL)
4116
+ {
4117
+ for (size_t i = 0; i < exchange_ptr->Get_exchange_comps().size(); i++)
4118
+ {
4119
+ add_elt_list(exchange_ptr->Get_exchange_comps()[i].Get_totals(), 1.0);
4120
+ }
4121
+ }
4122
+ if (surface_ptr != NULL)
4123
+ {
4124
+ for (size_t i = 0; i < surface_ptr->Get_surface_comps().size(); i++)
4125
+ {
4126
+ add_elt_list(surface_ptr->Get_surface_comps()[i].Get_totals(), 1.0);
4127
+ }
4128
+ }
4129
+ if (ss_assemblage_ptr != NULL)
4130
+ {
4131
+ std::vector<cxxSS *> ss_ptrs = ss_assemblage_ptr->Vectorize();
4132
+ for (size_t i = 0; i < ss_ptrs.size(); i++)
4133
+ {
4134
+ cxxSS *ss_ptr = ss_ptrs[i];
4135
+ for (size_t j = 0; j < ss_ptr->Get_ss_comps().size(); j++)
4136
+ {
4137
+ cxxSScomp *comp_ptr = &(ss_ptr->Get_ss_comps()[j]);
4138
+ int l;
4139
+ class phase *phase_ptr = phase_bsearch(comp_ptr->Get_name().c_str(), &l, FALSE);
4140
+ add_elt_list(phase_ptr->next_elt,
4141
+ comp_ptr->Get_moles());
4142
+ }
4143
+ }
4144
+ }
4145
+ if (gas_phase_ptr != NULL)
4146
+ {
4147
+ for (size_t j = 0; j < gas_phase_ptr->Get_gas_comps().size(); j++)
4148
+ {
4149
+ int i;
4150
+ class phase *phase_ptr =
4151
+ phase_bsearch(gas_phase_ptr->Get_gas_comps()[j].Get_phase_name().c_str(), &i, FALSE);
4152
+ add_elt_list(phase_ptr->next_elt, gas_phase_ptr->Get_gas_comps()[j].Get_moles());
4153
+ }
4154
+ }
4155
+ if (pp_assemblage_ptr != NULL)
4156
+ {
4157
+ std::map<std::string, cxxPPassemblageComp>::iterator it;
4158
+ it = pp_assemblage_ptr->Get_pp_assemblage_comps().begin();
4159
+ for ( ; it != pp_assemblage_ptr->Get_pp_assemblage_comps().end(); it++)
4160
+ {
4161
+ int j;
4162
+ class phase * phase_ptr = phase_bsearch(it->first.c_str(), &j, FALSE);
4163
+ add_elt_list(phase_ptr->next_elt,
4164
+ it->second.Get_moles());
4165
+ }
4166
+ }
4167
+ elt_list_combine();
4168
+ return (OK);
4169
+ }
4170
+
4171
+ LDBLE Phreeqc::
4172
+ iso_value(const char *total_name)
4173
+ {
4174
+ int j;
4175
+ char token[MAX_LENGTH];
4176
+ char my_total_name[MAX_LENGTH];
4177
+ Utilities::strcpy_safe(token, MAX_LENGTH, "");
4178
+ Utilities::strcpy_safe(my_total_name, MAX_LENGTH, total_name);
4179
+ while (replace(" ","_",my_total_name));
4180
+ for (j = 0; j < (int)isotope_ratio.size(); j++)
4181
+ {
4182
+ if (isotope_ratio[j]->ratio == MISSING)
4183
+ continue;
4184
+ if (strcmp(my_total_name, isotope_ratio[j]->name) != 0)
4185
+ continue;
4186
+ return (isotope_ratio[j]->converted_ratio);
4187
+ }
4188
+ Utilities::strcpy_safe(my_total_name, MAX_LENGTH, total_name);
4189
+ while (replace("[","",my_total_name));
4190
+ while (replace("]","",my_total_name));
4191
+ Utilities::strcat_safe(token, MAX_LENGTH, "R(");
4192
+ Utilities::strcat_safe(token, MAX_LENGTH, my_total_name);
4193
+ Utilities::strcat_safe(token, MAX_LENGTH, ")");
4194
+ for (j = 0; j < (int)isotope_ratio.size(); j++)
4195
+ {
4196
+ if (isotope_ratio[j]->ratio == MISSING)
4197
+ continue;
4198
+ if (strcmp(token, isotope_ratio[j]->name) != 0)
4199
+ continue;
4200
+ return (isotope_ratio[j]->converted_ratio);
4201
+ }
4202
+ return -1000.;
4203
+ }
4204
+
4205
+ char * Phreeqc::
4206
+ iso_unit(const char *total_name)
4207
+ {
4208
+ int j;
4209
+ char token[MAX_LENGTH], unit[MAX_LENGTH];
4210
+ class master_isotope *master_isotope_ptr;
4211
+ char my_total_name[MAX_LENGTH];
4212
+ Utilities::strcpy_safe(token, MAX_LENGTH, "");
4213
+ Utilities::strcpy_safe(my_total_name, MAX_LENGTH, total_name);
4214
+ while (replace(" ","_",my_total_name));
4215
+ Utilities::strcpy_safe(unit, MAX_LENGTH, "unknown");
4216
+ for (j = 0; j < (int)isotope_ratio.size(); j++)
4217
+ {
4218
+ if (isotope_ratio[j]->ratio == MISSING)
4219
+ continue;
4220
+ if (strcmp(my_total_name, isotope_ratio[j]->name) != 0)
4221
+ continue;
4222
+ master_isotope_ptr = master_isotope_search(isotope_ratio[j]->isotope_name);
4223
+ if (master_isotope_ptr != NULL)
4224
+ {
4225
+ Utilities::strcpy_safe(unit, MAX_LENGTH, master_isotope_ptr->units);
4226
+ }
4227
+ return string_duplicate(unit);
4228
+ }
4229
+ Utilities::strcpy_safe(my_total_name, MAX_LENGTH, total_name);
4230
+ while (replace("[","",my_total_name));
4231
+ while (replace("]","",my_total_name));
4232
+ Utilities::strcat_safe(token, MAX_LENGTH, "R(");
4233
+ Utilities::strcat_safe(token, MAX_LENGTH, my_total_name);
4234
+ Utilities::strcat_safe(token, MAX_LENGTH, ")");
4235
+ for (j = 0; j < (int)isotope_ratio.size(); j++)
4236
+ {
4237
+ if (isotope_ratio[j]->ratio == MISSING)
4238
+ continue;
4239
+ if (strcmp(token, isotope_ratio[j]->name) != 0)
4240
+ continue;
4241
+ master_isotope_ptr = master_isotope_search(isotope_ratio[j]->isotope_name);
4242
+ if (master_isotope_ptr != NULL)
4243
+ {
4244
+ Utilities::strcpy_safe(unit, MAX_LENGTH, master_isotope_ptr->units);
4245
+ }
4246
+ return string_duplicate(unit);
4247
+ }
4248
+ return string_duplicate(unit);
4249
+ }
4250
+
4251
+ int Phreeqc::
4252
+ basic_compile(const char *commands, void **lnbase, void **vbase, void **lpbase)
4253
+ {
4254
+ return this->basic_interpreter->basic_compile(commands, lnbase, vbase, lpbase);
4255
+ }
4256
+
4257
+ int Phreeqc::
4258
+ basic_run(char *commands, void *lnbase, void *vbase, void *lpbase)
4259
+ {
4260
+ return this->basic_interpreter->basic_run(commands, lnbase, vbase, lpbase);
4261
+ }
4262
+
4263
+ void Phreeqc::
4264
+ basic_free(void)
4265
+ {
4266
+ delete this->basic_interpreter;
4267
+ this->basic_interpreter = NULL;
4268
+ }
4269
+
4270
+ #if defined(SWIG) || defined(SWIG_IPHREEQC)
4271
+
4272
+ #include "BasicCallback.h"
4273
+
4274
+ double Phreeqc::
4275
+ basic_callback(double x1, double x2, const char * str)
4276
+ {
4277
+ if (this->basicCallback)
4278
+ {
4279
+ return this->basicCallback->Callback(x1, x2, str);
4280
+ }
4281
+ return 0.0;
4282
+ }
4283
+
4284
+ #else /* defined(SWIG) || defined(SWIG_IPHREEQC) */
4285
+
4286
+ #ifdef IPHREEQC_NO_FORTRAN_MODULE
4287
+ double Phreeqc::
4288
+ basic_callback(double x1, double x2, const char * str)
4289
+ #else
4290
+ double Phreeqc::
4291
+ basic_callback(double x1, double x2, const char * str)
4292
+ #endif
4293
+ {
4294
+ double local_x1 = x1;
4295
+ double local_x2 = x2;
4296
+
4297
+ if (basic_callback_ptr != NULL)
4298
+ {
4299
+ return (*basic_callback_ptr) (x1, x2, str, basic_callback_cookie);
4300
+ }
4301
+ if (basic_fortran_callback_ptr != NULL)
4302
+ {
4303
+ #ifdef IPHREEQC_NO_FORTRAN_MODULE
4304
+ return (*basic_fortran_callback_ptr) (&local_x1, &local_x2, str, (int) strlen(str));
4305
+ #else
4306
+ return (*basic_fortran_callback_ptr) (&local_x1, &local_x2, str, (int) strlen(str));
4307
+ #endif
4308
+ }
4309
+ return 0;
4310
+ }
4311
+
4312
+ void
4313
+ Phreeqc::register_basic_callback(double (*fcn)(double x1, double x2, const char *str, void *cookie), void *cookie1)
4314
+ {
4315
+ this->basic_callback_ptr = fcn;
4316
+ this->basic_callback_cookie = cookie1;
4317
+ }
4318
+ #ifdef IPHREEQC_NO_FORTRAN_MODULE
4319
+ void
4320
+ Phreeqc::register_fortran_basic_callback(double ( *fcn)(double *x1, double *x2, const char *str, size_t l))
4321
+ {
4322
+ this->basic_fortran_callback_ptr = fcn;
4323
+ }
4324
+ #else
4325
+
4326
+ void
4327
+ Phreeqc::register_fortran_basic_callback(double ( *fcn)(double *x1, double *x2, const char *str, int l))
4328
+ {
4329
+ this->basic_fortran_callback_ptr = fcn;
4330
+ }
4331
+ #endif
4332
+
4333
+ #endif /* defined(SWIG) || defined(SWIG_IPHREEQC) */