calphy 1.3.11__py3-none-any.whl → 1.3.13__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.
calphy/__init__.py CHANGED
@@ -4,7 +4,7 @@ from calphy.solid import Solid
4
4
  from calphy.alchemy import Alchemy
5
5
  from calphy.routines import MeltingTemp
6
6
 
7
- __version__ = "1.3.11"
7
+ __version__ = "1.3.13"
8
8
 
9
9
  def addtest(a,b):
10
10
  return a+b
calphy/input.py CHANGED
@@ -40,7 +40,7 @@ from pyscal3.core import structure_dict, element_dict, _make_crystal
40
40
  from ase.io import read, write
41
41
  import shutil
42
42
 
43
- __version__ = "1.3.11"
43
+ __version__ = "1.3.13"
44
44
 
45
45
  def _check_equal(val):
46
46
  if not (val[0]==val[1]==val[2]):
calphy/phase.py CHANGED
@@ -598,8 +598,12 @@ class Phase:
598
598
 
599
599
  #now we can check if it converted
600
600
  file = os.path.join(self.simfolder, "avg.dat")
601
- lx, ly, lz, ipress = np.loadtxt(file, usecols=(1, 2, 3, 4), unpack=True)
602
- lxpc = ipress
601
+ #we have to clean the data, so as just the last block is selected
602
+ lx, ly, lz, lxpc = np.loadtxt(file, usecols=(1, 2, 3, 4), unpack=True)
603
+ lx = lx[-ncount+1:]
604
+ ly = ly[-ncount+1:]
605
+ lz = lx[-ncount+1:]
606
+ lxpc = lxpc[-ncount+1:]
603
607
  mean = np.mean(lxpc)
604
608
  std = np.std(lxpc)
605
609
  volatom = np.mean((lx*ly*lz)/self.natoms)
@@ -612,16 +616,20 @@ class Phase:
612
616
  ncount = int(self.calc.md.n_small_steps)//int(self.calc.md.n_every_steps*self.calc.md.n_repeat_steps)
613
617
 
614
618
  file = os.path.join(self.simfolder, "avg.dat")
615
- lx, ly, lz, ipress = np.loadtxt(file, usecols=(1, 2, 3, 4), unpack=True)
616
- lxpc = ipress
619
+ lx, ly, lz, lxpc = np.loadtxt(file, usecols=(1, 2, 3, 4), unpack=True)
620
+ lx = lx[-ncount+1:]
621
+ ly = ly[-ncount+1:]
622
+ lz = lx[-ncount+1:]
623
+ lxpc = lxpc[-ncount+1:]
624
+
617
625
  mean = np.mean(lxpc)
618
626
  std = np.std(lxpc)
619
627
  volatom = np.mean((lx*ly*lz)/self.natoms)
620
628
 
621
629
  self.calc._pressure = mean
622
- self.lx = np.round(np.mean(lx[-ncount+1:]), decimals=3)
623
- self.ly = np.round(np.mean(ly[-ncount+1:]), decimals=3)
624
- self.lz = np.round(np.mean(lz[-ncount+1:]), decimals=3)
630
+ self.lx = np.round(np.mean(lx), decimals=3)
631
+ self.ly = np.round(np.mean(ly), decimals=3)
632
+ self.lz = np.round(np.mean(lz), decimals=3)
625
633
  self.volatom = volatom
626
634
  self.vol = self.lx*self.ly*self.lz
627
635
  self.rho = self.natoms/(self.lx*self.ly*self.lz)
calphy/postprocessing.py CHANGED
@@ -1,6 +1,8 @@
1
1
  import os
2
2
  import numpy as np
3
3
  import yaml
4
+ import matplotlib.pyplot as plt
5
+ import warnings
4
6
 
5
7
  def read_report(folder):
