PetThermoTools 0.2.37__tar.gz → 0.2.39__tar.gz

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 (25) hide show
  1. {PetThermoTools-0.2.37/src/PetThermoTools.egg-info → PetThermoTools-0.2.39}/PKG-INFO +1 -1
  2. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/GenFuncs.py +25 -0
  3. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/Melting.py +55 -18
  4. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/Path.py +8 -112
  5. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/Plotting.py +5 -4
  6. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/_version.py +1 -1
  7. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39/src/PetThermoTools.egg-info}/PKG-INFO +1 -1
  8. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/LICENSE.txt +0 -0
  9. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/README.md +0 -0
  10. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/setup.cfg +0 -0
  11. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/setup.py +0 -0
  12. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/Barom.py +0 -0
  13. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/Compositions.py +0 -0
  14. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/Holland.py +0 -0
  15. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/Installation.py +0 -0
  16. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/Liq.py +0 -0
  17. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/MELTS.py +0 -0
  18. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/Path_wrappers.py +0 -0
  19. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/PhaseDiagrams.py +0 -0
  20. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/Saturation.py +0 -0
  21. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools/__init__.py +0 -0
  22. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools.egg-info/SOURCES.txt +0 -0
  23. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools.egg-info/dependency_links.txt +0 -0
  24. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools.egg-info/requires.txt +0 -0
  25. {PetThermoTools-0.2.37 → PetThermoTools-0.2.39}/src/PetThermoTools.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PetThermoTools
3
- Version: 0.2.37
3
+ Version: 0.2.39
4
4
  Summary: PetThermoTools
5
5
  Home-page: https://github.com/gleesonm1/PetThermoTools
6
6
  Author: Matthew Gleeson
@@ -46,6 +46,31 @@ Names_MM = {'liq1': '_Liq',
46
46
  'spn1': '_Sp',
47
47
  'spn2': '_Sp2'}
48
48
 
49
+ def label_results(Result,label):
50
+ Results = Result.copy()
51
+ new_out = {}
52
+ if label == "CO2":
53
+ for r in Results:
54
+ new_out['CO2 = ' + str(Results[r]['Input']['comp']['CO2_Liq']) + ' wt%'] = Results[r].copy()
55
+ new_out = dict(sorted(new_out.items(), key=lambda x: float(x[0].split('=')[1].split(' ')[1])))
56
+ elif label == "pressure" or label == "P" or label == "P_bar":
57
+ for r in Results:
58
+ new_out['P = ' + str(Results[r]['Input']['P_bar']) + ' bars'] = Results[r].copy()
59
+ new_out = dict(sorted(new_out.items(), key=lambda x: float(x[0].split('=')[1].split(' ')[1])))
60
+ elif label == "fO2":
61
+ for r in Results:
62
+ new_out['fO2 = ' + Results[r]['Input']['fO2_buffer'] + ' ' + str(round(Results[r]['Input']['fO2_offset'],2))] = Results[r].copy()
63
+ new_out = dict(sorted(new_out.items(), key=lambda x: float(x[0].split('=')[1].split(' ')[2])))
64
+ elif label == 'H2O':
65
+ for r in Results:
66
+ new_out['H2O = ' + str(Results[r]['Input']['comp']['H2O_Liq']) + ' wt%'] = Results[r].copy()
67
+ new_out = dict(sorted(new_out.items(), key=lambda x: float(x[0].split('=')[1].split(' ')[1])))
68
+
69
+ if len(new_out) == 0:
70
+ new_out = Results.copy()
71
+
72
+ return new_out
73
+
49
74
  def supCalc(Model = "MELTSv1.0.2", bulk = None, phase = None, T_C = None, P_bar = None,
50
75
  Fe3Fet_Liq = None, H2O_Liq = None, CO2_Liq = None, fO2_buffer = None, fO2_offset = None,
51
76
  melts = None):
@@ -49,14 +49,15 @@ def AdiabaticDecompressionMelting(cores = multiprocessing.cpu_count(),
49
49
  P_path_bar = None, Frac = False, prop = None,
50
50
  fO2_buffer = None, fO2_offset = None, Fe3Fet = None, MELTS_filter = True):
51
51
 
52
- try:
53
- import pyMelt as m
54
- Lithologies = {'KLB-1': m.lithologies.matthews.klb1(),
55
- 'KG1': m.lithologies.matthews.kg1(),
56
- 'G2': m.lithologies.matthews.eclogite(),
57
- 'hz': m.lithologies.shorttle.harzburgite()}
58
- except ImportError:
59
- raise RuntimeError('You havent installed pyMelt or there is an error when importing pyMelt. pyMelt is currently required to estimate the starting point for the melting calculations.')
52
+ if Tp_Method == "pyMelt":
53
+ try:
54
+ import pyMelt as m
55
+ Lithologies = {'KLB-1': m.lithologies.matthews.klb1(),
56
+ 'KG1': m.lithologies.matthews.kg1(),
57
+ 'G2': m.lithologies.matthews.eclogite(),
58
+ 'hz': m.lithologies.shorttle.harzburgite()}
59
+ except ImportError:
60
+ raise RuntimeError('You havent installed pyMelt or there is an error when importing pyMelt. pyMelt is currently required to estimate the starting point for the melting calculations.')
60
61
 
61
62
  if bulk is not None and comp_lith_1 is None:
62
63
  comp_lith_1 = bulk
@@ -155,7 +156,9 @@ def AdiabaticDecompressionMelting(cores = multiprocessing.cpu_count(),
155
156
 
156
157
  return Results
157
158
 
158
- def AdiabaticMelt(q, index, *, Model = None, comp_1 = None, comp_2 = None, comp_3 = None, Tp_C = None, P_start_bar = None, P_end_bar = None, dp_bar = None, P_path_bar = None, Frac = None, fO2_buffer = None, fO2_offset = None, prop = None):
159
+ def AdiabaticMelt(q, index, *, Model = None, comp_1 = None, comp_2 = None, comp_3 = None,
160
+ Tp_C = None, P_start_bar = None, P_end_bar = None, dp_bar = None, P_path_bar = None,
161
+ Frac = None, fO2_buffer = None, fO2_offset = None, prop = None):
159
162
  '''
160
163
  Melting calculations to be performed in parallel.
161
164
 
@@ -163,21 +166,16 @@ def AdiabaticMelt(q, index, *, Model = None, comp_1 = None, comp_2 = None, comp_
163
166
  Results = {}
164
167
  if "MELTS" in Model:
165
168
  try:
166
- Results = AdiabaticDecompressionMelting_MELTS(Model = Model, comp = comp_1, Tp_C = Tp_C, P_path_bar = P_path_bar, P_start_bar = P_start_bar, P_end_bar = P_end_bar, dp_bar = dp_bar, fO2_buffer = fO2_buffer, fO2_offset = fO2_offset)
169
+ Results = AdiabaticDecompressionMelting_MELTS(Model = Model, comp = comp_1, Tp_C = Tp_C,
170
+ P_path_bar = P_path_bar, P_start_bar = P_start_bar, P_end_bar = P_end_bar, dp_bar = dp_bar,
171
+ fO2_buffer = fO2_buffer, fO2_offset = fO2_offset)
167
172
  q.put([Results, index])
168
173
  except:
169
174
  q.put([])
170
175
 
171
176
  return
172
-
173
- if Model == "Holland":
174
- # import pyMAGEMINcalc as MM
175
- # Results = MM.AdiabaticDecompressionMelting(comp = comp_1, T_p_C = Tp_C, P_start_kbar = P_start_bar/1000, P_end_kbar = P_end_bar/1000, dp_kbar = dp_bar/1000, Frac = 0)
176
- print('Note that the ability to use MAGEMin to performed adiabatic decompression melting in PetThermoTools has been temporarily disabled. The underlying issue will be fixed soon and this funciton will once again become available.')
177
- q.put([Results, index])
178
- return
179
177
 
180
- if Model == "pyMelt":
178
+ elif Model == "pyMelt":
181
179
  try:
182
180
  import pyMelt as m
183
181
  Lithologies = {'KLB-1': m.lithologies.matthews.klb1(),
@@ -239,5 +237,44 @@ def AdiabaticMelt(q, index, *, Model = None, comp_1 = None, comp_2 = None, comp_
239
237
 
240
238
  q.put([Results, index])
241
239
  return
240
+
241
+ else:
242
+ # import pyMAGEMINcalc as MM
243
+ # Results = MM.AdiabaticDecompressionMelting(comp = comp_1, T_p_C = Tp_C, P_start_kbar = P_start_bar/1000, P_end_kbar = P_end_bar/1000, dp_kbar = dp_bar/1000, Frac = 0)
244
+ # print('Note that the ability to use MAGEMin to performed adiabatic decompression melting in PetThermoTools has been temporarily disabled. The underlying issue will be fixed soon and this funciton will once again become available.')
245
+
246
+ try:
247
+ import pyMelt as m
248
+ Lithologies = {'KLB-1': m.lithologies.matthews.klb1(),
249
+ 'KG1': m.lithologies.matthews.kg1(),
250
+ 'G2': m.lithologies.matthews.eclogite(),
251
+ 'hz': m.lithologies.shorttle.harzburgite()}
252
+ except ImportError:
253
+ raise RuntimeError('You havent installed pyMelt or there is an error when importing pyMelt. pyMelt is currently required to estimate the starting point for the melting calculations.')
254
+
255
+ lz = m.lithologies.matthews.klb1()
256
+ mantle = m.mantle([lz], [1], ['Lz'])
257
+ T_start_C = mantle.adiabat(P_start_bar/10000.0, Tp_C)
258
+
259
+ from juliacall import Main as jl, convert as jlconvert
260
+
261
+ jl.seval("using MAGEMinCalc")
262
+
263
+ comp_1['O'] = comp_1['Fe3Fet_Liq']*(((159.59/2)/71.844)*comp_1['FeOt_Liq'] - comp_1['FeOt_Liq'])
264
+
265
+ if type(comp_1) == dict:
266
+ comp_julia = jl.seval("Dict")(comp_1)
267
+ else:
268
+ comp_new = comp_1.loc[i].to_dict()
269
+ comp_julia = jl.seval("Dict")(comp_new)
270
+
271
+ Output_jl = jl.MAGEMinCalc.AdiabaticDecompressionMelting(comp = comp_julia, P_start_kbar = P_start_bar/1000.0,
272
+ P_end_kbar = P_end_bar/1000.0, dp_kbar = dp_bar/1000.0,
273
+ T_start_C = T_start_C, fo2_buffer = fO2_buffer, fo2_offset = fO2_offset, Model = Model)
274
+ Results = dict(Output_jl)
275
+ # Results = stich(Results, Model = Model)
276
+
277
+ q.put([Results, index])
278
+ return
242
279
 
243
280
 
@@ -117,10 +117,8 @@ def multi_path(cores = None, Model = None, bulk = None, comp = None, Frac_solid
117
117
  Dictionary where each entry represents the results of a single calculation. Within the dictionary each single calculation is reported as a series of pandas DataFrames, displaying the composition and thermodynamic properties of each phase.
118
118
 
119
119
  '''
120
- try:
121
- from meltsdynamic import MELTSdynamic
122
- except:
123
- Warning('alphaMELTS for Python files are not on the python path. \n Please add these files to the path running \n import sys \n sys.path.append(r"insert_your_path_to_melts_here") \n You are looking for the location of the meltsdynamic.py file')
120
+ if timeout is None:
121
+ timeout = 180
124
122
 
125
123
  timeout_main = timeout
126
124
 
@@ -137,6 +135,12 @@ def multi_path(cores = None, Model = None, bulk = None, comp = None, Frac_solid
137
135
  if Model is None:
138
136
  Model == "MELTSv1.0.2"
139
137
 
138
+ if "MELTS" in Model:
139
+ try:
140
+ from meltsdynamic import MELTSdynamic
141
+ except:
142
+ Warning('alphaMELTS for Python files are not on the python path. \n Please add these files to the path running \n import sys \n sys.path.append(r"insert_your_path_to_melts_here") \n You are looking for the location of the meltsdynamic.py file')
143
+
140
144
  # if comp is entered as a pandas series, it must first be converted to a dict
141
145
  if type(comp) == pd.core.series.Series:
142
146
  comp = comp.to_dict()
@@ -357,89 +361,6 @@ def multi_path(cores = None, Model = None, bulk = None, comp = None, Frac_solid
357
361
  results = combined_results
358
362
 
359
363
  Results = stich(Res=results, multi=True, Model=Model, Frac_fluid = Frac_fluid, Frac_solid = Frac_solid)
360
-
361
- # for j in tqdm(range(len(Group))):
362
- # ps = []
363
-
364
- # if Print_suppress is None:
365
- # print("Running " + Model + " calculations " + str(int(cores*j)) + " to " + str(int(cores*j) + Group[j] - 1) + " ...", end = "", flush = True)
366
- # s = time.time()
367
-
368
- # for i in range(int(cores*j), int(cores*j + Group[j])):
369
- # if type(comp) == dict:
370
- # p = Process(target = path, args = (q, i),
371
- # kwargs = {'Model': Model, 'comp': comp, 'Frac_solid': Frac_solid, 'Frac_fluid': Frac_fluid,
372
- # 'T_C': T_C[i], 'T_path_C': T_path_C[i], 'T_start_C': T_start_C[i], 'T_end_C': T_end_C[i], 'dt_C': dt_C[i],
373
- # 'P_bar': P_bar[i], 'P_path_bar': P_path_bar[i], 'P_start_bar': P_start_bar[i], 'P_end_bar': P_end_bar[i], 'dp_bar': dp_bar[i],
374
- # 'isenthalpic': isenthalpic, 'isentropic': isentropic, 'isochoric': isochoric, 'find_liquidus': find_liquidus,
375
- # 'fO2_buffer': fO2_buffer, 'fO2_offset': fO2_offset[i], 'fluid_sat': fluid_sat, 'Crystallinity_limit': Crystallinity_limit,
376
- # 'Suppress': Suppress, 'Suppress_except': Suppress_except})
377
- # else:
378
- # p = Process(target = path, args = (q, i),
379
- # kwargs = {'Model': Model, 'comp': comp.loc[i].to_dict(), 'Frac_solid': Frac_solid, 'Frac_fluid': Frac_fluid,
380
- # 'T_C': T_C[i], 'T_path_C': T_path_C[i], 'T_start_C': T_start_C[i], 'T_end_C': T_end_C[i], 'dt_C': dt_C[i],
381
- # 'P_bar': P_bar[i], 'P_path_bar': P_path_bar[i], 'P_start_bar': P_start_bar[i], 'P_end_bar': P_end_bar[i], 'dp_bar': dp_bar[i],
382
- # 'isenthalpic': isenthalpic, 'isentropic': isentropic, 'isochoric': isochoric, 'find_liquidus': find_liquidus,
383
- # 'fO2_buffer': fO2_buffer, 'fO2_offset': fO2_offset[i], 'fluid_sat': fluid_sat, 'Crystallinity_limit': Crystallinity_limit,
384
- # 'Suppress': Suppress, 'Suppress_except': Suppress_except})
385
-
386
- # ps.append(p)
387
- # p.start()
388
-
389
- # if timeout is None:
390
- # TIMEOUT = 240
391
- # else:
392
- # TIMEOUT = timeout
393
-
394
- # start = time.time()
395
- # first = True
396
- # for p in ps:
397
- # if time.time() - start < TIMEOUT - 10:
398
- # try:
399
- # ret = q.get(timeout = TIMEOUT - (time.time()-start) + 10)
400
- # except:
401
- # ret = []
402
- # else:
403
- # if first == True:
404
- # print('Timeout Reached - this likely indicates the calculation failed. \n You can try increasing the timeout limit using the "timeout" kwarg.')
405
- # first = False
406
- # try:
407
- # ret = q.get(timeout = 10)
408
- # except:
409
- # ret = []
410
-
411
- # qs.append(ret)
412
-
413
- # TIMEOUT = 5
414
- # start = time.time()
415
- # for p in ps:
416
- # if p.is_alive():
417
- # while time.time() - start <= TIMEOUT:
418
- # if not p.is_alive():
419
- # p.join()
420
- # p.terminate()
421
- # break
422
- # time.sleep(.1)
423
- # else:
424
- # p.terminate()
425
- # p.join(5)
426
- # else:
427
- # p.join()
428
- # p.terminate()
429
-
430
- # if Print_suppress is None:
431
- # print(" Complete (time taken = " + str(round(time.time() - s,2)) + " seconds)", end = "\n", flush = True)
432
-
433
-
434
- # Results = {}
435
- # Out = {}
436
- # for i in range(len(qs)):
437
- # if len(qs[i]) > 0:
438
- # Res, index = qs[i]
439
- # Results['index = ' + str(index)] = Res
440
-
441
- #if "MELTS" in Model:
442
- # Results = stich(Results, multi = True, Model = Model, Frac_fluid = Frac_fluid, Frac_solid = Frac_solid)
443
364
 
444
365
  for r in Results:
445
366
  i = int(r.split('=')[1].strip())
@@ -464,31 +385,6 @@ def multi_path(cores = None, Model = None, bulk = None, comp = None, Frac_solid
464
385
  else:
465
386
  return Results
466
387
 
467
- def label_results(Result,label):
468
- Results = Result.copy()
469
- new_out = {}
470
- if label == "CO2":
471
- for r in Results:
472
- new_out['CO2 = ' + str(Results[r]['Input']['comp']['CO2_Liq']) + ' wt%'] = Results[r].copy()
473
- new_out = dict(sorted(new_out.items(), key=lambda x: float(x[0].split('=')[1].split(' ')[1])))
474
- elif label == "pressure" or label == "P" or label == "P_bar":
475
- for r in Results:
476
- new_out['P = ' + str(Results[r]['Input']['P_bar']) + ' bars'] = Results[r].copy()
477
- new_out = dict(sorted(new_out.items(), key=lambda x: float(x[0].split('=')[1].split(' ')[1])))
478
- elif label == "fO2":
479
- for r in Results:
480
- new_out['fO2 = ' + Results[r]['Input']['fO2_buffer'] + ' ' + str(round(Results[r]['Input']['fO2_offset'],2))] = Results[r].copy()
481
- new_out = dict(sorted(new_out.items(), key=lambda x: float(x[0].split('=')[1].split(' ')[2])))
482
- elif label == 'H2O':
483
- for r in Results:
484
- new_out['H2O = ' + str(Results[r]['Input']['comp']['H2O_Liq']) + ' wt%'] = Results[r].copy()
485
- new_out = dict(sorted(new_out.items(), key=lambda x: float(x[0].split('=')[1].split(' ')[1])))
486
-
487
- if len(new_out) == 0:
488
- new_out = Results.copy()
489
-
490
- return new_out
491
-
492
388
  def path_multi(q, index, *, Model = None, comp = None, Frac_solid = None, Frac_fluid = None,
493
389
  T_C = None, T_path_C = None, T_start_C = None, T_end_C = None, dt_C = None,
494
390
  P_bar = None, P_path_bar = None, P_start_bar = None, P_end_bar = None, dp_bar = None,
@@ -359,7 +359,7 @@ def residualT_plot(Results = None, P_bar = None, phases = None, H2O_Liq = None,
359
359
  a[i][j].set_zlim([0,50])
360
360
 
361
361
  def phase_plot(Results = None, y_axis = None, x_axis = None,
362
- phases = ['Liq','Ol', 'Opx', 'Cpx', 'Sp', 'Grt'], cmap = "Reds",
362
+ phases = ['Liq', 'Ol', 'Opx', 'Cpx', 'Sp', 'Grt'], cmap = "Reds",
363
363
  title = None, figsize = None):
364
364
 
365
365
  if type(Results) != list:
@@ -373,10 +373,11 @@ def phase_plot(Results = None, y_axis = None, x_axis = None,
373
373
 
374
374
  Stop = np.zeros(len(Results['All']['P_bar']))
375
375
  for idx, p in enumerate(phases):
376
- a.fill_betweenx(Results['All']['P_bar'], Stop,
377
- x2= Stop + Results['All']['Mass_' + p], alpha = 0.75, color = PhaseList[p], lw = 0)
376
+ if 'mass_' + p in Results['All'].keys():
377
+ a.fill_betweenx(Results['All']['P_bar'], Stop,
378
+ x2= Stop + Results['All']['mass_' + p], alpha = 0.75, color = PhaseList[p], lw = 0)
378
379
 
379
- Stop = Stop + Results['All']['Mass_'+p]
380
+ Stop = Stop + Results['All']['mass_' + p]
380
381
 
381
382
  a.set_ylabel('Pressure (bars)')
382
383
  a.set_xlabel('Mass (g)')
@@ -5,4 +5,4 @@
5
5
  # 1) we don't load dependencies by storing it in __init__.py
6
6
  # 2) we can import it in setup.py for the same reason
7
7
  # 3) we can import it into your module
8
- __version__ = '0.2.37'
8
+ __version__ = '0.2.39'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PetThermoTools
3
- Version: 0.2.37
3
+ Version: 0.2.39
4
4
  Summary: PetThermoTools
5
5
  Home-page: https://github.com/gleesonm1/PetThermoTools
6
6
  Author: Matthew Gleeson