gebpy 1.1.3__py3-none-any.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 (254) hide show
  1. gebpy/__init__.py +55 -0
  2. gebpy/__pycache__/__init__.cpython-310.pyc +0 -0
  3. gebpy/adapters/__init__.py +0 -0
  4. gebpy/cli/__init__.py +0 -0
  5. gebpy/core/__init__.py +0 -0
  6. gebpy/core/chemistry/__init__.py +0 -0
  7. gebpy/core/chemistry/common.py +1369 -0
  8. gebpy/core/chemistry/elements.py +317 -0
  9. gebpy/core/chemistry/geochemistry.py +1728 -0
  10. gebpy/core/fluids/__init__.py +0 -0
  11. gebpy/core/io/__init__.py +0 -0
  12. gebpy/core/mathematics/__init__.py +0 -0
  13. gebpy/core/minerals/__init__.py +0 -0
  14. gebpy/core/minerals/carbonates.py +412 -0
  15. gebpy/core/minerals/common.py +555 -0
  16. gebpy/core/minerals/config.py +77 -0
  17. gebpy/core/minerals/cyclosilicates.py +0 -0
  18. gebpy/core/minerals/halides.py +0 -0
  19. gebpy/core/minerals/inosilicates.py +0 -0
  20. gebpy/core/minerals/nesosilicates.py +0 -0
  21. gebpy/core/minerals/organics.py +0 -0
  22. gebpy/core/minerals/oxides.py +589 -0
  23. gebpy/core/minerals/phosphates.py +0 -0
  24. gebpy/core/minerals/phospides.py +0 -0
  25. gebpy/core/minerals/phyllosilicates.py +436 -0
  26. gebpy/core/minerals/sorosilicates.py +0 -0
  27. gebpy/core/minerals/sulfates.py +0 -0
  28. gebpy/core/minerals/sulfides.py +459 -0
  29. gebpy/core/minerals/synthesis.py +201 -0
  30. gebpy/core/minerals/tectosilicates.py +433 -0
  31. gebpy/core/physics/__init__.py +0 -0
  32. gebpy/core/physics/common.py +53 -0
  33. gebpy/core/physics/geophysics.py +351 -0
  34. gebpy/core/rocks/__init__.py +0 -0
  35. gebpy/core/rocks/anisotropic_rocks.py +395 -0
  36. gebpy/core/rocks/common.py +95 -0
  37. gebpy/core/rocks/config.py +77 -0
  38. gebpy/core/rocks/isotropic_rocks.py +395 -0
  39. gebpy/core/rocks/sedimentary.py +385 -0
  40. gebpy/core/subsurface/__init__.py +0 -0
  41. gebpy/data_minerals/__init__.py +0 -0
  42. gebpy/data_minerals/albite.yaml +59 -0
  43. gebpy/data_minerals/anatase.yaml +43 -0
  44. gebpy/data_minerals/ankerite.yaml +47 -0
  45. gebpy/data_minerals/annite.yaml +57 -0
  46. gebpy/data_minerals/anorthite.yaml +59 -0
  47. gebpy/data_minerals/antigorite.yaml +53 -0
  48. gebpy/data_minerals/aragonite.yaml +48 -0
  49. gebpy/data_minerals/argutite.yaml +43 -0
  50. gebpy/data_minerals/arsenolite.yaml +40 -0
  51. gebpy/data_minerals/au3oxide.yaml +46 -0
  52. gebpy/data_minerals/avicennite.yaml +40 -0
  53. gebpy/data_minerals/azurite.yaml +53 -0
  54. gebpy/data_minerals/baddeleyite.yaml +49 -0
  55. gebpy/data_minerals/bismite.yaml +49 -0
  56. gebpy/data_minerals/boehmite.yaml +48 -0
  57. gebpy/data_minerals/brookite.yaml +46 -0
  58. gebpy/data_minerals/brucite.yaml +45 -0
  59. gebpy/data_minerals/bunsenite.yaml +40 -0
  60. gebpy/data_minerals/calcite.yaml +45 -0
  61. gebpy/data_minerals/cassiterite.yaml +43 -0
  62. gebpy/data_minerals/cerussite.yaml +48 -0
  63. gebpy/data_minerals/chamosite.yaml +56 -0
  64. gebpy/data_minerals/chlorite.yaml +75 -0
  65. gebpy/data_minerals/chromite.yaml +42 -0
  66. gebpy/data_minerals/chrysotile.yaml +53 -0
  67. gebpy/data_minerals/claudetite.yaml +49 -0
  68. gebpy/data_minerals/clinochlore.yaml +55 -0
  69. gebpy/data_minerals/cochromite.yaml +42 -0
  70. gebpy/data_minerals/corundum.yaml +43 -0
  71. gebpy/data_minerals/crocoite.yaml +51 -0
  72. gebpy/data_minerals/cuprite.yaml +40 -0
  73. gebpy/data_minerals/cuprospinel.yaml +42 -0
  74. gebpy/data_minerals/diaspore.yaml +48 -0
  75. gebpy/data_minerals/dolomite.yaml +47 -0
  76. gebpy/data_minerals/eastonite.yaml +57 -0
  77. gebpy/data_minerals/eskolaite.yaml +43 -0
  78. gebpy/data_minerals/fechlorite.yaml +61 -0
  79. gebpy/data_minerals/fecolumbite.yaml +48 -0
  80. gebpy/data_minerals/ferberite.yaml +51 -0
  81. gebpy/data_minerals/fetantalite.yaml +48 -0
  82. gebpy/data_minerals/franklinite.yaml +42 -0
  83. gebpy/data_minerals/gahnite.yaml +42 -0
  84. gebpy/data_minerals/galaxite.yaml +42 -0
  85. gebpy/data_minerals/geikielite.yaml +45 -0
  86. gebpy/data_minerals/gibbsite.yaml +51 -0
  87. gebpy/data_minerals/glauconite.yaml +69 -0
  88. gebpy/data_minerals/goethite.yaml +48 -0
  89. gebpy/data_minerals/groutite.yaml +48 -0
  90. gebpy/data_minerals/hematite.yaml +43 -0
  91. gebpy/data_minerals/hercynite.yaml +42 -0
  92. gebpy/data_minerals/huebnerite.yaml +51 -0
  93. gebpy/data_minerals/ikaite.yaml +53 -0
  94. gebpy/data_minerals/illite.yaml +55 -0
  95. gebpy/data_minerals/ilmenite.yaml +45 -0
  96. gebpy/data_minerals/jacobsite.yaml +42 -0
  97. gebpy/data_minerals/kalsilite.yaml +47 -0
  98. gebpy/data_minerals/kaolinite.yaml +59 -0
  99. gebpy/data_minerals/karelianite.yaml +43 -0
  100. gebpy/data_minerals/lime.yaml +40 -0
  101. gebpy/data_minerals/litharge.yaml +43 -0
  102. gebpy/data_minerals/magnesiochromite.yaml +42 -0
  103. gebpy/data_minerals/magnesioferrite.yaml +42 -0
  104. gebpy/data_minerals/magnesite.yaml +45 -0
  105. gebpy/data_minerals/magnetite.yaml +41 -0
  106. gebpy/data_minerals/malachite.yaml +53 -0
  107. gebpy/data_minerals/manganite.yaml +51 -0
  108. gebpy/data_minerals/manganochromite.yaml +42 -0
  109. gebpy/data_minerals/manganosite.yaml +40 -0
  110. gebpy/data_minerals/marialite.yaml +49 -0
  111. gebpy/data_minerals/massicot.yaml +46 -0
  112. gebpy/data_minerals/meionite.yaml +49 -0
  113. gebpy/data_minerals/mgchlorite.yaml +61 -0
  114. gebpy/data_minerals/mgcolumbite.yaml +48 -0
  115. gebpy/data_minerals/mgtantalite.yaml +48 -0
  116. gebpy/data_minerals/microcline.yaml +59 -0
  117. gebpy/data_minerals/minium.yaml +44 -0
  118. gebpy/data_minerals/mnchlorite.yaml +61 -0
  119. gebpy/data_minerals/mncolumbite.yaml +48 -0
  120. gebpy/data_minerals/mntantalite.yaml +48 -0
  121. gebpy/data_minerals/monteponite.yaml +40 -0
  122. gebpy/data_minerals/montmorillonite.yaml +77 -0
  123. gebpy/data_minerals/muscovite.yaml +55 -0
  124. gebpy/data_minerals/nanepheline.yaml +47 -0
  125. gebpy/data_minerals/nichlorite.yaml +61 -0
  126. gebpy/data_minerals/nichromite.yaml +42 -0
  127. gebpy/data_minerals/nimite.yaml +55 -0
  128. gebpy/data_minerals/nontronite.yaml +73 -0
  129. gebpy/data_minerals/orthoclase.yaml +53 -0
  130. gebpy/data_minerals/paratellurite.yaml +43 -0
  131. gebpy/data_minerals/pennantite.yaml +61 -0
  132. gebpy/data_minerals/periclase.yaml +40 -0
  133. gebpy/data_minerals/phlogopite.yaml +57 -0
  134. gebpy/data_minerals/plattnerite.yaml +43 -0
  135. gebpy/data_minerals/powellite.yaml +45 -0
  136. gebpy/data_minerals/pyrite.yaml +40 -0
  137. gebpy/data_minerals/pyrolusite.yaml +43 -0
  138. gebpy/data_minerals/pyrophanite.yaml +45 -0
  139. gebpy/data_minerals/pyrophyllite.yaml +59 -0
  140. gebpy/data_minerals/quartz.yaml +43 -0
  141. gebpy/data_minerals/rhodochrosite.yaml +45 -0
  142. gebpy/data_minerals/rutile.yaml +43 -0
  143. gebpy/data_minerals/saponite.yaml +77 -0
  144. gebpy/data_minerals/scheelite.yaml +45 -0
  145. gebpy/data_minerals/scrutinyite.yaml +46 -0
  146. gebpy/data_minerals/senarmontite.yaml +40 -0
  147. gebpy/data_minerals/siderite.yaml +45 -0
  148. gebpy/data_minerals/siderophyllite.yaml +57 -0
  149. gebpy/data_minerals/smithsonite.yaml +45 -0
  150. gebpy/data_minerals/spinel.yaml +42 -0
  151. gebpy/data_minerals/stishovite.yaml +43 -0
  152. gebpy/data_minerals/stolzite.yaml +45 -0
  153. gebpy/data_minerals/talc.yaml +53 -0
  154. gebpy/data_minerals/tistarite.yaml +43 -0
  155. gebpy/data_minerals/trevorite.yaml +42 -0
  156. gebpy/data_minerals/ulvoespinel.yaml +42 -0
  157. gebpy/data_minerals/uraninite.yaml +40 -0
  158. gebpy/data_minerals/valentinite.yaml +46 -0
  159. gebpy/data_minerals/vermiculite.yaml +69 -0
  160. gebpy/data_minerals/wulfenite.yaml +45 -0
  161. gebpy/data_minerals/wustite.yaml +40 -0
  162. gebpy/data_minerals/zincite.yaml +43 -0
  163. gebpy/data_minerals/zincochromite.yaml +42 -0
  164. gebpy/data_rocks/__init__.py +0 -0
  165. gebpy/data_rocks/dolostone.yaml +40 -0
  166. gebpy/data_rocks/limestone.yaml +40 -0
  167. gebpy/data_rocks/marl.yaml +50 -0
  168. gebpy/data_rocks/sandstone.yaml +39 -0
  169. gebpy/data_rocks/shale.yaml +50 -0
  170. gebpy/gebpy_app.py +8732 -0
  171. gebpy/gui/__init__.py +0 -0
  172. gebpy/lib/images/GebPy_Header.png +0 -0
  173. gebpy/lib/images/GebPy_Icon.png +0 -0
  174. gebpy/lib/images/GebPy_Logo.png +0 -0
  175. gebpy/main.py +29 -0
  176. gebpy/modules/__init__.py +0 -0
  177. gebpy/modules/__pycache__/__init__.cpython-310.pyc +0 -0
  178. gebpy/modules/__pycache__/metamorphics.cpython-310.pyc +0 -0
  179. gebpy/modules/__pycache__/silicates.cpython-310.pyc +0 -0
  180. gebpy/modules/carbonates.py +2658 -0
  181. gebpy/modules/chemistry.py +1369 -0
  182. gebpy/modules/core.py +1805 -0
  183. gebpy/modules/elements.py +317 -0
  184. gebpy/modules/evaporites.py +1299 -0
  185. gebpy/modules/exploration.py +1145 -0
  186. gebpy/modules/fluids.py +339 -0
  187. gebpy/modules/geochemistry.py +1727 -0
  188. gebpy/modules/geophysics.py +351 -0
  189. gebpy/modules/gui.py +9093 -0
  190. gebpy/modules/gui_elements.py +145 -0
  191. gebpy/modules/halides.py +485 -0
  192. gebpy/modules/igneous.py +2241 -0
  193. gebpy/modules/metamorphics.py +3222 -0
  194. gebpy/modules/mineralogy.py +442 -0
  195. gebpy/modules/minerals.py +7954 -0
  196. gebpy/modules/ore.py +1648 -0
  197. gebpy/modules/organics.py +530 -0
  198. gebpy/modules/oxides.py +9057 -0
  199. gebpy/modules/petrophysics.py +98 -0
  200. gebpy/modules/phosphates.py +589 -0
  201. gebpy/modules/phospides.py +194 -0
  202. gebpy/modules/plotting.py +619 -0
  203. gebpy/modules/pyllosilicates.py +380 -0
  204. gebpy/modules/sedimentary_rocks.py +908 -0
  205. gebpy/modules/sequences.py +2166 -0
  206. gebpy/modules/series.py +1625 -0
  207. gebpy/modules/silicates.py +11102 -0
  208. gebpy/modules/siliciclastics.py +1846 -0
  209. gebpy/modules/subsurface_2d.py +179 -0
  210. gebpy/modules/sulfates.py +1629 -0
  211. gebpy/modules/sulfides.py +4786 -0
  212. gebpy/plotting/__init__.py +0 -0
  213. gebpy/ui_nb/__init__.py +0 -0
  214. gebpy/user_data/.gitkeep +0 -0
  215. gebpy-1.1.3.dist-info/LICENSE +165 -0
  216. gebpy-1.1.3.dist-info/METADATA +207 -0
  217. gebpy-1.1.3.dist-info/RECORD +254 -0
  218. gebpy-1.1.3.dist-info/WHEEL +5 -0
  219. gebpy-1.1.3.dist-info/entry_points.txt +2 -0
  220. gebpy-1.1.3.dist-info/top_level.txt +1 -0
  221. modules/__init__.py +0 -0
  222. modules/carbonates.py +2658 -0
  223. modules/chemistry.py +1369 -0
  224. modules/core.py +1805 -0
  225. modules/elements.py +317 -0
  226. modules/evaporites.py +1299 -0
  227. modules/exploration.py +765 -0
  228. modules/fluids.py +339 -0
  229. modules/geochemistry.py +1727 -0
  230. modules/geophysics.py +337 -0
  231. modules/gui.py +9093 -0
  232. modules/gui_elements.py +145 -0
  233. modules/halides.py +485 -0
  234. modules/igneous.py +2196 -0
  235. modules/metamorphics.py +2699 -0
  236. modules/mineralogy.py +442 -0
  237. modules/minerals.py +7954 -0
  238. modules/ore.py +1628 -0
  239. modules/organics.py +530 -0
  240. modules/oxides.py +9057 -0
  241. modules/petrophysics.py +98 -0
  242. modules/phosphates.py +589 -0
  243. modules/phospides.py +194 -0
  244. modules/plotting.py +619 -0
  245. modules/pyllosilicates.py +380 -0
  246. modules/sedimentary_rocks.py +908 -0
  247. modules/sequences.py +2166 -0
  248. modules/series.py +1625 -0
  249. modules/silicates.py +11102 -0
  250. modules/siliciclastics.py +1830 -0
  251. modules/subsurface_2d.py +179 -0
  252. modules/sulfates.py +1629 -0
  253. modules/sulfides.py +4786 -0
  254. notebooks/__init__.py +0 -0
