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