pyEQL 1.4.0rc9__cp310-cp310-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-310-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,3381 @@
1
+ #include "Utils.h"
2
+ #include "Phreeqc.h"
3
+ #include <iostream>
4
+
5
+ #include "phqalloc.h"
6
+ #include "Temperature.h"
7
+ #include "cxxMix.h"
8
+ #include "Exchange.h"
9
+ #include "GasPhase.h"
10
+ #include "Reaction.h"
11
+ #include "PPassemblage.h"
12
+ #include "Use.h"
13
+ #include "SSassemblage.h"
14
+ #include "cxxKinetics.h"
15
+ #include "Surface.h"
16
+ #include "Solution.h"
17
+
18
+ #if defined(PHREEQCI_GUI)
19
+ #ifdef _DEBUG
20
+ #define new DEBUG_NEW
21
+ #undef THIS_FILE
22
+ static char THIS_FILE[] = __FILE__;
23
+ #endif
24
+ #endif
25
+
26
+ /* ---------------------------------------------------------------------- */
27
+ int Phreeqc::
28
+ clean_up(void)
29
+ /* ---------------------------------------------------------------------- */
30
+ {
31
+ /*
32
+ * Free all allocated memory, except strings
33
+ */
34
+ int i, j;
35
+ #if defined MULTICHART
36
+ chart_handler.End_timer();
37
+ output_flush();
38
+ #if 0
39
+ // Wait for charts to end
40
+ while (0 != this->chart_handler.Get_active_charts())
41
+ {
42
+ System::Threading::Thread::Sleep(60);
43
+ }
44
+ #endif
45
+ #endif
46
+
47
+ isotopes_x.clear();
48
+ /* model */
49
+ last_model.gas_phase.clear();
50
+ last_model.pp_assemblage.clear();
51
+ last_model.add_formula.clear();
52
+ last_model.si.clear();
53
+ last_model.ss_assemblage.clear();
54
+ last_model.surface_comp.clear();
55
+ last_model.surface_charge.clear();
56
+ /* model */
57
+ free_model_allocs();
58
+
59
+ /* species */
60
+
61
+ for (j = 0; j < (int)s.size(); j++)
62
+ {
63
+ s_free(s[j]);
64
+ delete s[j];
65
+ }
66
+ s.clear();
67
+
68
+ /* master species */
69
+
70
+ for (j = 0; j < (int)master.size(); j++)
71
+ {
72
+ master_free(master[j]);
73
+ }
74
+ master.clear();
75
+
76
+ /* elements */
77
+
78
+ for (j = 0; j < (int)elements.size(); j++)
79
+ {
80
+ delete elements[j];
81
+ }
82
+ elements.clear();
83
+ /* solutions */
84
+ Rxn_solution_map.clear();
85
+ /* surfaces */
86
+ Rxn_surface_map.clear();
87
+ /* exchange */
88
+ Rxn_exchange_map.clear();
89
+ /* pp assemblages */
90
+ Rxn_pp_assemblage_map.clear();
91
+ /* s_s assemblages */
92
+ Rxn_ss_assemblage_map.clear();
93
+ /* irreversible reactions */
94
+ Rxn_reaction_map.clear();
95
+ /* temperature */
96
+ Rxn_temperature_map.clear();
97
+ /* pressure */
98
+ Rxn_pressure_map.clear();
99
+ /* unknowns */
100
+ for (j = 0; j < (int)x.size(); j++)
101
+ {
102
+ unknown_free(x[j]);
103
+ }
104
+ x.clear();
105
+ /* mixtures */
106
+ Rxn_mix_map.clear();
107
+ /* phases */
108
+ for (j = 0; j < (int)phases.size(); j++)
109
+ {
110
+ phase_free(phases[j]);
111
+ delete phases[j];
112
+ }
113
+ phases.clear();
114
+ /* inverse */
115
+ for (j = 0; j < count_inverse; j++)
116
+ {
117
+ inverse_free(&(inverse[j]));
118
+ }
119
+ inverse.clear();
120
+ /* gases */
121
+ Rxn_gas_phase_map.clear();
122
+ /* kinetics */
123
+ Rxn_kinetics_map.clear();
124
+ x0_moles.clear();
125
+ m_temp.clear();
126
+ m_original.clear();
127
+ rk_moles.clear();
128
+ /* rates */
129
+ for (j = 0; j < (int)rates.size(); j++)
130
+ {
131
+ rate_free(&rates[j]);
132
+ }
133
+ rates.clear();
134
+ /* logk table */
135
+ for (j = 0; j < (int)logk.size(); j++)
136
+ {
137
+ logk[j]->add_logk.clear();
138
+ delete logk[j];
139
+ }
140
+ logk.clear();
141
+ save_values.clear();
142
+ save_strings.clear();
143
+ /* working pe*/
144
+ pe_x.clear();
145
+ /*species_list*/
146
+ species_list.clear();
147
+ /* transport data */
148
+ cell_data.clear();
149
+ /* advection */
150
+ advection_punch.clear();
151
+ advection_print.clear();
152
+ /* selected_output */
153
+ SelectedOutput_map.clear();
154
+ /* user_print and user_punch */
155
+ UserPunch_map.clear();
156
+ rate_free(user_print);
157
+ delete user_print;
158
+ /*
159
+ Clear llnl aqueous model parameters
160
+ */
161
+ llnl_temp.clear();
162
+ llnl_adh.clear();
163
+ llnl_bdh.clear();
164
+ llnl_bdot.clear();
165
+ llnl_co2_coefs.clear();
166
+ /* master_isotope */
167
+ for (i = 0; i < (int)master_isotope.size(); i++)
168
+ {
169
+ delete master_isotope[i];
170
+ }
171
+ master_isotope.clear();
172
+ master_isotope_map.clear();
173
+ /* calculate_value */
174
+ for (i = 0; i < (int)calculate_value.size(); i++)
175
+ {
176
+ calculate_value_free(calculate_value[i]);
177
+ delete calculate_value[i];
178
+ }
179
+ calculate_value.clear();
180
+ calculate_value_map.clear();
181
+ /* isotope_ratio */
182
+ for (i = 0; i < (int)isotope_ratio.size(); i++)
183
+ {
184
+ delete isotope_ratio[i];
185
+ }
186
+ isotope_ratio.clear();
187
+ isotope_ratio_map.clear();
188
+ /* isotope_alpha */
189
+ for (i = 0; i < (int)isotope_alpha.size(); i++)
190
+ {
191
+ delete isotope_alpha[i];
192
+ }
193
+ isotope_alpha.clear();
194
+ isotope_alpha_map.clear();
195
+ /* tally table */
196
+ free_tally_table();
197
+ /* CVODE memory */
198
+ free_cvode();
199
+ /* pitzer */
200
+ pitzer_clean_up();
201
+ /* sit */
202
+ sit_clean_up();
203
+ /* elements, species, phases*/
204
+ elements_map.clear();
205
+ species_map.clear();
206
+ phases_map.clear();
207
+ logk_map.clear();
208
+ /* strings */
209
+ strings_map_clear();
210
+ /* delete basic interpreter */
211
+ basic_free();
212
+ /* change_surf */
213
+ change_surf = (struct Change_Surf *) free_check_null(change_surf);
214
+ /* miscellaneous work space */
215
+ elt_list.clear();
216
+ trxn.token.clear();
217
+ mb_unknowns.clear();
218
+ line = (char *) free_check_null(line);
219
+ line_save = (char *) free_check_null(line_save);
220
+ /* free user database name if defined */
221
+ dump_file_name = (char *) free_check_null(dump_file_name);
222
+ #ifdef PHREEQCI_GUI
223
+ free_spread();
224
+ #endif
225
+ title_x.clear();
226
+ last_title_x.clear();
227
+ count_inverse = 0;
228
+
229
+ sformatf_buffer = (char *) free_check_null(sformatf_buffer);
230
+ return (OK);
231
+ }
232
+ /* ---------------------------------------------------------------------- */
233
+ int Phreeqc::
234
+ reinitialize(void)
235
+ /* ---------------------------------------------------------------------- */
236
+ {
237
+ /* solutions */
238
+ Rxn_solution_map.clear();
239
+ /* surfaces */
240
+ Rxn_surface_map.clear();
241
+ /* exchange */
242
+ Rxn_exchange_map.clear();
243
+ /* pp assemblages */
244
+ Rxn_pp_assemblage_map.clear();
245
+ /* s_s assemblages */
246
+ Rxn_ss_assemblage_map.clear();
247
+ /* gases */
248
+ Rxn_gas_phase_map.clear();
249
+ /* kinetics */
250
+ Rxn_kinetics_map.clear();
251
+ /* irreversible reactions */
252
+ Rxn_reaction_map.clear();
253
+ // Temperature
254
+ Rxn_temperature_map.clear();
255
+ // Pressure
256
+ Rxn_pressure_map.clear();
257
+ return (OK);
258
+ }
259
+ /* **********************************************************************
260
+ *
261
+ * Routines related to CReaction
262
+ *
263
+ * ********************************************************************** */
264
+ CReaction::CReaction(void)
265
+ {
266
+ for (size_t i = 0; i < MAX_LOG_K_INDICES; i++) this->logk[i] = 0.0;
267
+ for (size_t i = 0; i < 3; i++) this->dz[i] = 0.0;
268
+ }
269
+ CReaction::CReaction(size_t ntoken)
270
+ {
271
+ for (size_t i = 0; i < MAX_LOG_K_INDICES; i++) this->logk[i] = 0.0;
272
+ for (size_t i = 0; i < 3; i++) this->dz[i] = 0.0;
273
+ this->token.resize(ntoken);
274
+ }
275
+ void CReaction::Set_logk(double* d)
276
+ {
277
+ for (size_t i = 0; i < MAX_LOG_K_INDICES; i++)logk[i] = d[i];
278
+ }
279
+ void CReaction::Set_dz(double* d)
280
+ {
281
+ for (size_t i = 0; i < 3; i++) dz[i] = d[i];
282
+ }
283
+ CReaction Phreeqc::CReaction_internal_copy(CReaction& rxn_ref)
284
+ {
285
+ CReaction rxn;
286
+ for (size_t i = 0; i < MAX_LOG_K_INDICES; i++) rxn.logk[i] = rxn_ref.logk[i];
287
+ for (size_t i = 0; i < 3; i++) rxn.dz[i] = rxn_ref.dz[i];
288
+ rxn.Get_tokens().resize(rxn_ref.Get_tokens().size());
289
+ for (size_t i = 0; i < rxn_ref.Get_tokens().size(); i++)
290
+ {
291
+ rxn.token[i].s = (rxn_ref.token[i].s == NULL) ? NULL :
292
+ s_store(rxn_ref.token[i].s->name, rxn_ref.token[i].s->z, false);
293
+ rxn.token[i].coef = rxn_ref.token[i].coef;
294
+ rxn.token[i].name = (rxn_ref.token[i].name == NULL) ? NULL :
295
+ string_hsave(rxn_ref.token[i].name);
296
+ }
297
+ return rxn;
298
+ }
299
+ /* ---------------------------------------------------------------------- */
300
+ double Phreeqc::
301
+ rxn_find_coef(CReaction& r_ref, const char* str)
302
+ /* ---------------------------------------------------------------------- */
303
+ {
304
+ /*
305
+ * Finds coefficient of token in reaction.
306
+ * input: r_ptr, pointer to a reaction structure
307
+ * str, string to find as reaction token
308
+ *
309
+ * Return: 0.0, if token not found
310
+ * coefficient of token, if found.
311
+ */
312
+ class rxn_token* r_token;
313
+ LDBLE coef;
314
+
315
+ r_token = &r_ref.token[1];
316
+ coef = 0.0;
317
+ while (r_token->s != NULL)
318
+ {
319
+ if (strcmp(r_token->s->name, str) == 0)
320
+ {
321
+ coef = r_token->coef;
322
+ break;
323
+ }
324
+ r_token++;
325
+ }
326
+ return (coef);
327
+ }
328
+ /* **********************************************************************
329
+ *
330
+ * Routines related to structure "element"
331
+ *
332
+ * ********************************************************************** */
333
+ /* ---------------------------------------------------------------------- */
334
+ int Phreeqc::
335
+ element_compare(const void *ptr1, const void *ptr2)
336
+ /* ---------------------------------------------------------------------- */
337
+ {
338
+ const class element *element_ptr1, *element_ptr2;
339
+ element_ptr1 = *(const class element **) ptr1;
340
+ element_ptr2 = *(const class element **) ptr2;
341
+ /* return(strcmp_nocase(element_ptr1->name, element_ptr2->name)); */
342
+ return (strcmp(element_ptr1->name, element_ptr2->name));
343
+
344
+ }
345
+
346
+ /* ---------------------------------------------------------------------- */
347
+ class element* Phreeqc::
348
+ element_store(const char * element)
349
+ /* ---------------------------------------------------------------------- */
350
+ {
351
+ /*
352
+ * Function locates the string "element" in the map for elements.
353
+ *
354
+ * If found, pointer to the appropriate element structure is returned.
355
+ *
356
+ * If the string is not found, a new entry is made at the end of
357
+ * the elements array (position count_elements) and count_elements is
358
+ * incremented. Pointer to the new structure is returned.
359
+ *
360
+ * Arguments:
361
+ * element input, std::string to be located or stored.
362
+ *
363
+ * Returns:
364
+ * The address of an elt structure that contains the element data.
365
+ */
366
+ /*
367
+ * Search list
368
+ */
369
+ std::map<std::string, class element *>::const_iterator it;
370
+ it = elements_map.find(element);
371
+ if (it != elements_map.end())
372
+ {
373
+ return (it->second);
374
+ }
375
+ /*
376
+ * Save new element structure and return pointer to it
377
+ */
378
+ class element *elt_ptr = new class element;
379
+ elt_ptr->name = string_hsave(element);
380
+ elt_ptr->master = NULL;
381
+ elt_ptr->primary = NULL;
382
+ elt_ptr->gfw = 0.0;
383
+ elements.push_back(elt_ptr);
384
+ elements_map[element] = elt_ptr;
385
+ return (elt_ptr);
386
+ }
387
+ /* **********************************************************************
388
+ *
389
+ * Routines related to structure "elt_list"
390
+ *
391
+ * ********************************************************************** */
392
+ /* ---------------------------------------------------------------------- */
393
+ int Phreeqc::
394
+ add_elt_list(const cxxNameDouble& nd, LDBLE coef)
395
+ /* ---------------------------------------------------------------------- */
396
+ {
397
+ cxxNameDouble::const_iterator cit = nd.begin();
398
+ for (; cit != nd.end(); cit++)
399
+ {
400
+ if (count_elts >= (int)elt_list.size())
401
+ {
402
+ elt_list.resize(count_elts + 1);
403
+ }
404
+ elt_list[count_elts].elt = element_store(cit->first.c_str());
405
+ elt_list[count_elts].coef = cit->second * coef;
406
+ count_elts++;
407
+ }
408
+ return (OK);
409
+ }
410
+ int Phreeqc::
411
+ add_elt_list(const std::vector<class elt_list>& el, double coef)
412
+ /* ---------------------------------------------------------------------- */
413
+ {
414
+ const class elt_list* elt_list_ptr = &el[0];
415
+
416
+ for (; elt_list_ptr->elt != NULL; elt_list_ptr++)
417
+ {
418
+ if (count_elts >= elt_list.size())
419
+ {
420
+ elt_list.resize(count_elts + 1);
421
+ }
422
+ elt_list[count_elts].elt = elt_list_ptr->elt;
423
+ elt_list[count_elts].coef = elt_list_ptr->coef * coef;
424
+ count_elts++;
425
+ }
426
+ return (OK);
427
+ }
428
+ /* ---------------------------------------------------------------------- */
429
+ int Phreeqc::
430
+ change_hydrogen_in_elt_list(LDBLE charge)
431
+ /* ---------------------------------------------------------------------- */
432
+ {
433
+ int j;
434
+ int found_h, found_o;
435
+ LDBLE coef_h, coef_o, coef;
436
+ found_h = -1;
437
+ found_o = -1;
438
+ coef_h = 0.0;
439
+ coef_o = 0.0;
440
+ elt_list_combine();
441
+ for (j = 0; j < count_elts; j++)
442
+ {
443
+ if (strcmp(elt_list[j].elt->name, "H") == 0)
444
+ {
445
+ found_h = j;
446
+ coef_h = elt_list[j].coef;
447
+ }
448
+ else if (strcmp(elt_list[j].elt->name, "O") == 0)
449
+ {
450
+ found_o = j;
451
+ coef_o = elt_list[j].coef;
452
+ }
453
+ }
454
+ coef = coef_h - 2 * coef_o - charge;
455
+ if (found_h < 0 && found_o < 0)
456
+ return (OK);
457
+ if (found_h >= 0 && found_o < 0)
458
+ return (OK);
459
+ if (found_h < 0 && found_o >= 0)
460
+ {
461
+ elt_list[count_elts].elt = s_hplus->primary->elt;
462
+ elt_list[count_elts].coef = coef;
463
+ count_elts++;
464
+ elt_list_combine();
465
+ return (OK);
466
+ }
467
+ elt_list[found_h].coef = coef;
468
+ return (OK);
469
+ }
470
+ /* ---------------------------------------------------------------------- */
471
+ int Phreeqc::
472
+ elt_list_combine(void)
473
+ /* ---------------------------------------------------------------------- */
474
+ /*
475
+ * Function goes through the list of elements pointed to by elt_list
476
+ * and combines the coefficients of elements that are the same.
477
+ * Assumes elt_list has been sorted by element name.
478
+ */
479
+ {
480
+ int i, j;
481
+
482
+ //if (count_elts < 1)
483
+ //{
484
+ // output_msg("elt_list_combine: How did this happen?\n");
485
+ // return (ERROR);
486
+ //}
487
+ if (count_elts <= 1)
488
+ {
489
+ return (OK);
490
+ }
491
+ qsort(&elt_list[0], count_elts,
492
+ sizeof(class elt_list), Phreeqc::elt_list_compare);
493
+ j = 0;
494
+ for (i = 1; i < count_elts; i++)
495
+ {
496
+ if (elt_list[i].elt == elt_list[j].elt)
497
+ {
498
+ elt_list[j].coef += elt_list[i].coef;
499
+ }
500
+ else
501
+ {
502
+ j++;
503
+ if (i != j)
504
+ {
505
+ elt_list[j].elt = elt_list[i].elt;
506
+ elt_list[j].coef = elt_list[i].coef;
507
+ }
508
+ }
509
+ }
510
+ count_elts = j + 1;
511
+ return (OK);
512
+ }
513
+ /* ---------------------------------------------------------------------- */
514
+ int Phreeqc::
515
+ elt_list_compare(const void* ptr1, const void* ptr2)
516
+ /* ---------------------------------------------------------------------- */
517
+ {
518
+ const class elt_list* a, * b;
519
+
520
+ a = (const class elt_list*)ptr1;
521
+ b = (const class elt_list*)ptr2;
522
+ return (strncmp(a->elt->name, b->elt->name, MAX_LENGTH));
523
+ }
524
+ /* ---------------------------------------------------------------------- */
525
+ std::vector<class elt_list> Phreeqc::
526
+ elt_list_internal_copy(const std::vector<class elt_list>& el)
527
+ /* ---------------------------------------------------------------------- */
528
+ {
529
+ std::vector<class elt_list> new_elt_list;
530
+ if (el.size() == 0) return new_elt_list;
531
+ const class elt_list* elt_list_ptr = &el[0];
532
+
533
+ new_elt_list.resize(el.size());
534
+ size_t count = 0;
535
+ for (; elt_list_ptr->elt != NULL; elt_list_ptr++)
536
+ {
537
+ new_elt_list[count].elt = element_store(elt_list_ptr->elt->name);
538
+ new_elt_list[count].coef = elt_list_ptr->coef;
539
+ count++;
540
+ }
541
+ new_elt_list[count].elt = NULL;
542
+ return new_elt_list;
543
+ }
544
+ /* ---------------------------------------------------------------------- */
545
+ std::vector<class elt_list> Phreeqc::
546
+ elt_list_vsave(void)
547
+ /* ---------------------------------------------------------------------- */
548
+ {
549
+ /*
550
+ * Takes data from work space elt_list, allocates a new elt_list structure,
551
+ * copies data from work space to new structure, and returns pointer to
552
+ * new structure.
553
+ */
554
+ size_t j;
555
+ std::vector<class elt_list> new_elt_list;
556
+ /*
557
+ * Sort elements in reaction and combine
558
+ */
559
+ elt_list_combine();
560
+ /*
561
+ * Malloc space and store element data
562
+ */
563
+ new_elt_list.resize(count_elts + 1);
564
+ for (j = 0; j < count_elts; j++)
565
+ {
566
+ new_elt_list[j].elt = elt_list[j].elt;
567
+ new_elt_list[j].coef = elt_list[j].coef;
568
+ }
569
+ new_elt_list[count_elts].elt = NULL;
570
+ return new_elt_list;
571
+ }
572
+
573
+ /* ---------------------------------------------------------------------- */
574
+ cxxNameDouble Phreeqc::
575
+ elt_list_NameDouble(void)
576
+ /* ---------------------------------------------------------------------- */
577
+ {
578
+ /*
579
+ * Takes data from work space elt_list, makes NameDouble
580
+ */
581
+ cxxNameDouble nd;
582
+ for (int i = 0; i < count_elts; i++)
583
+ {
584
+ nd.add(elt_list[i].elt->name, elt_list[i].coef);
585
+ }
586
+ return (nd);
587
+ }
588
+ /* **********************************************************************
589
+ *
590
+ * Routines related to structure "inverse"
591
+ *
592
+ * ********************************************************************** */
593
+ /* ---------------------------------------------------------------------- */
594
+ class inverse * Phreeqc::
595
+ inverse_alloc(void)
596
+ /* ---------------------------------------------------------------------- */
597
+ /*
598
+ * Allocates space for a new inverse structure at position count_inverse.
599
+ * Initializes structure.
600
+ * arguments
601
+ * input: none
602
+ * output: pointer to an inverse structure
603
+ * return: OK
604
+ */
605
+ {
606
+ class inverse *inverse_ptr = NULL;
607
+ inverse.resize(count_inverse + 1);
608
+ inverse_ptr = &(inverse[count_inverse++]);
609
+ /*
610
+ * Initialize variables
611
+ */
612
+ inverse_ptr->description = NULL;
613
+ inverse_ptr->count_solns = 0;
614
+ /*
615
+ * allocate space for pointers in structure to NULL
616
+ */
617
+ inverse_ptr->count_solns = 0;
618
+
619
+ return (inverse_ptr);
620
+ }
621
+
622
+ /* ---------------------------------------------------------------------- */
623
+ int Phreeqc::
624
+ inverse_compare(const void *ptr1, const void *ptr2)
625
+ /* ---------------------------------------------------------------------- */
626
+ {
627
+ /*
628
+ * Compare inverse values for n_user
629
+ */
630
+ const class inverse *nptr1;
631
+ const class inverse *nptr2;
632
+
633
+ nptr1 = (const class inverse *) ptr1;
634
+ nptr2 = (const class inverse *) ptr2;
635
+ if (nptr1->n_user > nptr2->n_user)
636
+ return (1);
637
+ if (nptr1->n_user < nptr2->n_user)
638
+ return (-1);
639
+ return (0);
640
+ }
641
+
642
+ /* ---------------------------------------------------------------------- */
643
+ int Phreeqc::
644
+ inverse_delete(int i)
645
+ /* ---------------------------------------------------------------------- */
646
+ {
647
+ /*
648
+ * Deletes inverse i from list (i is not user number),
649
+ * Frees memory allocated to inverse struct
650
+ * Input: i, number of inverse struct to delete
651
+ * Return: OK
652
+ */
653
+ inverse_free(&(inverse[i]));
654
+ inverse.erase(inverse.begin() + (size_t)i);
655
+ count_inverse--;
656
+ return (OK);
657
+ }
658
+
659
+ /* ---------------------------------------------------------------------- */
660
+ int Phreeqc::
661
+ inverse_free(class inverse *inverse_ptr)
662
+ /* ---------------------------------------------------------------------- */
663
+ {
664
+ /*
665
+ * Free all memory for an inverse structure.
666
+ */
667
+ int i;
668
+
669
+ inverse_ptr->description =
670
+ (char *) free_check_null(inverse_ptr->description);
671
+ /* Free solns */
672
+ inverse_ptr->solns.clear();
673
+
674
+ /* Free uncertainties */
675
+ inverse_ptr->uncertainties.clear();
676
+ inverse_ptr->ph_uncertainties.clear();
677
+
678
+ /* Free force_solns */
679
+ inverse_ptr->force_solns.clear();
680
+
681
+ /* Free elts */
682
+ for (i = 0; i < inverse_ptr->elts.size(); i++)
683
+ {
684
+ inverse_ptr->elts[i].uncertainties.clear();
685
+ };
686
+ inverse_ptr->elts.clear();
687
+
688
+ /* Free isotopes */
689
+ for (i = 0; i < inverse_ptr->isotopes.size(); i++)
690
+ {
691
+ inverse_ptr->isotopes[i].uncertainties.clear();
692
+ };
693
+ inverse_ptr->isotopes.clear();
694
+
695
+ for (i = 0; i < inverse_ptr->i_u.size(); i++)
696
+ {
697
+ inverse_ptr->i_u[i].uncertainties.clear();
698
+ };
699
+ inverse_ptr->i_u.clear();
700
+
701
+ /* Free phases */
702
+ for (i = 0; i < inverse_ptr->phases.size(); i++)
703
+ {
704
+ inverse_ptr->phases[i].isotopes.clear();
705
+ }
706
+ inverse_ptr->phases.clear();
707
+
708
+ /* Free carbon derivatives */
709
+ inverse_ptr->dalk_dph.clear();
710
+ inverse_ptr->dalk_dc.clear();
711
+
712
+ return (OK);
713
+ }
714
+
715
+ /* ---------------------------------------------------------------------- */
716
+ int Phreeqc::
717
+ inverse_isotope_compare(const void *ptr1, const void *ptr2)
718
+ /* ---------------------------------------------------------------------- */
719
+ {
720
+ int i;
721
+ const class inv_isotope *iso_ptr1, *iso_ptr2;
722
+
723
+ iso_ptr1 = (const class inv_isotope *) ptr1;
724
+ iso_ptr2 = (const class inv_isotope *) ptr2;
725
+ i = strcmp_nocase(iso_ptr1->elt_name, iso_ptr2->elt_name);
726
+ if (i != 0)
727
+ return (i);
728
+ if (iso_ptr1->isotope_number < iso_ptr2->isotope_number)
729
+ {
730
+ return (-1);
731
+ }
732
+ else if (iso_ptr1->isotope_number > iso_ptr2->isotope_number)
733
+ {
734
+ return (1);
735
+ }
736
+ return (0);
737
+ }
738
+
739
+ /* ---------------------------------------------------------------------- */
740
+ class inverse * Phreeqc::
741
+ inverse_search(int n_user, int *n)
742
+ /* ---------------------------------------------------------------------- */
743
+ {
744
+ /* Linear search of the structure array "inverse" for user number n_user.
745
+ *
746
+ * Arguments:
747
+ * n_user input, user number
748
+ * n output, position in inverse
749
+ *
750
+ * Returns:
751
+ * if found, the address of the inverse element
752
+ * if not found, NULL
753
+ *
754
+ */
755
+ int i;
756
+ for (i = 0; i < count_inverse; i++)
757
+ {
758
+ if (inverse[i].n_user == n_user)
759
+ {
760
+ *n = i;
761
+ return (&(inverse[i]));
762
+ }
763
+ }
764
+ /*
765
+ * An inverse structure with n_user was not found
766
+ */
767
+ return (NULL);
768
+ }
769
+
770
+ /* ---------------------------------------------------------------------- */
771
+ int Phreeqc::
772
+ inverse_sort(void)
773
+ /* ---------------------------------------------------------------------- */
774
+ {
775
+ /*
776
+ * Sort array of inverse structures
777
+ */
778
+ if (count_inverse > 1)
779
+ {
780
+ qsort(&inverse[0], (size_t) count_inverse,
781
+ sizeof(class inverse), inverse_compare);
782
+ }
783
+ return (OK);
784
+ }
785
+
786
+ /* **********************************************************************
787
+ *
788
+ * Routines related to structure "master"
789
+ *
790
+ * ********************************************************************** */
791
+ /* ---------------------------------------------------------------------- */
792
+ class master * Phreeqc::
793
+ master_alloc(void)
794
+ /* ---------------------------------------------------------------------- */
795
+ /*
796
+ * Allocates space to a master structure and initializes the space.
797
+ * arguments: void
798
+ * return: pointer to a master structure
799
+ */
800
+ {
801
+ class master *ptr = new class master;
802
+ /*
803
+ * set pointers in structure to NULL
804
+ */
805
+ ptr->in = FALSE;
806
+ ptr->number = -1;
807
+ ptr->last_model = -1;
808
+ ptr->type = 0;
809
+ ptr->primary = FALSE;
810
+ ptr->coef = 0.0;
811
+ ptr->total = 0.0;
812
+ ptr->isotope_ratio = 0;
813
+ ptr->isotope_ratio_uncertainty = 0;
814
+ ptr->isotope = 0;
815
+ ptr->total_primary = 0;
816
+ ptr->elt = NULL;
817
+ ptr->alk = 0.0;
818
+ ptr->gfw = 0.0;
819
+ ptr->gfw_formula = NULL;
820
+ ptr->unknown = NULL;
821
+ ptr->s = NULL;
822
+ ptr->pe_rxn = NULL;
823
+ ptr->minor_isotope = FALSE;
824
+ return (ptr);
825
+ }
826
+
827
+ /* ---------------------------------------------------------------------- */
828
+ int Phreeqc::
829
+ master_delete(const char* cptr)
830
+ /* ---------------------------------------------------------------------- */
831
+ {
832
+ /*
833
+ * Delete master species: Free memory of master species structure, free
834
+ * the structure, and remove from array master.
835
+ *
836
+ * Input
837
+ * ptr character string with name of element or valence state
838
+ * Returns
839
+ * TRUE if master species was deleted.
840
+ * FALSE if master species was not found.
841
+ */
842
+ int n;
843
+
844
+ if (master_search(cptr, &n) == NULL)
845
+ return (FALSE);
846
+ master_free(master[n]);
847
+ master.erase(master.begin() + n);
848
+ return (TRUE);
849
+ }
850
+
851
+ /* ---------------------------------------------------------------------- */
852
+ int Phreeqc::
853
+ master_free(class master *master_ptr)
854
+ /* ---------------------------------------------------------------------- */
855
+ {
856
+ /*
857
+ * Free memory pointed to by master species pointer, master_ptr.
858
+ * Frees master_ptr itself.
859
+ */
860
+ if (master_ptr == NULL)
861
+ return (ERROR);
862
+ delete master_ptr;
863
+ return (OK);
864
+ }
865
+
866
+ /* ---------------------------------------------------------------------- */
867
+ class master * Phreeqc::
868
+ master_bsearch(const char* cptr)
869
+ /* ---------------------------------------------------------------------- */
870
+ {
871
+ /*
872
+ * Uses binary search. Assumes master is in sort order.
873
+ * Find master species for string (*cptr) containing name of element or valence state.
874
+ *
875
+ * Input: cptr pointer to string containing element name
876
+ *
877
+ * Return: pointer to master structure containing name cptr or NULL.
878
+ */
879
+ void *void_ptr;
880
+ if (master.size() == 0)
881
+ {
882
+ return (NULL);
883
+ }
884
+ void_ptr = bsearch((const char *) cptr,
885
+ (char *) &master[0],
886
+ master.size(),
887
+ sizeof(class master *), master_compare_string);
888
+ if (void_ptr == NULL)
889
+ {
890
+ void_ptr = bsearch(cptr,
891
+ (char*)&master[0],
892
+ master.size(),
893
+ sizeof(class master*), master_compare_string);
894
+ }
895
+ if (void_ptr == NULL)
896
+ {
897
+ return (NULL);
898
+ }
899
+ else
900
+ {
901
+ return (*(class master **) void_ptr);
902
+ }
903
+ }
904
+
905
+ /* ---------------------------------------------------------------------- */
906
+ int Phreeqc::
907
+ master_compare_string(const void *ptr1, const void *ptr2)
908
+ /* ---------------------------------------------------------------------- */
909
+ {
910
+ const char *string_ptr;
911
+ const class master *master_ptr;
912
+
913
+ string_ptr = (const char *) ptr1;
914
+ master_ptr = *(const class master **) ptr2;
915
+ return (strcmp_nocase(string_ptr, master_ptr->elt->name));
916
+ }
917
+
918
+ /* ---------------------------------------------------------------------- */
919
+ int Phreeqc::
920
+ master_compare(const void *ptr1, const void *ptr2)
921
+ /* ---------------------------------------------------------------------- */
922
+ {
923
+ const class master *master_ptr1, *master_ptr2;
924
+ master_ptr1 = *(const class master **) ptr1;
925
+ master_ptr2 = *(const class master **) ptr2;
926
+ return (strcmp_nocase(master_ptr1->elt->name, master_ptr2->elt->name));
927
+ }
928
+
929
+ /* ---------------------------------------------------------------------- */
930
+ class master * Phreeqc::
931
+ master_bsearch_primary(const char* cptr)
932
+ /* ---------------------------------------------------------------------- */
933
+ {
934
+ /*
935
+ * Find primary master species for first element in the string, cptr.
936
+ * Uses binary search. Assumes master is in sort order.
937
+ */
938
+ int l;
939
+ const char* cptr1;
940
+ class master *master_ptr_primary;
941
+ /*
942
+ * Find element name
943
+ */
944
+ cptr1 = cptr;
945
+ {
946
+ std::string elt;
947
+ get_elt(&cptr1, elt, &l);
948
+ /*
949
+ * Search master species list
950
+ */
951
+ master_ptr_primary = master_bsearch(elt.c_str());
952
+ }
953
+ if (master_ptr_primary == NULL)
954
+ {
955
+ input_error++;
956
+ error_string = sformatf(
957
+ "Could not find primary master species for %s.", cptr);
958
+ error_msg(error_string, CONTINUE);
959
+ }
960
+ return (master_ptr_primary);
961
+ }
962
+ /* ---------------------------------------------------------------------- */
963
+ class master * Phreeqc::
964
+ master_bsearch_secondary(const char* cptr)
965
+ /* ---------------------------------------------------------------------- */
966
+ {
967
+ /*
968
+ * Find secondary master species that corresponds to the primary master species.
969
+ * i.e. S(6) for S.
970
+ */
971
+ int l;
972
+ const char* cptr1;
973
+ std::string elt;
974
+ class master *master_ptr_primary, *master_ptr=NULL, *master_ptr_secondary=NULL;
975
+ /*
976
+ * Find element name
977
+ */
978
+ cptr1 = cptr;
979
+ get_elt(&cptr1, elt, &l);
980
+ /*
981
+ * Search master species list
982
+ */
983
+ master_ptr_primary = master_bsearch(elt.c_str());
984
+ if (master_ptr_primary == NULL)
985
+ {
986
+ input_error++;
987
+ error_string = sformatf(
988
+ "Could not find primary master species for %s.", cptr);
989
+ error_msg(error_string, CONTINUE);
990
+ }
991
+ /*
992
+ * If last in list or not redox
993
+ */
994
+ if (master_ptr_primary)
995
+ {
996
+ if ((master_ptr_primary->number >= (int)master.size() - 1) ||
997
+ (master[(size_t)master_ptr_primary->number + 1]->elt->primary != master_ptr_primary))
998
+ {
999
+ return(master_ptr_primary);
1000
+ }
1001
+ /*
1002
+ * Find secondary master with same species as primary
1003
+ */
1004
+ master_ptr = NULL;
1005
+ for (size_t j = master_ptr_primary->number + 1; j < master.size(); j++)
1006
+ {
1007
+ if (master[j]->s == master_ptr_primary->s)
1008
+ {
1009
+ master_ptr = master[j];
1010
+ }
1011
+ }
1012
+ }
1013
+ /*
1014
+ *
1015
+ */
1016
+ if (master_ptr != NULL && master_ptr->elt != NULL && (master_ptr->elt->primary == master_ptr_primary))
1017
+ {
1018
+ master_ptr_secondary = master_ptr;
1019
+ }
1020
+ else
1021
+ {
1022
+ input_error++;
1023
+ error_string = sformatf(
1024
+ "Could not find secondary master species for %s.", cptr);
1025
+ error_msg(error_string, STOP);
1026
+ }
1027
+
1028
+
1029
+ return (master_ptr_secondary);
1030
+ }
1031
+ /* ---------------------------------------------------------------------- */
1032
+ class master * Phreeqc::
1033
+ master_search(const char* cptr, int *n)
1034
+ /* ---------------------------------------------------------------------- */
1035
+ {
1036
+ /*
1037
+ * Linear search of master to find master species in string, cptr.
1038
+ * Returns pointer if found. n contains position in array master.
1039
+ * Returns NULL if not found.
1040
+ */
1041
+ int i;
1042
+ class master *master_ptr;
1043
+ /*
1044
+ * Search master species list
1045
+ */
1046
+ *n = -999;
1047
+ for (i = 0; i < (int)master.size(); i++)
1048
+ {
1049
+ if (strcmp(cptr, master[i]->elt->name) == 0)
1050
+ {
1051
+ *n = i;
1052
+ master_ptr = master[i];
1053
+ return (master_ptr);
1054
+ }
1055
+ }
1056
+ return (NULL);
1057
+ }
1058
+ /* **********************************************************************
1059
+ *
1060
+ * Routines related to structure "phases"
1061
+ *
1062
+ * ********************************************************************** */
1063
+ /* ---------------------------------------------------------------------- */
1064
+ class phase * Phreeqc::
1065
+ phase_alloc(void)
1066
+ /* ---------------------------------------------------------------------- */
1067
+ {
1068
+ /*
1069
+ * Allocates space to a phase structure and initializes
1070
+ * arguments: void
1071
+ * return: pointer to new phase structure
1072
+ */
1073
+ class phase *phase_ptr;
1074
+ /*
1075
+ * Allocate space
1076
+ */
1077
+ phase_ptr = new class phase;
1078
+ /*
1079
+ * Initialize space
1080
+ */
1081
+ phase_init(phase_ptr);
1082
+ return (phase_ptr);
1083
+ }
1084
+ #ifdef OBSOLETE
1085
+ /* ---------------------------------------------------------------------- */
1086
+ int Phreeqc::
1087
+ phase_compare(const void *ptr1, const void *ptr2)
1088
+ /* ---------------------------------------------------------------------- */
1089
+ {
1090
+ /*
1091
+ * Compares names of phases for sort
1092
+ */
1093
+ const class phase *phase_ptr1, *phase_ptr2;
1094
+ phase_ptr1 = *(const class phase **) ptr1;
1095
+ phase_ptr2 = *(const class phase **) ptr2;
1096
+ return (strcmp_nocase(phase_ptr1->name, phase_ptr2->name));
1097
+ }
1098
+ #endif
1099
+ /* ---------------------------------------------------------------------- */
1100
+ int Phreeqc::
1101
+ phase_compare_string(const void *ptr1, const void *ptr2)
1102
+ /* ---------------------------------------------------------------------- */
1103
+ {
1104
+ const char *char_ptr;
1105
+ const class phase *phase_ptr;
1106
+ char_ptr = (const char *) ptr1;
1107
+ phase_ptr = *(const class phase **) ptr2;
1108
+ return (strcmp_nocase(char_ptr, phase_ptr->name));
1109
+ }
1110
+
1111
+ /* ---------------------------------------------------------------------- */
1112
+ int Phreeqc::
1113
+ phase_delete(int i)
1114
+ /* ---------------------------------------------------------------------- */
1115
+ {
1116
+ /*
1117
+ * Deletes phase i from list, phases
1118
+ * Frees memory allocated to phase[i] and renumbers phases to remove number i.
1119
+ * Input: i, number of phase
1120
+ * Return: OK
1121
+ */
1122
+ phase_free(phases[i]);
1123
+ phases.erase(phases.begin() + (size_t)i);
1124
+ return (OK);
1125
+ }
1126
+
1127
+ /* ---------------------------------------------------------------------- */
1128
+ int Phreeqc::
1129
+ phase_free(class phase *phase_ptr)
1130
+ /* ---------------------------------------------------------------------- */
1131
+ {
1132
+ /*
1133
+ * Frees memory allocated within phase[i], does not free phase structure
1134
+ * Input: i, number of phase
1135
+ * Return: OK
1136
+ */
1137
+ if (phase_ptr == NULL)
1138
+ return (ERROR);
1139
+ phase_ptr->next_elt.clear();
1140
+ phase_ptr->next_sys_total.clear();;
1141
+ phase_ptr->add_logk.clear();
1142
+ return (OK);
1143
+ }
1144
+
1145
+ /* ---------------------------------------------------------------------- */
1146
+ class phase * Phreeqc::
1147
+ phase_bsearch(const char* cptr, int *j, int print)
1148
+ /* ---------------------------------------------------------------------- */
1149
+ {
1150
+ /* Binary search the structure array "phases" for a name that is equal to
1151
+ * cptr. Assumes array phases is in sort order.
1152
+ *
1153
+ * Arguments:
1154
+ * name input, a character string to be located in phases.
1155
+ * j index number in array phases.
1156
+ *
1157
+ * Returns:
1158
+ * if found, pointer to phase structure.
1159
+ * if not found, NULL
1160
+ *
1161
+ */
1162
+ void *void_ptr;
1163
+
1164
+ void_ptr = NULL;
1165
+ if ((int)phases.size() > 0)
1166
+ {
1167
+ void_ptr = (void *)
1168
+ bsearch((char *) cptr,
1169
+ (char *) &phases[0],
1170
+ phases.size(),
1171
+ sizeof(class phase *), phase_compare_string);
1172
+ }
1173
+ if (void_ptr == NULL && print == TRUE)
1174
+ {
1175
+ error_string = sformatf( "Could not find phase in list, %s.", cptr);
1176
+ error_msg(error_string, CONTINUE);
1177
+ }
1178
+
1179
+ if (void_ptr == NULL)
1180
+ {
1181
+ *j = -1;
1182
+ return (NULL);
1183
+ }
1184
+
1185
+ *j = (int) ((class phase **) void_ptr - &phases[0]);
1186
+ return (*(class phase **) void_ptr);
1187
+ }
1188
+
1189
+ /* ---------------------------------------------------------------------- */
1190
+ int Phreeqc::
1191
+ phase_init(class phase *phase_ptr)
1192
+ /* ---------------------------------------------------------------------- */
1193
+ /*
1194
+ * set pointers in phase structure to NULL
1195
+ */
1196
+ {
1197
+ int i;
1198
+
1199
+ phase_ptr->name = NULL;
1200
+ phase_ptr->formula = NULL;
1201
+ phase_ptr->in = FALSE;
1202
+ phase_ptr->lk = 0.0;
1203
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
1204
+ phase_ptr->logk[i] = 0.0;
1205
+ phase_ptr->original_units = kjoules;
1206
+ phase_ptr->add_logk.clear();
1207
+ phase_ptr->moles_x = 0;
1208
+ phase_ptr->delta_max = 0;
1209
+ phase_ptr->p_soln_x = 0;
1210
+ phase_ptr->fraction_x = 0;
1211
+ phase_ptr->log10_lambda = 0;
1212
+ phase_ptr->log10_fraction_x = 0;
1213
+ phase_ptr->dn = 0;
1214
+ phase_ptr->dnb = 0;
1215
+ phase_ptr->dnc = 0;
1216
+ phase_ptr->gn = 0;
1217
+ phase_ptr->gntot = 0;
1218
+ phase_ptr->t_c = 0.0;
1219
+ phase_ptr->p_c = 0.0;
1220
+ phase_ptr->omega = 0.0;
1221
+ phase_ptr->pr_a = 0.0;
1222
+ phase_ptr->pr_b = 0.0;
1223
+ phase_ptr->pr_alpha = 0.0;
1224
+ phase_ptr->pr_tk = 0;
1225
+ phase_ptr->pr_p = 0;
1226
+ phase_ptr->pr_phi = 1.0;
1227
+ phase_ptr->pr_aa_sum2 = 0;
1228
+ for (i = 0; i < 9; i++)
1229
+ phase_ptr->delta_v[i] = 0.0;
1230
+ phase_ptr->pr_si_f = 0;
1231
+ phase_ptr->pr_in = false;
1232
+ phase_ptr->type = SOLID;
1233
+ phase_ptr->check_equation = TRUE;
1234
+ phase_ptr->replaced = 0;
1235
+ phase_ptr->in_system = 1;
1236
+ phase_ptr->original_deltav_units = cm3_per_mol;
1237
+ return (OK);
1238
+ }
1239
+
1240
+ /* ---------------------------------------------------------------------- */
1241
+ class phase * Phreeqc::
1242
+ phase_store(const char *name_in)
1243
+ /* ---------------------------------------------------------------------- */
1244
+ {
1245
+ /*
1246
+ * Function locates the string "name" in the map for phases.
1247
+ *
1248
+ * If found, pointer to the appropriate phase structure is returned.
1249
+ *
1250
+ * If the string is not found, a new entry is made at the end of
1251
+ * the phases array (position count_phases), it is added to the map,
1252
+ * and the new structure is returned.
1253
+ *
1254
+ * Arguments:
1255
+ * name input, character string to be located or stored.
1256
+ *
1257
+ * Returns:
1258
+ * The address of a phase structure that contains the phase data.
1259
+ * If phase existed, it is reinitialized. The structure returned
1260
+ * contains only the name of the phase.
1261
+ */
1262
+ class phase *phase_ptr = NULL;
1263
+ /*
1264
+ * Search list
1265
+ */
1266
+ std::string name = name_in;
1267
+ str_tolower(name);
1268
+ std::map<std::string, class phase*>::iterator p_it =
1269
+ phases_map.find(name);
1270
+ if (p_it != phases_map.end())
1271
+ {
1272
+ phase_ptr = p_it->second;
1273
+ phase_free(phase_ptr);
1274
+ phase_init(phase_ptr);
1275
+ phase_ptr->name = string_hsave(name_in);
1276
+ return (phase_ptr);
1277
+ }
1278
+ /*
1279
+ * Make new phase structure and return pointer to it
1280
+ */
1281
+ size_t n = phases.size();
1282
+ phases.resize(n + 1);
1283
+ phases[n] = phase_alloc();
1284
+ /* set name in phase structure */
1285
+ phases[n]->name = string_hsave(name_in);
1286
+ /*
1287
+ * Update map
1288
+ */
1289
+ phases_map[name] = phases[n];
1290
+ return (phases[n]);
1291
+ }
1292
+ /* **********************************************************************
1293
+ *
1294
+ * Routines related to structure "rates"
1295
+ *
1296
+ * ********************************************************************** */
1297
+ /* ---------------------------------------------------------------------- */
1298
+ class rate * Phreeqc::
1299
+ rate_bsearch(const char* cptr, int *j)
1300
+ /* ---------------------------------------------------------------------- */
1301
+ {
1302
+ /* Binary search the structure array "rates" for a name that is equal to
1303
+ * cptr. Assumes array rates is in sort order.
1304
+ *
1305
+ * Arguments:
1306
+ * name input, a character string to be located in rates.
1307
+ * j index number in array rates.
1308
+ *
1309
+ * Returns:
1310
+ * if found, pointer to rate structure.
1311
+ * if not found, NULL
1312
+ *
1313
+ */
1314
+ void *void_ptr;
1315
+
1316
+ if (rates.size() == 0)
1317
+ {
1318
+ *j = -1;
1319
+ return (NULL);
1320
+ }
1321
+ void_ptr = (void *)
1322
+ bsearch((char *) cptr,
1323
+ (char *) &rates[0],
1324
+ rates.size(),
1325
+ sizeof(class rate *), rate_compare_string);
1326
+
1327
+ if (void_ptr == NULL)
1328
+ {
1329
+ *j = -1;
1330
+ return (NULL);
1331
+ }
1332
+
1333
+ *j = (int) ((class rate *) void_ptr - &rates[0]);
1334
+ return ((class rate *) void_ptr);
1335
+ }
1336
+
1337
+ /* ---------------------------------------------------------------------- */
1338
+ int Phreeqc::
1339
+ rate_compare(const void *ptr1, const void *ptr2)
1340
+ /* ---------------------------------------------------------------------- */
1341
+ {
1342
+ /*
1343
+ * Compares names of rates for sort
1344
+ */
1345
+ const class rate *rate_ptr1, *rate_ptr2;
1346
+ rate_ptr1 = *(const class rate **) ptr1;
1347
+ rate_ptr2 = *(const class rate **) ptr2;
1348
+ return (strcmp_nocase(rate_ptr1->name, rate_ptr2->name));
1349
+ }
1350
+
1351
+ /* ---------------------------------------------------------------------- */
1352
+ int Phreeqc::
1353
+ rate_compare_string(const void *ptr1, const void *ptr2)
1354
+ /* ---------------------------------------------------------------------- */
1355
+ {
1356
+ const char *char_ptr;
1357
+ const class rate *rate_ptr;
1358
+ char_ptr = (const char *) ptr1;
1359
+ rate_ptr = *(const class rate **) ptr2;
1360
+ return (strcmp_nocase(char_ptr, rate_ptr->name));
1361
+ }
1362
+
1363
+ /* ---------------------------------------------------------------------- */
1364
+ int Phreeqc::
1365
+ rate_free(class rate *rate_ptr)
1366
+ /* ---------------------------------------------------------------------- */
1367
+ {
1368
+ /*
1369
+ * Frees memory allocated within rate[i], does not free rate structure
1370
+ * Input: i, number of rate
1371
+ * Return: OK
1372
+ */
1373
+
1374
+
1375
+ if (rate_ptr == NULL)
1376
+ return (ERROR);
1377
+ rate_ptr->commands.clear();
1378
+ if (rate_ptr->linebase != NULL)
1379
+ {
1380
+ char cmd[] = "new; quit";
1381
+ basic_run(cmd, rate_ptr->linebase, rate_ptr->varbase, rate_ptr->loopbase);
1382
+ rate_ptr->linebase = NULL;
1383
+ rate_ptr->varbase = NULL;
1384
+ rate_ptr->loopbase = NULL;
1385
+ }
1386
+ return (OK);
1387
+ }
1388
+
1389
+ /* ---------------------------------------------------------------------- */
1390
+ class rate * Phreeqc::
1391
+ rate_copy(const class rate *rate_ptr)
1392
+ /* ---------------------------------------------------------------------- */
1393
+ {
1394
+ /*
1395
+ * Copies a rate to new allocated space
1396
+ */
1397
+ if (rate_ptr == NULL)
1398
+ return (NULL);
1399
+ class rate* rate_new = new class rate;
1400
+ rate_new->name = string_hsave(rate_ptr->name);
1401
+ rate_new->commands = rate_ptr->commands;
1402
+ rate_new->new_def = TRUE;
1403
+ rate_new->linebase = NULL;
1404
+ rate_new->varbase = NULL;
1405
+ rate_new->loopbase = NULL;
1406
+ return (rate_new);
1407
+ }
1408
+
1409
+ /* ---------------------------------------------------------------------- */
1410
+ class rate * Phreeqc::
1411
+ rate_search(const char *name_in, int *n)
1412
+ /* ---------------------------------------------------------------------- */
1413
+ {
1414
+ /* Linear search of the structure array "rates" for name.
1415
+ *
1416
+ * Arguments:
1417
+ * name input, name of rate
1418
+ * n output, position in rates
1419
+ *
1420
+ * Returns:
1421
+ * if found, the address of the pp_assemblage element
1422
+ * if not found, NULL
1423
+ */
1424
+ std::map<const char *, int>::iterator it;
1425
+
1426
+ const char * name;
1427
+ name = string_hsave(name_in);
1428
+
1429
+ it = rates_map.find(name);
1430
+ if (it != rates_map.end())
1431
+ {
1432
+ *n = it->second;
1433
+ if (*n >= 0)
1434
+ {
1435
+ return &(rates[it->second]);
1436
+ }
1437
+ return NULL;
1438
+ }
1439
+
1440
+ int i;
1441
+ *n = -1;
1442
+ for (i = 0; i < (int)rates.size(); i++)
1443
+ {
1444
+ if (strcmp_nocase(rates[i].name, name) == 0)
1445
+ {
1446
+ *n = i;
1447
+ rates_map[name] = i;
1448
+ return (&(rates[i]));
1449
+ }
1450
+ }
1451
+ /*
1452
+ * rate name not found
1453
+ */
1454
+ rates_map[name] = *n;
1455
+ return (NULL);
1456
+ }
1457
+
1458
+ /* ---------------------------------------------------------------------- */
1459
+ int Phreeqc::
1460
+ rate_sort(void)
1461
+ /* ---------------------------------------------------------------------- */
1462
+ {
1463
+ /*
1464
+ * Sort array of rate structures
1465
+ */
1466
+ if (rates.size() > 1)
1467
+ {
1468
+ qsort(&rates[0], rates.size(), sizeof(class rate),
1469
+ rate_compare);
1470
+ }
1471
+ return (OK);
1472
+ }
1473
+ /* **********************************************************************
1474
+ *
1475
+ * Routines related to structure "species"
1476
+ *
1477
+ * ********************************************************************** */
1478
+ /* ---------------------------------------------------------------------- */
1479
+ class species * Phreeqc::
1480
+ s_alloc(void)
1481
+ /* ---------------------------------------------------------------------- */
1482
+ /*
1483
+ * Allocates space to a species structure, initializes
1484
+ * arguments: void
1485
+ * return: pointer to a species structure
1486
+ */
1487
+ {
1488
+ class species *s_ptr;
1489
+ s_ptr = new class species;
1490
+ /*
1491
+ * set pointers in structure to NULL, variables to zero
1492
+ */
1493
+ s_init(s_ptr);
1494
+
1495
+ return (s_ptr);
1496
+ }
1497
+
1498
+ /* ---------------------------------------------------------------------- */
1499
+ int Phreeqc::
1500
+ s_compare(const void *ptr1, const void *ptr2)
1501
+ /* ---------------------------------------------------------------------- */
1502
+ {
1503
+ const class species *s_ptr1, *s_ptr2;
1504
+ s_ptr1 = *(const class species **) ptr1;
1505
+ s_ptr2 = *(const class species **) ptr2;
1506
+ return (strcmp(s_ptr1->name, s_ptr2->name));
1507
+
1508
+ }
1509
+
1510
+ /* ---------------------------------------------------------------------- */
1511
+ int Phreeqc::
1512
+ s_delete(int i)
1513
+ /* ---------------------------------------------------------------------- */
1514
+ {
1515
+ /*
1516
+ * Delete species i: free memory and renumber array of pointers, s.
1517
+ */
1518
+ s_free(s[i]);
1519
+ s[i] = (class species *) free_check_null(s[i]);
1520
+ s.erase(s.begin() + i);
1521
+ return (OK);
1522
+ }
1523
+
1524
+ /* ---------------------------------------------------------------------- */
1525
+ int Phreeqc::
1526
+ s_free(class species *s_ptr)
1527
+ /* ---------------------------------------------------------------------- */
1528
+ {
1529
+ /*
1530
+ * Free space allocated for species structure, s_ptr. Does not free s_ptr.
1531
+ */
1532
+ if (s_ptr == NULL)
1533
+ return (ERROR);
1534
+ s_ptr->next_elt.clear();
1535
+ s_ptr->next_secondary.clear();
1536
+ s_ptr->next_sys_total.clear();
1537
+ s_ptr->add_logk.clear();
1538
+ return (OK);
1539
+ }
1540
+
1541
+ /* ---------------------------------------------------------------------- */
1542
+ int Phreeqc::
1543
+ s_init(class species *s_ptr)
1544
+ /* ---------------------------------------------------------------------- */
1545
+ /*
1546
+ * return: pointer to a species structure
1547
+ */
1548
+ {
1549
+ int i;
1550
+ /*
1551
+ * set pointers in structure to NULL
1552
+ */
1553
+ s_ptr->name = NULL;
1554
+ s_ptr->mole_balance = NULL;
1555
+ s_ptr->in = FALSE;
1556
+ s_ptr->number = 0;
1557
+ s_ptr->primary = NULL;
1558
+ s_ptr->secondary = NULL;
1559
+ s_ptr->gfw = 0.0;
1560
+ s_ptr->z = 0.0;
1561
+ s_ptr->dw = 0.0;
1562
+ s_ptr->dw_t = 0.0;
1563
+ s_ptr->dw_a = 0.0;
1564
+ s_ptr->dw_a2 = 0.0;
1565
+ s_ptr->dw_a3 = 0.0;
1566
+ s_ptr->erm_ddl = 1.0;
1567
+ s_ptr->equiv = 0;
1568
+ s_ptr->alk = 0.0;
1569
+ s_ptr->carbon = 0.0;
1570
+ s_ptr->co2 = 0.0;
1571
+ s_ptr->h = 0.0;
1572
+ s_ptr->o = 0.0;
1573
+ s_ptr->dha = 0.0;
1574
+ s_ptr->dhb = 0.0;
1575
+ s_ptr->a_f = 0.0;
1576
+ s_ptr->lk = 0.0;
1577
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
1578
+ {
1579
+ s_ptr->logk[i] = 0.0;
1580
+ }
1581
+ for (i = 0; i < 10; i++)
1582
+ {
1583
+ s_ptr->Jones_Dole[i] = 0.0;
1584
+ }
1585
+ /* VP: Density Start */
1586
+ for (i = 0; i < 6; i++)
1587
+ {
1588
+ s_ptr->millero[i] = 0.0;
1589
+ }
1590
+ /* VP: Density End */
1591
+ s_ptr->original_units = kjoules;
1592
+ s_ptr->add_logk.clear();
1593
+ s_ptr->lg = 0.0;
1594
+ s_ptr->lg_pitzer = 0.0;
1595
+ s_ptr->lm = 0.0;
1596
+ s_ptr->la = 0.0;
1597
+ s_ptr->dg = 0.0;
1598
+ s_ptr->dg_total_g = 0;
1599
+ s_ptr->moles = 0.0;
1600
+ s_ptr->type = 0;
1601
+ s_ptr->gflag = 0;
1602
+ s_ptr->exch_gflag = 0;
1603
+ s_ptr->check_equation = TRUE;
1604
+ s_ptr->tot_g_moles = 0;
1605
+ s_ptr->tot_dh2o_moles = 0;
1606
+ for (i = 0; i < 5; i++)
1607
+ {
1608
+ s_ptr->cd_music[i] = 0.0;
1609
+ }
1610
+ for (i = 0; i < 3; i++)
1611
+ {
1612
+ s_ptr->dz[i] = 0.0;
1613
+ }
1614
+ s_ptr->original_deltav_units = cm3_per_mol;
1615
+ return (OK);
1616
+ }
1617
+ /* ---------------------------------------------------------------------- */
1618
+ class species* Phreeqc::
1619
+ s_search(const char* name)
1620
+ /* ---------------------------------------------------------------------- */
1621
+ {
1622
+ /*
1623
+ * Function locates the string "name" in the species_map.
1624
+ *
1625
+ * Arguments:
1626
+ * name input, a character string to be located in species.
1627
+ *
1628
+ * Returns:
1629
+ * If found, pointer to the appropriate species structure is returned.
1630
+ * else, NULL pointer is returned.
1631
+ */
1632
+ class species* s_ptr = NULL;
1633
+ std::map<std::string, class species*>::iterator s_it =
1634
+ species_map.find(name);
1635
+ if (s_it != species_map.end())
1636
+ {
1637
+ s_ptr = s_it->second;
1638
+ }
1639
+ return (s_ptr);
1640
+ }
1641
+ /* ---------------------------------------------------------------------- */
1642
+ class species * Phreeqc::
1643
+ s_store(const char *name, LDBLE l_z, int replace_if_found)
1644
+ /* ---------------------------------------------------------------------- */
1645
+ {
1646
+ /*
1647
+ * Function locates the string "name" in the map for species.
1648
+ *
1649
+ * Pointer to a species structure is always returned.
1650
+ *
1651
+ * If the string is not found, a new entry is made at the end of
1652
+ * the elements array (position count_elements) and count_elements is
1653
+ * incremented. A new entry is made in the map. Pointer to
1654
+ * the new structure is returned.
1655
+ * If "name" is found and replace is true, pointers in old species structure
1656
+ * are freed and replaced with additional input.
1657
+ * If "name" is found and replace is false, the old species structure is not
1658
+ * modified and a pointer to it is returned.
1659
+ *
1660
+ * Arguments:
1661
+ * name input, character string to be found in "species".
1662
+ * l_z input, charge on "name"
1663
+ * replace_if_found input, TRUE means reinitialize species if found
1664
+ * FALSE means just return pointer if found.
1665
+ *
1666
+ * Returns:
1667
+ * pointer to species structure "s" where "name" can be found.
1668
+ */
1669
+
1670
+ /*
1671
+ * Search list
1672
+ */
1673
+ class species* s_ptr = NULL;
1674
+ s_ptr = s_search(name);
1675
+ if (s_ptr != NULL && replace_if_found == FALSE)
1676
+ {
1677
+ return (s_ptr);
1678
+ }
1679
+ else if (s_ptr != NULL && replace_if_found == TRUE)
1680
+ {
1681
+ s_free(s_ptr);
1682
+ s_init(s_ptr);
1683
+ }
1684
+ else
1685
+ {
1686
+ size_t n = s.size();
1687
+ s.resize(n + 1);
1688
+ /* Make new species structure */
1689
+ s[n] = s_alloc();
1690
+ s_ptr = s[n];
1691
+ }
1692
+ /* set name and z in pointer in species structure */
1693
+ s_ptr->name = string_hsave(name);
1694
+ s_ptr->z = l_z;
1695
+ /*
1696
+ * Update map
1697
+ */
1698
+ species_map[name] = s_ptr;
1699
+ return (s_ptr);
1700
+ }
1701
+ /* ---------------------------------------------------------------------- */
1702
+ int Phreeqc::
1703
+ isotope_compare(const void *ptr1, const void *ptr2)
1704
+ /* ---------------------------------------------------------------------- */
1705
+ {
1706
+ int i;
1707
+ const class isotope *iso_ptr1, *iso_ptr2;
1708
+
1709
+ iso_ptr1 = (const class isotope *) ptr1;
1710
+ iso_ptr2 = (const class isotope *) ptr2;
1711
+ i = strcmp_nocase(iso_ptr1->elt_name, iso_ptr2->elt_name);
1712
+ if (i != 0)
1713
+ return (i);
1714
+ if (iso_ptr1->isotope_number < iso_ptr2->isotope_number)
1715
+ {
1716
+ return (-1);
1717
+ }
1718
+ else if (iso_ptr1->isotope_number > iso_ptr2->isotope_number)
1719
+ {
1720
+ return (1);
1721
+ }
1722
+ return (0);
1723
+ }
1724
+ /* **********************************************************************
1725
+ *
1726
+ * Routines related to structure "species_list"
1727
+ *
1728
+ * ********************************************************************** */
1729
+ /* ---------------------------------------------------------------------- */
1730
+ int Phreeqc::
1731
+ species_list_compare(const void *ptr1, const void *ptr2)
1732
+ /* ---------------------------------------------------------------------- */
1733
+ {
1734
+ int j;
1735
+ const char *name1, *name2;
1736
+ const class species_list *nptr1, *nptr2;
1737
+
1738
+ nptr1 = (const class species_list *) ptr1;
1739
+ nptr2 = (const class species_list *) ptr2;
1740
+
1741
+ /*
1742
+ * Put H+ first
1743
+ */
1744
+ if (nptr1->master_s != nptr2->master_s)
1745
+ {
1746
+ /*
1747
+ if (nptr1->master_s == s_hplus)
1748
+ return (-1);
1749
+ if (nptr2->master_s == s_hplus)
1750
+ return (1);
1751
+ */
1752
+ if ((strcmp(nptr1->master_s->name,"H+") == 0) || (strcmp(nptr1->master_s->name,"H3O+") == 0))
1753
+ return (-1);
1754
+ if ((strcmp(nptr2->master_s->name,"H+") == 0) || (strcmp(nptr2->master_s->name,"H3O+") == 0))
1755
+ return (1);
1756
+ }
1757
+ /*
1758
+ * Other element valence states
1759
+ */
1760
+ if (nptr1->master_s->secondary != NULL)
1761
+ {
1762
+ name1 = nptr1->master_s->secondary->elt->name;
1763
+ }
1764
+ else
1765
+ {
1766
+ name1 = nptr1->master_s->primary->elt->name;
1767
+ }
1768
+ if (nptr2->master_s->secondary != NULL)
1769
+ {
1770
+ name2 = nptr2->master_s->secondary->elt->name;
1771
+ }
1772
+ else
1773
+ {
1774
+ name2 = nptr2->master_s->primary->elt->name;
1775
+ }
1776
+ /*
1777
+ * Compare name of primary or secondary master species; log molality
1778
+ */
1779
+
1780
+ j = strcmp(name1, name2);
1781
+
1782
+ /*
1783
+ * Different master species
1784
+ */
1785
+ if (j != 0)
1786
+ return (j);
1787
+
1788
+ /*
1789
+ * Else, descending order by log molality
1790
+ */
1791
+ if (nptr1->s->lm > nptr2->s->lm)
1792
+ {
1793
+ return (-1);
1794
+ }
1795
+ else if (nptr1->s->lm < nptr2->s->lm)
1796
+ {
1797
+ return (1);
1798
+ }
1799
+ else
1800
+ {
1801
+ return (0);
1802
+ }
1803
+ }
1804
+
1805
+ /* ---------------------------------------------------------------------- */
1806
+ int Phreeqc::
1807
+ species_list_compare_alk(const void *ptr1, const void *ptr2)
1808
+ /* ---------------------------------------------------------------------- */
1809
+ {
1810
+ const class species_list *nptr1, *nptr2;
1811
+ LDBLE alk1, alk2;
1812
+
1813
+ nptr1 = (const class species_list *) ptr1;
1814
+ nptr2 = (const class species_list *) ptr2;
1815
+ /*
1816
+ * Else, descending order by log molality
1817
+ */
1818
+ alk1 = fabs(under(nptr1->s->lm) * nptr1->s->alk);
1819
+ alk2 = fabs(under(nptr2->s->lm) * nptr2->s->alk);
1820
+
1821
+ if (alk1 > alk2)
1822
+ {
1823
+ return (-1);
1824
+ }
1825
+ else if (alk1 < alk2)
1826
+ {
1827
+ return (1);
1828
+ }
1829
+ else
1830
+ {
1831
+ return (0);
1832
+ }
1833
+ }
1834
+ /* ---------------------------------------------------------------------- */
1835
+ int Phreeqc::
1836
+ species_list_compare_master(const void *ptr1, const void *ptr2)
1837
+ /* ---------------------------------------------------------------------- */
1838
+ {
1839
+ const char *name1, *name2;
1840
+ const class species_list *nptr1, *nptr2;
1841
+
1842
+ nptr1 = (const class species_list *) ptr1;
1843
+ nptr2 = (const class species_list *) ptr2;
1844
+
1845
+ /*
1846
+ * Put H+ first
1847
+ */
1848
+ if (nptr1->master_s != nptr2->master_s)
1849
+ {
1850
+ /*
1851
+ if (nptr1->master_s == s_hplus)
1852
+ return (-1);
1853
+ if (nptr2->master_s == s_hplus)
1854
+ return (1);
1855
+ */
1856
+ if ((strcmp(nptr1->master_s->name,"H+") == 0) || (strcmp(nptr1->master_s->name,"H3O+") == 0))
1857
+ return (-1);
1858
+ if ((strcmp(nptr2->master_s->name,"H+") == 0) || (strcmp(nptr2->master_s->name,"H3O+") == 0))
1859
+ return (1);
1860
+ }
1861
+ /*
1862
+ * Other element valence states
1863
+ */
1864
+ if (nptr1->master_s->secondary != NULL)
1865
+ {
1866
+ name1 = nptr1->master_s->secondary->elt->name;
1867
+ }
1868
+ else
1869
+ {
1870
+ name1 = nptr1->master_s->primary->elt->name;
1871
+ }
1872
+ if (nptr2->master_s->secondary != NULL)
1873
+ {
1874
+ name2 = nptr2->master_s->secondary->elt->name;
1875
+ }
1876
+ else
1877
+ {
1878
+ name2 = nptr2->master_s->primary->elt->name;
1879
+ }
1880
+ /*
1881
+ * Compare name of primary or secondary master species; log molality
1882
+ */
1883
+
1884
+ return (strcmp(name1, name2));
1885
+ }
1886
+
1887
+
1888
+ /* ---------------------------------------------------------------------- */
1889
+ int Phreeqc::
1890
+ species_list_sort(void)
1891
+ /* ---------------------------------------------------------------------- */
1892
+ {
1893
+ /*
1894
+ * Sort list using rules in species_list_compare
1895
+ */
1896
+ if (species_list.size() > 1)
1897
+ {
1898
+ qsort(&species_list[0], species_list.size(),
1899
+ sizeof(class species_list), species_list_compare);
1900
+ }
1901
+ return (OK);
1902
+ }
1903
+
1904
+ /* **********************************************************************
1905
+ *
1906
+ * Routines related to structure "surface"
1907
+ *
1908
+ * ********************************************************************** */
1909
+ /* ---------------------------------------------------------------------- */
1910
+ struct Change_Surf * Phreeqc::
1911
+ change_surf_alloc(int count)
1912
+ /* ---------------------------------------------------------------------- */
1913
+ {
1914
+ if (count == 1)
1915
+ return (change_surf);
1916
+ change_surf =
1917
+ (struct Change_Surf *) PHRQ_realloc(change_surf,
1918
+ (size_t) count *
1919
+ sizeof(struct Change_Surf));
1920
+ if (change_surf == NULL)
1921
+ malloc_error();
1922
+ change_surf[count - 1].cell_no = -99;
1923
+ change_surf[count - 1].next = FALSE;
1924
+ change_surf[count - 2].next = TRUE;
1925
+
1926
+ return (change_surf);
1927
+ }
1928
+ /* ---------------------------------------------------------------------- */
1929
+ class master * Phreeqc::
1930
+ surface_get_psi_master(const char *name, int plane)
1931
+ /* ---------------------------------------------------------------------- */
1932
+ {
1933
+ class master *master_ptr;
1934
+ std::string token;
1935
+
1936
+ if (name == NULL)
1937
+ return (NULL);
1938
+ token = name;
1939
+ token.append("_psi");
1940
+ switch (plane)
1941
+ {
1942
+ case SURF_PSI:
1943
+ break;
1944
+ case SURF_PSI1:
1945
+ token.append("b");
1946
+ break;
1947
+ case SURF_PSI2:
1948
+ token.append("d");
1949
+ break;
1950
+ default:
1951
+ error_msg("Unknown plane for surface_get_psi_master", STOP);
1952
+ }
1953
+ master_ptr = master_bsearch(token.c_str());
1954
+ return (master_ptr);
1955
+ }
1956
+ /* **********************************************************************
1957
+ *
1958
+ * Routines related to structure "trxn"
1959
+ *
1960
+ * ********************************************************************** */
1961
+
1962
+ /* ---------------------------------------------------------------------- */
1963
+ bool Phreeqc::
1964
+ phase_rxn_to_trxn(class phase* phase_ptr, CReaction& rxn_ref)
1965
+ /* ---------------------------------------------------------------------- */
1966
+ {
1967
+ /*
1968
+ * Copy reaction from reaction structure to
1969
+ * temp reaction structure.
1970
+ */
1971
+ int l;
1972
+ const char* cptr;
1973
+ LDBLE l_z;
1974
+ trxn.token.resize(rxn_ref.size());
1975
+ trxn.token[0].name = phase_ptr->formula;
1976
+ /* charge */
1977
+ cptr = phase_ptr->formula;
1978
+ {
1979
+ std::string token;
1980
+ get_token(&cptr, token, &l_z, &l);
1981
+ }
1982
+ trxn.token[0].z = l_z;
1983
+ trxn.token[0].s = NULL;
1984
+ trxn.token[0].unknown = NULL;
1985
+ /*trxn.token[0].coef = -1.0; */
1986
+ /* check for leading coefficient of 1.0 for phase did not work */
1987
+ trxn.token[0].coef = phase_ptr->rxn.token[0].coef;
1988
+ for (size_t i = 1; rxn_ref.token[i].s != NULL; i++)
1989
+ {
1990
+ trxn.token[i].name = rxn_ref.token[i].s->name;
1991
+ trxn.token[i].z = rxn_ref.token[i].s->z;
1992
+ trxn.token[i].s = NULL;
1993
+ trxn.token[i].unknown = NULL;
1994
+ trxn.token[i].coef = rxn_ref.token[i].coef;
1995
+ count_trxn = i + 1;
1996
+ }
1997
+ return (OK);
1998
+ }
1999
+ /* ---------------------------------------------------------------------- */
2000
+ bool Phreeqc::
2001
+ trxn_add(CReaction& r_ref, double coef, bool combine)
2002
+ /* ---------------------------------------------------------------------- */
2003
+ {
2004
+ /*
2005
+ * Adds reactions together.
2006
+ *
2007
+ * Global variable count_trxn determines which position in trxn is used.
2008
+ * If count_trxn=0, then the equation effectively is copied into trxn.
2009
+ * If count_trxn>0, then new equation is added to existing equation.
2010
+ *
2011
+ * Arguments:
2012
+ * *r_ptr points to rxn structure to add.
2013
+ *
2014
+ * coef added equation is multiplied by coef.
2015
+ * combine if TRUE, reaction is reaction is sorted and
2016
+ * like terms combined.
2017
+ */
2018
+ /*
2019
+ * Accumulate log k for reaction
2020
+ */
2021
+ if (count_trxn == 0)
2022
+ {
2023
+ for (int i = 0; i < MAX_LOG_K_INDICES; i++) trxn.logk[i] = r_ref.Get_logk()[i];
2024
+ for (int i = 0; i < 3; i++) trxn.dz[i] = r_ref.Get_dz()[i];
2025
+ }
2026
+ else
2027
+ {
2028
+ for (int i = 0; i < MAX_LOG_K_INDICES; i++) trxn.logk[i] += coef * r_ref.Get_logk()[i];
2029
+ for (int i = 0; i < 3; i++) trxn.dz[i] += coef * r_ref.Get_dz()[i];
2030
+ }
2031
+ /*
2032
+ * Copy equation into work space
2033
+ */
2034
+ class rxn_token* next_token = &r_ref.token[0];
2035
+ while (next_token->s != NULL)
2036
+ {
2037
+ if (count_trxn + 1 > trxn.token.size())
2038
+ trxn.token.resize(count_trxn + 1);
2039
+ trxn.token[count_trxn].name = next_token->s->name;
2040
+ trxn.token[count_trxn].s = next_token->s;
2041
+ trxn.token[count_trxn].coef = coef * next_token->coef;
2042
+ count_trxn++;
2043
+ next_token++;
2044
+ }
2045
+ if (combine == TRUE)
2046
+ trxn_combine();
2047
+ return (OK);
2048
+ }
2049
+ /* ---------------------------------------------------------------------- */
2050
+ bool Phreeqc::
2051
+ trxn_add_phase(CReaction& r_ref, double coef, bool combine)
2052
+ /* ---------------------------------------------------------------------- */
2053
+ {
2054
+ /*
2055
+ * Adds reactions together.
2056
+ *
2057
+ * Global variable count_trxn determines which position in trxn is used.
2058
+ * If count_trxn=0, then the equation effectively is copied into trxn.
2059
+ * If count_trxn>0, then new equation is added to existing equation.
2060
+ *
2061
+ * Arguments:
2062
+ * *r_ptr points to rxn structure to add.
2063
+ *
2064
+ * coef added equation is multiplied by coef.
2065
+ * combine if TRUE, reaction is reaction is sorted and
2066
+ * like terms combined.
2067
+ */
2068
+ int i;
2069
+ class rxn_token* next_token;
2070
+ /*
2071
+ * Accumulate log k for reaction
2072
+ */
2073
+ if (count_trxn == 0)
2074
+ {
2075
+ memcpy((void*)trxn.logk, (void*)r_ref.Get_logk(),
2076
+ (size_t)MAX_LOG_K_INDICES * sizeof(double));
2077
+ }
2078
+ else
2079
+ {
2080
+ for (i = 0; i < MAX_LOG_K_INDICES; i++) trxn.logk[i] += coef * r_ref.Get_logk()[i];
2081
+ }
2082
+ /*
2083
+ * Copy equation into work space
2084
+ */
2085
+ next_token = &r_ref.token[0];
2086
+ while (next_token->s != NULL || next_token->name != NULL)
2087
+ {
2088
+ if (count_trxn + 1 > trxn.token.size())
2089
+ trxn.token.resize(count_trxn + 1);
2090
+ if (next_token->s != NULL)
2091
+ {
2092
+ trxn.token[count_trxn].name = next_token->s->name;
2093
+ trxn.token[count_trxn].s = next_token->s;
2094
+ }
2095
+ else
2096
+ {
2097
+ trxn.token[count_trxn].name = next_token->name;
2098
+ trxn.token[count_trxn].s = NULL;
2099
+ }
2100
+ trxn.token[count_trxn].coef = coef * next_token->coef;
2101
+ count_trxn++;
2102
+ next_token++;
2103
+ }
2104
+ if (combine)
2105
+ trxn_combine();
2106
+ return (OK);
2107
+ }
2108
+
2109
+ /* ---------------------------------------------------------------------- */
2110
+ int Phreeqc::
2111
+ trxn_combine(void)
2112
+ /* ---------------------------------------------------------------------- */
2113
+ {
2114
+ /*
2115
+ * Combines coefficients of tokens that are equal in temporary
2116
+ * reaction structure, trxn.
2117
+ */
2118
+ int j, k;
2119
+ /*
2120
+ * Sort trxn species
2121
+ */
2122
+ trxn_sort();
2123
+ /*
2124
+ * Combine trxn tokens
2125
+ */
2126
+ j = 1;
2127
+ for (k = 2; k < count_trxn; k++)
2128
+ {
2129
+ if (trxn.token[k].s != NULL)
2130
+ {
2131
+ if ((j > 0) && (trxn.token[k].s == trxn.token[j].s))
2132
+ {
2133
+ trxn.token[j].coef += trxn.token[k].coef;
2134
+ if (equal(trxn.token[j].coef, 0.0, 1e-5))
2135
+ j--;
2136
+ }
2137
+ else
2138
+ {
2139
+ j++;
2140
+ if (k != j)
2141
+ {
2142
+ trxn.token[j].name = trxn.token[k].name;
2143
+ trxn.token[j].s = trxn.token[k].s;
2144
+ trxn.token[j].coef = trxn.token[k].coef;
2145
+ }
2146
+ }
2147
+ }
2148
+ else
2149
+ {
2150
+ if ((j > 0) && (trxn.token[k].s == trxn.token[j].s)
2151
+ && (trxn.token[k].name == trxn.token[j].name))
2152
+ {
2153
+ trxn.token[j].coef += trxn.token[k].coef;
2154
+ if (equal(trxn.token[j].coef, 0.0, 1e-5))
2155
+ j--;
2156
+ }
2157
+ else
2158
+ {
2159
+ j++;
2160
+ if (k != j)
2161
+ {
2162
+ trxn.token[j].name = trxn.token[k].name;
2163
+ trxn.token[j].s = trxn.token[k].s;
2164
+ trxn.token[j].coef = trxn.token[k].coef;
2165
+ }
2166
+ }
2167
+ }
2168
+ }
2169
+ count_trxn = j + 1; /* number excluding final NULL */
2170
+ return (OK);
2171
+ }
2172
+ /* ---------------------------------------------------------------------- */
2173
+ int Phreeqc::
2174
+ trxn_compare(const void* ptr1, const void* ptr2)
2175
+ /* ---------------------------------------------------------------------- */
2176
+ {
2177
+ const class rxn_token_temp* rxn_token_temp_ptr1, * rxn_token_temp_ptr2;
2178
+ rxn_token_temp_ptr1 = (const class rxn_token_temp*)ptr1;
2179
+ rxn_token_temp_ptr2 = (const class rxn_token_temp*)ptr2;
2180
+ return (strcmp(rxn_token_temp_ptr1->name, rxn_token_temp_ptr2->name));
2181
+ }
2182
+ /* ---------------------------------------------------------------------- */
2183
+ bool Phreeqc::
2184
+ trxn_copy(CReaction& rxn_ref)
2185
+ /* ---------------------------------------------------------------------- */
2186
+ {
2187
+ /*
2188
+ * Copies trxn to a reaction structure.
2189
+ *
2190
+ * Input: rxn_ptr, pointer to reaction structure to copy trxn to.
2191
+ *
2192
+ */
2193
+ int i;
2194
+ /*
2195
+ * Copy logk data
2196
+ */
2197
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
2198
+ {
2199
+ rxn_ref.logk[i] = trxn.logk[i];
2200
+ }
2201
+ /*
2202
+ * Copy dz data
2203
+ */
2204
+ for (i = 0; i < 3; i++)
2205
+ {
2206
+ rxn_ref.dz[i] = trxn.dz[i];
2207
+ }
2208
+ /*
2209
+ * Copy tokens
2210
+ */
2211
+ rxn_ref.Get_tokens().resize(count_trxn + 1);
2212
+ for (size_t i = 0; i < count_trxn; i++)
2213
+ {
2214
+ rxn_ref.Get_tokens()[i].s = trxn.token[i].s;
2215
+ rxn_ref.Get_tokens()[i].name = trxn.token[i].name;
2216
+ rxn_ref.Get_tokens()[i].coef = trxn.token[i].coef;
2217
+ }
2218
+ rxn_ref.token[count_trxn].s = NULL;
2219
+ rxn_ref.token[count_trxn].name = NULL;
2220
+ return (OK);
2221
+ }
2222
+ /* ---------------------------------------------------------------------- */
2223
+ LDBLE Phreeqc::
2224
+ trxn_find_coef(const char *str, int start)
2225
+ /* ---------------------------------------------------------------------- */
2226
+ {
2227
+ /*
2228
+ * Finds coefficient of specified token in trxn.
2229
+ * Input: str, token name in reaction.
2230
+ *
2231
+ * Return: 0.0, if token not found.
2232
+ * coefficient of token, if token found.
2233
+ */
2234
+ int i;
2235
+ LDBLE coef;
2236
+
2237
+ coef = 0.0;
2238
+ for (i = start; i < count_trxn; i++)
2239
+ {
2240
+ if (strcmp(trxn.token[i].s->name, str) == 0)
2241
+ {
2242
+ coef = trxn.token[i].coef;
2243
+ break;
2244
+ }
2245
+ }
2246
+ return (coef);
2247
+ }
2248
+
2249
+ /* ---------------------------------------------------------------------- */
2250
+ int Phreeqc::
2251
+ trxn_multiply(LDBLE coef)
2252
+ /* ---------------------------------------------------------------------- */
2253
+ {
2254
+ /*
2255
+ * Multiplies temporary reaction, trxn, by a constant
2256
+ *
2257
+ * Arguments:
2258
+ * input: coef multiplier.
2259
+ */
2260
+ int i;
2261
+ /*
2262
+ * Multiply log k for reaction
2263
+ */
2264
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
2265
+ {
2266
+ trxn.logk[i] *= coef;
2267
+ }
2268
+ /*
2269
+ * Multiply dz for reaction
2270
+ */
2271
+ for (i = 0; i < 3; i++)
2272
+ {
2273
+ trxn.dz[i] *= coef;
2274
+ }
2275
+ /*
2276
+ * Multiply coefficients of reaction
2277
+ */
2278
+ for (i = 0; i < count_trxn; i++)
2279
+ {
2280
+ trxn.token[i].coef *= coef;
2281
+ }
2282
+ return (OK);
2283
+ }
2284
+
2285
+ /* ---------------------------------------------------------------------- */
2286
+ int Phreeqc::
2287
+ trxn_print(void)
2288
+ /* ---------------------------------------------------------------------- */
2289
+ {
2290
+ /*
2291
+ * Prints trxn
2292
+ */
2293
+ int i;
2294
+ /*
2295
+ * Print log k for reaction
2296
+ */
2297
+
2298
+ output_msg(sformatf( "\tlog k data:\n"));
2299
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
2300
+ {
2301
+ output_msg(sformatf( "\t\t%f\n", (double) trxn.logk[i]));
2302
+ }
2303
+
2304
+ /*
2305
+ * Print dz for reaction
2306
+ */
2307
+ output_msg(sformatf( "\tdz data:\n"));
2308
+ for (i = 0; i < 3; i++)
2309
+ {
2310
+ output_msg(sformatf( "\t\t%f\n", (double) trxn.dz[i]));
2311
+ }
2312
+ /*
2313
+ * Print stoichiometry
2314
+ */
2315
+ output_msg(sformatf( "\tReaction stoichiometry\n"));
2316
+ for (i = 0; i < count_trxn; i++)
2317
+ {
2318
+ output_msg(sformatf( "\t\t%-20s\t%10.2f\n", trxn.token[i].name,
2319
+ (double) trxn.token[i].coef));
2320
+ }
2321
+ output_msg(sformatf( "\n"));
2322
+ return (OK);
2323
+ }
2324
+
2325
+ /* ---------------------------------------------------------------------- */
2326
+ int Phreeqc::
2327
+ trxn_reverse_k(void)
2328
+ /* ---------------------------------------------------------------------- */
2329
+ {
2330
+ /*
2331
+ * Changes K from dissociation to association and back
2332
+ */
2333
+ int i;
2334
+ /*
2335
+ * Accumulate log k for reaction
2336
+ */
2337
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
2338
+ {
2339
+ trxn.logk[i] = -trxn.logk[i];
2340
+ }
2341
+ for (i = 0; i < 3; i++)
2342
+ {
2343
+ trxn.dz[i] = -trxn.dz[i];
2344
+ }
2345
+ return (OK);
2346
+ }
2347
+
2348
+ /* ---------------------------------------------------------------------- */
2349
+ int Phreeqc::
2350
+ trxn_sort(void)
2351
+ /* ---------------------------------------------------------------------- */
2352
+ {
2353
+ /*
2354
+ * Compare names in tokens in trxn array for sorting
2355
+ */
2356
+ if (count_trxn - 1 > 1)
2357
+ {
2358
+ qsort(&trxn.token[1],
2359
+ (size_t)count_trxn - 1,
2360
+ sizeof(class rxn_token_temp),
2361
+ trxn_compare);
2362
+ }
2363
+ return (OK);
2364
+ }
2365
+
2366
+ /* ---------------------------------------------------------------------- */
2367
+ int Phreeqc::
2368
+ trxn_swap(const char *token)
2369
+ /* ---------------------------------------------------------------------- */
2370
+ {
2371
+ /*
2372
+ * Moves specified token to initial position in reaction.
2373
+ * Input: token, token name to move to initial position.
2374
+ *
2375
+ * Return: ERROR, if token not found.
2376
+ * OK, if token moved to initial position.
2377
+ */
2378
+ int i, j;
2379
+ LDBLE coef;
2380
+ /*
2381
+ * Locate token
2382
+ */
2383
+ for (j = 0; j < count_trxn; j++)
2384
+ {
2385
+ if (strcmp(trxn.token[j].s->name, token) == 0)
2386
+ break;
2387
+ }
2388
+ if (j >= count_trxn)
2389
+ {
2390
+ input_error++;
2391
+ error_string = sformatf( "Could not find token in equation, %s.", token);
2392
+ error_msg(error_string, CONTINUE);
2393
+ for (i = 0; i < count_trxn; i++)
2394
+ {
2395
+ output_msg(sformatf( "%f\t%s\t",
2396
+ (double) trxn.token[i].coef, trxn.token[i].name));
2397
+ }
2398
+ output_msg(sformatf( "\n"));
2399
+ return (ERROR);
2400
+ }
2401
+ /*
2402
+ * Swap token to first position
2403
+ */
2404
+ trxn.token[count_trxn].name = trxn.token[0].name;
2405
+ trxn.token[count_trxn].s = trxn.token[0].s;
2406
+ trxn.token[count_trxn].coef = trxn.token[0].coef;
2407
+
2408
+ trxn.token[0].name = trxn.token[j].name;
2409
+ trxn.token[0].s = trxn.token[j].s;
2410
+ trxn.token[0].coef = trxn.token[j].coef;
2411
+
2412
+ trxn.token[j].name = trxn.token[count_trxn].name;
2413
+ trxn.token[j].s = trxn.token[count_trxn].s;
2414
+ trxn.token[j].coef = trxn.token[count_trxn].coef;
2415
+ /*
2416
+ * Make coefficient of token -1.0
2417
+ */
2418
+ coef = -1.0 / trxn.token[0].coef;
2419
+ trxn_multiply(coef);
2420
+ return (OK);
2421
+ }
2422
+
2423
+ /* **********************************************************************
2424
+ *
2425
+ * Routines related to structure "unknown"
2426
+ *
2427
+ * ********************************************************************** */
2428
+ /* ---------------------------------------------------------------------- */
2429
+ class unknown * Phreeqc::
2430
+ unknown_alloc(void)
2431
+ /* ---------------------------------------------------------------------- */
2432
+ {
2433
+ /*
2434
+ * Allocates space to an "unknown" structure
2435
+ * arguments: void
2436
+ * return: pointer to an "unknown" structure
2437
+ */
2438
+ class unknown *unknown_ptr;
2439
+ /*
2440
+ * Allocate space
2441
+ */
2442
+ unknown_ptr = new class unknown;
2443
+ /*
2444
+ * set pointers in structure to NULL
2445
+ */
2446
+ unknown_ptr->type = 0;
2447
+ unknown_ptr->moles = 0.0;
2448
+ unknown_ptr->ln_moles = 0.0;
2449
+ unknown_ptr->f = 0.0;
2450
+ unknown_ptr->sum = 0.0;
2451
+ unknown_ptr->delta = 0.0;
2452
+ unknown_ptr->la = 0.0;
2453
+ unknown_ptr->number = 0;
2454
+ unknown_ptr->description = NULL;
2455
+ unknown_ptr->phase = NULL;
2456
+ unknown_ptr->si = 0.0;
2457
+ unknown_ptr->s = NULL;
2458
+ unknown_ptr->exch_comp = NULL;
2459
+ unknown_ptr->pp_assemblage_comp_name = NULL;
2460
+ unknown_ptr->pp_assemblage_comp_ptr = NULL;
2461
+ unknown_ptr->ss_name = NULL;
2462
+ unknown_ptr->ss_ptr = NULL;
2463
+ unknown_ptr->ss_comp_name = NULL;
2464
+ unknown_ptr->ss_comp_ptr = NULL;
2465
+ unknown_ptr->ss_comp_number = 0;
2466
+ unknown_ptr->ss_in = FALSE;
2467
+ unknown_ptr->surface_comp = NULL;
2468
+ unknown_ptr->related_moles = 0.0;
2469
+ unknown_ptr->potential_unknown = NULL;
2470
+ unknown_ptr->potential_unknown1 = NULL;
2471
+ unknown_ptr->potential_unknown2 = NULL;
2472
+ unknown_ptr->phase_unknown = NULL;
2473
+ unknown_ptr->surface_charge = NULL;
2474
+ unknown_ptr->mass_water = 0.0;
2475
+ unknown_ptr->dissolve_only = FALSE;
2476
+ unknown_ptr->inert_moles = 0.0;
2477
+ unknown_ptr->V_m = 0.0;
2478
+ unknown_ptr->pressure = 0.0;
2479
+ unknown_ptr->mb_number = 0;
2480
+ unknown_ptr->iteration = 0;
2481
+
2482
+ return (unknown_ptr);
2483
+ }
2484
+
2485
+ /* ---------------------------------------------------------------------- */
2486
+ int Phreeqc::
2487
+ unknown_delete(int i)
2488
+ /* ---------------------------------------------------------------------- */
2489
+ {
2490
+ /*
2491
+ * Delete unknown from list x
2492
+ */
2493
+ unknown_free(x[i]);
2494
+ x.erase(x.begin() + (size_t)i);
2495
+ count_unknowns--;
2496
+ return (OK);
2497
+ }
2498
+
2499
+ /* ---------------------------------------------------------------------- */
2500
+ int Phreeqc::
2501
+ unknown_free(class unknown *unknown_ptr)
2502
+ /* ---------------------------------------------------------------------- */
2503
+ {
2504
+ /*
2505
+ * Frees space allocated to an unknown structure, frees unknown_ptr.
2506
+ */
2507
+ if (unknown_ptr == NULL)
2508
+ return (ERROR);
2509
+ unknown_ptr->master.clear();
2510
+ if (unknown_ptr->type == SURFACE_CB)
2511
+ {
2512
+ /*
2513
+ surface_charge_free(unknown_ptr->surface_charge);
2514
+ unknown_ptr->surface_charge = (struct surface_charge *) free_check_null(unknown_ptr->surface_charge);
2515
+ */
2516
+ }
2517
+ unknown_ptr->comp_unknowns.clear();
2518
+ delete unknown_ptr;
2519
+ return (OK);
2520
+ }
2521
+
2522
+ /* ---------------------------------------------------------------------- */
2523
+ int Phreeqc::
2524
+ system_duplicate(int i, int save_old)
2525
+ /* ---------------------------------------------------------------------- */
2526
+ {
2527
+ Utilities::Rxn_copy(Rxn_solution_map, i, save_old);
2528
+
2529
+ Utilities::Rxn_copy(Rxn_pp_assemblage_map, i, save_old);
2530
+
2531
+ Utilities::Rxn_copy(Rxn_exchange_map, i, save_old);
2532
+
2533
+ Utilities::Rxn_copy(Rxn_surface_map, i, save_old);
2534
+
2535
+ Utilities::Rxn_copy(Rxn_gas_phase_map, i, save_old);
2536
+
2537
+ Utilities::Rxn_copy(Rxn_kinetics_map, i, save_old);
2538
+
2539
+ Utilities::Rxn_copy(Rxn_ss_assemblage_map, i, save_old);
2540
+
2541
+ return (OK);
2542
+ }
2543
+
2544
+ /* ---------------------------------------------------------------------- */
2545
+ class logk * Phreeqc::
2546
+ logk_store(const char *name_in, int replace_if_found)
2547
+ /* ---------------------------------------------------------------------- */
2548
+ {
2549
+ /*
2550
+ * Function locates the string "name" in the map for logk.
2551
+ *
2552
+ * Pointer to a logk structure is always returned.
2553
+ *
2554
+ * If the string is not found, a new entry is made in the map. Pointer to
2555
+ * the new structure is returned.
2556
+ * If "name" is found and replace is true, pointers in old logk structure
2557
+ * are freed and replaced with additional input.
2558
+ * If "name" is found and replace is false, the old logk structure is not
2559
+ * modified and a pointer to it is returned.
2560
+ *
2561
+ * Arguments:
2562
+ * name input, character string to be found in "logk".
2563
+ * replace_if_found input, TRUE means reinitialize logk structure if found
2564
+ * FALSE means just return pointer if found.
2565
+ *
2566
+ * Returns:
2567
+ * pointer to logk structure "logk" where "name" can be found.
2568
+ */
2569
+ /*
2570
+ * Search list
2571
+ */
2572
+ class logk* logk_ptr = NULL;
2573
+ std::string name = name_in;
2574
+ str_tolower(name);
2575
+ std::map<std::string, class logk*>::iterator it =
2576
+ logk_map.find(name);
2577
+
2578
+ if (it != logk_map.end() && replace_if_found == FALSE)
2579
+ {
2580
+ logk_ptr = it->second;
2581
+ return (logk_ptr);
2582
+ }
2583
+ else if (it != logk_map.end() && replace_if_found == TRUE)
2584
+ {
2585
+ logk_ptr = it->second;
2586
+ logk_init(logk_ptr);
2587
+ }
2588
+ else
2589
+ {
2590
+ /* Make new logk structure */
2591
+ size_t n = logk.size();
2592
+ logk.resize(n + 1);
2593
+ logk[n] = logk_alloc();
2594
+ logk_ptr = logk[n];
2595
+ }
2596
+ /* set name and z in pointer in logk structure */
2597
+ logk_ptr->name = string_hsave(name_in);
2598
+ /*
2599
+ * Update map
2600
+ */
2601
+ logk_map[name] = logk_ptr;
2602
+ return (logk_ptr);
2603
+ }
2604
+
2605
+ /* ---------------------------------------------------------------------- */
2606
+ class logk * Phreeqc::
2607
+ logk_alloc(void)
2608
+ /* ---------------------------------------------------------------------- */
2609
+ /*
2610
+ * Allocates space to a logk structure, initializes
2611
+ * arguments: void
2612
+ * return: pointer to a logk structure
2613
+ */
2614
+ {
2615
+ class logk *logk_ptr;
2616
+ logk_ptr = new class logk;
2617
+ /*
2618
+ * set pointers in structure to NULL, variables to zero
2619
+ */
2620
+ logk_init(logk_ptr);
2621
+
2622
+ return (logk_ptr);
2623
+ }
2624
+
2625
+ /* ---------------------------------------------------------------------- */
2626
+ int Phreeqc::
2627
+ logk_init(class logk *logk_ptr)
2628
+ /* ---------------------------------------------------------------------- */
2629
+ /*
2630
+ * return: pointer to a logk structure
2631
+ */
2632
+ {
2633
+ int i;
2634
+ /*
2635
+ * set pointers in structure to NULL
2636
+ */
2637
+ logk_ptr->name = NULL;
2638
+ /*
2639
+ * set variables = 0
2640
+ */
2641
+ logk_ptr->lk = 0.0;
2642
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
2643
+ {
2644
+ logk_ptr->log_k[i] = 0.0;
2645
+ logk_ptr->log_k_original[i] = 0.0;
2646
+ }
2647
+ logk_ptr->add_logk.clear();
2648
+ return (OK);
2649
+ }
2650
+
2651
+ /* ---------------------------------------------------------------------- */
2652
+ int Phreeqc::
2653
+ logk_copy2orig(class logk *logk_ptr)
2654
+ /* ---------------------------------------------------------------------- */
2655
+ /*
2656
+ * Copies log k data to logk_original
2657
+ */
2658
+ {
2659
+ int i;
2660
+ for (i = 0; i < MAX_LOG_K_INDICES; i++)
2661
+ {
2662
+ logk_ptr->log_k_original[i] = logk_ptr->log_k[i];
2663
+ }
2664
+ return (OK);
2665
+ }
2666
+
2667
+ /* ---------------------------------------------------------------------- */
2668
+ class logk * Phreeqc::
2669
+ logk_search(const char *name_in)
2670
+ /* ---------------------------------------------------------------------- */
2671
+ {
2672
+ /*
2673
+ * Function locates the string "name" in the map for logk.
2674
+ *
2675
+ * Arguments:
2676
+ * name input, character string to be found in "logk".
2677
+ *
2678
+ * Returns:
2679
+ * pointer to logk structure "logk" where "name" can be found.
2680
+ * or NULL if not found.
2681
+ */
2682
+ class logk *logk_ptr;
2683
+ /*
2684
+ * Search list
2685
+ */
2686
+ std::string name = name_in;
2687
+ str_tolower(name);
2688
+ std::map<std::string, class logk*>::iterator l_it =
2689
+ logk_map.find(name);
2690
+ if (l_it != logk_map.end())
2691
+ {
2692
+ logk_ptr = l_it->second;
2693
+ return (logk_ptr);
2694
+ }
2695
+ return (NULL);
2696
+ }
2697
+
2698
+ /* ---------------------------------------------------------------------- */
2699
+ int Phreeqc::
2700
+ entity_exists(const char *name, int n_user)
2701
+ /* ---------------------------------------------------------------------- */
2702
+ {
2703
+ /*
2704
+ * Reads solution, 0 Solution
2705
+ * reaction, 1 Reaction
2706
+ * exchange, 2 Exchange
2707
+ * surface, 3 Surface
2708
+ * gas_phase, 4 Gas_phase
2709
+ * equilibrium_phases, 5 Pure_phase
2710
+ * solid_solution, 6 Ss_phase
2711
+ * kinetics, 7 Kinetics
2712
+ * mix, 8 Mix
2713
+ * reaction_temperature 9 Temperature
2714
+ * unknown 10 UnKnown
2715
+ */
2716
+ int return_value;
2717
+ char token[MAX_LENGTH];
2718
+ enum entity_type type;
2719
+ /*
2720
+ * Read keyword
2721
+ */
2722
+ strncpy(token, name, MAX_LENGTH-1);
2723
+ token[MAX_LENGTH-1] = '\0';
2724
+ type = get_entity_enum(token);
2725
+ return_value = TRUE;
2726
+ switch (type)
2727
+ {
2728
+ case UnKnown:
2729
+ warning_msg
2730
+ ("EXISTS expecting keyword solution, mix, kinetics, reaction, reaction_temperature, equilibrium_phases, exchange, surface, gas_phase, or solid_solutions.");
2731
+ return_value = 2;
2732
+ break;
2733
+ case Solution: /* Solution */
2734
+ if (Utilities::Rxn_find(Rxn_solution_map, n_user) == NULL)
2735
+ {
2736
+ return_value = FALSE;
2737
+ }
2738
+ break;
2739
+ case Pure_phase: /* Pure phases */
2740
+ if (Utilities::Rxn_find(Rxn_pp_assemblage_map, n_user) == NULL)
2741
+ {
2742
+ return_value = FALSE;
2743
+ }
2744
+ break;
2745
+ case Reaction: /* Reaction */
2746
+ if (Utilities::Rxn_find(Rxn_reaction_map, n_user) == NULL)
2747
+ {
2748
+ return_value = FALSE;
2749
+ }
2750
+ break;
2751
+ case Mix: /* Mix */
2752
+ if (Utilities::Rxn_find(Rxn_mix_map, n_user) == NULL)
2753
+ {
2754
+ return_value = FALSE;
2755
+ }
2756
+ break;
2757
+ case Exchange: /* Ex */
2758
+ if (Utilities::Rxn_find(Rxn_exchange_map, n_user) == NULL)
2759
+ {
2760
+ return_value = FALSE;
2761
+ }
2762
+ break;
2763
+ case Surface: /* Surface */
2764
+ if (Utilities::Rxn_find(Rxn_surface_map, n_user) == NULL)
2765
+ {
2766
+ return_value = FALSE;
2767
+ }
2768
+ break;
2769
+ case Temperature:
2770
+ if (Utilities::Rxn_find(Rxn_temperature_map, n_user) == NULL)
2771
+ {
2772
+ return_value = FALSE;
2773
+ }
2774
+ case Pressure:
2775
+ if (Utilities::Rxn_find(Rxn_pressure_map, n_user) == NULL)
2776
+ {
2777
+ return_value = FALSE;
2778
+ }
2779
+ case Gas_phase: /* Gas */
2780
+ if (Utilities::Rxn_find(Rxn_gas_phase_map, n_user) == NULL)
2781
+ {
2782
+ return_value = FALSE;
2783
+ }
2784
+ break;
2785
+ case Kinetics: /* Kinetics */
2786
+ if (Utilities::Rxn_find(Rxn_kinetics_map, n_user) == NULL)
2787
+ {
2788
+ return_value = FALSE;
2789
+ }
2790
+ break;
2791
+ case Ss_phase: /* solid_solutions */
2792
+ if (Utilities::Rxn_find(Rxn_ss_assemblage_map, n_user) == NULL)
2793
+ {
2794
+ return_value = FALSE;
2795
+ }
2796
+ break;
2797
+ }
2798
+ return (return_value);
2799
+ }
2800
+
2801
+ /* ---------------------------------------------------------------------- */
2802
+ enum entity_type Phreeqc::
2803
+ get_entity_enum(char *name)
2804
+ /* ---------------------------------------------------------------------- */
2805
+ {
2806
+ /*
2807
+ * Reads solution, 0 Solution
2808
+ * reaction, 1 Reaction
2809
+ * exchange, 2 Exchange
2810
+ * surface, 3 Surface
2811
+ * gas_phase, 4 Gas_phase
2812
+ * equilibrium_phases, 5 Pure_phase
2813
+ * solid_solution, 6 Ss_phase
2814
+ * kinetics, 7 Kinetics
2815
+ * mix, 8 Mix
2816
+ * reaction_temperature 9 Temperature
2817
+ * reaction_pressure
2818
+ * unknown 10 UnKnown
2819
+ *
2820
+ */
2821
+ int i;
2822
+ const char* cptr;
2823
+ char token[MAX_LENGTH];
2824
+ /*
2825
+ * Read keyword
2826
+ */
2827
+ cptr = name;
2828
+ copy_token(token, &cptr, &i);
2829
+ check_key(token);
2830
+
2831
+ switch (next_keyword)
2832
+ {
2833
+ case Keywords::KEY_SOLUTION: /* Solution */
2834
+ return (Solution);
2835
+ break;
2836
+ case Keywords::KEY_EQUILIBRIUM_PHASES: /* Pure phases */
2837
+ return (Pure_phase);
2838
+ break;
2839
+ case Keywords::KEY_REACTION: /* Reaction */
2840
+ return (Reaction);
2841
+ break;
2842
+ case Keywords::KEY_MIX: /* Mix */
2843
+ return (Mix);
2844
+ break;
2845
+ case Keywords::KEY_EXCHANGE: /* Ex */
2846
+ return (Exchange);
2847
+ break;
2848
+ case Keywords::KEY_SURFACE: /* Surface */
2849
+ return (Surface);
2850
+ break;
2851
+ case Keywords::KEY_REACTION_TEMPERATURE: /* Temperature */
2852
+ return (Temperature);
2853
+ break;
2854
+ case Keywords::KEY_REACTION_PRESSURE: /* Pressure */
2855
+ return (Pressure);
2856
+ break;
2857
+ case Keywords::KEY_GAS_PHASE: /* Gas */
2858
+ return (Gas_phase);
2859
+ break;
2860
+ case Keywords::KEY_KINETICS: /* Kinetics */
2861
+ return (Kinetics);
2862
+ break;
2863
+ case Keywords::KEY_SOLID_SOLUTIONS: /* solid_solutions */
2864
+ return (Ss_phase);
2865
+ break;
2866
+ default:
2867
+ warning_msg
2868
+ ("EXISTS expecting keyword solution, mix, kinetics, reaction, reaction_temperature, equilibrium_phases, exchange, surface, gas_phase, or solid_solutions.");
2869
+ break;
2870
+ }
2871
+ return (UnKnown);
2872
+ }
2873
+
2874
+ /*
2875
+ * copier routines
2876
+ */
2877
+ /* ---------------------------------------------------------------------- */
2878
+ int Phreeqc::
2879
+ copier_add(class copier *copier_ptr, int n_user, int start, int end)
2880
+ /* ---------------------------------------------------------------------- */
2881
+ /*
2882
+ * add new set of copy instructions
2883
+ */
2884
+ {
2885
+ copier_ptr->n_user.push_back(n_user);
2886
+ copier_ptr->start.push_back(start);
2887
+ copier_ptr->end.push_back(end);
2888
+ return (OK);
2889
+ }
2890
+ /* ---------------------------------------------------------------------- */
2891
+ int Phreeqc::
2892
+ copier_clear(class copier* copier_ptr)
2893
+ /* ---------------------------------------------------------------------- */
2894
+ /*
2895
+ * clear copier
2896
+ */
2897
+ {
2898
+ copier_ptr->n_user.clear();
2899
+ copier_ptr->start.clear();
2900
+ copier_ptr->end.clear();
2901
+ return (OK);
2902
+ }
2903
+
2904
+ #include "StorageBin.h"
2905
+
2906
+ /* ---------------------------------------------------------------------- */
2907
+ void Phreeqc::
2908
+ Use2cxxStorageBin(cxxStorageBin & sb)
2909
+ /* ---------------------------------------------------------------------- */
2910
+ {
2911
+ //Add everything from use structure to storagebin sb
2912
+
2913
+ sb.Get_system().Set_io(sb.Get_io());
2914
+ if (use.Get_mix_in())
2915
+ {
2916
+ cxxMix *entity = use.Get_mix_ptr();
2917
+ if (entity != NULL)
2918
+ {
2919
+ sb.Set_Mix(use.Get_n_mix_user(), entity);
2920
+ }
2921
+
2922
+ // put mix solutions in sb
2923
+ cxxMix * mix_ptr = use.Get_mix_ptr();
2924
+ std::map<int, LDBLE>::const_iterator cit;
2925
+ for (cit = mix_ptr->Get_mixComps().begin(); cit != mix_ptr->Get_mixComps().end(); cit++)
2926
+ {
2927
+ cxxSolution *entity = Utilities::Rxn_find(Rxn_solution_map, cit->first);
2928
+ if (entity != NULL)
2929
+ {
2930
+ sb.Set_Solution(cit->first, entity);
2931
+ }
2932
+ }
2933
+ }
2934
+ else if (use.Get_solution_in())
2935
+ {
2936
+ cxxSolution *entity = Utilities::Rxn_find(Rxn_solution_map, use.Get_n_solution_user());
2937
+ if (entity != NULL)
2938
+ {
2939
+ sb.Set_Solution(use.Get_n_solution_user(), entity);
2940
+ }
2941
+ }
2942
+ if (use.Get_pp_assemblage_in())
2943
+ {
2944
+ cxxPPassemblage *entity_ptr = Utilities::Rxn_find(Rxn_pp_assemblage_map, use.Get_n_pp_assemblage_user());
2945
+ if (entity_ptr != NULL)
2946
+ {
2947
+ sb.Set_PPassemblage(use.Get_n_pp_assemblage_user(), entity_ptr);
2948
+ }
2949
+ }
2950
+ if (use.Get_exchange_in())
2951
+ {
2952
+ cxxExchange *entity_ptr = Utilities::Rxn_find(Rxn_exchange_map, use.Get_n_exchange_user());
2953
+ if (entity_ptr != NULL)
2954
+ {
2955
+ sb.Set_Exchange(use.Get_n_exchange_user(), entity_ptr);
2956
+ }
2957
+ }
2958
+ if (use.Get_surface_in())
2959
+ {
2960
+ cxxSurface *entity_ptr = Utilities::Rxn_find(Rxn_surface_map, use.Get_n_surface_user());
2961
+ if (entity_ptr != NULL)
2962
+ {
2963
+ sb.Set_Surface(use.Get_n_surface_user(), entity_ptr);
2964
+ }
2965
+ }
2966
+ if (use.Get_gas_phase_in())
2967
+ {
2968
+ cxxGasPhase *entity_ptr = Utilities::Rxn_find(Rxn_gas_phase_map, use.Get_n_gas_phase_user());
2969
+ if (entity_ptr != NULL)
2970
+ {
2971
+ sb.Set_GasPhase(use.Get_n_gas_phase_user(), entity_ptr);
2972
+ }
2973
+ }
2974
+ if (use.Get_ss_assemblage_in())
2975
+ {
2976
+ cxxSSassemblage *entity_ptr = Utilities::Rxn_find(Rxn_ss_assemblage_map, use.Get_n_ss_assemblage_user());
2977
+ if (entity_ptr != NULL)
2978
+ {
2979
+ sb.Set_SSassemblage(use.Get_n_ss_assemblage_user(), entity_ptr);
2980
+ }
2981
+ }
2982
+ if (use.Get_kinetics_in())
2983
+ {
2984
+ cxxKinetics *entity_ptr = Utilities::Rxn_find(Rxn_kinetics_map, use.Get_n_kinetics_user());
2985
+ if (entity_ptr != NULL)
2986
+ {
2987
+ sb.Set_Kinetics(use.Get_n_kinetics_user(), entity_ptr);
2988
+ }
2989
+ }
2990
+ if (use.Get_reaction_in())
2991
+ {
2992
+ cxxReaction *entity = Utilities::Rxn_find(Rxn_reaction_map, use.Get_n_reaction_user());
2993
+ if (entity != NULL)
2994
+ {
2995
+ sb.Set_Reaction(use.Get_n_reaction_user(), entity);
2996
+ }
2997
+ }
2998
+ if (use.Get_temperature_in())
2999
+ {
3000
+ cxxTemperature *entity = Utilities::Rxn_find(Rxn_temperature_map, use.Get_n_temperature_user());
3001
+ if (entity != NULL)
3002
+ {
3003
+ sb.Set_Temperature(use.Get_n_temperature_user(), entity);
3004
+ }
3005
+ }
3006
+ if (use.Get_pressure_in())
3007
+ {
3008
+ cxxPressure *entity = Utilities::Rxn_find(Rxn_pressure_map, use.Get_n_pressure_user());
3009
+ if (entity != NULL)
3010
+ {
3011
+ sb.Set_Pressure(use.Get_n_pressure_user(), entity);
3012
+ }
3013
+ }
3014
+ }
3015
+
3016
+ void Phreeqc::
3017
+ phreeqc2cxxStorageBin(cxxStorageBin & sb)
3018
+ //
3019
+ // Fills StorageBin sb with all reactants from phreeqc instance.
3020
+ // equivalent to old import_phreeqc.
3021
+ //
3022
+ {
3023
+ // Solutions
3024
+ {
3025
+ std::map<int, cxxSolution>::iterator it;
3026
+ for (it = Rxn_solution_map.begin(); it != Rxn_solution_map.end(); it++)
3027
+ {
3028
+ sb.Set_Solution(it->second.Get_n_user(), &(it->second));
3029
+ }
3030
+ }
3031
+ // Exchangers
3032
+ {
3033
+ std::map<int, cxxExchange>::iterator it;
3034
+ for (it = Rxn_exchange_map.begin(); it != Rxn_exchange_map.end(); it++)
3035
+ {
3036
+ sb.Set_Exchange(it->second.Get_n_user(), &(it->second));
3037
+ }
3038
+ }
3039
+ // GasPhases
3040
+ {
3041
+ std::map<int, cxxGasPhase>::iterator it;
3042
+ for (it = Rxn_gas_phase_map.begin(); it != Rxn_gas_phase_map.end(); it++)
3043
+ {
3044
+ sb.Set_GasPhase(it->second.Get_n_user(), &(it->second));
3045
+ }
3046
+ }
3047
+
3048
+ // Kinetics
3049
+ {
3050
+ std::map<int, cxxKinetics>::iterator it;
3051
+ for (it = Rxn_kinetics_map.begin(); it != Rxn_kinetics_map.end(); it++)
3052
+ {
3053
+ sb.Set_Kinetics(it->second.Get_n_user(), &(it->second));
3054
+ }
3055
+ }
3056
+ // PPassemblages
3057
+ {
3058
+ std::map<int, cxxPPassemblage>::iterator it;
3059
+ for (it = Rxn_pp_assemblage_map.begin(); it != Rxn_pp_assemblage_map.end(); it++)
3060
+ {
3061
+ sb.Set_PPassemblage(it->second.Get_n_user(), &(it->second));
3062
+ }
3063
+ }
3064
+ // SSassemblages
3065
+ {
3066
+ std::map<int, cxxSSassemblage>::iterator it;
3067
+ for (it = Rxn_ss_assemblage_map.begin(); it != Rxn_ss_assemblage_map.end(); it++)
3068
+ {
3069
+ sb.Set_SSassemblage(it->second.Get_n_user(), &(it->second));
3070
+ }
3071
+ }
3072
+ // Surfaces
3073
+ {
3074
+ std::map<int, cxxSurface>::iterator it;
3075
+ for (it = Rxn_surface_map.begin(); it != Rxn_surface_map.end(); it++)
3076
+ {
3077
+ sb.Set_Surface(it->second.Get_n_user(), &(it->second));
3078
+ }
3079
+ }
3080
+ // Mixes
3081
+ {
3082
+ std::map<int, cxxMix>::iterator it;
3083
+ for (it = Rxn_mix_map.begin(); it != Rxn_mix_map.end(); it++)
3084
+ {
3085
+ sb.Set_Mix(it->second.Get_n_user(), &(it->second));
3086
+ }
3087
+ }
3088
+
3089
+ // Reactions
3090
+ {
3091
+ std::map<int, cxxReaction>::iterator it;
3092
+ for (it = Rxn_reaction_map.begin(); it != Rxn_reaction_map.end(); it++)
3093
+ {
3094
+ sb.Set_Reaction(it->second.Get_n_user(), &(it->second));
3095
+ }
3096
+ }
3097
+
3098
+ // Temperatures
3099
+ {
3100
+ std::map<int, cxxTemperature>::iterator it;
3101
+ for (it = Rxn_temperature_map.begin(); it != Rxn_temperature_map.end(); it++)
3102
+ {
3103
+ sb.Set_Temperature(it->second.Get_n_user(), &(it->second));
3104
+ }
3105
+ }
3106
+
3107
+ // Pressures
3108
+ {
3109
+ std::map<int, cxxPressure>::iterator it;
3110
+ for (it = Rxn_pressure_map.begin(); it != Rxn_pressure_map.end(); it++)
3111
+ {
3112
+ sb.Set_Pressure(it->second.Get_n_user(), &(it->second));
3113
+ }
3114
+ }
3115
+ }
3116
+
3117
+ void Phreeqc::
3118
+ phreeqc2cxxStorageBin(cxxStorageBin & sb, int n)
3119
+ //
3120
+ // copy phreeqc reactants numbered n to StorageBin sb
3121
+ //
3122
+ {
3123
+ // Solutions
3124
+ {
3125
+ cxxSolution *entity_ptr = Utilities::Rxn_find(Rxn_solution_map, n);
3126
+ if (entity_ptr != NULL)
3127
+ {
3128
+ sb.Set_Solution(n, entity_ptr);
3129
+ }
3130
+ }
3131
+ // Exchangers
3132
+ {
3133
+ cxxExchange *entity_ptr = Utilities::Rxn_find(Rxn_exchange_map, n);
3134
+ if (entity_ptr != NULL)
3135
+ {
3136
+ sb.Set_Exchange(n, entity_ptr);
3137
+ }
3138
+ }
3139
+
3140
+ // GasPhases
3141
+ {
3142
+ cxxGasPhase *entity_ptr = Utilities::Rxn_find(Rxn_gas_phase_map, n);
3143
+ if (entity_ptr != NULL)
3144
+ {
3145
+ sb.Set_GasPhase(n, entity_ptr);
3146
+ }
3147
+ }
3148
+
3149
+ // Kinetics
3150
+ {
3151
+ cxxKinetics *entity_ptr = Utilities::Rxn_find(Rxn_kinetics_map, n);
3152
+ if (entity_ptr != NULL)
3153
+ {
3154
+ sb.Set_Kinetics(n, entity_ptr);
3155
+ }
3156
+ }
3157
+ // PPassemblages
3158
+ {
3159
+ cxxPPassemblage *entity_ptr = Utilities::Rxn_find(Rxn_pp_assemblage_map, n);
3160
+ if (entity_ptr != NULL)
3161
+ {
3162
+ sb.Set_PPassemblage(n, entity_ptr);
3163
+ }
3164
+ }
3165
+ // SSassemblages
3166
+ {
3167
+ cxxSSassemblage *entity_ptr = Utilities::Rxn_find(Rxn_ss_assemblage_map, n);
3168
+ if (entity_ptr != NULL)
3169
+ {
3170
+ sb.Set_SSassemblage(n, entity_ptr);
3171
+ }
3172
+ }
3173
+ // Surfaces
3174
+ {
3175
+ cxxSurface *entity_ptr = Utilities::Rxn_find(Rxn_surface_map, n);
3176
+ if (entity_ptr != NULL)
3177
+ {
3178
+ sb.Set_Surface(n, entity_ptr);
3179
+ }
3180
+ }
3181
+ }
3182
+ void Phreeqc::
3183
+ cxxStorageBin2phreeqc(cxxStorageBin & sb, int n)
3184
+ //
3185
+ // copy all reactants from storage bin number n to phreeqc
3186
+ // replaces any existing reactants in phreeqc
3187
+ //
3188
+ {
3189
+ // Solutions
3190
+ {
3191
+ std::map < int, cxxSolution >::const_iterator it = sb.Get_Solutions().find(n);
3192
+ if (it != sb.Get_Solutions().end())
3193
+ {
3194
+ Rxn_solution_map[n] = it->second;
3195
+ }
3196
+ }
3197
+ // Exchangers
3198
+ {
3199
+ std::map < int, cxxExchange >::const_iterator it = sb.Get_Exchangers().find(n);
3200
+ if (it != sb.Get_Exchangers().end())
3201
+ {
3202
+ Rxn_exchange_map[n] = it->second;
3203
+ }
3204
+ }
3205
+
3206
+ // GasPhases
3207
+ {
3208
+ std::map < int, cxxGasPhase >::const_iterator it = sb.Get_GasPhases().find(n);
3209
+ if (it != sb.Get_GasPhases().end())
3210
+ {
3211
+ Rxn_gas_phase_map[n] = it->second;
3212
+ }
3213
+ }
3214
+
3215
+ // Kinetics
3216
+ {
3217
+ std::map < int, cxxKinetics >::const_iterator it = sb.Get_Kinetics().find(n);
3218
+ if (it != sb.Get_Kinetics().end())
3219
+ {
3220
+ Rxn_kinetics_map[n] = it->second;
3221
+ }
3222
+ }
3223
+ // PPassemblages
3224
+ {
3225
+ std::map < int, cxxPPassemblage >::const_iterator it = sb.Get_PPassemblages().find(n);
3226
+ if (it != sb.Get_PPassemblages().end())
3227
+ {
3228
+ Rxn_pp_assemblage_map[n] = it->second;
3229
+ }
3230
+ }
3231
+ // SSassemblages
3232
+ {
3233
+ std::map < int, cxxSSassemblage >::const_iterator it = sb.Get_SSassemblages().find(n);
3234
+ if (it != sb.Get_SSassemblages().end())
3235
+ {
3236
+ Rxn_ss_assemblage_map[n] = it->second;
3237
+ }
3238
+ }
3239
+ // Surfaces
3240
+ {
3241
+ std::map < int, cxxSurface >::const_iterator it = sb.Get_Surfaces().find(n);
3242
+ if (it != sb.Get_Surfaces().end())
3243
+ {
3244
+ Rxn_surface_map[n] = it->second;
3245
+ }
3246
+ }
3247
+ // Mixes
3248
+ {
3249
+ std::map < int, cxxMix >::const_iterator it = sb.Get_Mixes().find(n);
3250
+ if (it != sb.Get_Mixes().end())
3251
+ {
3252
+ Rxn_mix_map[n] = it->second;
3253
+ }
3254
+ }
3255
+
3256
+ // Reactions
3257
+ {
3258
+ std::map < int, cxxReaction >::const_iterator it = sb.Get_Reactions().find(n);
3259
+ if (it != sb.Get_Reactions().end())
3260
+ {
3261
+ Rxn_reaction_map[n] = it->second;
3262
+ }
3263
+ }
3264
+ // Temperatures
3265
+ {
3266
+ std::map < int, cxxTemperature >::const_iterator it = sb.Get_Temperatures().find(n);
3267
+ if (it != sb.Get_Temperatures().end())
3268
+ {
3269
+ Rxn_temperature_map[n] = it->second;
3270
+ }
3271
+ }
3272
+ // Pressures
3273
+ {
3274
+ std::map < int, cxxPressure >::const_iterator it = sb.Get_Pressures().find(n);
3275
+ if (it != sb.Get_Pressures().end())
3276
+ {
3277
+ Rxn_pressure_map[n] = it->second;
3278
+ }
3279
+ }
3280
+ }
3281
+ void Phreeqc::
3282
+ cxxStorageBin2phreeqc(cxxStorageBin & sb)
3283
+ //
3284
+ // copy data from storage bin to phreeqc
3285
+ // replaces any existing reactants in phreeqc
3286
+ //
3287
+ {
3288
+ // Solutions
3289
+ {
3290
+ std::map < int, cxxSolution >::const_iterator it = sb.Get_Solutions().begin();
3291
+ for ( ; it != sb.Get_Solutions().end(); it++)
3292
+ {
3293
+ Rxn_solution_map[it->first] = it->second;
3294
+ }
3295
+ }
3296
+ // Exchangers
3297
+ {
3298
+ std::map < int, cxxExchange >::const_iterator it = sb.Get_Exchangers().begin();
3299
+ for ( ; it != sb.Get_Exchangers().end(); it++)
3300
+ {
3301
+ Rxn_exchange_map[it->first] = it->second;
3302
+ }
3303
+ }
3304
+
3305
+ // GasPhases
3306
+ {
3307
+ std::map < int, cxxGasPhase >::const_iterator it = sb.Get_GasPhases().begin();
3308
+ for ( ; it != sb.Get_GasPhases().end(); it++)
3309
+ {
3310
+ Rxn_gas_phase_map[it->first] = it->second;
3311
+ }
3312
+ }
3313
+
3314
+ // Kinetics
3315
+ {
3316
+ std::map < int, cxxKinetics >::const_iterator it = sb.Get_Kinetics().begin();
3317
+ for ( ; it != sb.Get_Kinetics().end(); it++)
3318
+ {
3319
+ Rxn_kinetics_map[it->first] = it->second;
3320
+ }
3321
+ }
3322
+ // PPassemblages
3323
+ {
3324
+ std::map < int, cxxPPassemblage >::const_iterator it = sb.Get_PPassemblages().begin();
3325
+ for ( ; it != sb.Get_PPassemblages().end(); it++)
3326
+ {
3327
+ Rxn_pp_assemblage_map[it->first] = it->second;
3328
+ }
3329
+ }
3330
+ // SSassemblages
3331
+ {
3332
+ std::map < int, cxxSSassemblage >::const_iterator it = sb.Get_SSassemblages().begin();
3333
+ for ( ; it != sb.Get_SSassemblages().end(); it++)
3334
+ {
3335
+ Rxn_ss_assemblage_map[it->first] = it->second;
3336
+ }
3337
+ }
3338
+ // Surfaces
3339
+ {
3340
+ std::map < int, cxxSurface >::const_iterator it = sb.Get_Surfaces().begin();
3341
+ for ( ; it != sb.Get_Surfaces().end(); it++)
3342
+ {
3343
+ Rxn_surface_map[it->first] = it->second;
3344
+ }
3345
+ }
3346
+ // Mixes
3347
+ {
3348
+ std::map < int, cxxMix >::const_iterator it = sb.Get_Mixes().begin();
3349
+ for ( ; it != sb.Get_Mixes().end(); it++)
3350
+ {
3351
+ Rxn_mix_map[it->first] = it->second;
3352
+ }
3353
+ }
3354
+
3355
+ // Reactions
3356
+ {
3357
+ std::map < int, cxxReaction >::const_iterator it = sb.Get_Reactions().begin();
3358
+ for ( ; it != sb.Get_Reactions().end(); it++)
3359
+ {
3360
+ Rxn_reaction_map[it->first] = it->second;
3361
+ }
3362
+ }
3363
+ // Temperatures
3364
+ {
3365
+ std::map < int, cxxTemperature >::const_iterator it = sb.Get_Temperatures().begin();
3366
+ for ( ; it != sb.Get_Temperatures().end(); it++)
3367
+ {
3368
+ Rxn_temperature_map[it->first] = it->second;
3369
+ }
3370
+ }
3371
+ // Pressures
3372
+ {
3373
+ std::map < int, cxxPressure >::const_iterator it = sb.Get_Pressures().begin();
3374
+ for ( ; it != sb.Get_Pressures().end(); it++)
3375
+ {
3376
+ Rxn_pressure_map[it->first] = it->second;
3377
+ }
3378
+ }
3379
+ }
3380
+
3381
+