@@ -0,0 +1,1728 @@
1
+ #!/usr/bin/env python
2
+ # -*-coding: utf-8 -*-
3
+
4
+ #-----------------------------------------------
5
+
6
+ # Name: geochemistry.py
7
+ # Author: Maximilian A. Beeskow
8
+ # Version: 1.0
9
+ # Date: 15.12.2025
10
+
11
+ #-----------------------------------------------
12
+
13
+ # PACKAGES
14
+ import re
15
+ import numpy as np
16
+ from numpy import round
17
+ import scipy.constants as const
18
+ import matplotlib.pyplot as plt
19
+ from random import *
20
+ import random as rd
21
+
22
+ # MODULES
23
+ from .common import PeriodicSystem
24
+ from .elements import elements
25
+
26
+ class MassSpectrometry():
27
+ #
28
+ def __init__(self, data):
29
+ """
30
+ :param data: List/Array of a mineralogical dataset, e.g. quartz
31
+ """
32
+ self.data = data
33
+ MassSpectrometry.show_plot(self)
34
+ #
35
+ def show_plot(self):
36
+ u = const.physical_constants["atomic mass constant"][0]
37
+ na = const.physical_constants["Avogadro constant"][0]
38
+ print(u)
39
+ atoms = self.data[-1]
40
+ print(elements)
41
+ results = []
42
+ for i in range(len(atoms)):
43
+ results.append([atoms[i][0], (PeriodicSystem(name=atoms[i][0]).get_data()[2]*u)/(atoms[i][1]), atoms[i][2]*na])
44
+ print(results)
45
+ results = np.array(results, dtype=object)
46
+ print(results[:, 1])
47
+ fig, ax = plt.subplots(dpi=100)
48
+ ax.scatter(x=results[:, 1], y=results[:, 2])
49
+ plt.show()
50
+
51
+ class dataanalysis:
52
+ #
53
+ def __init__(self, lithologies, sequences):
54
+ self.lithologies = lithologies
55
+ self.sequences = sequences
56
+ #
57
+ def sortGeodata(self):
58
+ data = []
59
+ for i in range(0, len(self.lithologies)):
60
+ data.append([self.lithologies[i], [], [], [], [], []])
61
+ #
62
+ for i in range(0, len(self.sequences)):
63
+ for j in range(0, len(self.lithologies)):
64
+ if self.sequences[i][0] == self.lithologies[j]:
65
+ data[j][1].append(self.sequences[i][4]) # Density
66
+ data[j][2].append(self.sequences[i][5][0]) # P-wave velocity
67
+ data[j][3].append(self.sequences[i][5][1]) # S-wave velocity
68
+ data[j][4].append(self.sequences[i][6]) # Gamma ray
69
+ data[j][5].append(self.sequences[i][7]) # Neutron porosity
70
+ #
71
+ return data
72
+ #
73
+
74
+ class geophysics:
75
+ #
76
+ def __init__(self, sequences):
77
+ self.sequences = sequences
78
+ #
79
+ def calculatePressure(self):
80
+ data = [0]
81
+ g = 9.81
82
+ for i in range(0, len(self.sequences)):
83
+ data.append(data[i]+self.sequences[i][4]*1000*g*(self.sequences[i][3]-self.sequences[i][2]))
84
+ #
85
+ return data
86
+ #
87
+ def calculateTemperature(self):
88
+ data = [randint(0, 25)]
89
+ a = 30/1000
90
+ for i in range(0, len(self.sequences)):
91
+ data.append(round(data[0]+self.sequences[i][3]*a, 1))
92
+ #
93
+ return data
94
+
95
+ class elementanalysis:
96
+ #
97
+ def __init__(self, n, m):
98
+ self.n = n
99
+ self.m = m
100
+ #
101
+ def analyzeQuartz(self):
102
+ # input = n
103
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
104
+ chemSi = elements.Si(self)
105
+ chemO = elements.O(self)
106
+ #
107
+ data = []
108
+ m = chemSi[2]+2*chemO[2]
109
+ wSi = chemSi[2]/m
110
+ wO = (2*chemO[2])/m
111
+ #
112
+ for i in range(0, len(self.m)):
113
+ for j in range(2, len(self.m[i])):
114
+ if self.m[i][j][0] == "Qz":
115
+ mSi = wSi*self.m[i][j][1]
116
+ mO = wO*self.m[i][j][1]
117
+ data.append([self.m[i][0], [[chemSi[0], mSi], [chemO[0], mO]]])
118
+ #
119
+ return data
120
+ #
121
+ def analyzeCalcite(self):
122
+ # input = n
123
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
124
+ chemCa = elements.Ca(self)
125
+ chemC = elements.C(self)
126
+ chemO = elements.O(self)
127
+ #
128
+ data = []
129
+ m = chemCa[2]+chemC[2]+3*chemO[2]
130
+ wCa = chemCa[2]/m
131
+ wC = chemC[2]/m
132
+ wO = (3*chemO[2])/m
133
+ #
134
+ for i in range(0, len(self.m)):
135
+ for j in range(2, len(self.m[i])):
136
+ if self.m[i][j][0] == "Cal":
137
+ mCa = wCa*self.m[i][j][1]
138
+ mC = wC*self.m[i][j][1]
139
+ mO = wO*self.m[i][j][1]
140
+ data.append([self.m[i][0], [[chemCa[0], mCa], [chemC[0], mC], [chemO[0], mO]]])
141
+ #
142
+ return data
143
+ #
144
+ def analyzeDolomite(self):
145
+ # input = n
146
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
147
+ chemCa = elements.Ca(self)
148
+ chemMg = elements.Mg(self)
149
+ chemC = elements.C(self)
150
+ chemO = elements.O(self)
151
+ #
152
+ data = []
153
+ m = chemCa[2]+chemMg[2]+2*(chemC[2]+3*chemO[2])
154
+ wCa = chemCa[2]/m
155
+ wMg = chemMg[2]/m
156
+ wC = 2*chemC[2]/m
157
+ wO = 6*chemO[2]/m
158
+ #
159
+ for i in range(0, len(self.m)):
160
+ for j in range(2, len(self.m[i])):
161
+ if self.m[i][j][0] == "Dol":
162
+ mCa = wCa*self.m[i][j][1]
163
+ mMg = wMg*self.m[i][j][1]
164
+ mC = wC*self.m[i][j][1]
165
+ mO = wO*self.m[i][j][1]
166
+ data.append([self.m[i][0], [[chemCa[0], mCa], [chemMg[0], mMg], [chemC[0], mC], [chemO[0], mO]]])
167
+ #
168
+ return data
169
+ #
170
+ def analyzeOrthoclase(self):
171
+ # input = n
172
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
173
+ chemK = elements.K(self)
174
+ chemAl = elements.Al(self)
175
+ chemSi = elements.Si(self)
176
+ chemO = elements.O(self)
177
+ #
178
+ data = []
179
+ m = chemK[2]+chemAl[2]+3*chemSi[2]+8*chemO[2]
180
+ wK = chemK[2]/m
181
+ wAl = chemAl[2]/m
182
+ wSi = 3*chemSi[2]/m
183
+ wO = 8*chemO[2]/m
184
+ #
185
+ for i in range(0, len(self.m)):
186
+ for j in range(2, len(self.m[i])):
187
+ if self.m[i][j][0] == "Or":
188
+ mK = wK*self.m[i][j][1]
189
+ mAl = wAl*self.m[i][j][1]
190
+ mSi = wSi*self.m[i][j][1]
191
+ mO = wO*self.m[i][j][1]
192
+ data.append([self.m[i][0], [[chemK[0], mK], [chemAl[0], mAl], [chemSi[0], mSi], [chemO[0], mO]]])
193
+ #
194
+ return data
195
+ #
196
+ def analyzeBiotite(self):
197
+ # input = n
198
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
199
+ chemK = elements.K(self)
200
+ chemMg = elements.Mg(self)
201
+ chemFe = elements.Fe(self)
202
+ chemAl = elements.Al(self)
203
+ chemSi = elements.Si(self)
204
+ chemO = elements.O(self)
205
+ chemH = elements.H(self)
206
+ chemF = elements.F(self)
207
+ #
208
+ data = []
209
+ m = chemK[2]+2.5*chemMg[2]+0.5*chemFe[2]+chemAl[2]+3*chemSi[2]+10*chemO[2]+1.75*(chemO[2]+chemH[2])+0.25*chemF[2]
210
+ wK = chemK[2]/m
211
+ wMg = 2.5*chemMg[2]/m
212
+ wFe = 0.5*chemFe[2]/m
213
+ wAl = chemAl[2]/m
214
+ wSi = 3*chemSi[2]/m
215
+ wO = (10*chemO[2]+1.75*chemO[2])/m
216
+ wH = 1.75*chemH[2]/m
217
+ wF = 0.25*chemF[2]/m
218
+ #
219
+ for i in range(0, len(self.m)):
220
+ for j in range(2, len(self.m[i])):
221
+ if self.m[i][j][0] == "Bt":
222
+ mK = wK*self.m[i][j][1]
223
+ mMg = wMg*self.m[i][j][1]
224
+ mFe = wFe*self.m[i][j][1]
225
+ mAl = wAl*self.m[i][j][1]
226
+ mSi = wSi*self.m[i][j][1]
227
+ mO = wO*self.m[i][j][1]
228
+ mH = wH*self.m[i][j][1]
229
+ mF = wF*self.m[i][j][1]
230
+ data.append([self.m[i][0], [[chemK[0], mK], [chemMg[0], mMg], [chemFe[0], mFe], [chemAl[0], mAl], [chemSi[0], mSi], [chemO[0], mO], [chemH[0], mH], [chemF[0], mF]]])
231
+ #
232
+ return data
233
+ #
234
+ def analyzeIllite(self):
235
+ # input = n
236
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
237
+ chemK = elements.K(self)
238
+ chemH = elements.H(self)
239
+ chemO = elements.O(self)
240
+ chemAl = elements.Al(self)
241
+ chemMg = elements.Mg(self)
242
+ chemFe = elements.Fe(self)
243
+ chemSi = elements.Si(self)
244
+ #
245
+ data = []
246
+ m = 0.6*chemK[2]+0.4*(3*chemH[2]+chemO[2])+1.3*chemAl[2]+0.3*chemMg[2]+0.1*chemFe[2]+3.5*chemSi[2]+10*chemO[2]+2*(chemO[2]+chemH[2])+2*chemH[2]+chemO[2]
247
+ wK = (0.6*chemK[2])/m
248
+ wMg = (0.3*chemMg[2])/m
249
+ wAl = (1.3*chemAl[2])/m
250
+ wFe = (0.1*chemFe[2])/m
251
+ wSi = (3.5*chemSi[2])/m
252
+ wH = (0.4*3*chemH[2]+2*2*chemH[2])/m
253
+ wO = (0.4*chemO[2]+10*chemO[2]+2*chemO[2]+chemO[2])/m
254
+ #
255
+ for i in range(0, len(self.m)):
256
+ for j in range(2, len(self.m[i])):
257
+ if self.m[i][j][0] == "Ilt":
258
+ mK = wK*self.m[i][j][1]
259
+ mMg = wMg*self.m[i][j][1]
260
+ mAl = wAl*self.m[i][j][1]
261
+ mFe = wFe*self.m[i][j][1]
262
+ mSi = wSi*self.m[i][j][1]
263
+ mH = wH*self.m[i][j][1]
264
+ mO = wO*self.m[i][j][1]
265
+ data.append([self.m[i][0], [[chemK[0], mK], [chemMg[0], mMg], [chemAl[0], mAl], [chemFe[0], mFe], [chemSi[0], mSi], [chemH[0], mH], [chemO[0], mO]]])
266
+ #
267
+ return data
268
+ #
269
+ def analyzeChlorite(self):
270
+ # input = n
271
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
272
+ chemFe = elements.Fe(self)
273
+ chemMg = elements.Mg(self)
274
+ chemO = elements.O(self)
275
+ chemAl = elements.Al(self)
276
+ chemH = elements.H(self)
277
+ chemSi = elements.Si(self)
278
+ #
279
+ data = []
280
+ m = 3*chemFe[2]+1.5*chemMg[2]+chemAl[2]+0.5*chemFe[2]+3*chemSi[2]+chemAl[2]+12*chemO[2]+6*(chemO[2]+chemH[2])
281
+ wFe = ((3+0.5)*chemFe[2])/m
282
+ wMg = (1.5*chemMg[2])/m
283
+ wAl = (2*chemAl[2])/m
284
+ wSi = (3*chemSi[2])/m
285
+ wO = ((12+6)*chemO[2])/m
286
+ wH = (6*chemH[2])/m
287
+ #
288
+ for i in range(0, len(self.m)):
289
+ for j in range(2, len(self.m[i])):
290
+ if self.m[i][j][0] == "Chl":
291
+ mFe = wFe*self.m[i][j][1]
292
+ mMg = wMg*self.m[i][j][1]
293
+ mAl = wAl*self.m[i][j][1]
294
+ mSi = wSi*self.m[i][j][1]
295
+ mO = wO*self.m[i][j][1]
296
+ mH = wH*self.m[i][j][1]
297
+ data.append([self.m[i][0], [[chemFe[0], mFe], [chemMg[0], mMg], [chemAl[0], mAl], [chemSi[0], mSi], [chemO[0], mO], [chemH[0], mH]]])
298
+ #
299
+ return data
300
+ #
301
+ def analyzeGlauconite(self):
302
+ # input = n
303
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
304
+ chemK = elements.K(self)
305
+ chemNa = elements.Na(self)
306
+ chemMg = elements.Mg(self)
307
+ chemFe = elements.Fe(self)
308
+ chemAl = elements.Al(self)
309
+ chemSi = elements.Si(self)
310
+ chemO = elements.O(self)
311
+ chemH = elements.H(self)
312
+ #
313
+ data = []
314
+ m = 0.6*chemK[2]+0.05*chemNa[2]+1.5*chemFe[2]+0.4*chemMg[2]+0.3*chemAl[2]+3.8*chemSi[2]+10*chemO[2]+2*(chemO[2]+chemH[2])
315
+ wK = (0.6*chemK[2])/m
316
+ wNa = (0.05*chemNa[2])/m
317
+ wMg = (0.4*chemMg[2])/m
318
+ wAl = (0.3*chemAl[2])/m
319
+ wFe = ((1.3+0.2)*chemFe[2])/m
320
+ wSi = (3.8*chemSi[2])/m
321
+ wO = ((10+2)*chemO[2])/m
322
+ wH = (2*chemH[2])/m
323
+ #
324
+ for i in range(0, len(self.m)):
325
+ for j in range(2, len(self.m[i])):
326
+ if self.m[i][j][0] == "Glt":
327
+ dataK = wK*self.m[i][j][1]
328
+ dataNa = wNa*self.m[i][j][1]
329
+ dataMg = wMg*self.m[i][j][1]
330
+ dataAl = wAl*self.m[i][j][1]
331
+ dataFe = wFe*self.m[i][j][1]
332
+ dataSi = wSi*self.m[i][j][1]
333
+ dataO = wO*self.m[i][j][1]
334
+ dataH = wH*self.m[i][j][1]
335
+ data.append([self.m[i][0], [[chemK[0], dataK], [chemNa[0], dataNa], [chemMg[0], dataMg], [chemAl[0], dataAl], [chemFe[0], dataFe], [chemSi[0], dataSi], [chemO[0], dataO], [chemH[0], dataH]]])
336
+ #
337
+ return data
338
+ #
339
+ def analyzeAlbite(self):
340
+ # input = n
341
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
342
+ chemNa = elements.K(self)
343
+ chemAl = elements.Al(self)
344
+ chemSi = elements.Si(self)
345
+ chemO = elements.O(self)
346
+ #
347
+ data = []
348
+ m = chemNa[2] + chemAl[2] + 3*chemSi[2] + 8*chemO[2]
349
+ wNa = (chemNa[2])/m
350
+ wAl = (chemAl[2])/m
351
+ wSi = (3*chemSi[2])/m
352
+ wO = (8*chemO[2])/m
353
+ #
354
+ for i in range(0, len(self.m)):
355
+ for j in range(2, len(self.m[i])):
356
+ if self.m[i][j][0] == "Ab":
357
+ dataNa = wNa*self.m[i][j][1]
358
+ dataAl = wAl*self.m[i][j][1]
359
+ dataSi = wSi*self.m[i][j][1]
360
+ dataO = wO*self.m[i][j][1]
361
+ data.append([self.m[i][0], [[chemNa[0], dataNa], [chemAl[0], dataAl], [chemSi[0], dataSi], [chemO[0], dataO]]])
362
+ #
363
+ return data
364
+ #
365
+ def analyzeAnorthite(self):
366
+ # input = n
367
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
368
+ chemCa = elements.K(self)
369
+ chemAl = elements.Al(self)
370
+ chemSi = elements.Si(self)
371
+ chemO = elements.O(self)
372
+ #
373
+ data = []
374
+ M = chemCa[2] + 2*chemAl[2] + 2*chemSi[2] + 8*chemO[2]
375
+ wCa = (chemCa[2])/M
376
+ wAl = (2*chemAl[2])/M
377
+ wSi = (2*chemSi[2])/M
378
+ wO = (8*chemO[2])/M
379
+ #
380
+ for i in range(0, len(self.m)):
381
+ for j in range(2, len(self.m[i])):
382
+ if self.m[i][j][0] == "An":
383
+ dataCa = wCa*self.m[i][j][1]
384
+ dataAl = wAl*self.m[i][j][1]
385
+ dataSi = wSi*self.m[i][j][1]
386
+ dataO = wO*self.m[i][j][1]
387
+ data.append([self.m[i][0], [[chemCa[0], dataCa], [chemAl[0], dataAl], [chemSi[0], dataSi], [chemO[0], dataO]]])
388
+ #
389
+ return data
390
+ #
391
+ def analyzeMuscovite(self):
392
+ # input = n
393
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
394
+ chemK = elements.K(self)
395
+ chemAl = elements.Al(self)
396
+ chemSi = elements.Si(self)
397
+ chemO = elements.O(self)
398
+ chemH = elements.H(self)
399
+ chemF = elements.F(self)
400
+ #
401
+ data = []
402
+ M = chemK[2]+3*chemAl[2]+3*chemSi[2]+10*chemO[2]+1.8*(chemO[2]+chemH[2])+0.2*chemF[2]
403
+ wK = (chemK[2])/M
404
+ wAl = (3*chemAl[2])/M
405
+ wSi = (3*chemSi[2])/M
406
+ wO = ((10+1.8)*chemO[2])/M
407
+ wH = (1.8*chemH[2])/M
408
+ wF = (0.2*chemF[2])/M
409
+ #
410
+ for i in range(0, len(self.m)):
411
+ for j in range(2, len(self.m[i])):
412
+ if self.m[i][j][0] == "Ms":
413
+ dataK = wK*self.m[i][j][1]
414
+ dataAl = wAl*self.m[i][j][1]
415
+ dataSi = wSi*self.m[i][j][1]
416
+ dataO = wO*self.m[i][j][1]
417
+ dataH = wH*self.m[i][j][1]
418
+ dataF = wF*self.m[i][j][1]
419
+ data.append([self.m[i][0], [[chemK[0], dataK], [chemAl[0], dataAl], [chemSi[0], dataSi], [chemO[0], dataO], [chemH[0], dataH], [chemF[0], dataF]]])
420
+ #
421
+ return data
422
+ #
423
+ def analyzePyrite(self):
424
+ # input = n
425
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
426
+ chemFe = elements.Fe(self)
427
+ chemS = elements.S(self)
428
+ #
429
+ data = []
430
+ M = chemFe[2] + 2*chemS[2]
431
+ wFe = (chemFe[2])/M
432
+ wS = (2*chemS[2])/M
433
+ #
434
+ for i in range(0, len(self.m)):
435
+ for j in range(2, len(self.m[i])):
436
+ if self.m[i][j][0] == "Py":
437
+ dataFe = wFe*self.m[i][j][1]
438
+ dataS = wS*self.m[i][j][1]
439
+ data.append([self.m[i][0], [[chemFe[0], dataFe], [chemS[0], dataS]]])
440
+ #
441
+ return data
442
+ #
443
+ def analyzeHalite(self):
444
+ # input = n
445
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
446
+ chemNa = elements.Na(self)
447
+ chemCl = elements.Cl(self)
448
+ #
449
+ data = []
450
+ M = chemNa[2] + chemCl[2]
451
+ wNa = (chemNa[2])/M
452
+ wCl = (chemCl[2])/M
453
+ #
454
+ for i in range(0, len(self.m)):
455
+ for j in range(2, len(self.m[i])):
456
+ if self.m[i][j][0] == "Hl":
457
+ dataNa = wNa*self.m[i][j][1]
458
+ dataCl = wCl*self.m[i][j][1]
459
+ data.append([self.m[i][0], [[chemNa[0], dataNa], [chemCl[0], dataCl]]])
460
+ #
461
+ return data
462
+ #
463
+ def analyzeAnhydrite(self):
464
+ # input = n
465
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
466
+ chemCa = elements.Ca(self)
467
+ chemS = elements.S(self)
468
+ chemO = elements.O(self)
469
+ #
470
+ data = []
471
+ M = chemCa[2] + chemS[2] + 4*chemO[2]
472
+ wCa = (chemCa[2]) / M
473
+ wS = (chemS[2]) / M
474
+ wO = (chemO[2]) / M
475
+ #
476
+ for i in range(0, len(self.m)):
477
+ for j in range(2, len(self.m[i])):
478
+ if self.m[i][j][0] == "Anh":
479
+ dataCa = wCa * self.m[i][j][1]
480
+ dataS = wS * self.m[i][j][1]
481
+ dataO = wO * self.m[i][j][1]
482
+ data.append([self.m[i][0], [[chemCa[0], dataCa], [chemS[0], dataS], [chemO[0], dataO]]])
483
+ #
484
+ return data
485
+ #
486
+ def analyzeGypsum(self): # CaSO4*H2O
487
+ # input = n
488
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
489
+ chemCa = elements.Ca(self)
490
+ chemS = elements.S(self)
491
+ chemO = elements.O(self)
492
+ chemH = elements.H(self)
493
+ #
494
+ data = []
495
+ M = chemCa[2] + chemS[2] + 4*chemO[2] + 2*chemH[2] + chemO[2]
496
+ wCa = (chemCa[2]) / M
497
+ wS = (chemS[2]) / M
498
+ wO = (chemO[2]) / M
499
+ wH = (chemH[2]) / M
500
+ #
501
+ for i in range(0, len(self.m)):
502
+ for j in range(2, len(self.m[i])):
503
+ if self.m[i][j][0] == "Gp":
504
+ dataCa = wCa * self.m[i][j][1]
505
+ dataS = wS * self.m[i][j][1]
506
+ dataO = wO * self.m[i][j][1]
507
+ dataH = wH * self.m[i][j][1]
508
+ data.append([self.m[i][0], [[chemCa[0], dataCa], [chemS[0], dataS], [chemO[0], dataO], [chemH[0], dataH]]])
509
+ #
510
+ return data
511
+ #
512
+ def analyzeSylvite(self): # KCl
513
+ # input = n
514
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
515
+ chemK = elements.K(self)
516
+ chemCl = elements.Cl(self)
517
+ #
518
+ data = []
519
+ M = chemK[2] + chemCl[2]
520
+ wK = (chemK[2]) / M
521
+ wCl = (chemCl[2]) / M
522
+ #
523
+ for i in range(0, len(self.m)):
524
+ for j in range(2, len(self.m[i])):
525
+ if self.m[i][j][0] == "Syl":
526
+ dataK = wK * self.m[i][j][1]
527
+ dataCl = wCl * self.m[i][j][1]
528
+ data.append([self.m[i][0], [[chemK[0], dataK], [chemCl[0], dataCl]]])
529
+ return data
530
+ #
531
+ def analyzeGalena(self): # PbS
532
+ # input = n
533
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
534
+ chemPb = elements.Pb(self)
535
+ chemS = elements.S(self)
536
+ #
537
+ data = []
538
+ M = chemPb[2] + chemS[2]
539
+ wPb = (chemPb[2]) / M
540
+ wS = (chemS[2]) / M
541
+ #
542
+ for i in range(0, len(self.m)):
543
+ for j in range(2, len(self.m[i])):
544
+ if self.m[i][j][0] == "Gn":
545
+ dataPb = wPb * self.m[i][j][1]
546
+ dataS = wS * self.m[i][j][1]
547
+ data.append([self.m[i][0], [[chemPb[0], dataPb], [chemS[0], dataS]]])
548
+ return data
549
+ #
550
+ def analyzeChalcopyrite(self): # CuFeS2
551
+ # input = n
552
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
553
+ chemCu = elements.Cu(self)
554
+ chemFe = elements.Fe(self)
555
+ chemS = elements.S(self)
556
+ #
557
+ data = []
558
+ M = chemCu[2] + chemFe[2] + 2*chemS[2]
559
+ wCu = (chemCu[2]) / M
560
+ wFe = (chemFe[2]) / M
561
+ wS = (chemS[2]) / M
562
+ #
563
+ for i in range(0, len(self.m)):
564
+ for j in range(2, len(self.m[i])):
565
+ if self.m[i][j][0] == "Ccp":
566
+ dataCu = wCu * self.m[i][j][1]
567
+ dataFe = wFe * self.m[i][j][1]
568
+ dataS = wS * self.m[i][j][1]
569
+ data.append([self.m[i][0], [[chemCu[0], dataCu], [chemFe[0], dataFe], [chemS[0], dataS]]])
570
+ return data
571
+ #
572
+ def analyzeMolybdenite(self): # MoS2
573
+ # input = n
574
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
575
+ chemMo = elements.Mo(self)
576
+ chemS = elements.S(self)
577
+ #
578
+ data = []
579
+ M = chemMo[2] + 2*chemS[2]
580
+ wMo = (chemMo[2]) / M
581
+ wS = (chemS[2]) / M
582
+ #
583
+ for i in range(0, len(self.m)):
584
+ for j in range(2, len(self.m[i])):
585
+ if self.m[i][j][0] == "Mol":
586
+ dataMo = wMo * self.m[i][j][1]
587
+ dataS = wS * self.m[i][j][1]
588
+ data.append([self.m[i][0], [[chemMo[0], dataMo], [chemS[0], dataS]]])
589
+ return data
590
+ #
591
+ def analyzeKaolinite(self): # Al2(OH)4Si2O5
592
+ # input = n
593
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
594
+ chemAl = elements.Al(self)
595
+ chemO = elements.O(self)
596
+ chemH = elements.H(self)
597
+ chemSi = elements.Si(self)
598
+ chemO = elements.O(self)
599
+ #
600
+ data = []
601
+ M = round(2*chemAl[2] + 4*(chemO[2]+chemH[2]) + 2*chemSi[2] + 5*chemO[2], 3)
602
+ wAl = (chemAl[2]) / M
603
+ wO = (chemO[2]) / M
604
+ wH = (chemH[2]) / M
605
+ wSi = (chemSi[2]) / M
606
+ #
607
+ for i in range(0, len(self.m)):
608
+ for j in range(2, len(self.m[i])):
609
+ if self.m[i][j][0] == "Kln":
610
+ dataAl = wAl * self.m[i][j][1]
611
+ dataO = wO * self.m[i][j][1]
612
+ dataH = wH * self.m[i][j][1]
613
+ dataSi = wSi * self.m[i][j][1]
614
+ data.append([self.m[i][0], [[chemAl[0], dataAl], [chemO[0], dataO], [chemH[0], dataH], [chemSi[0], dataSi]]])
615
+ return data
616
+ #
617
+ def analyzeAlkalifeldspar(self, sequences): # Na(x)K(1-x)AlSi3O8
618
+ # input = n
619
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
620
+ chemNa = elements.Na(self)
621
+ chemK = elements.K(self)
622
+ chemAl = elements.Al(self)
623
+ chemSi = elements.Si(self)
624
+ chemO = elements.O(self)
625
+ self.sequences = sequences
626
+ #
627
+ data = []
628
+ for i in range(0, len(self.sequences)):
629
+ for j in range(0, len(self.sequences[i][9])):
630
+ if self.sequences[i][9][j][0] == "Kfs" or self.sequences[i][9][j][0] == "Afs":
631
+ M = self.sequences[i][9][j][2]
632
+ wNa = (chemNa[2]) / M
633
+ wK = (chemK[2]) / M
634
+ wAl = (chemAl[2]) / M
635
+ wSi = (chemSi[2]) / M
636
+ wO = (chemO[2]) / M
637
+ #
638
+ for i in range(0, len(self.m)):
639
+ for j in range(2, len(self.m[i])):
640
+ if self.m[i][j][0] == "Kfs":
641
+ dataNa = wNa * self.m[i][j][1]
642
+ dataK = wK * self.m[i][j][1]
643
+ dataAl = wAl * self.m[i][j][1]
644
+ dataSi = wSi * self.m[i][j][1]
645
+ dataO = wO * self.m[i][j][1]
646
+ data.append([self.m[i][0], [[chemNa[0], dataNa], [chemK[0], dataK], [chemAl[0], dataAl], [chemSi[0], dataSi], [chemO[0], dataO]]])
647
+ return data
648
+ #
649
+ def analyzePlagioclase(self, sequences): # Na(x)Ca(1-x)Al(2-x)Si(2+x)O8
650
+ # input = n
651
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
652
+ chemNa = elements.Na(self)
653
+ chemCa = elements.Ca(self)
654
+ chemAl = elements.Al(self)
655
+ chemSi = elements.Si(self)
656
+ chemO = elements.O(self)
657
+ self.sequences = sequences
658
+ #
659
+ data = []
660
+ for i in range(0, len(self.sequences)):
661
+ for j in range(0, len(self.sequences[i][9])):
662
+ if self.sequences[i][9][j][0] == "Pl":
663
+ M = self.sequences[i][9][j][2]
664
+ wNa = (chemNa[2]) / M
665
+ wCa = (chemCa[2]) / M
666
+ wAl = (chemAl[2]) / M
667
+ wSi = (chemSi[2]) / M
668
+ wO = (chemO[2]) / M
669
+ #
670
+ for i in range(0, len(self.m)):
671
+ for j in range(2, len(self.m[i])):
672
+ if self.m[i][j][0] == "Pl":
673
+ dataNa = wNa * self.m[i][j][1]
674
+ dataCa = wCa * self.m[i][j][1]
675
+ dataAl = wAl * self.m[i][j][1]
676
+ dataSi = wSi * self.m[i][j][1]
677
+ dataO = wO * self.m[i][j][1]
678
+ data.append([self.m[i][0], [[chemNa[0], dataNa], [chemCa[0], dataCa], [chemAl[0], dataAl], [chemSi[0], dataSi], [chemO[0], dataO]]])
679
+ return data
680
+ #
681
+ def analyzeSiderite(self): # FeCO3
682
+ # input = n
683
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
684
+ chemFe = elements.Fe(self)
685
+ chemC = elements.C(self)
686
+ chemO = elements.O(self)
687
+ #
688
+ data = []
689
+ M = round(chemFe[2] + chemC[2] + 3*chemO[2], 3)
690
+ wFe = (chemFe[2]) / M
691
+ wC = (chemC[2]) / M
692
+ wO = (chemO[2]) / M
693
+ #
694
+ for i in range(0, len(self.m)):
695
+ for j in range(2, len(self.m[i])):
696
+ if self.m[i][j][0] == "Sd":
697
+ dataFe = wFe * self.m[i][j][1]
698
+ dataC = wC * self.m[i][j][1]
699
+ dataO = wO * self.m[i][j][1]
700
+ data.append([self.m[i][0], [[chemFe[0], dataFe], [chemC[0], dataC], [chemO[0], dataO]]])
701
+ return data
702
+ #
703
+ def analyzeMagnesite(self): # MgCO3
704
+ # input = n
705
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
706
+ chemMg = elements.Mg(self)
707
+ chemC = elements.C(self)
708
+ chemO = elements.O(self)
709
+ #
710
+ data = []
711
+ M = round(chemMg[2] + chemC[2] + 3*chemO[2], 3)
712
+ wMg = (chemMg[2]) / M
713
+ wC = (chemC[2]) / M
714
+ wO = (chemO[2]) / M
715
+ #
716
+ for i in range(0, len(self.m)):
717
+ for j in range(2, len(self.m[i])):
718
+ if self.m[i][j][0] == "Mgs":
719
+ dataMg = wMg * self.m[i][j][1]
720
+ dataC = wC * self.m[i][j][1]
721
+ dataO = wO * self.m[i][j][1]
722
+ data.append([self.m[i][0], [[chemMg[0], dataMg], [chemC[0], dataC], [chemO[0], dataO]]])
723
+ return data
724
+ #
725
+ def analyzeActinolite(self, sequences): # Ca2(Mg,Fe)5Si8O22(OH)2
726
+ # input = n
727
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
728
+ chem_Ca = elements.Ca(self)
729
+ chem_Mg = elements.Mg(self)
730
+ chem_Fe = elements.Fe(self)
731
+ chem_Si = elements.Si(self)
732
+ chem_O = elements.O(self)
733
+ chem_H = elements.H(self)
734
+ self.sequences = sequences
735
+ #
736
+ data = []
737
+ for i in range(0, len(self.sequences)):
738
+ for j in range(0, len(self.sequences[i][9])):
739
+ if self.sequences[i][9][j][0] == "Act":
740
+ M = round(2*chem_Ca[2] + 5*(self.sequences[i][9][j][2]*chem_Mg[2]+(1-self.sequences[i][9][j][2])*chem_Fe[2]) + 8*chem_Si[2] + 22*chem_O[2] + 2*(chem_O[2]+chem_H[2]), 3)
741
+ wCa = (chem_Ca[2]) / M
742
+ wMg = (chem_Mg[2]) / M
743
+ wFe = (chem_Fe[2]) / M
744
+ wSi = (chem_Si[2]) / M
745
+ wO = (chem_O[2]) / M
746
+ wH = (chem_H[2]) / M
747
+ #
748
+ for i in range(0, len(self.m)):
749
+ for j in range(2, len(self.m[i])):
750
+ if self.m[i][j][0] == "Act":
751
+ dataCa = wCa * self.m[i][j][1]
752
+ dataMg = wMg * self.m[i][j][1]
753
+ dataFe = wFe * self.m[i][j][1]
754
+ dataSi = wSi * self.m[i][j][1]
755
+ dataO = wO * self.m[i][j][1]
756
+ dataH = wH * self.m[i][j][1]
757
+ data.append([self.m[i][0], [[chem_Ca[0], dataCa], [chem_Mg[0], dataMg], [chem_Fe[0], dataFe], [chem_Si[0], dataSi], [chem_O[0], dataO], [chem_H[0], dataH]]])
758
+ return data
759
+ #
760
+ def analyzeTremolite(self): # Ca2Mg5Si8O22(OH)2
761
+ # input = n
762
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
763
+ chem_Ca = elements.Ca(self)
764
+ chem_Mg = elements.Mg(self)
765
+ chem_Si = elements.Si(self)
766
+ chem_O = elements.O(self)
767
+ chem_H = elements.H(self)
768
+ #
769
+ data = []
770
+ M = round(2*chem_Ca[2] + 5*chem_Mg[2] + 2*(4*chem_Si[2]+11*chem_O[2]+(chem_O[2]+chem_H[2])), 3)
771
+ wCa = (chem_Ca[2]) / M
772
+ wMg = (chem_Mg[2]) / M
773
+ wSi = (chem_Si[2]) / M
774
+ wO = (chem_O[2]) / M
775
+ wH = (chem_H[2]) / M
776
+ #
777
+ for i in range(0, len(self.m)):
778
+ for j in range(2, len(self.m[i])):
779
+ if self.m[i][j][0] == "Tr":
780
+ dataCa = wCa * self.m[i][j][1]
781
+ dataMg = wMg * self.m[i][j][1]
782
+ dataSi = wSi * self.m[i][j][1]
783
+ dataO = wO * self.m[i][j][1]
784
+ dataH = wH * self.m[i][j][1]
785
+ data.append([self.m[i][0], [[chem_Ca[0], dataCa], [chem_Mg[0], dataMg], [chem_Si[0], dataSi], [chem_O[0], dataO], [chem_H[0], dataH]]])
786
+ return data
787
+ #
788
+ def analyzeMagnetite(self): # Fe3O4
789
+ # input = n
790
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
791
+ chem_Fe = elements.Fe(self)
792
+ chem_O = elements.O(self)
793
+ #
794
+ data = []
795
+ M = round(3*chem_Fe[2] + 4*chem_O[2], 3)
796
+ w_Fe = (chem_Fe[2])/M
797
+ w_O = (chem_O[2])/M
798
+ #
799
+ for i in range(0, len(self.m)):
800
+ for j in range(2, len(self.m[i])):
801
+ if self.m[i][j][0] == "Mag":
802
+ data_Fe = w_Fe*self.m[i][j][1]
803
+ data_O = w_O*self.m[i][j][1]
804
+ data.append([self.m[i][0], [[chem_Fe[0], data_Fe], [chem_O[0], data_O]]])
805
+ return data
806
+ #
807
+ def analyzeHematite(self): # Fe2O3
808
+ # input = n
809
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
810
+ chem_Fe = elements.Fe(self)
811
+ chem_O = elements.O(self)
812
+ #
813
+ data = []
814
+ M = round(2*chem_Fe[2] + 3*chem_O[2], 3)
815
+ w_Fe = (chem_Fe[2])/M
816
+ w_O = (chem_O[2])/M
817
+ #
818
+ for i in range(0, len(self.m)):
819
+ for j in range(2, len(self.m[i])):
820
+ if self.m[i][j][0] == "Hem":
821
+ data_Fe = w_Fe*self.m[i][j][1]
822
+ data_O = w_O*self.m[i][j][1]
823
+ data.append([self.m[i][0], [[chem_Fe[0], data_Fe], [chem_O[0], data_O]]])
824
+ return data
825
+ #
826
+ def analyze_biotite(self, sequences): # K [Mg(a)Fe(1-a)]3 Al(b)Fe(1-b) [Al(c)Si(1-c)]3 O10 [OH(d)F(1-d)]2
827
+ # input = n
828
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
829
+ chem_H = elements.H(self)
830
+ chem_O = elements.O(self)
831
+ chem_F = elements.F(self)
832
+ chem_Mg = elements.Mg(self)
833
+ chem_Al = elements.Al(self)
834
+ chem_Si = elements.Si(self)
835
+ chem_K = elements.K(self)
836
+ chem_Fe = elements.Fe(self)
837
+ self.sequences = sequences
838
+ #
839
+ data = []
840
+ for i in range(0, len(self.sequences)):
841
+ for j in range(0, len(self.sequences[i][9])):
842
+ if self.sequences[i][9][j][0] == "Bt":
843
+ M = self.sequences[i][9][j][2]
844
+ w_H = (chem_H[2])/M
845
+ w_O = (chem_O[2])/M
846
+ w_F = (chem_F[2])/M
847
+ w_Mg = (chem_Mg[2])/M
848
+ w_Al = (chem_Al[2])/M
849
+ w_Si = (chem_Si[2])/M
850
+ w_K = (chem_K[2])/M
851
+ w_Fe = (chem_Fe[2])/M
852
+ #
853
+ for i in range(0, len(self.m)):
854
+ for j in range(2, len(self.m[i])):
855
+ if self.m[i][j][0] == "Bt":
856
+ data_H = w_H*self.m[i][j][1]
857
+ data_O = w_O*self.m[i][j][1]
858
+ data_F = w_F*self.m[i][j][1]
859
+ data_Mg = w_Mg*self.m[i][j][1]
860
+ data_Al = w_Al*self.m[i][j][1]
861
+ data_Si = w_Si*self.m[i][j][1]
862
+ data_K = w_K*self.m[i][j][1]
863
+ data_Fe = w_Fe*self.m[i][j][1]
864
+ data.append([self.m[i][0], [[chem_H[0], data_H], [chem_O[0], data_O], [chem_F[0], data_F], [chem_Mg[0], data_Mg], [chem_Al[0], data_Al], [chem_Si[0], data_Si], [chem_K[0], data_K], [chem_Fe[0], data_Fe]]])
865
+ return data
866
+ #
867
+ def analyze_enstatite(self): # Mg2Si2O6
868
+ # input = n
869
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
870
+ chem_Mg = elements.Mg(self)
871
+ chem_Si = elements.Si(self)
872
+ chem_O = elements.O(self)
873
+ #
874
+ data = []
875
+ M = round(2*chem_Mg[2] + 2*chem_Si[2] + 6*chem_O[2],3)
876
+ w_Mg = (chem_Mg[2])/M
877
+ w_Si = (chem_Si[2])/M
878
+ w_O = (chem_O[2])/M
879
+ #
880
+ for i in range(0, len(self.m)):
881
+ for j in range(2, len(self.m[i])):
882
+ if self.m[i][j][0] == "En":
883
+ data_Mg = w_Mg*self.m[i][j][1]
884
+ data_Si = w_Si*self.m[i][j][1]
885
+ data_O = w_O*self.m[i][j][1]
886
+ data.append([self.m[i][0], [[chem_Mg[0], data_Mg], [chem_Si[0], data_Si], [chem_O[0], data_O]]])
887
+ return data
888
+ #
889
+ def analyze_ferrosilite(self): # FeSiO3
890
+ # input = n
891
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
892
+ chem_Fe = elements.Fe(self)
893
+ chem_Si = elements.Si(self)
894
+ chem_O = elements.O(self)
895
+ #
896
+ data = []
897
+ M = round(chem_Fe[2] + chem_Si[2] + 3*chem_O[2], 3)
898
+ w_Fe = (chem_Fe[2])/M
899
+ w_Si = (chem_Si[2])/M
900
+ w_O = (chem_O[2])/M
901
+ #
902
+ for i in range(0, len(self.m)):
903
+ for j in range(2, len(self.m[i])):
904
+ if self.m[i][j][0] == "Fs":
905
+ data_Fe = w_Fe*self.m[i][j][1]
906
+ data_Si = w_Si*self.m[i][j][1]
907
+ data_O = w_O*self.m[i][j][1]
908
+ data.append([self.m[i][0], [[chem_Fe[0], data_Fe], [chem_Si[0], data_Si], [chem_O[0], data_O]]])
909
+ return data
910
+ #
911
+ def analyze_olivine(self, sequences): # (Mg,Fe,Mn)2 Si O4
912
+ # input = n
913
+ # [symbol, atomic number, atomic mass, molar volume, density, bulk modulus, shear modulus, young's modulus, vP, vS]
914
+ chem_O = elements.O(self)
915
+ chem_Mg = elements.Mg(self)
916
+ chem_Si = elements.Si(self)
917
+ chem_Mn = elements.Mn(self)
918
+ chem_Fe = elements.Fe(self)
919
+ self.sequences = sequences
920
+ #
921
+ data = []
922
+ for i in range(0, len(self.sequences)):
923
+ for j in range(0, len(self.sequences[i][9])):
924
+ if self.sequences[i][9][j][0] == "Ol":
925
+ M = self.sequences[i][9][j][2]
926
+ w_O = (chem_O[2])/M
927
+ w_Mg = (chem_Mg[2])/M
928
+ w_Si = (chem_Si[2])/M
929
+ w_Mn = (chem_Mn[2])/M
930
+ w_Fe = (chem_Fe[2])/M
931
+ #
932
+ for i in range(0, len(self.m)):
933
+ for j in range(2, len(self.m[i])):
934
+ if self.m[i][j][0] == "Ol":
935
+ data_O = w_O*self.m[i][j][1]
936
+ data_Mg = w_Mg*self.m[i][j][1]
937
+ data_Si = w_Si*self.m[i][j][1]
938
+ data_Mn = w_Mn*self.m[i][j][1]
939
+ data_Fe = w_Fe*self.m[i][j][1]
940
+ data.append([self.m[i][0], [[chem_O[0], data_O], [chem_Mg[0], data_Mg], [chem_Si[0], data_Si], [chem_Mn[0], data_Mn], [chem_Fe[0], data_Fe]]])
941
+ return data
942
+ #
943
+ class Fractions:
944
+ #
945
+ def __init__(self,):
946
+ pass
947
+ #
948
+ def calculate_volume_fraction(self, mineralogy, w):
949
+ self.mineralogy = mineralogy
950
+ self.w = w
951
+ #
952
+ V0 = np.sum([self.w[i]/self.mineralogy[i][2] for i in range(len(self.mineralogy))])
953
+ #
954
+ phi = []
955
+ for i in range(len(self.mineralogy)):
956
+ phi.append(self.w[i]/(self.mineralogy[i][2]*V0))
957
+ #
958
+ return phi
959
+ #
960
+ class MineralChemistry():
961
+ #
962
+ def __init__(self, mineral=None, traces=None, w_traces=None, molar_mass_pure=None, majors=None):
963
+ self.mineral = mineral
964
+ self.traces = traces
965
+ self.w_traces = w_traces # [ [Atom name, amount] ]
966
+ self.molar_mass_pure = molar_mass_pure
967
+ self.majors = majors
968
+ self.compounds = [["H", ["H2O", 2, 1, "O"]], ["Li", ["Li2O", 2, 1, "O"]], ["B", ["B2O3", 2, 3, "O"]],
969
+ ["Na", ["Na2O", 2, 1, "O"]], ["Mg", ["MgO", 1, 1, "O"]], ["Al", ["Al2O3", 2, 3, "O"]],
970
+ ["Si", ["SiO2", 1, 2, "O"]], ["K", ["K2O", 2, 1, "O"]], ["Ti", ["TiO2", 1, 2, "O"]],
971
+ ["Fe", ["Fe2O3", 2, 3, "O"]], ["Cu", ["CuO", 1, 1, "O"]], ["Ga", ["Ga2O3", 2, 3, "O"]],
972
+ ["Ge", ["GeO2", 1, 2, "O"]], ["As", ["As2O3", 2, 3, "O"]], ["Ag", ["Ag2O", 2, 1, "O"]],
973
+ ["Sn", ["SnO2", 1, 2, "O"]]]
974
+ #
975
+ def calculate_molar_mass_compounds(self):
976
+ molar_mass_compounds = []
977
+ for item in self.compounds:
978
+ for element in self.traces:
979
+ if element in item:
980
+ molar_mass_trace_compound = item[1][1]*PeriodicSystem(name=item[0]).get_data()[2] + item[1][2]*\
981
+ PeriodicSystem(name=item[1][-1]).get_data()[2]
982
+ molar_mass_compounds.append([item[0], item[1], molar_mass_trace_compound])
983
+ return molar_mass_compounds
984
+ #
985
+ def calculate_molar_volume(self, volume_cell, z):
986
+ N_A = const.physical_constants["Avogadro constant"][0]
987
+ V_m = (N_A * volume_cell)/(z)
988
+ #
989
+ return V_m
990
+ #
991
+ def calculate_molar_mass(self):
992
+ molar_mass = 0
993
+ molar_masses = []
994
+ if len(self.w_traces) > 0:
995
+ molar_mass_tracer = MineralChemistry(traces=self.w_traces[:, 0]).calculate_molar_mass_compounds()
996
+ for i in range(len(self.w_traces)):
997
+ molar_mass += self.w_traces[i][2]*molar_mass_tracer[i][2]
998
+ molar_masses.append(round(self.w_traces[i][2]*molar_mass_tracer[i][2], 6))
999
+ molar_masses.append(round((1-np.sum(self.w_traces[:, 2]))*self.molar_mass_pure, 6))
1000
+ molar_mass += (1-np.sum(self.w_traces[:, 2]))*self.molar_mass_pure
1001
+ else:
1002
+ molar_mass += self.molar_mass_pure
1003
+ for i in range(len(self.majors)):
1004
+ molar_masses.append(round(self.majors[i][2]*self.majors[i][3], 6))
1005
+ #
1006
+ amounts_helper = []
1007
+ helper_sum = 0
1008
+ amounts = []
1009
+ if len(self.w_traces) > 0:
1010
+ for i in range(len(self.w_traces)):
1011
+ helper_sum += self.w_traces[i][2]*molar_mass
1012
+ amounts_helper.append([self.w_traces[i][0], helper_sum])
1013
+ amounts.append([self.w_traces[i][0], self.w_traces[i][1], round(self.w_traces[i][2], 6)])
1014
+ for i in range(len(self.majors)):
1015
+ if self.majors[i][0] != "O":
1016
+ helper_sum += (1-np.sum(self.w_traces[:, 2]))*self.majors[i][3]
1017
+ amounts_helper.append([self.majors[i][0], helper_sum])
1018
+ amounts.append([self.majors[i][0], self.majors[i][1], round((1-np.sum(self.w_traces[:, 2]))*
1019
+ self.majors[i][3]/molar_mass, 6)])
1020
+ else:
1021
+ pass
1022
+ amounts_helper.append(["O", molar_mass-helper_sum])
1023
+ amounts.append(["O", 8, round(amounts_helper[-1][1]/molar_mass, 6)])
1024
+ else:
1025
+ for i in range(len(self.majors)):
1026
+ amounts.append([self.majors[i][0], self.majors[i][1], round((self.majors[i][2]*
1027
+ self.majors[i][3])/self.molar_mass_pure, 6)])
1028
+ amounts = np.array(amounts, dtype=object)
1029
+ amounts = amounts[amounts[:, 1].argsort()]
1030
+ amounts = amounts.tolist()
1031
+ #
1032
+ return molar_mass, amounts
1033
+ #
1034
+ class Compounds:
1035
+ #
1036
+ def __init__(self, formula):
1037
+ self.formula = formula
1038
+ #
1039
+ def split_formula(self):
1040
+ compound = {}
1041
+ chemistry = {}
1042
+ for item in self.formula:
1043
+ key = re.search(r"([A-Z][a-z]?)(\d*)([A-Z][a-z]?)(\d*)?", item)
1044
+ if key == None:
1045
+ key = re.search(r"([A-Z][a-z]?)(\d*)", item)
1046
+ if len(key.groups()) == 4:
1047
+ compound[key.group()] = {}
1048
+ compound[key.group()]["Total"] = 0
1049
+ chemistry[key.group(1)] = PeriodicSystem(name=key.group(1)).get_data()[2]
1050
+ if key.group(3) not in chemistry:
1051
+ chemistry[key.group(3)] = PeriodicSystem(name=key.group(3)).get_data()[2]
1052
+ #
1053
+ if key.group(2) == "":
1054
+ compound[key.group()][key.group(1)] = [1, PeriodicSystem(name=key.group(1)).get_data()[2]]
1055
+ compound[key.group()]["Total"] += round(1*chemistry[key.group(1)], 3)
1056
+ else:
1057
+ compound[key.group()][key.group(1)] = [int(key.group(2)), PeriodicSystem(name=key.group(1)).get_data()[2]]
1058
+ compound[key.group()]["Total"] += round(int(key.group(2))*PeriodicSystem(name=key.group(1)).get_data()[2], 3)
1059
+ if key.group(4) == "":
1060
+ compound[key.group()][key.group(3)] = [1, PeriodicSystem(name=key.group(3)).get_data()[2]]
1061
+ compound[key.group()]["Total"] += round(1*chemistry[key.group(3)], 3)
1062
+ else:
1063
+ compound[key.group()][key.group(3)] = [int(key.group(4)), PeriodicSystem(name=key.group(3)).get_data()[2]]
1064
+ compound[key.group()]["Total"] += round(int(key.group(4))*PeriodicSystem(name=key.group(3)).get_data()[2], 3)
1065
+ #
1066
+ compound[key.group()]["Total"] = round(compound[key.group()]["Total"], 3)
1067
+ compound[key.group()][key.group(1)].append(
1068
+ compound[key.group()][key.group(1)][0]*chemistry[key.group(1)]/compound[key.group()]["Total"])
1069
+ compound[key.group()][key.group(3)].append(compound[key.group()][key.group(3)][0]*
1070
+ chemistry[key.group(3)]/compound[key.group()]["Total"])
1071
+ elif len(key.groups()) == 2:
1072
+ compound[key.group()] = {}
1073
+ compound[key.group()]["Total"] = 0
1074
+ chemistry[key.group(1)] = PeriodicSystem(name=key.group(1)).get_data()[2]
1075
+ #
1076
+ if key.group(2) == "":
1077
+ compound[key.group()][key.group(1)] = [1, PeriodicSystem(name=key.group(1)).get_data()[2]]
1078
+ compound[key.group()]["Total"] += round(1*chemistry[key.group(1)], 3)
1079
+ else:
1080
+ compound[key.group()][key.group(1)] = [int(key.group(2)), PeriodicSystem(name=key.group(1)).get_data()[2]]
1081
+ compound[key.group()]["Total"] += round(int(key.group(2))*PeriodicSystem(name=key.group(1)).get_data()[2], 3)
1082
+ #
1083
+ compound[key.group()]["Total"] = round(compound[key.group()]["Total"], 3)
1084
+ compound[key.group()][key.group(1)].append(round(compound[key.group()][key.group(1)][0]*chemistry[key.group(1)]/compound[key.group()]["Total"], 4))
1085
+ #
1086
+ return compound
1087
+ #
1088
+ class TraceElements:
1089
+ #
1090
+ def __init__(self, tracer):
1091
+ self.traces_data = tracer
1092
+ #
1093
+ def calculate_composition_oxides(self, var_oxides, var_composition, var_mineral, var_elements):
1094
+ ## Split Formulas
1095
+ compounds_splitted = Compounds(formula=var_oxides).split_formula()
1096
+ #
1097
+ cond_w = False
1098
+ cond_x = False
1099
+ while cond_w == False and cond_x == False:
1100
+ w_total = 0
1101
+ x_total = 0
1102
+ M = 0
1103
+ #
1104
+ for oxide in var_composition:
1105
+ M += var_composition[oxide]*10**(-6)*compounds_splitted[oxide]["Total"]
1106
+ element_list = np.sort(var_elements)
1107
+ final_comp = {}
1108
+ for element in element_list:
1109
+ final_comp[element] = {}
1110
+ final_comp[element]["w"] = 0
1111
+ final_comp[element]["x"] = 0
1112
+ for oxide in var_composition:
1113
+ for element in element_list:
1114
+ if element in compounds_splitted[oxide]:
1115
+ final_comp[element]["w"] += round(var_composition[oxide]*10**(-6)*compounds_splitted[oxide][element][2], 6)
1116
+ final_comp[element]["x"] += round(var_composition[oxide]*10**(-6)*compounds_splitted[oxide][element][0], 6)
1117
+ #
1118
+ if var_mineral == "Quartz":
1119
+ final_comp["O"]["w"] = 1
1120
+ final_comp["O"]["x"] = 2
1121
+ final_comp["Si"]["x"] = 1
1122
+ for element in final_comp:
1123
+ if element != "O":
1124
+ final_comp["O"]["w"] -= final_comp[element]["w"]
1125
+ if element != "Si":
1126
+ final_comp["Si"]["x"] -= final_comp[element]["x"]
1127
+ #
1128
+ elif var_mineral == "Magnetite":
1129
+ final_comp["O"]["w"] = 1
1130
+ final_comp["O"]["x"] = 4
1131
+ final_comp["Fe"]["x"] = 3
1132
+ for element in final_comp:
1133
+ if element != "O":
1134
+ final_comp["O"]["w"] -= final_comp[element]["w"]
1135
+ if element != "Fe":
1136
+ final_comp["Fe"]["x"] -= final_comp[element]["x"]
1137
+ #
1138
+ elif var_mineral == "Boehmite":
1139
+ final_comp["O"]["w"] = 1
1140
+ final_comp["H"]["x"] = 1
1141
+ final_comp["O"]["x"] = 2
1142
+ final_comp["Al"]["x"] = 1
1143
+ for element in final_comp:
1144
+ if element != "O":
1145
+ final_comp["O"]["w"] -= final_comp[element]["w"]
1146
+ if element not in ["Al", "H"]:
1147
+ final_comp["Al"]["x"] -= final_comp[element]["x"]
1148
+ #
1149
+ for element in final_comp:
1150
+ final_comp[element]["w"] = round(final_comp[element]["w"], 6)
1151
+ final_comp[element]["x"] = round(final_comp[element]["x"], 6)
1152
+ w_total += final_comp[element]["w"]
1153
+ x_total += final_comp[element]["x"]
1154
+ #
1155
+ if np.isclose(w_total, 1.0000) == True:
1156
+ cond_w = True
1157
+ #
1158
+ if var_mineral == "Quartz":
1159
+ if np.isclose(x_total, 3.0000) == True:
1160
+ cond_x = True
1161
+ elif var_mineral == "Magnetite":
1162
+ if np.isclose(x_total, 7.0000) == True:
1163
+ cond_x = True
1164
+ elif var_mineral == "Boehmite":
1165
+ if np.isclose(x_total, 4.0000) == True:
1166
+ cond_x = True
1167
+ #
1168
+ return final_comp
1169
+ #
1170
+ def calculate_composition_sulfides(self, var_elements, var_composition, var_mineral, var_x=None):
1171
+ cond_w = False
1172
+ cond_x = False
1173
+ while cond_w == False and cond_x == False:
1174
+ w_total = 0
1175
+ x_total = 0
1176
+ M = 0
1177
+ #
1178
+ for element in var_composition:
1179
+ M += var_composition[element]*10**(-6)
1180
+ element_list = np.sort(var_elements)
1181
+ final_comp = {}
1182
+ for element in element_list:
1183
+ final_comp[element] = {}
1184
+ final_comp[element]["w"] = 0
1185
+ final_comp[element]["x"] = 0
1186
+ for element in element_list:
1187
+ final_comp[element]["w"] += round(
1188
+ var_composition[element]*10**(-6), 6)
1189
+ final_comp[element]["x"] += round(
1190
+ var_composition[element]*10**(-6), 6)
1191
+ #
1192
+ if var_mineral == "Cobaltite":
1193
+ final_comp["S"]["w"] = 1
1194
+ final_comp["S"]["x"] = 1
1195
+ final_comp["As"]["x"] = 1
1196
+ final_comp["Co"]["x"] = 1
1197
+ for element in final_comp:
1198
+ if element != "S":
1199
+ final_comp["S"]["w"] -= final_comp[element]["w"]
1200
+ if element in ["Sb", "Fe"]:
1201
+ final_comp["As"]["x"] -= final_comp[element]["x"]
1202
+ elif element in ["Cu", "Pb", "Ni"]:
1203
+ final_comp["Co"]["x"] -= final_comp[element]["x"]
1204
+ #
1205
+ if var_mineral == "Marmatite":
1206
+ final_comp["S"]["w"] = 1
1207
+ final_comp["S"]["x"] = 1
1208
+ final_comp["Fe"]["x"] = var_x
1209
+ final_comp["Zn"]["x"] = 1 - var_x
1210
+ for element in final_comp:
1211
+ if element != "S":
1212
+ final_comp["S"]["w"] -= final_comp[element]["w"]
1213
+ if element in ["Mn", "Cd", "Hg", "In", "Tl", "Ga", "Ge", "Sb", "Sn", "Pb", "Ag", "Co"]:
1214
+ final_comp["Zn"]["x"] -= final_comp[element]["x"]
1215
+ #
1216
+ for element in final_comp:
1217
+ final_comp[element]["w"] = round(final_comp[element]["w"], 6)
1218
+ final_comp[element]["x"] = round(final_comp[element]["x"], 6)
1219
+ w_total += final_comp[element]["w"]
1220
+ x_total += final_comp[element]["x"]
1221
+ #
1222
+ if np.isclose(w_total, 1.0000) == True:
1223
+ cond_w = True
1224
+ #
1225
+ if var_mineral == "Cobaltite":
1226
+ if np.isclose(x_total, 3.0000) == True:
1227
+ cond_x = True
1228
+ elif var_mineral == "Marmatite":
1229
+ if np.isclose(x_total, 2.0000) == True:
1230
+ cond_x = True
1231
+ #
1232
+ return final_comp
1233
+
1234
+ def calculate_composition_quartz(self):
1235
+ parts_qz = 1000000
1236
+ oxides = ["SiO2"]
1237
+
1238
+ cond_w = 0
1239
+ cond_x = 0
1240
+ while cond_w == False and cond_x == False:
1241
+ w_total = 0
1242
+ x_total = 0
1243
+ #
1244
+ element_list = ["O", "Si"]
1245
+ composition = {}
1246
+ composition[oxides[0]] = parts_qz
1247
+ #
1248
+ trace_groups = {}
1249
+ trace_groups["W"] = []
1250
+ trace_groups["X"] = []
1251
+ trace_groups["Y"] = []
1252
+ trace_groups["Z"] = []
1253
+ trace_combinations = {}
1254
+ trace_combinations["singles"] = []
1255
+ trace_combinations["couples"] = []
1256
+ trace_combinations["individual"] = []
1257
+ if type(self.traces_data) == dict:
1258
+ for tracer in list(self.traces_data.keys()):
1259
+ if tracer in ["Ti", "Ge", "Sn"]:
1260
+ element_list.append(tracer)
1261
+ compound = tracer+str("O2")
1262
+ trace_groups["X"].append(compound)
1263
+ trace_combinations["singles"].append([compound])
1264
+ elif tracer in ["Al", "Fe", "B", "As", "Ga"]:
1265
+ element_list.append(tracer)
1266
+ compound = tracer+str("2O3")
1267
+ trace_groups["Y"].append(compound)
1268
+ trace_combinations["couples"].append([compound])
1269
+ elif tracer in ["H", "Li", "Na", "Ag", "K"]:
1270
+ element_list.append(tracer)
1271
+ compound = tracer+str("2O")
1272
+ trace_groups["Z"].append(compound)
1273
+ elif tracer in ["Mg", "Be", "Ca", "Mn", "Cu", "Zn"]:
1274
+ element_list.append(tracer)
1275
+ compound = tracer+str("O")
1276
+ trace_groups["W"].append(compound)
1277
+ trace_combinations["couples"].append([compound])
1278
+ #
1279
+ trace_combinations["individual"].append([tracer, compound])
1280
+ #
1281
+ for index_y, couple in enumerate(trace_combinations["couples"], start=0):
1282
+ for index_z, item_z in enumerate(trace_groups["Z"], start=0):
1283
+ if item_z not in couple and index_y == index_z:
1284
+ if len(couple) == 2:
1285
+ del couple[-1]
1286
+ if couple[0] in trace_groups["W"]:
1287
+ key = re.search(r"([A-Z][a-z]?)(\d*)([A-Z][a-z]?)(\d*)?", item_z)
1288
+ couple.append(key.group(1)+key.group(2))
1289
+ else:
1290
+ couple.append(item_z)
1291
+ elif item_z not in couple and len(couple) == 1 and index_y-index_z != 1:
1292
+ if couple[0] in trace_groups["W"]:
1293
+ key = re.search(r"([A-Z][a-z]?)(\d*)([A-Z][a-z]?)(\d*)?", item_z)
1294
+ couple.append(key.group(1)+key.group(2))
1295
+ else:
1296
+ couple.append(item_z)
1297
+ #
1298
+ for key in trace_combinations:
1299
+ if key != "individual":
1300
+ pass
1301
+ else:
1302
+ for item in trace_combinations[key]:
1303
+ trace_element = item[0]
1304
+ compound = item[1]
1305
+ oxides.append(compound)
1306
+ val_min = self.traces_data[trace_element]["Min"]
1307
+ val_max = self.traces_data[trace_element]["Max"]
1308
+ mean = (val_min + val_max)/2
1309
+ sigma = (mean - val_min)/3
1310
+ #
1311
+ condition = False
1312
+ while condition == False:
1313
+ amount_ppm = int(np.random.normal(loc=mean, scale=sigma, size=1)[0])
1314
+ if amount_ppm >= 0:
1315
+ condition = True
1316
+
1317
+ composition[compound] = amount_ppm
1318
+ composition[oxides[0]] -= amount_ppm
1319
+ #
1320
+ # print("Groups:", trace_groups)
1321
+ # print("Families:", trace_combinations)
1322
+ #
1323
+ results = Compounds(formula=oxides).split_formula()
1324
+ # print("Composition:", composition)
1325
+ # print("Results:", results)
1326
+ M = 0
1327
+ for oxide in composition:
1328
+ M += composition[oxide]*10**(-6) * results[oxide]["Total"]
1329
+ element_list = np.sort(element_list)
1330
+ final_comp = {}
1331
+ for element in element_list:
1332
+ final_comp[element] = {}
1333
+ final_comp[element]["w"] = 0
1334
+ final_comp[element]["x"] = 0
1335
+ for oxide in composition:
1336
+ for element in element_list:
1337
+ if element in results[oxide]:
1338
+ final_comp[element]["w"] += round(composition[oxide]*10**(-6) * results[oxide][element][2], 6)
1339
+ final_comp[element]["x"] += round(composition[oxide]*10**(-6)*results[oxide][element][0], 6)
1340
+ final_comp["O"]["w"] = 1
1341
+ final_comp["O"]["x"] = 2
1342
+ final_comp["Si"]["x"] = 1
1343
+ for element in final_comp:
1344
+ if element != "O":
1345
+ final_comp["O"]["w"] -= final_comp[element]["w"]
1346
+ if element != "Si":
1347
+ final_comp["Si"]["x"] -= final_comp[element]["x"]
1348
+ for element in final_comp:
1349
+ final_comp[element]["w"] = round(final_comp[element]["w"], 6)
1350
+ final_comp[element]["x"] = round(final_comp[element]["x"], 6)
1351
+ w_total += final_comp[element]["w"]
1352
+ x_total += final_comp[element]["x"]
1353
+ #
1354
+ if w_total == 1:
1355
+ cond_w = True
1356
+ if x_total == 3:
1357
+ cond_x = True
1358
+
1359
+ #print("Final:", final_comp)
1360
+ #print("Final:", round(w_total, 6), round(x_total, 6))
1361
+ #
1362
+ return final_comp
1363
+
1364
+ def calculate_composition_orthoclase(self):
1365
+ parts_mineral = 1000000
1366
+ oxides = ["Al2O3", "SiO2", "K2O"]
1367
+
1368
+ cond_w = 0
1369
+ cond_x = 0
1370
+ while cond_w == False and cond_x == False:
1371
+ w_total = 0
1372
+ x_total = 0
1373
+
1374
+ element_list = ["O", "Al", "Si", "K"]
1375
+ composition = {}
1376
+ composition["Al2O3"] = int(0.1832*parts_mineral)
1377
+ composition["SiO2"] = int(0.6476*parts_mineral)
1378
+ composition["K2O"] = int(0.1692*parts_mineral)
1379
+
1380
+ trace_groups = {}
1381
+ trace_groups["W"] = []
1382
+ trace_groups["Y"] = []
1383
+ trace_groups["Z"] = []
1384
+ trace_combinations = {}
1385
+ trace_combinations["singles"] = []
1386
+ trace_combinations["couples"] = []
1387
+ trace_combinations["individual"] = []
1388
+
1389
+ if type(self.traces_data) == dict:
1390
+ for tracer in list(self.traces_data.keys()):
1391
+ if tracer in ["Ba", "Ca", "Fe"]:
1392
+ element_list.append(tracer)
1393
+ compound = tracer+str("O")
1394
+ trace_groups["W"].append(compound)
1395
+ trace_combinations["couples"].append([compound])
1396
+ charge = 2
1397
+ elif tracer in ["Na", "Rb"]:
1398
+ element_list.append(tracer)
1399
+ compound = tracer+str("2O")
1400
+ trace_groups["Z"].append(compound)
1401
+ charge = 1
1402
+
1403
+ trace_combinations["individual"].append([tracer, compound, charge])
1404
+
1405
+ for index_y, couple in enumerate(trace_combinations["couples"], start=0):
1406
+ for index_z, item_z in enumerate(trace_groups["Z"], start=0):
1407
+ if item_z not in couple and index_y == index_z:
1408
+ if len(couple) == 2:
1409
+ del couple[-1]
1410
+ if couple[0] in trace_groups["W"]:
1411
+ key = re.search(r"([A-Z][a-z]?)(\d*)([A-Z][a-z]?)(\d*)?", item_z)
1412
+ couple.append(key.group(1)+key.group(2))
1413
+ else:
1414
+ couple.append(item_z)
1415
+ elif item_z not in couple and len(couple) == 1 and index_y-index_z != 1:
1416
+ if couple[0] in trace_groups["W"]:
1417
+ key = re.search(r"([A-Z][a-z]?)(\d*)([A-Z][a-z]?)(\d*)?", item_z)
1418
+ couple.append(key.group(1)+key.group(2))
1419
+ else:
1420
+ couple.append(item_z)
1421
+
1422
+ for key in trace_combinations:
1423
+ if key != "individual":
1424
+ pass
1425
+ else:
1426
+ for item in trace_combinations[key]:
1427
+ trace_element = item[0]
1428
+ compound = item[1]
1429
+ charge = item[2]
1430
+ oxides.append(compound)
1431
+ val_min = self.traces_data[trace_element]["Min"]
1432
+ val_max = self.traces_data[trace_element]["Max"]
1433
+ mean = (val_min + val_max)/2
1434
+ sigma = (mean - val_min)/3
1435
+
1436
+ condition = False
1437
+ while condition == False:
1438
+ amount_ppm = int(np.random.normal(loc=mean, scale=sigma, size=1)[0])
1439
+ if amount_ppm >= 0:
1440
+ condition = True
1441
+
1442
+ composition[compound] = amount_ppm
1443
+ composition["K2O"] -= amount_ppm
1444
+ #
1445
+ # print("Groups:", trace_groups)
1446
+ # print("Families:", trace_combinations)
1447
+ #
1448
+ results = Compounds(formula=oxides).split_formula()
1449
+ #print("Composition:", composition)
1450
+ #print("Results:", results)
1451
+ M = 0
1452
+ for oxide in composition:
1453
+ M += composition[oxide]*10**(-6) * results[oxide]["Total"]
1454
+ element_list = np.sort(element_list)
1455
+ final_comp = {}
1456
+ for element in element_list:
1457
+ final_comp[element] = {}
1458
+ final_comp[element]["w"] = 0
1459
+ final_comp[element]["x"] = 0
1460
+ for oxide in composition:
1461
+ for element in element_list:
1462
+ if element in results[oxide]:
1463
+ final_comp[element]["w"] += round(composition[oxide]*10**(-6) * results[oxide][element][2], 6)
1464
+ final_comp[element]["x"] += round(composition[oxide]*10**(-6)*results[oxide][element][0], 6)
1465
+ final_comp["O"]["w"] = 1
1466
+ final_comp["O"]["x"] = 8
1467
+ final_comp["Al"]["x"] = 1
1468
+ final_comp["Si"]["x"] = 3
1469
+ final_comp["K"]["x"] = 1
1470
+ for element in final_comp:
1471
+ if element != "O":
1472
+ final_comp["O"]["w"] -= final_comp[element]["w"]
1473
+ if element not in ["K", "Al", "Si"]:
1474
+ final_comp["K"]["x"] -= final_comp[element]["x"]
1475
+ for element in final_comp:
1476
+ final_comp[element]["w"] = round(final_comp[element]["w"], 6)
1477
+ final_comp[element]["x"] = round(final_comp[element]["x"], 6)
1478
+ w_total += final_comp[element]["w"]
1479
+ x_total += final_comp[element]["x"]
1480
+ #
1481
+ if w_total == 1:
1482
+ cond_w = True
1483
+ if x_total == 13:
1484
+ cond_x = True
1485
+
1486
+ #print("Final:", final_comp)
1487
+ #print("Final:", round(w_total, 6), round(x_total, 6))
1488
+ #
1489
+ return final_comp
1490
+
1491
+ def calculate_composition_illite(self):
1492
+ parts_mineral = 1000000
1493
+ oxides = ["H2O", "Al2O3", "SiO2", "K2O"]
1494
+
1495
+ cond_w = 0
1496
+ cond_x = 0
1497
+ while cond_w == False and cond_x == False:
1498
+ w_total = 0
1499
+ x_total = 0
1500
+
1501
+ element_list = ["H", "O", "Al", "Si", "K"]
1502
+ composition = {}
1503
+ composition["H2O"] = int(0.0468*parts_mineral)
1504
+ composition["Al2O3"] = int(0.3509*parts_mineral)
1505
+ composition["SiO2"] = int(0.5228*parts_mineral)
1506
+ composition["K2O"] = int(0.0795*parts_mineral)
1507
+
1508
+ trace_groups = {}
1509
+ trace_groups["W"] = []
1510
+ trace_groups["Y"] = []
1511
+ trace_groups["Z"] = []
1512
+ trace_combinations = {}
1513
+ trace_combinations["singles"] = []
1514
+ trace_combinations["couples"] = []
1515
+ trace_combinations["individual"] = []
1516
+
1517
+ if type(self.traces_data) == dict:
1518
+ for tracer in list(self.traces_data.keys()):
1519
+ if tracer in ["Mg", "Fe"]:
1520
+ element_list.append(tracer)
1521
+ compound = tracer+str("O")
1522
+ trace_groups["W"].append(compound)
1523
+ trace_combinations["couples"].append([compound])
1524
+ charge = 2
1525
+
1526
+ trace_combinations["individual"].append([tracer, compound, charge])
1527
+
1528
+ for index_y, couple in enumerate(trace_combinations["couples"], start=0):
1529
+ for index_z, item_z in enumerate(trace_groups["Z"], start=0):
1530
+ if item_z not in couple and index_y == index_z:
1531
+ if len(couple) == 2:
1532
+ del couple[-1]
1533
+ if couple[0] in trace_groups["W"]:
1534
+ key = re.search(r"([A-Z][a-z]?)(\d*)([A-Z][a-z]?)(\d*)?", item_z)
1535
+ couple.append(key.group(1)+key.group(2))
1536
+ else:
1537
+ couple.append(item_z)
1538
+ elif item_z not in couple and len(couple) == 1 and index_y-index_z != 1:
1539
+ if couple[0] in trace_groups["W"]:
1540
+ key = re.search(r"([A-Z][a-z]?)(\d*)([A-Z][a-z]?)(\d*)?", item_z)
1541
+ couple.append(key.group(1)+key.group(2))
1542
+ else:
1543
+ couple.append(item_z)
1544
+
1545
+ for key in trace_combinations:
1546
+ if key != "individual":
1547
+ pass
1548
+ else:
1549
+ for item in trace_combinations[key]:
1550
+ trace_element = item[0]
1551
+ compound = item[1]
1552
+ charge = item[2]
1553
+ oxides.append(compound)
1554
+ val_min = self.traces_data[trace_element]["Min"]
1555
+ val_max = self.traces_data[trace_element]["Max"]
1556
+ mean = (val_min + val_max)/2
1557
+ sigma = (mean - val_min)/3
1558
+
1559
+ condition = False
1560
+ while condition == False:
1561
+ amount_ppm = int(np.random.normal(loc=mean, scale=sigma, size=1)[0])
1562
+ if amount_ppm >= 0:
1563
+ condition = True
1564
+
1565
+ composition[compound] = amount_ppm
1566
+ composition["K2O"] -= amount_ppm
1567
+ #
1568
+ # print("Groups:", trace_groups)
1569
+ # print("Families:", trace_combinations)
1570
+ #
1571
+ results = Compounds(formula=oxides).split_formula()
1572
+ #print("Composition:", composition)
1573
+ #print("Results:", results)
1574
+ M = 0
1575
+ for oxide in composition:
1576
+ M += composition[oxide]*10**(-6) * results[oxide]["Total"]
1577
+ element_list = np.sort(element_list)
1578
+ final_comp = {}
1579
+ for element in element_list:
1580
+ final_comp[element] = {}
1581
+ final_comp[element]["w"] = 0
1582
+ final_comp[element]["x"] = 0
1583
+ for oxide in composition:
1584
+ for element in element_list:
1585
+ if element in results[oxide]:
1586
+ final_comp[element]["w"] += round(composition[oxide]*10**(-6) * results[oxide][element][2], 6)
1587
+ final_comp[element]["x"] += round(composition[oxide]*10**(-6)*results[oxide][element][0], 6)
1588
+ final_comp["O"]["w"] = 1
1589
+ final_comp["O"]["x"] = 12
1590
+ final_comp["Al"]["x"] = 2.65
1591
+ final_comp["Si"]["x"] = 3.35
1592
+ final_comp["K"]["x"] = 0.65
1593
+ final_comp["H"]["x"] = 2
1594
+ for element in final_comp:
1595
+ if element != "O":
1596
+ final_comp["O"]["w"] -= final_comp[element]["w"]
1597
+ if element not in ["K", "Al", "Si", "H"]:
1598
+ final_comp["K"]["x"] -= final_comp[element]["x"]
1599
+ for element in final_comp:
1600
+ final_comp[element]["w"] = round(final_comp[element]["w"], 6)
1601
+ final_comp[element]["x"] = round(final_comp[element]["x"], 6)
1602
+ w_total += final_comp[element]["w"]
1603
+ x_total += final_comp[element]["x"]
1604
+ #
1605
+ if w_total == 1:
1606
+ cond_w = True
1607
+ if x_total == 20.65:
1608
+ cond_x = True
1609
+
1610
+ #print("Final:", final_comp)
1611
+ #print("Final:", round(w_total, 6), round(x_total, 6))
1612
+ #
1613
+ return final_comp
1614
+ #
1615
+ def calculate_composition_apatite_f(self):
1616
+ parts_ap = 1000000
1617
+ oxides = ["CaO", "PO4"]
1618
+ element_list = ["O", "Ca", "P", "F"]
1619
+ #
1620
+ cond_w = 0
1621
+ cond_x = 0
1622
+ while cond_w == False and cond_x == False:
1623
+ w_total = 0
1624
+ x_total = 0
1625
+ #
1626
+ element_list = ["O", "Ca", "P", "F"]
1627
+ composition = {}
1628
+ composition[oxides[0]] = parts_ap
1629
+ #
1630
+ trace_groups = {}
1631
+ trace_groups["W"] = []
1632
+ trace_groups["X"] = []
1633
+ trace_groups["Y"] = []
1634
+ trace_groups["Z"] = []
1635
+ trace_combinations = {}
1636
+ trace_combinations["singles"] = []
1637
+ trace_combinations["couples"] = []
1638
+ for tracer in self.tracer:
1639
+ if tracer in ["Ti", "Zr", "Hf", "Th"]: # 4+
1640
+ element_list.append(tracer)
1641
+ compound = tracer+str("O2")
1642
+ trace_groups["X"].append(compound)
1643
+ trace_combinations["singles"].append([compound])
1644
+ elif tracer in ["La", "Ce", "Pr", "Nd", "Sm", "Eu", "Gd", "Dy", "Y", "Er", "Cr", "As"]: # 3+
1645
+ element_list.append(tracer)
1646
+ compound = tracer+str("2O3")
1647
+ trace_groups["Y"].append(compound)
1648
+ trace_combinations["couples"].append([compound])
1649
+ elif tracer in ["Cl", "H", "Rb"]: # 1+
1650
+ element_list.append(tracer)
1651
+ compound = tracer+str("2O")
1652
+ trace_groups["Z"].append(compound)
1653
+ elif tracer in ["Mn", "Co", "Sr", "Ba", "Pb"]: # 2+
1654
+ element_list.append(tracer)
1655
+ compound = tracer+str("O")
1656
+ trace_groups["W"].append(compound)
1657
+ trace_combinations["couples"].append([compound])
1658
+ for index_y, couple in enumerate(trace_combinations["couples"], start=0):
1659
+ for index_z, item_z in enumerate(trace_groups["Z"], start=0):
1660
+ if item_z not in couple and index_y == index_z:
1661
+ if len(couple) == 2:
1662
+ del couple[-1]
1663
+ if couple[0] in trace_groups["W"]:
1664
+ key = re.search(r"([A-Z][a-z]?)(\d*)([A-Z][a-z]?)(\d*)?", item_z)
1665
+ couple.append(key.group(1)+key.group(2))
1666
+ else:
1667
+ couple.append(item_z)
1668
+ elif item_z not in couple and len(couple) == 1 and index_y-index_z != 1:
1669
+ if couple[0] in trace_groups["W"]:
1670
+ key = re.search(r"([A-Z][a-z]?)(\d*)([A-Z][a-z]?)(\d*)?", item_z)
1671
+ couple.append(key.group(1)+key.group(2))
1672
+ else:
1673
+ couple.append(item_z)
1674
+ #
1675
+ for key in trace_combinations:
1676
+ for item in trace_combinations[key]:
1677
+ amount = rd.uniform(1*10**(-6), 0.1)
1678
+ amount_ppm = int(amount*10000)
1679
+ for compound in item:
1680
+ oxides.append(compound)
1681
+ composition[compound] = amount_ppm
1682
+ composition[oxides[0]] -= amount_ppm
1683
+ item.append(amount_ppm)
1684
+ #
1685
+ #print("Groups:", trace_groups)
1686
+ #print("Families:", trace_combinations)
1687
+ #
1688
+ results = Compounds(formula=oxides).split_formula()
1689
+ #print("Composition:", composition)
1690
+ #print("Results:", results)
1691
+ M = 0
1692
+ for oxide in composition:
1693
+ M += composition[oxide]*10**(-6) * results[oxide]["Total"]
1694
+ element_list = np.sort(element_list)
1695
+ final_comp = {}
1696
+ for element in element_list:
1697
+ final_comp[element] = {}
1698
+ final_comp[element]["w"] = 0
1699
+ final_comp[element]["x"] = 0
1700
+ for oxide in composition:
1701
+ for element in element_list:
1702
+ if element in results[oxide]:
1703
+ #final_comp[element]["w"] += composition[oxide]*10**(-6) * results[oxide][element][0]*results[oxide][element][1]/M
1704
+ final_comp[element]["w"] += round(composition[oxide]*10**(-6) * results[oxide][element][2], 6)
1705
+ final_comp[element]["x"] += round(composition[oxide]*10**(-6)*results[oxide][element][0], 6)
1706
+ final_comp["O"]["w"] = 1
1707
+ final_comp["O"]["x"] = 2
1708
+ final_comp["Ca"]["x"] = 1
1709
+ for element in final_comp:
1710
+ if element != "O":
1711
+ final_comp["O"]["w"] -= final_comp[element]["w"]
1712
+ if element != "Ca":
1713
+ final_comp["Ca"]["x"] -= final_comp[element]["x"]
1714
+ for element in final_comp:
1715
+ final_comp[element]["w"] = round(final_comp[element]["w"], 6)
1716
+ final_comp[element]["x"] = round(final_comp[element]["x"], 6)
1717
+ w_total += final_comp[element]["w"]
1718
+ x_total += final_comp[element]["x"]
1719
+ #
1720
+ if w_total == 1:
1721
+ cond_w = True
1722
+ if x_total == 3:
1723
+ cond_x = True
1724
+
1725
+ #print("Final:", final_comp)
1726
+ #print("Final:", round(w_total, 6), round(x_total, 6))
1727
+ #
1728
+ return final_comp