calphy 1.3.11__tar.gz → 1.3.13__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 (36) hide show
  1. {calphy-1.3.11/calphy.egg-info → calphy-1.3.13}/PKG-INFO +1 -1
  2. {calphy-1.3.11 → calphy-1.3.13}/calphy/__init__.py +1 -1
  3. {calphy-1.3.11 → calphy-1.3.13}/calphy/input.py +1 -1
  4. {calphy-1.3.11 → calphy-1.3.13}/calphy/phase.py +15 -7
  5. {calphy-1.3.11 → calphy-1.3.13}/calphy/postprocessing.py +82 -1
  6. {calphy-1.3.11 → calphy-1.3.13/calphy.egg-info}/PKG-INFO +1 -1
  7. {calphy-1.3.11 → calphy-1.3.13}/setup.py +1 -1
  8. {calphy-1.3.11 → calphy-1.3.13}/LICENSE +0 -0
  9. {calphy-1.3.11 → calphy-1.3.13}/MANIFEST.in +0 -0
  10. {calphy-1.3.11 → calphy-1.3.13}/README.md +0 -0
  11. {calphy-1.3.11 → calphy-1.3.13}/calphy/alchemy.py +0 -0
  12. {calphy-1.3.11 → calphy-1.3.13}/calphy/clitools.py +0 -0
  13. {calphy-1.3.11 → calphy-1.3.13}/calphy/composition_transformation.py +0 -0
  14. {calphy-1.3.11 → calphy-1.3.13}/calphy/errors.py +0 -0
  15. {calphy-1.3.11 → calphy-1.3.13}/calphy/helpers.py +0 -0
  16. {calphy-1.3.11 → calphy-1.3.13}/calphy/integrators.py +0 -0
  17. {calphy-1.3.11 → calphy-1.3.13}/calphy/kernel.py +0 -0
  18. {calphy-1.3.11 → calphy-1.3.13}/calphy/liquid.py +0 -0
  19. {calphy-1.3.11 → calphy-1.3.13}/calphy/phase_diagram.py +0 -0
  20. {calphy-1.3.11 → calphy-1.3.13}/calphy/queuekernel.py +0 -0
  21. {calphy-1.3.11 → calphy-1.3.13}/calphy/routines.py +0 -0
  22. {calphy-1.3.11 → calphy-1.3.13}/calphy/scheduler.py +0 -0
  23. {calphy-1.3.11 → calphy-1.3.13}/calphy/solid.py +0 -0
  24. {calphy-1.3.11 → calphy-1.3.13}/calphy/splines.py +0 -0
  25. {calphy-1.3.11 → calphy-1.3.13}/calphy/utils.py +0 -0
  26. {calphy-1.3.11 → calphy-1.3.13}/calphy.egg-info/SOURCES.txt +0 -0
  27. {calphy-1.3.11 → calphy-1.3.13}/calphy.egg-info/dependency_links.txt +0 -0
  28. {calphy-1.3.11 → calphy-1.3.13}/calphy.egg-info/entry_points.txt +0 -0
  29. {calphy-1.3.11 → calphy-1.3.13}/calphy.egg-info/not-zip-safe +0 -0
  30. {calphy-1.3.11 → calphy-1.3.13}/calphy.egg-info/requires.txt +0 -0
  31. {calphy-1.3.11 → calphy-1.3.13}/calphy.egg-info/top_level.txt +0 -0
  32. {calphy-1.3.11 → calphy-1.3.13}/setup.cfg +0 -0
  33. {calphy-1.3.11 → calphy-1.3.13}/tests/test_helpers.py +0 -0
  34. {calphy-1.3.11 → calphy-1.3.13}/tests/test_integrators.py +0 -0
  35. {calphy-1.3.11 → calphy-1.3.13}/tests/test_options.py +0 -0
  36. {calphy-1.3.11 → calphy-1.3.13}/tests/test_solid_methods.py +0 -0
@@ -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
@@ -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
@@ -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]):
@@ -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)
@@ -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
@@ -53,7 +53,7 @@ setup(
53
53
  packages=find_packages(include=['calphy', 'calphy.*']),
54
54
  test_suite='tests',
55
55
  url='https://github.com/ICAMS/calphy',
56
- version='1.3.11',
56
+ version='1.3.13',
57
57
  zip_safe=False,
58
58
  entry_points={
59
59
  'console_scripts': [
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes