Example 02: Phase transformation in Fe#
In this example, we will make use of the temperature sweep algorithm in calphy to calculate the transformation temperature for BCC to FCC transition in Fe.
The EAM potential that will be used: Meyer, R, and P Entel. “Martensite-austenite transition and phonon dispersion curves of Fe1−xNix studied by molecular-dynamics simulations.” Phys. Rev. B 57, 5140.
The reference data is from: Freitas, Rodrigo, Mark Asta, and Maurice de Koning. “Nonequilibrium Free-Energy Calculation of Solids Using LAMMPS.” Computational Materials Science 112 (February 2016): 333–41.
The input file a is provided in the folder. The calculation can be started from the terminal using:
calphy -i input.yaml
In the input file, the calculations block is as shown below:
calculations:
- element: Fe
lattice: BCC
lattice_constant: 0.0
mass: 55.845
md:
barostat_damping: 0.1
equilibration_control: nose_hoover
thermostat_damping: 0.1
timestep: 0.001
mode: ts
n_equilibration_steps: 10000
n_iterations: 1
n_switching_steps: 25000
pair_coeff: '* * ../potentials/Fe.eam'
pair_style: eam
pressure: 0.0
queue:
commands:
- conda activate calphy
cores: 4
scheduler: local
reference_phase: solid
repeat:
- 5
- 5
- 5
temperature:
- 100.0
- 1400.0
- element: Fe
lattice: FCC
lattice_constant: 6.0
mass: 55.845
md:
barostat_damping: 0.1
equilibration_control: nose_hoover
thermostat_damping: 0.1
timestep: 0.001
mode: ts
n_equilibration_steps: 10000
n_iterations: 1
n_switching_steps: 25000
pair_coeff: '* * ../potentials/Fe.eam'
pair_style: eam
pressure: 0.0
queue:
commands:
- conda activate calphy
cores: 4
scheduler: local
reference_phase: solid
repeat:
- 5
- 5
- 5
temperature:
- 100.0
- 1400.0
The mode is listed as ts, which stands for temperature sweep. The sweep starts from the first value in the temperature option, which is 100 K. The free energy is integrated until 1400 K, which is the second value listed. Furthermore, there are also two calculation blocks. You can see that the lattice mentioned is different; one set is for BCC structure, while the other is FCC.
Once the calculation is over, there will a file called temperature_sweep.dat in each of the folders. This file indicates the variation of free energy with the temperature. We can read in the files and calculate the transition temperature as follows:
[8]:
import numpy as np
import matplotlib.pyplot as plt
[9]:
bt, bfe, bferr = np.loadtxt("ts-bcc-solid-100-0/temperature_sweep.dat", unpack=True)
ft, ffe, fferr = np.loadtxt("ts-fcc-solid-100-0/temperature_sweep.dat", unpack=True)
args = np.argsort(np.abs(bfe-ffe))
print(bt[args[0]], "K")
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[9], line 2
1 bt, bfe, bferr = np.loadtxt("ts-bcc-solid-100-0/temperature_sweep.dat", unpack=True)
----> 2 ft, ffe, fferr = np.loadtxt("ts-fcc-solid-100-0/temperature_sweep.dat", unpack=True)
4 args = np.argsort(np.abs(bfe-ffe))
5 print(bt[args[0]], "K")
File ~/miniforge3/envs/calphy/lib/python3.12/site-packages/numpy/lib/_npyio_impl.py:1397, in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows, quotechar, like)
1394 if isinstance(delimiter, bytes):
1395 delimiter = delimiter.decode('latin1')
-> 1397 arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
1398 converters=converters, skiplines=skiprows, usecols=usecols,
1399 unpack=unpack, ndmin=ndmin, encoding=encoding,
1400 max_rows=max_rows, quote=quotechar)
1402 return arr
File ~/miniforge3/envs/calphy/lib/python3.12/site-packages/numpy/lib/_npyio_impl.py:1024, in _read(fname, delimiter, comment, quote, imaginary_unit, usecols, skiplines, max_rows, converters, ndmin, unpack, dtype, encoding)
1022 fname = os.fspath(fname)
1023 if isinstance(fname, str):
-> 1024 fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
1025 if encoding is None:
1026 encoding = getattr(fh, 'encoding', 'latin1')
File ~/miniforge3/envs/calphy/lib/python3.12/site-packages/numpy/lib/_datasource.py:192, in open(path, mode, destpath, encoding, newline)
155 """
156 Open `path` with `mode` and return the file object.
157
(...) 188
189 """
191 ds = DataSource(destpath)
--> 192 return ds.open(path, mode, encoding=encoding, newline=newline)
File ~/miniforge3/envs/calphy/lib/python3.12/site-packages/numpy/lib/_datasource.py:529, in DataSource.open(self, path, mode, encoding, newline)
526 return _file_openers[ext](found, mode=mode,
527 encoding=encoding, newline=newline)
528 else:
--> 529 raise FileNotFoundError(f"{path} not found.")
FileNotFoundError: ts-fcc-solid-100-0/temperature_sweep.dat not found.
[10]:
plt.plot(bt, bfe, color="#E53935", label="bcc")
plt.plot(ft, ffe, color="#0097A7", label="fcc")
plt.xlabel("Temperature (K)", fontsize=12)
plt.ylabel("F (ev/atom)", fontsize=12)
plt.legend()
plt.savefig("fe_transition.png", dpi=300, bbox_inches="tight")
[ ]: