PetThermoTools 0.2.34__py3-none-any.whl → 0.2.36__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.
PetThermoTools/Barom.py CHANGED
@@ -11,46 +11,17 @@ from PetThermoTools.Plotting import *
11
11
  from PetThermoTools.Liq import *
12
12
  from PetThermoTools.MELTS import *
13
13
  from PetThermoTools.Path import *
14
- # try:
15
- # from PetThermoTools.Holland import *
16
- # except:
17
- # pass
18
14
  import multiprocessing
19
15
  from multiprocessing import Queue
20
16
  from multiprocessing import Process
21
17
  import time
22
- import sys
23
- from tqdm.notebook import tqdm, trange
24
18
  from scipy import interpolate
25
19
  from shapely.geometry import MultiPoint, Point, Polygon
26
20
 
27
- from functools import partial
28
- import concurrent.futures
29
-
30
21
  import numpy as np
31
22
  import pandas as pd
32
- from joblib import Parallel, delayed
33
23
  import multiprocessing
34
24
  import time
35
-
36
- def path_4_saturation(q, index, *, Model = None, P_bar = None, comp = None, T_maxdrop_C = None, dt_C = None, T_initial_C = None, fO2_buffer = None,
37
- fO2_offset = 0.0, H2O_Sat = None, phases = None):
38
- if "MELTS" in Model:
39
- Results = path_MELTS(P_bar = P_bar,
40
- Model=Model,
41
- comp=comp,
42
- T_maxdrop_C=T_maxdrop_C,
43
- dt_C=dt_C,
44
- T_initial_C=T_initial_C,
45
- find_liquidus=True,
46
- fO2_buffer=fO2_buffer,
47
- fO2_offset=fO2_offset,
48
- fluid_sat=H2O_Sat,
49
- Suppress=['rutile', 'tridymite'],
50
- phases=phases
51
- )
52
- q.put([index, Results])
53
- return
54
25
 
55
26
  def path_4_saturation_multi(q, index, *, Model = None, P_bar = None, comp = None, T_maxdrop_C = None, dt_C = None, T_initial_C = None, fO2_buffer = None,
56
27
  fO2_offset = 0.0, H2O_Sat = None, phases = None):