6
8
  """
@@ -145,4 +147,83 @@ def gather_results(mainfolder):
145
147
  datadict['error_code'][-1] = _extract_error(errfile)
146
148
 
147
149
  df = pd.DataFrame(data=datadict)
148
- return df
150
+ return df
151
+
152
+ def find_transition_temperature(folder1, folder2, fit_order=4, plot=True):
153
+ """
154
+ Find transition temperature where free energy of two phases are equal.
155
+
156
+ Parameters
157
+ ----------
158
+ folder1: string
159
+ directory with temperature scale calculation
160
+
161
+ folder2: string
162
+ directory with temperature scale calculation
163
+
164
+ fit_order: int, optional
165
+ default 4. Order for polynomial fit of temperature vs free energy
166
+
167
+ plot: bool, optional
168
+ default True. Plot the results.
169
+ """
170
+ file1 = os.path.join(folder1, 'temperature_sweep.dat')
171
+ file2 = os.path.join(folder2, 'temperature_sweep.dat')
172
+ if not os.path.exists(file1):
173
+ raise FileNotFoundError(f'{file1} does not exist')
174
+ if not os.path.exists(file2):
175
+ raise FileNotFoundError(f'{file2} does not exist')
176
+
177
+ t1, f1 = np.loadtxt(file1, unpack=True, usecols=(0,1))
178
+ t2, f2 = np.loadtxt(file2, unpack=True, usecols=(0,1))
179
+
180
+ #do some fitting to determine temps
181
+ t1min = np.min(t1)
182
+ t2min = np.min(t2)
183
+ t1max = np.max(t1)
184
+ t2max = np.max(t2)
185
+
186
+ tmin = np.min([t1min, t2min])
187
+ tmax = np.max([t1max, t2max])
188
+
189
+ #warn about extrapolation
190
+ if not t1min == t2min:
191
+ warnings.warn(f'free energy is being extrapolated!')
192
+ if not t1max == t2max:
193
+ warnings.warn(f'free energy is being extrapolated!')
194
+
195
+ #now fit
196
+ f1fit = np.polyfit(t1, f1, fit_order)
197
+ f2fit = np.polyfit(t2, f2, fit_order)
198
+
199
+ #reevaluate over the new range
200
+ fit_t = np.arange(tmin, tmax+1, 1)
201
+ fit_f1 = np.polyval(f1fit, fit_t)
202
+ fit_f2 = np.polyval(f2fit, fit_t)
203
+
204
+ #now evaluate the intersection temp
205
+ arg = np.argsort(np.abs(fit_f1-fit_f2))[0]
206
+ transition_temp = fit_t[arg]
207
+
208
+ #warn if the temperature is shady
209
+ if np.abs(transition_temp-tmin) < 1E-3:
210
+ warnings.warn('It is likely there is no intersection of free energies')
211
+ elif np.abs(transition_temp-tmax) < 1E-3:
212
+ warnings.warn('It is likely there is no intersection of free energies')
213
+
214
+ #plot
215
+ if plot:
216
+ c1lo = '#ef9a9a'
217
+ c1hi = '#b71c1c'
218
+ c2lo = '#90caf9'
219
+ c2hi = '#0d47a1'
220
+
221
+ plt.plot(fit_t, fit_f1, color=c1lo, label=f'{folder1} fit')
222
+ plt.plot(fit_t, fit_f2, color=c2lo, label=f'{folder2} fit')
223
+ plt.plot(t1, f1, color=c1hi, label=folder1, ls='dashed')
224
+ plt.plot(t2, f2, color=c2hi, label=folder2, ls='dashed')
225
+ plt.axvline(transition_temp, ls='dashed', c='#37474f')
226
+ plt.ylabel('Free energy (eV/atom)')
227
+ plt.xlabel('Temperature (K)')
228
+ plt.legend(frameon=False)
229
+ return transition_temp
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: calphy
3
- Version: 1.3.11
3
+ Version: 1.3.13
4
4
  Summary: free energy calculation for python
5
5
  Home-page: https://github.com/ICAMS/calphy
6
6
  Author: Sarath Menon, Yury Lysogorskiy, Ralf Drautz
@@ -1,25 +1,25 @@
1
- calphy/__init__.py,sha256=yzftsRGAExKS7j5P49gh0fpg-c43MIsUCXKiUgGnCCg,234
1
+ calphy/__init__.py,sha256=O46MqskwAlD2DmoXB8prjLeuCUBlzHuKsv-SaqjTohY,234
2
2
  calphy/alchemy.py,sha256=epv_vJoAMVbj-S1TuPSbBGr4w_a9qEr4EIxKlgwdlSo,12893
3
3
  calphy/clitools.py,sha256=oDqaw0s-LJ7tAdW_Njk2SFljVx6K34Rs8sdMz48SNSI,4125
4
4
  calphy/composition_transformation.py,sha256=Hh240-iVGC8ATlJ3nQK757qVZIBrE2aw7dsF46mi3oo,15353
5
5
  calphy/errors.py,sha256=KN47RWTLbg1H_NZMrhCiJCbqjqJScJ1pgQAuzj1-l84,1268
6
6
  calphy/helpers.py,sha256=nj8g53H6ScohQtyV7Enzms8Rv_89PRrDDY1IHjFSZdQ,8292
7
- calphy/input.py,sha256=R-M0C-7i1ux1IWop0UzlqAKoYIre7cxVuFLspcUwsPk,29400
7
+ calphy/input.py,sha256=836ifhhVHm6Nd9jMWLjMUYKukk_pcZwvoGcLzQXIWuU,29400
8
8
  calphy/integrators.py,sha256=hJYmbznsgY-x-eZm7ng8gW0qsGbopERl5gGDnw5uLms,21719
9
9
  calphy/kernel.py,sha256=rd_-EfCiBhQjkxcVaoLtVJB2_qDgS-g-dQ0BZBTJQ_A,6190
10
10
  calphy/liquid.py,sha256=a5NTAjc3VsrPBQoEMGe9O1WXfv1vxGoB0xPguf0fOyM,13762
11
- calphy/phase.py,sha256=FOm5_eP_8XbCYG3_UJoAToD3KKxlXcbSoEfQncZXTeA,44967
11
+ calphy/phase.py,sha256=NBkOGkG3U9Uo-dbupFWndOaaCiiSRoD8WHUpunYZty0,45190
12
12
  calphy/phase_diagram.py,sha256=2EwmT_qkT5BEP6Sx0_rm09kPP2RWh5JY4sogIBK_AhA,12992
13
- calphy/postprocessing.py,sha256=hFsc5Kr1FOgfjicjm23Dy19BUbZU9GxKpbCa8_U6gbU,4947
13
+ calphy/postprocessing.py,sha256=CztgekCvQ8lZPVfZ_hMAwlyvwetjSfADjTca8aVTftY,7602
14
14
  calphy/queuekernel.py,sha256=4GMIYnjMiAPipoLNKP5noYcfeEOI_vCqm84zgokk7Xw,5321
15
15
  calphy/routines.py,sha256=W6OZEPv6HEG11EYsoIbum2WVrO3Ly36i5UWsYQ4oBdQ,17473
16
16
  calphy/scheduler.py,sha256=IN8ogDedpTbZZsdpOj-hYZI05gWoD4bN7mHOb1z77Vo,8579
17
17
  calphy/solid.py,sha256=ZU_c4LqASoLzhjXX6eQY_8k_FNO9wjmMVTiOCKNsmis,19896
18
18
  calphy/splines.py,sha256=BGwUVz_qXQxUzpUCuZo6CsELcd5JVNWzI-Ttcz22G_E,61627
19
19
  calphy/utils.py,sha256=0UpsYoxjS5N-iGs-cdm0YDMkLF8IHvKO3smXDHrj3eg,3818
20
- calphy-1.3.11.dist-info/LICENSE,sha256=XIHGB5RZLIhOjjoO1bPf0II-qDbjhP5Cv5HJMRE9v1g,16651
21
- calphy-1.3.11.dist-info/METADATA,sha256=Pw5F6YJyyaGZlJG4kPU_MMf8UoilMH16JPa4iU7TFvY,4216
22
- calphy-1.3.11.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
23
- calphy-1.3.11.dist-info/entry_points.txt,sha256=W9qq254koyWnAgo1jtfQP9bO5Q7sgZrzc8BMnfo3vf4,386
24
- calphy-1.3.11.dist-info/top_level.txt,sha256=w871dhMqPwgjjbifBWdkT9_aOnK1ek4Odrh8UnSG3PE,7
25
- calphy-1.3.11.dist-info/RECORD,,
20
+ calphy-1.3.13.dist-info/LICENSE,sha256=XIHGB5RZLIhOjjoO1bPf0II-qDbjhP5Cv5HJMRE9v1g,16651
21
+ calphy-1.3.13.dist-info/METADATA,sha256=JCQSN5W690zkuPLQ9vqmc8mSOr56K6GOq8EiqEaymWo,4216
22
+ calphy-1.3.13.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
23
+ calphy-1.3.13.dist-info/entry_points.txt,sha256=W9qq254koyWnAgo1jtfQP9bO5Q7sgZrzc8BMnfo3vf4,386
24
+ calphy-1.3.13.dist-info/top_level.txt,sha256=w871dhMqPwgjjbifBWdkT9_aOnK1ek4Odrh8UnSG3PE,7
25
+ calphy-1.3.13.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.2.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5