@@ -127,7 +98,7 @@ def mineral_cosaturation(Model="MELTSv1.0.2", cores=int(np.floor(multiprocessing
127
98
  P_bar=np.linspace(250, 5000, 32), Fe3Fet_init=None, H2O_init=None,
128
99
  CO2_init=None, H2O_Sat=False, T_initial_C=None, dt_C=2,
129
100
  T_maxdrop_C=50, T_cut_C=20, find_range=True,
130
- find_min=True, fO2_buffer=None, fO2_offset=0.0, timeout = 30):
101
+ find_min=True, fO2_buffer=None, fO2_offset=0.0, timeout = 90, multiprocesses = True):
131
102
 
132
103
  comp = bulk.copy()
133
104
  if H2O_Sat:
@@ -136,105 +107,100 @@ def mineral_cosaturation(Model="MELTSv1.0.2", cores=int(np.floor(multiprocessing
136
107
  comp = comp_fix(Model=Model, comp=comp, Fe3Fet_Liq=Fe3Fet_init,
137
108
  H2O_Liq=H2O_init, CO2_Liq=CO2_init)
138
109
 
139
- index_in = np.arange(len(P_bar))
140
- # index_in = index
141
110
  combined_results = {}
142
- index_out = np.array([], dtype=int)
143
-
144
- while len(index_out) < len(index_in):
145
- index = np.setdiff1d(index_in, index_out)
146
- groups = np.array_split(index, cores)
147
-
148
- processes = []
149
- for i in range(len(groups)):
150
- q = Queue()
151
- p = Process(target = path_4_saturation_multi, args = (q, groups[i]),
152
- kwargs = {'Model': Model, 'comp': comp,
153
- 'T_initial_C': T_initial_C, 'T_maxdrop_C': T_maxdrop_C,
154
- 'dt_C': dt_C, 'P_bar': P_bar, 'phases': phases,
155
- 'fO2_buffer': fO2_buffer, 'fO2_offset': fO2_offset})
156
-
157
- processes.append((p, q))
158
- p.start()
111
+ if multiprocesses:
112
+ index_in = np.arange(len(P_bar))
113
+ index_out = np.array([], dtype=int)
114
+
115
+ while len(index_out) < len(index_in):
116
+ index = np.setdiff1d(index_in, index_out)
117
+ groups = np.array_split(index, cores)
118
+ non_empty_groups = [g for g in groups if g.size > 0]
119
+ groups = non_empty_groups
120
+
121
+ processes = []
122
+ for i in range(len(groups)):
123
+ q = Queue()
124
+ p = Process(target = path_4_saturation_multi, args = (q, groups[i]),
125
+ kwargs = {'Model': Model, 'comp': comp,
126
+ 'T_initial_C': T_initial_C, 'T_maxdrop_C': T_maxdrop_C,
127
+ 'dt_C': dt_C, 'P_bar': P_bar, 'phases': phases,
128
+ 'fO2_buffer': fO2_buffer, 'fO2_offset': fO2_offset})
129
+
130
+ processes.append((p, q, groups[i]))
131
+ p.start()
132
+
133
+ for p, q, group in processes:
134
+ try:
135
+ res = q.get(timeout=timeout)
136
+ except:
137
+ res = []
138
+ idx_chunks = np.array([group[0]], dtype = int)
139
+ p.join(timeout = 2)
140
+ p.terminate()
159
141
 
160
- for p, q in processes:
161
- res = q.get(timeout=timeout)
162
- p.join(timeout = 2)
163
- p.terminate()
142
+ if len(res) > 0.0:
143
+ idx_chunks, results = res
144
+ combined_results.update(results)
164
145
 
165
- idx_chunks, results = res
146
+ index_out = np.hstack((index_out, idx_chunks))
147
+ else:
148
+ if "MELTS" in Model:
149
+ from meltsdynamic import MELTSdynamic
150
+
151
+ if Model is None or Model == "MELTSv1.0.2":
152
+ melts = MELTSdynamic(1)
153
+ elif Model == "pMELTS":
154
+ melts = MELTSdynamic(2)
155
+ elif Model == "MELTSv1.1.0":
156
+ melts = MELTSdynamic(3)
157
+ elif Model == "MELTSv1.2.0":
158
+ melts = MELTSdynamic(4)
159
+ else:
160
+ from juliacall import Main as jl, convert as jlconvert
161
+
162
+ jl.seval("using MAGEMinCalc")
163
+
164
+ comp_julia = jl.seval("Dict")(comp)
165
+
166
+ if "MELTS" in Model:
167
+ for i in range(len(P_bar)):
168
+ results = {}
169
+ Results = path_MELTS(P_bar = P_bar[i],
170
+ Model=Model,
171
+ comp=comp,
172
+ T_maxdrop_C=T_maxdrop_C,
173
+ dt_C=dt_C,
174
+ T_initial_C=T_initial_C,
175
+ find_liquidus=True,
176
+ fO2_buffer=fO2_buffer,
177
+ fO2_offset=fO2_offset,
178
+ fluid_sat=H2O_Sat,
179
+ Suppress=['rutile', 'tridymite'],
180
+ phases=phases,
181
+ melts = melts
182
+ )
183
+ results[f"index = {i}"] = Results
184
+ combined_results.update(results)
185
+ else:
186
+ if fO2_offset is None:
187
+ fO2_offset = 0.0
166
188
 
167
- index_out = np.hstack((index_out, idx_chunks))
168
- combined_results.update(results)
189
+ for i in range(len(P_bar)):
190
+ results = {}
191
+ Results_df = jl.MAGEMinCalc.path(
192
+ comp=comp_julia, dt_C=dt_C,
193
+ P_bar=P_bar[i], T_min_C = T_maxdrop_C,
194
+ Model=Model, fo2_buffer=fO2_buffer,
195
+ fo2_offset=fO2_offset, find_liquidus=True,
196
+ frac_xtal = False
197
+ )
198
+
199
+ Results = dict(Results_df)
200
+ results[f"index = {i}"] = Results
201
+ combined_results.update(results)
169
202
 
170
203
  results = combined_results
171
- # results = {}
172
- # if len(P_bar) > 1:
173
- # A = len(P_bar)//cores
174
- # B = len(P_bar) % cores
175
-
176
- # if A > 0:
177
- # Group = np.zeros(A) + cores
178
- # if B > 0:
179
- # Group = np.append(Group, B)
180
- # else:
181
- # Group = np.array([B])
182
-
183
- # # initialise queue
184
- # qs = []
185
- # q = Queue()
186
-
187
-
188
- # # run calculations
189
- # for k in range(len(Group)):
190
- # ps = []
191
-
192
- # for kk in range(int(cores*k), int(cores*k + Group[k])):
193
- # p = Process(target = path_4_saturation, args = (q, kk),
194
- # kwargs = {'Model': Model, 'comp': comp,
195
- # 'T_initial_C': T_initial_C, 'T_maxdrop_C': T_maxdrop_C,
196
- # 'dt_C': dt_C, 'P_bar': P_bar[kk], 'phases': phases,
197
- # 'fO2_buffer': fO2_buffer, 'fO2_offset': fO2_offset})
198
-
199
- # ps.append(p)
200
- # p.start()
201
-
202
- # start = time.time()
203
- # for p in ps:
204
- # if time.time() - start < timeout - 10:
205
- # try:
206
- # ret = q.get(timeout = timeout - (time.time()-start) + 10)
207
- # except:
208
- # ret = []
209
- # else:
210
- # try:
211
- # ret = q.get(timeout = 10)
212
- # except:
213
- # ret = []
214
-
215
- # qs.append(ret)
216
-
217
- # TIMEOUT = 5
218
- # start = time.time()
219
- # for p in ps:
220
- # if p.is_alive():
221
- # while time.time() - start <= TIMEOUT:
222
- # if not p.is_alive():
223
- # p.join()
224
- # p.terminate()
225
- # break
226
- # time.sleep(.1)
227
- # else:
228
- # p.terminate()
229
- # p.join(5)
230
- # else:
231
- # p.join()
232
- # p.terminate()
233
-
234
- # for kk in range(len(qs)):
235
- # if len(qs[kk]) > 0:
236
- # index, res = qs[kk]
237
- # results[f"P = {P_bar[index]:.2f} bars"] = res.copy()
238
204
 
239
205
  Results = stich(Res=results, multi=True, Model=Model)
240
206
 
@@ -255,7 +221,7 @@ def mineral_cosaturation(Model="MELTSv1.0.2", cores=int(np.floor(multiprocessing
255
221
  arr2[:, 0] = np.abs(arr[:,1] - arr[:,2])
256
222
  arr2[:, 1] = np.abs(arr[:,1] - arr[:,3])
257
223
  arr2[:, 2] = np.abs(arr[:,2] - arr[:,3])
258
- arr2[:,3] = np.max(arr2[:,0:2], axis = 1)
224
+ arr2[:, 3] = np.max(arr2[:,0:2], axis = 1)
259
225
 
260
226
  r_arr = np.hstack((arr,arr2))
261
227
 
@@ -431,6 +397,8 @@ def find_mineral_cosaturation(cores = None, Model = None, bulk = None, phases =
431
397
  Results: Dict
432
398
  Dictionary containing information regarding the saturation temperature of each phase and the residuals between the different phases
433
399
  '''
400
+ print('This function will be removed following the update to v0.3.0. Please switch to using the mineral_cosaturation() function')
401
+
434
402
  try:
435
403
  from meltsdynamic import MELTSdynamic
436
404
  except:
PetThermoTools/MELTS.py CHANGED
@@ -1114,7 +1114,8 @@ def path_MELTS(Model = None, comp = None, Frac_solid = None, Frac_fluid = None,
1114
1114
  else:
1115
1115
  melts.engine.calcEquilibriumState(2,0)
1116
1116
  except:
1117
- trail = False
1117
+ if trail is not None:
1118
+ trail = False
1118
1119
  # if trail is not None:
1119
1120
  # return Results, trail
1120
1121
  # else:
@@ -1128,7 +1129,8 @@ def path_MELTS(Model = None, comp = None, Frac_solid = None, Frac_fluid = None,
1128
1129
  else:
1129
1130
  melts.engine.calcEquilibriumState(3,0)
1130
1131
  except:
1131
- trail = False
1132
+ if trail is not None:
1133
+ trail = False
1132
1134
  # return Results
1133
1135
  break
1134
1136
 
@@ -1136,7 +1138,8 @@ def path_MELTS(Model = None, comp = None, Frac_solid = None, Frac_fluid = None,
1136
1138
  try:
1137
1139
  melts.engine.calcEquilibriumState(4,0)
1138
1140
  except:
1139
- trail = False
1141
+ if trail is not None:
1142
+ trail = False
1140
1143
  # return Results
1141
1144
  break
1142
1145
 
@@ -1156,7 +1159,8 @@ def path_MELTS(Model = None, comp = None, Frac_solid = None, Frac_fluid = None,
1156
1159
  try:
1157
1160
  PhaseList = ['liquid1'] + melts.engine.solidNames
1158
1161
  except:
1159
- trail = False
1162
+ if trail is not None:
1163
+ trail = False
1160
1164
  # return Results
1161
1165
  break
1162
1166
 
PetThermoTools/Path.py CHANGED
@@ -122,6 +122,7 @@ def multi_path(cores = None, Model = None, bulk = None, comp = None, Frac_solid
122
122
  except:
123
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')
124
124
 
125
+ timeout_main = timeout
125
126
 
126
127
  if Frac_solid is False:
127
128
  Frac_solid = None
@@ -302,157 +303,143 @@ def multi_path(cores = None, Model = None, bulk = None, comp = None, Frac_solid
302
303
  elif type(fO2_offset) == float or type(fO2_offset) == int:
303
304
  fO2_offset = np.zeros(int(L)) + fO2_offset
304
305
 
305
- for j in tqdm(range(len(Group))):
306
- ps = []
306
+ index_in = np.arange(int(L))
307
+ combined_results = {}
308
+ index_out = np.array([], dtype=int)
307
309
 
308
- if Print_suppress is None:
309
- print("Running " + Model + " calculations " + str(int(cores*j)) + " to " + str(int(cores*j) + Group[j] - 1) + " ...", end = "", flush = True)
310
- s = time.time()
310
+ while len(index_out) < len(index_in):
311
+ index = np.setdiff1d(index_in, index_out)
312
+ groups = np.array_split(index, cores)
313
+ non_empty_groups = [g for g in groups if g.size > 0]
314
+ groups = non_empty_groups
311
315
 
312
- for i in range(int(cores*j), int(cores*j + Group[j])):
313
- if type(comp) == dict:
314
- p = Process(target = path, args = (q, i),
316
+ if len(groups[0])< 15:
317
+ timeout = len(groups[0])*timeout_main
318
+ else:
319
+ timeout = 15*timeout_main
320
+
321
+ processes = []
322
+ Start = time.time()
323
+ for i in range(len(groups)):
324
+ q = Queue()
325
+ p = Process(target = path_multi, args = (q, groups[i]),
315
326
  kwargs = {'Model': Model, 'comp': comp, 'Frac_solid': Frac_solid, 'Frac_fluid': Frac_fluid,
316
- '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],
317
- '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],
318
- 'isenthalpic': isenthalpic, 'isentropic': isentropic, 'isochoric': isochoric, 'find_liquidus': find_liquidus,
319
- 'fO2_buffer': fO2_buffer, 'fO2_offset': fO2_offset[i], 'fluid_sat': fluid_sat, 'Crystallinity_limit': Crystallinity_limit,
320
- 'Suppress': Suppress, 'Suppress_except': Suppress_except})
321
- else:
322
- p = Process(target = path, args = (q, i),
323
- kwargs = {'Model': Model, 'comp': comp.loc[i].to_dict(), 'Frac_solid': Frac_solid, 'Frac_fluid': Frac_fluid,
324
- '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],
325
- '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],
327
+ 'T_C': T_C, 'T_path_C': T_path_C, 'T_start_C': T_start_C, 'T_end_C': T_end_C, 'dt_C': dt_C,
328
+ 'P_bar': P_bar, 'P_path_bar': P_path_bar, 'P_start_bar': P_start_bar, 'P_end_bar': P_end_bar, 'dp_bar': dp_bar,
326
329
  'isenthalpic': isenthalpic, 'isentropic': isentropic, 'isochoric': isochoric, 'find_liquidus': find_liquidus,
327
- 'fO2_buffer': fO2_buffer, 'fO2_offset': fO2_offset[i], 'fluid_sat': fluid_sat, 'Crystallinity_limit': Crystallinity_limit,
330
+ 'fO2_buffer': fO2_buffer, 'fO2_offset': fO2_offset, 'fluid_sat': fluid_sat, 'Crystallinity_limit': Crystallinity_limit,
328
331
  'Suppress': Suppress, 'Suppress_except': Suppress_except})
329
-
330
- ps.append(p)
332
+
333
+ processes.append((p, q, groups[i]))
331
334
  p.start()
332
335
 
333
- if timeout is None:
334
- TIMEOUT = 240
335
- else:
336
- TIMEOUT = timeout
337
-
338
- start = time.time()
339
- first = True
340
- for p in ps:
341
- if time.time() - start < TIMEOUT - 10:
342
- try:
343
- ret = q.get(timeout = TIMEOUT - (time.time()-start) + 10)
344
- except:
345
- ret = []
346
- else:
347
- if first == True:
348
- print('Timeout Reached - this likely indicates the calculation failed. \n You can try increasing the timeout limit using the "timeout" kwarg.')
349
- first = False
350
- try:
351
- ret = q.get(timeout = 10)
352
- except:
353
- ret = []
354
-
355
- qs.append(ret)
356
-
357
- TIMEOUT = 5
358
- start = time.time()
359
- for p in ps:
360
- if p.is_alive():
361
- while time.time() - start <= TIMEOUT:
362
- if not p.is_alive():
363
- p.join()
364
- p.terminate()
365
- break
366
- time.sleep(.1)
336
+ for p, q, group in processes:
337
+ try:
338
+ if time.time() - Start < timeout + 5:
339
+ res = q.get(timeout=timeout)
367
340
  else:
368
- p.terminate()
369
- p.join(5)
370
- else:
371
- p.join()
372
- p.terminate()
341
+ res = q.get(timeout=10)
342
+ except:
343
+ res = []
344
+ idx_chunks = np.array([group[0]], dtype = int)
373
345
 
374
- if Print_suppress is None:
375
- print(" Complete (time taken = " + str(round(time.time() - s,2)) + " seconds)", end = "\n", flush = True)
376
-
377
-
378
- Results = {}
379
- Out = {}
380
- for i in range(len(qs)):
381
- if len(qs[i]) > 0:
382
- Res, index = qs[i]
383
- # if label is None:
384
- Results['index = ' + str(index)] = Res
385
- # elif label == "P" or label == "pressure" or label == "P_bar":
386
- # Out[str(round(Res['Conditions']['pressure'].loc[0]))] = Res
387
- # elif label == "water" or label == "H2O" or label == "H2O_Liq":
388
- # if H2O_Liq is not None:
389
- # Out[str(round(H2O_Liq[index], 2))] = Res
390
- # else:
391
- # Out[str(round(bulk.loc[index, "H2O_Liq"], 2))] = Res
392
- # elif label == "carbon" or label == "CO2":
393
- # Out[str(round(Res['liquid1']['CO2'].loc[0], 2))] = Res
394
- # elif label == "oxygen fugacity" or label == "fO2":
395
- # Out[str(round(fO2_offset[index], 2))] = Res
396
- # elif label == "Fe redox" or label == "Fe3Fet" or label == "Fe3Fet_Liq":
397
- # Out[str[round(Res['liquid1']['FeO'].loc[0]/(Res['liquid1']['FeO'].loc[0] + (71.844/(159.69/2))*Res['liquid1']['Fe2O3'].loc[0]),2)]] = Res
398
- # elif label in list(comp.keys()):
399
- # Results[str(comp[label].loc[index])] = Res
400
-
401
- # if label == "P" or label == "pressure" or label == "P_bar":
402
- # # A = Out.copy()
403
- # # B = [float(x) for x in A]
404
- # O = sorted(Out)
405
- # for o in O:
406
- # # if o % 1 == 0:
407
- # # o = int(o)
408
- # Results['P = ' + o + ' bars'] = Out[o]
409
-
410
- # if label == "water" or label == "H2O" or label == "H2O_Liq":
411
- # # A = Out.copy()
412
- # # B = [float(x) for x in A]
413
- # O = sorted(Out)
414
- # for o in O:
415
- # # if o % 1 == 0:
416
- # # o = int(o)
417
- # Results['H2O_i = ' + o + ' wt%'] = Out[o]
418
-
419
- # # if label == "carbon" or label == "CO2":
420
- # # # A = Out.copy()
421
- # # # B = [float(x) for x in A]
422
- # # O = sorted(B)
423
- # # for o in O:
424
- # # # if o % 1 == 0:
425
- # # # o = int(o)
426
- # # Results['CO2 = ' + str(o) + ' wt%'] = Out[str[o]]
427
-
428
- # if label == "oxygen fugacity" or label == "fO2":
429
- # # A = Out.copy()
430
- # # B = [float(x) for x in A]
431
- # O = sorted(B)
432
- # for o in O:
433
- # # if o % 1 == 0:
434
- # # o = int(o)
435
-
436
- # # if o > 0.0:
437
- # # Results[fO2_buffer + ' +' + str(o)] = out[str(o)]
438
- # # else:
439
- # Results[fO2_buffer + ' ' + str(o)] = Out[str[o]]
440
-
441
- # if label == "Fe redox" or label == "Fe3Fet_Liq" or label == 'Fe3Fet':
442
- # # A = Out.copy()
443
- # # B = [float(x) for x in A]
444
- # O = sorted(B)
445
- # for o in O:
446
- # # if o % 1 == 0:
447
- # # o = int(o)
448
- # Results['Fe3/Fet = ' + str(o)] = Out[str[o]]
449
-
450
- # if print_label is not None:
451
- # print(Results.keys())
346
+ p.join(timeout = 2)
347
+ p.terminate()
452
348
 
349
+ if len(res) > 0.0:
350
+ idx_chunks, results = res
351
+ combined_results.update(results)
352
+
353
+ index_out = np.hstack((index_out, idx_chunks))
354
+
355
+ print(f"Completed {100*len(index_out)/len(index_in)} %")
356
+
357
+ results = combined_results
358
+
359
+ 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
453
440
 
454
441
  #if "MELTS" in Model:
455
- Results = stich(Results, multi = True, Model = Model, Frac_fluid = Frac_fluid, Frac_solid = Frac_solid)
442
+ # Results = stich(Results, multi = True, Model = Model, Frac_fluid = Frac_fluid, Frac_solid = Frac_solid)
456
443
 
457
444
  for r in Results:
458
445
  i = int(r.split('=')[1].strip())
@@ -502,6 +489,99 @@ def label_results(Result,label):
502
489
 
503
490
  return new_out
504
491
 
492
+ def path_multi(q, index, *, Model = None, comp = None, Frac_solid = None, Frac_fluid = None,
493
+ T_C = None, T_path_C = None, T_start_C = None, T_end_C = None, dt_C = None,
494
+ P_bar = None, P_path_bar = None, P_start_bar = None, P_end_bar = None, dp_bar = None,
495
+ isenthalpic = None, isentropic = None, isochoric = None, find_liquidus = None,
496
+ fO2_buffer = None, fO2_offset = None, fluid_sat = None, Crystallinity_limit = None,
497
+ Suppress = None, Suppress_except = None, trail = True):
498
+ results = {}
499
+ idx = []
500
+
501
+ if len(index) > 15:
502
+ index = index[:15]
503
+
504
+ if "MELTS" in Model:
505
+ from meltsdynamic import MELTSdynamic
506
+
507
+ if Model is None or Model == "MELTSv1.0.2":
508
+ melts = MELTSdynamic(1)
509
+ elif Model == "pMELTS":
510
+ melts = MELTSdynamic(2)
511
+ elif Model == "MELTSv1.1.0":
512
+ melts = MELTSdynamic(3)
513
+ elif Model == "MELTSv1.2.0":
514
+ melts = MELTSdynamic(4)
515
+ else:
516
+ from juliacall import Main as jl, convert as jlconvert
517
+
518
+ jl.seval("using MAGEMinCalc")
519
+
520
+
521
+ for i in index:
522
+ try:
523
+ if "MELTS" in Model:
524
+ if type(comp) == dict:
525
+ Results, tr = path_MELTS(Model = Model, comp = comp, Frac_solid = Frac_solid, Frac_fluid = Frac_fluid,
526
+ T_initial_C = 1400, T_C = T_C[i], T_path_C = T_path_C[i], T_start_C = T_start_C[i],
527
+ T_end_C = T_end_C[i], dt_C = dt_C[i], P_bar = P_bar[i], P_path_bar = P_path_bar[i],
528
+ P_start_bar = P_start_bar[i], P_end_bar = P_end_bar[i], dp_bar = dp_bar[i],
529
+ isenthalpic = isenthalpic, isentropic = isentropic, isochoric = isochoric,
530
+ find_liquidus = find_liquidus, fO2_buffer = fO2_buffer, fO2_offset = fO2_offset[i],
531
+ fluid_sat = fluid_sat, Crystallinity_limit = Crystallinity_limit, Suppress = Suppress,
532
+ Suppress_except=Suppress_except, trail = trail, melts = melts)
533
+ else:
534
+ Results, tr = path_MELTS(Model = Model, comp = comp.loc[i].to_dict(), Frac_solid = Frac_solid, Frac_fluid = Frac_fluid,
535
+ T_initial_C = 1400, T_C = T_C[i], T_path_C = T_path_C[i], T_start_C = T_start_C[i],
536
+ T_end_C = T_end_C[i], dt_C = dt_C[i], P_bar = P_bar[i], P_path_bar = P_path_bar[i],
537
+ P_start_bar = P_start_bar[i], P_end_bar = P_end_bar[i], dp_bar = dp_bar[i],
538
+ isenthalpic = isenthalpic, isentropic = isentropic, isochoric = isochoric,
539
+ find_liquidus = find_liquidus, fO2_buffer = fO2_buffer, fO2_offset = fO2_offset[i],
540
+ fluid_sat = fluid_sat, Crystallinity_limit = Crystallinity_limit, Suppress = Suppress,
541
+ Suppress_except=Suppress_except, trail = trail, melts = melts)
542
+ else:
543
+ if fO2_offset[i] is None:
544
+ fO2_offset[i] = 0.0
545
+
546
+ if Frac_solid is None:
547
+ Frac_solid = False
548
+
549
+ if type(comp) == dict:
550
+ comp_julia = jl.seval("Dict")(comp)
551
+ else:
552
+ comp_new = comp.loc[i].to_dict()
553
+ comp_julia = jl.seval("Dict")(comp_new)
554
+
555
+ # Results_df = jl.MAGEMinCalc.path(Model = Model, comp=comp_julia, T_start_C = T_start_C[i], T_end_C = T_end_C[i], dt_C=dt_C,
556
+ # T_C = T_C[i], T_path_C = T_path_C[i], P_start_bar = P_start_bar[i], P_end_bar = P_end_bar[i],
557
+ # dp_bar = dp_bar[i], P_bar = P_bar[i], P_path_bar = P_path_bar[i], frac_xtal = Frac_solid,
558
+ # fo2_buffer = fO2_buffer, fo2_offset = fO2_offset[i], find_liquidus = find_liquidus)
559
+
560
+ Results_df = jl.MAGEMinCalc.path(
561
+ comp=comp_julia, T_start_C=T_start_C[i], T_end_C=T_end_C[i], dt_C=dt_C[i],
562
+ T_C=T_C[i], P_start_bar=P_start_bar[i], P_end_bar=P_end_bar[i], dp_bar=dp_bar[i],
563
+ P_bar=P_bar[i], T_path_C=T_path_C[i], P_path_bar=P_path_bar[i], frac_xtal=Frac_solid,
564
+ Model=Model, fo2_buffer=fO2_buffer, fo2_offset=fO2_offset[i], find_liquidus=find_liquidus
565
+ )
566
+
567
+ Results = dict(Results_df)
568
+
569
+ tr = True
570
+
571
+ idx.append(i)
572
+
573
+
574
+ results[f"index = {i}"] = Results
575
+
576
+ if tr is False:
577
+ break
578
+ except:
579
+ idx.append(i)
580
+ break
581
+
582
+ q.put([idx, results])
583
+ return
584
+
505
585
 
506
586
  def path(q, index, *, Model = None, comp = None, Frac_solid = None, Frac_fluid = None,
507
587
  T_C = None, T_path_C = None, T_start_C = None, T_end_C = None, dt_C = None,
@@ -650,11 +730,14 @@ def path(q, index, *, Model = None, comp = None, Frac_solid = None, Frac_fluid =
650
730
  Frac_solid = False
651
731
 
652
732
  comp_julia = jl.seval("Dict")(comp)
733
+ # T_path_C = T_path_C.tolist()
734
+ T_path_C_julia = jlconvert(jl.Vector[jl.Float64], T_path_C)
735
+ P_path_bar_julia = jlconvert(jl.Vector[jl.Float64], P_path_bar)
653
736
 
654
737
  Results = jl.MAGEMinCalc.path(
655
738
  comp=comp_julia, T_start_C=T_start_C, T_end_C=T_end_C, dt_C=dt_C,
656
739
  T_C=T_C, P_start_bar=P_start_bar, P_end_bar=P_end_bar, dp_bar=dp_bar,
657
- P_bar=P_bar, T_path_C=T_path_C, P_path_bar=P_path_bar, frac_xtal=Frac_solid,
740
+ P_bar=P_bar, T_path_C=T_path_C_julia, P_path_bar=P_path_bar_julia, frac_xtal=Frac_solid,
658
741
  Model=Model, fo2_buffer=fO2_buffer, fo2_offset=fO2_offset, find_liquidus=find_liquidus
659
742
  )
660
743
  # Results = jl.pyconvert(dict, Results)
@@ -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.34'
8
+ __version__ = '0.2.36'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PetThermoTools
3
- Version: 0.2.34
3
+ Version: 0.2.36
4
4
  Summary: PetThermoTools
5
5
  Home-page: https://github.com/gleesonm1/PetThermoTools
6
6
  Author: Matthew Gleeson
@@ -1,20 +1,20 @@
1
- PetThermoTools/Barom.py,sha256=chxLZCCu0I8PLw0-TWsJboxiRqQJufKyVEVLk35dzVo,40494
1
+ PetThermoTools/Barom.py,sha256=CXjwCb7KpQG8x7IhewCLTfqoJ02s4Ott3NwDcGQMWtQ,40221
2
2
  PetThermoTools/Compositions.py,sha256=65NzfduzWdfHJ8VmHBN1Cv7fMz7kF3QbDVLei-e4v00,1483
3
3
  PetThermoTools/GenFuncs.py,sha256=u2GWqH--Wmqd0WXHxfulEAatQb6uswjl1s9SyyoHSa8,16412
4
4
  PetThermoTools/Holland.py,sha256=udBFeVUyTBpSfLIhx7Hy6o0I8ApNCDvwU_gZa0diY5w,7251
5
5
  PetThermoTools/Installation.py,sha256=UfVOW1NZFdzMWPyID5u7t0KwvpJA0AqYohzidXIAwYs,6098
6
6
  PetThermoTools/Liq.py,sha256=2kdU8r00Y20khwvPvCvLr6P7y2HEOvCH2cwrF_qw5u8,35541
7
- PetThermoTools/MELTS.py,sha256=CjUOJSUEoq4yXEojl77HgCj7aewhFDeSGt4ZGk3L3vs,73688
7
+ PetThermoTools/MELTS.py,sha256=DeTM8j2fJ5dAw_2DVCGfgh1R_lQB4Z5rLopKSJ1Q5xQ,73852
8
8
  PetThermoTools/Melting.py,sha256=h1-KchPFw5tI2xoOyNJUfVy_TJqTtcYiHtGuInIwzio,11017
9
- PetThermoTools/Path.py,sha256=FI_JkpCDXUVWsaKxA_PKOyKvXSzsQEBiLonGNiamcIM,33424
9
+ PetThermoTools/Path.py,sha256=3jzojfIefiYbSJQ3aDtjk5YDjbsGCS5OgGoR5_R-gXQ,38411
10
10
  PetThermoTools/Path_wrappers.py,sha256=_0pBs_cK2hICxAHkYxKXICUnUEBSiUg07-qhgBeuTdc,26555
11
11
  PetThermoTools/PhaseDiagrams.py,sha256=8S_BcqggBzfUbiCPcsJRWFBenGL4tcCevte3-ATQjQI,30884
12
12
  PetThermoTools/Plotting.py,sha256=IMYYusZy6REQATG9NI3dGlGs6h3vQ48aJHkZnHmSDDY,28924
13
13
  PetThermoTools/Saturation.py,sha256=XXY6fKVouQM3RLgQgXur4xSq7_uGp7bCw_k7NNlWYi8,14095
14
14
  PetThermoTools/__init__.py,sha256=PbiwQj_mNNEwuIZOLETmtMMshiXa50wjCA6mfvpOpOs,2393
15
- PetThermoTools/_version.py,sha256=ZyVKd7JEm_88aeNoezRSEHfFgAtOuHaYQWt8wmb4mgc,296
16
- PetThermoTools-0.2.34.dist-info/LICENSE.txt,sha256=-mkx4iEw8Pk1RZUvncBhGLW87Uur5JB7FBQtOmX-VP0,1752
17
- PetThermoTools-0.2.34.dist-info/METADATA,sha256=okQdLGfhCpo2f211FXt6szwCr2KrRHpqxAVKSl6kPec,796
18
- PetThermoTools-0.2.34.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
19
- PetThermoTools-0.2.34.dist-info/top_level.txt,sha256=IqK8iYBR3YJozzMOTRZ8x8mU2k6x8ycoMBxZTm-I06U,15
20
- PetThermoTools-0.2.34.dist-info/RECORD,,
15
+ PetThermoTools/_version.py,sha256=QMMdJR5-U4I1DZsdoQ1JdfCcA4AfdgUeqgFymIkCgHM,296
16
+ PetThermoTools-0.2.36.dist-info/LICENSE.txt,sha256=-mkx4iEw8Pk1RZUvncBhGLW87Uur5JB7FBQtOmX-VP0,1752
17
+ PetThermoTools-0.2.36.dist-info/METADATA,sha256=0mexGlH4AM6Inj69yfCSBZ03NBgCj4t9qN122iLoqR0,796
18
+ PetThermoTools-0.2.36.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
19
+ PetThermoTools-0.2.36.dist-info/top_level.txt,sha256=IqK8iYBR3YJozzMOTRZ8x8mU2k6x8ycoMBxZTm-I06U,15
20
+ PetThermoTools-0.2.36.dist-info/RECORD,,