Accessing thermodynamic properties from sampling methods¶
The notebook includes the Pt/Cu(111) model data. We use the correlations calculator and fitted effective cluster interactions from that database to construct a CELL model:
[2]:
%matplotlib inline
from ase.db import connect
from clusterx.correlations import CorrelationsCalculator
from clusterx.model import Model
from clusterx.visualization import juview
with connect(ptcu_database) as database:
parameters = database.metadata["model_parameters"]
cemodelE = Model(
corrc=CorrelationsCalculator(db=database),
ecis=parameters["ECIs"],
property_name=parameters["property_name"],
)
\(E_{\rm ads}\) predicted by this CE model is given in units of \(eV\) per subsitutional site, short \(eV/site\). How this CE model is obtained, is described in detail in tutorial_CE_Pt/Cu(111).
Now, we use the parent lattice for which the CE model is based on to create the simulation cell. Our simulation cell is an object of the class SuperCell, and can be initialized as:
[3]:
# Intialization of the SuperCell object being the simulation cell
from clusterx.super_cell import SuperCell
scell = SuperCell(cemodelE.get_parent_lattice(),[[4,0],[-2,4]])
# Display information of the SuperCell object
scell.print_sublattice_types()
sites_dict = scell.get_nsites_per_type()
for key in sites_dict.keys():
print("Number of atoms in sublattice "+str(key)+":", sites_dict[key])
juview(scell)
+--------------------------------------------------------------------+
| The structure consists of 2 sublattices |
+--------------------------------------------------------------------+
| Sublattice type | Chemical symbols | Atomic numbers |
+--------------------------------------------------------------------+
| 0 | ['Cu'] | [29] |
| 1 | ['Cu' 'Pt'] | [29, 78] |
+--------------------------------------------------------------------+
Number of atoms in sublattice 0: 32
Number of atoms in sublattice 1: 16
[3]:
As we see from the displayed information, the supercell consists of two sublattices, with indices 0 and 1. Both sublattices contain species “Cu”. In sublattice 0, they can not be substituted, while in sublattice 1 that contains all sites of one (111) surface, “Cu” can be substituted by “Pt”. This simulation cell has, in total, 16 substitutional surface sites:
[4]:
nsites = len(scell.get_substitutional_atoms())
print(nsites)
16
Metropolis Monte-Carlo sampling¶
In the following, we perform a Metropolis Monte-Carlo (MMC) sampling [N. Metropolis et. al., J. Chem. Phys. 21, 1087 (1953)] in the canonical ensemble, i.e. the volume of the simulation cell, the composition and the temperature remain unchanged. During such a sampling algorithm, a sequence of configurations is generated by modifying the configuration at each step by one or multiple swaps of two randomly-choosen species in the substitutional lattice(s). After a swap, the new proposed structure with energy \(E_1\) is accepted with the probability
\begin{equation*} P ( E_0 \rightarrow E_1) = \min \left[ \exp \left( - \frac{E_1-E_0}{k_{\rm B} T} \right) , 1 \right]. \end{equation*}
Here, \(E_0\) is the energy of the structure before the swap. This acceptance probability distribution depends on the Boltzmann probability distribution \(\exp \left( - \frac{E}{k_{\rm B} T} \right)\) at given temperature \(T\) and the Boltzmann constant \(k_{\rm B}\).
For canonical samplings in the surface alloy Pt/Cu(111), we choose a composition with 4 Pt atoms, e.g. a Cu\(_3\)Pt alloy in the surface layer. Now, we perform a MMC sampling at \(T=300\,\)K with:
[5]:
import numpy as np
from clusterx.thermodynamics.monte_carlo import MonteCarlo
nsubs = {1: [4]}
kb = 8.6173303e-5 # Boltzmann constant in eV/K
temp = 800 # Temperature in K
energy_factor = nsites # Convert eV per surface site to total supercell eV
mc = MonteCarlo(
cemodelE, scell, ensemble="canonical", nsubs=nsubs, predict_swap=True, seed=0
)
traj = mc.metropolis(
no_of_sampling_steps=1000,
temperature=temp,
boltzmann_constant=kb,
energy_factor=energy_factor,
)
MMC sim. | Acc. rate: 0.4850 | delta_E: -4.0e-03: 100%|██████████| 1000/1000 [00:01<00:00, 942.30it/s]
In the first three lines, we define the number of Pt atoms in the substitutional lattice 1 by nsubs, \(k_{\rm B}\) and \(T\). Afterwards, we load the MonteCarlo class, and create an object of this class, called mc. The initialization of this object requires the CE model for the energy cemodelE, the simulation cell scell, and for a canonical sampling the composition defined by nsubs. As an option, you
can put predict_swap=True to speed up the sampling time (more details are given in the description of the class MonteCarlo). The object mc contains the main components to set up a sampling procedure, but does not perform a sampling by itself and is temperature independent.
The metropolis method takes the sampling step count, temperature, and Boltzmann constant. The model predicts adsorption energy in eV per surface site. Set energy_factor=nsites to convert its predictions to total supercell eV for comparison with \(k_{\rm B}T\).
The metropolis creates an object of the class MonteCarloTrajectory that stores all information of the trajectory generated from the MMC sampling. This object, named traj in the code above, is used to access this information after the MMC sampling. In the following, we show some examples how to obtained certain properties from the traj object (for more details please see the description of the class
MonteCarloTrajectory).
Below, we visualize e.g. the last structure visited in the MMC sampling:
[6]:
last_structure = traj.get_structure(-1)
juview(last_structure)
[6]:
In the code shown below, we visualize the first three accepted structures in the sampling. For this, we first get the list of the accepted steps from the method get_sampling_step_nos. Then, in a for loop over the first three accepted steps of this list, Structure objects at these steps are created and stored. At the end the stored structures are visualized:
[7]:
steps_accepted = traj.get_sampling_step_nos()
first_three_accepted_structures = []
for step in steps_accepted[:3]:
struc = traj.get_structure_at_step(step)
first_three_accepted_structures.append(struc)
juview(first_three_accepted_structures)
[7]:
We can extract the energies of the accepted MMC steps with the method get_energies and plot them versus the sampling step number:
[8]:
energies_accepted = traj.get_energies() / nsites
from clusterx.visualization import plot_property
plot_property(steps_accepted, energies_accepted, \
prop_name = "Energy of visited structures", \
xaxis_label = "step no.", yaxis_label = "Energy [eV/#sites]")
[8]:
{'property_name': 'Energy of visited structures',
'xaxis_label': 'step no.',
'yaxis_label': 'Energy [eV/#sites]',
'xvalues': array([0]),
'yvalues': array([-0.00538135])}
The trajectory can estimate the configurational heat capacity from energy fluctuations. CELL exposes it under the historical name "C_p" and returns the result for the whole supercell in eV/K. After discarding the first 100 steps for equilibration, divide by kb * nsites to express it in units of the Boltzmann constant per surface site.
[9]:
cp = traj.calculate_average_property(prop_name = "C_p", \
no_of_equilibration_steps = 100) / (kb * nsites)
print("Specific heat for",temp,"K:", cp, "k_B/#sites")
Specific heat for 800 K: 6.4838806930011e-31 k_B/#sites
This single value does not say much. To study the temperature dependence of \(C_p\), we need to perform MMC samplings in a range of temperatures. This is done in the following piece of code (be aware that this sampling takes a few minutes):
[10]:
temp_list = []
cp_list = []
rng = np.random.default_rng(0)
init_structure = scell.gen_random_structure(nsubs=nsubs, rng=rng)
# Simulated annealing
for temp in range(1400, 0, -100):
traj = mc.metropolis(
no_of_sampling_steps=1000,
temperature=temp,
boltzmann_constant=kb,
energy_factor=energy_factor,
initial_decoration=init_structure.get_atomic_numbers(),
)
cp = traj.calculate_average_property(
prop_name="C_p", no_of_equilibration_steps=200
) / (kb * nsites)
print(f"{temp} K: {cp:.4f} k_B per surface site")
temp_list.append(temp)
cp_list.append(cp)
init_structure = traj.get_structure(-1)
MMC sim. | Acc. rate: 0.6800 | delta_E: -2.2e-03: 100%|██████████| 1000/1000 [00:01<00:00, 981.46it/s]
1400 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.6580 | delta_E: 6.4e-03: 100%|██████████| 1000/1000 [00:00<00:00, 1384.56it/s]
1300 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.6110 | delta_E: 4.1e-03: 100%|██████████| 1000/1000 [00:00<00:00, 1376.06it/s]
1200 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.5770 | delta_E: 9.6e-03: 100%|██████████| 1000/1000 [00:00<00:00, 1365.84it/s]
1100 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.5510 | delta_E: 6.9e-03: 100%|██████████| 1000/1000 [00:00<00:00, 1369.80it/s]
1000 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.4810 | delta_E: -2.2e-03: 100%|██████████| 1000/1000 [00:00<00:00, 1363.10it/s]
900 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.4560 | delta_E: 5.1e-03: 100%|██████████| 1000/1000 [00:00<00:00, 1361.67it/s]
800 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.3500 | delta_E: 5.8e-03: 100%|██████████| 1000/1000 [00:00<00:00, 1385.43it/s]
700 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.2780 | delta_E: 1.3e-02: 100%|██████████| 1000/1000 [00:00<00:00, 1290.76it/s]
600 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.1550 | delta_E: 5.1e-03: 100%|██████████| 1000/1000 [00:00<00:00, 1357.54it/s]
500 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.0800 | delta_E: 1.8e-02: 100%|██████████| 1000/1000 [00:00<00:00, 1270.21it/s]
400 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.0990 | delta_E: 8.7e-03: 100%|██████████| 1000/1000 [00:00<00:00, 1365.43it/s]
300 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.0090 | delta_E: 1.6e-02: 100%|██████████| 1000/1000 [00:00<00:00, 1374.39it/s]
200 K: 0.0000 k_B per surface site
MMC sim. | Acc. rate: 0.0060 | delta_E: 1.5e-02: 100%|██████████| 1000/1000 [00:00<00:00, 1350.48it/s]
100 K: 0.0000 k_B per surface site
With the code above, a simulated annealing is performed. I.e. the for loop starts from a reasonable high temperature of \(T=1400\,\)K and gradually decreases \(T\) in steps of \(100\,\)K. For each temperature, an MMC sampling is performed and the \(C_p\) calculated. After each sampling, the last structure is stored as init_structure in order to use it as initial structure for the following MMC sampling. Here, for the first temperature, the MMC starts from a random
structure (initialized with the if case).
After the simulated annealing, we can visualize the lowest-energy structure visited at the last sampled temperature of \(T=100\,\)K with:
[11]:
juview(traj.get_lowest_energy_structure())
[11]:
This structure is expected to show an ordered pattern. For the surface stoichiometry of Cu\(_3\)Pt, a \(p(2\times2)\) ordering is expected accoring to Ref. [F. R. Lucci et. al., J. Phys. Chem. C 118, 6, 3015 (2014)]. If your result is not showing this ordering, it can be due to an insufficent number of sampling steps.
The plot below shows the \(C_p\) versus temperature obtained from the simulated annealing. For a phase transition from an ordered ground state to disorderd state, \(C_p\) is expected to have a maximum at the transition temperature.
[12]:
plot_property(temp_list, cp_list, \
prop_name = "Specific heat", \
xaxis_label = "Temperature [K]", yaxis_label = r'C$_p$ [k$_B$/#sites]')
[12]:
{'property_name': 'Specific heat',
'xaxis_label': 'Temperature [K]',
'yaxis_label': 'C$_p$ [k$_B$/#sites]',
'xvalues': [1400,
1300,
1200,
1100,
1000,
900,
800,
700,
600,
500,
400,
300,
200,
100],
'yvalues': [np.float64(2.1171855324085226e-31),
np.float64(2.455434108592133e-31),
np.float64(2.8817247524449332e-31),
np.float64(3.4294906144799206e-31),
np.float64(4.149683643520704e-31),
np.float64(5.12306622656877e-31),
np.float64(6.4838806930011e-31),
np.float64(8.46874212963409e-31),
np.float64(1.1526899009779733e-30),
np.float64(1.6598734574082818e-30),
np.float64(2.59355227720044e-30),
np.float64(4.610759603911893e-30),
np.float64(1.037420910880176e-29),
np.float64(4.149683643520704e-29)]}
The parameters of the MMC samplings above are chosen to achieve fast samplings and give only rough estimates of actual properties of the system.
To determine a precise transition temperature of the order-disorder phase transition for the Pt/Cu(111) surface alloy, e.g. MMC samplings with larger sampling steps, in total, are required (see Excercises at the end). As another possibility to access thermodynamic properties, we present in the next section the Wang-Landau method.
Wang-Landau method¶
As an alternative to the MMC sampling, we present the Wang-Landau (WL) method [F. Wang and D. P. Landau, Phys. Rev. Lett. 86, 2050 (2001)]. Instead of performing temperature-dependent samplings, this methods obtains directly the temperature-independent configurational density of states \(g(E)\) from a single sampling procedure. Once the \(g(E)\) is known, thermodynamic properties at any desired temperature can directly be calculated.
Short introduction into the Wang-Landau method: In the WL sampling, the new structure proposed by a random swap of atoms with energy \(E_1\) and corresponding \(g(E_1)\) is accepted with the probability \begin{equation*} P(E_0 \rightarrow E_1) = \min \left[ 1, \frac{g(E_0)}{g(E_{1})} \right] \end{equation*} Here, \(E_0\) and \(g(E_0)\) are the energy and the corresponding configurational density of states of the previous structure. The acceptance probability is proportional to \(1/g(E)\). If the true \(g(E)\) is used in \(P(E_0 \rightarrow E_1)\), the sampling generates a flat histogram. Upon reversion, it means that if a sampling generates a flat histogram, the \(g(E)\) is close to the true \(g(E)\).
As a starting point for such a sampling, the complete energy space, that can be visited during a canonical sampling, is discretized into energy bins with predefined width \(\Delta E\). The \(g(E)\) of those bins is unknown, thus it is initially set to \(g(E)=1\) for all bins. Furthermore, the histogram of the sampling is initially set to \(H(E)=0\) (no visits). At each sampling step, independent of the acceptance or rejection of the new structure, \(g(E)\) and \(H(E)\) of the currently visited structure are updated with \(g(E)=g(E) \cdot f\) and \(H(E)=H(E)+1\). Here, \(f\) is the so-called modification factor, which is initially set to \(f=\exp(1)\). The sampling algorithm performs a nested loop consisting of an inner loop to generate a flat histogram for a given \(f\) and an outer loop that lowers \(f\) (usually by \(f \rightarrow \sqrt{f}\) in each iteration). The accuracy of the final \(g(E)\) depends on \(f\) and the flatness of the histogram. A histogram is considered as flat if the minimum of \(H(E)\) is larger than a fraction \(x\) of the mean value of \(H(E)\), i.e. \(\min H(E) > x \cdot \bar{H}(E)\). This fraction is usually \(x=0.5\) for the first iterations in the outer loop and is increased up to \(x=0.98\) in the last iterations (depends highly on the complexity of the system). Details about this method can be found in Ref. [F. Wang and D. P. Landau, Phys. Rev. Lett. 86, 2050 (2001)] and [D. P. Landau et. al., Am. J. Phys. 72, 1294 (2004)].
In the following, we use the class WangLandau to obtain the \(g(E)\) for surface alloy Pt/Cu(111) at the stoichiometry of Cu\(_3\)Pt, i.e. 4 Pt atoms in the 16 surface sites (be aware that the execution of the following code lines take a few minutes).
[13]:
from clusterx.thermodynamics.wang_landau import WangLandau
# Bounds in total supercell eV for this model and composition
emin, emax = -1.70, -1.10
wl = WangLandau(
cemodelE, scell, ensemble="canonical", nsubs=nsubs,
predict_swap=True, energy_factor=energy_factor,
)
cdos = wl.wang_landau_sampling(
energy_range=[emin, emax],
energy_bin_width=0.025,
f_range=[np.exp(1), np.exp(1e-2)],
flatness_conditions=[
[0.8, np.exp(1e-1)],
[0.90, np.exp(1e-3)],
[0.95, np.exp(1e-5)],
],
serialize=True,
serialize_during_sampling=True,
filename="cdos.json",
niter_per_sweep=10_000,
seed=0,
)
----------------------------------------
Info (Wang-Landau): Running WL sampling.
Mod. factor | Histogram | Flatness | Tgt. Flat. | # non 0 Bins | N iter. | emin | emax
2.718281828 |▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁| 0.000 | 0.800 | 0 | 0 | -1.700 | -1.100
2.718281828 |▁▆▁▄▇▂▆▁▇▇▇█▇▇▇▇▇▇▇▃▁▆| 0.916 | 0.800 | 18 | 10000 | -1.700 | -1.100
1.648721271 |▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁| 0.000 | 0.800 | 0 | 0 | -1.700 | -1.100
1.648721271 |▁▅▁▄▇▂▆▁▇▇▇▇▇▇▇▇▇▇▇▃▁█| 0.913 | 0.800 | 18 | 10000 | -1.700 | -1.100
1.284025417 |▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁| 0.000 | 0.800 | 0 | 0 | -1.700 | -1.100
1.284025417 |▁▆▁▄▇▂▆▁▇▇▇▇▇▇▇▇▇█▇▃▁▆| 0.923 | 0.800 | 18 | 10000 | -1.700 | -1.100
1.133148453 |▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁| 0.000 | 0.800 | 0 | 0 | -1.700 | -1.100
1.133148453 |▁▆▁▃▇▂▆▁▇▇▇▇▇▇▇▇█▇▇▃▁▇| 0.889 | 0.800 | 18 | 10000 | -1.700 | -1.100
1.064494459 |▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁| 0.000 | 0.900 | 0 | 0 | -1.700 | -1.100
1.064494459 |▁▆▁▄█▂▆▁▇▇▇▇▇▇▇▇▇▇▇▃▁▆| 0.947 | 0.900 | 18 | 10000 | -1.700 | -1.100
1.031743407 |▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁| 0.000 | 0.900 | 0 | 0 | -1.700 | -1.100
1.031743407 |▁▆▁▄█▂▆▁▇▇▇▇▇▇▇▇▇▇▇▃▁▇| 0.949 | 0.900 | 18 | 10000 | -1.700 | -1.100
1.015747709 |▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁| 0.000 | 0.900 | 0 | 0 | -1.700 | -1.100
1.015747709 |▁▅▁▄▇▂▆▁█▇▇▇▇▇▇▇▇▇▇▃▁▆| 0.790 | 0.900 | 18 | 10000 | -1.700 | -1.100
1.015747709 |▁▅▁▄█▂▆▁▇▇▇▇▇▇▇▇▇▇▇▃▁▆| 0.941 | 0.900 | 18 | 20000 | -1.700 | -1.100
We reuse the same composition and energy conversion. We initialize an object wl of the WangLandau class with the same arguments used to initialize a MonteCarlo object, i.e. the CE model for the energy cemodelE, the simulation cell scell, and the composition defined by nsubs (optional predict_swap=True).
Using the object wl, the WL sampling can be executed with the method wang_landau_sampling. It needs the following arguments:
the energy range
energy_rangedefined by a list containing the minimum energy (first entry in list) and the maximum energy (secondt entry), that covers the complete energy space visited during the canonical sampling,the discretization of the energy range \(\Delta E\)
energy_bin_width,the range of the modification factor
f_rangedefined by a list contining the initial \(f\) (first entry in list) and a threshold for the final \(f\) (second entry) (if the next proposed \(f\) is below this threshold, the WL sampling stops),and optional arguments as
serializeto serialize thecdosobject after the sampling,serialize_during_samplingto serialize thecdosobject after every iteration of the outer loop during the sampling, andfilenameto set the name of the file in which thecdosis stored. (more details are given in the description of the class WangLandau)
The returned object cdos is an object of the class ConfigurationalDensityOfStates and contains all information about the \(g(E)\) obained at each iteration of the outer loop in the WL algorithm. If the option serialize_during_sampling is set to True, the information can be accessed even during the WL sampling. This is done by reading the ConfigurationalDensityOfStates object from file
(see code lines below).
In the following, we show some examples how to obtained thermodynamic properties from the wl object (for more details please see the description of the class ConfigurationalDensityOfStates).
We read the density of states from cdos.json and use it to calculate the configurational heat capacity and internal energy. The internal energy is measured relative to the lowest sampled energy.
[14]:
from clusterx.thermodynamics.wang_landau import ConfigurationalDensityOfStates
temps = range(150, 1500, 10)
cdos_read = ConfigurationalDensityOfStates(filename="cdos.json", read=True)
e, lng = cdos_read.get_cdos(ln=True, normalization=True)
plot_property(np.asarray(e) / nsites, lng, xaxis_label="Energy [eV/site]", yaxis_label="ln(g(E))", prop_name="lng")
cp = cdos_read.calculate_thermodynamic_property(temps, prop_name="C_p") / (kb * nsites)
plot_property(temps, cp, xaxis_label="Temperature [K]", yaxis_label="Heat capacity [k_B/site]", prop_name="C_p")
u = cdos_read.calculate_thermodynamic_property(temps, prop_name="U") / nsites
plot_property(temps, u, xaxis_label="Temperature [K]", yaxis_label="Relative internal energy [eV/site]", prop_name="U")
[14]:
{'property_name': 'U',
'xaxis_label': 'Temperature [K]',
'yaxis_label': 'Relative internal energy [eV/site]',
'xvalues': range(150, 1500, 10),
'yvalues': array([5.15778472e-05, 7.71929925e-05, 1.10825622e-04, 1.53708987e-04,
2.07083679e-04, 2.72188793e-04, 3.50248188e-04, 4.42449705e-04,
5.49916483e-04, 6.73670884e-04, 8.14592823e-04, 9.73375367e-04,
1.15048123e-03, 1.34610418e-03, 1.56013920e-03, 1.79216481e-03,
2.04143958e-03, 2.30691416e-03, 2.58725799e-03, 2.88089912e-03,
3.18607408e-03, 3.50088420e-03, 3.82335440e-03, 4.15149081e-03,
4.48333384e-03, 4.81700442e-03, 5.15074163e-03, 5.48293117e-03,
5.81212462e-03, 6.13705016e-03, 6.45661573e-03, 6.76990609e-03,
7.07617491e-03, 7.37483343e-03, 7.66543676e-03, 7.94766886e-03,
8.22132718e-03, 8.48630734e-03, 8.74258862e-03, 8.99022038e-03,
9.22930964e-03, 9.46001006e-03, 9.68251209e-03, 9.89703448e-03,
1.01038169e-02, 1.03031139e-02, 1.04951894e-02, 1.06803128e-02,
1.08587548e-02, 1.10307854e-02, 1.11966706e-02, 1.13566717e-02,
1.15110431e-02, 1.16600315e-02, 1.18038755e-02, 1.19428047e-02,
1.20770397e-02, 1.22067916e-02, 1.23322625e-02, 1.24536452e-02,
1.25711235e-02, 1.26848724e-02, 1.27950584e-02, 1.29018396e-02,
1.30053664e-02, 1.31057815e-02, 1.32032204e-02, 1.32978117e-02,
1.33896773e-02, 1.34789329e-02, 1.35656884e-02, 1.36500478e-02,
1.37321101e-02, 1.38119690e-02, 1.38897137e-02, 1.39654285e-02,
1.40391939e-02, 1.41110860e-02, 1.41811775e-02, 1.42495370e-02,
1.43162303e-02, 1.43813195e-02, 1.44448641e-02, 1.45069204e-02,
1.45675423e-02, 1.46267810e-02, 1.46846853e-02, 1.47413019e-02,
1.47966750e-02, 1.48508473e-02, 1.49038591e-02, 1.49557491e-02,
1.50065544e-02, 1.50563102e-02, 1.51050503e-02, 1.51528072e-02,
1.51996117e-02, 1.52454936e-02, 1.52904812e-02, 1.53346018e-02,
1.53778816e-02, 1.54203455e-02, 1.54620176e-02, 1.55029210e-02,
1.55430779e-02, 1.55825097e-02, 1.56212367e-02, 1.56592787e-02,
1.56966546e-02, 1.57333827e-02, 1.57694805e-02, 1.58049649e-02,
1.58398523e-02, 1.58741583e-02, 1.59078980e-02, 1.59410861e-02,
1.59737367e-02, 1.60058632e-02, 1.60374789e-02, 1.60685964e-02,
1.60992280e-02, 1.61293855e-02, 1.61590803e-02, 1.61883235e-02,
1.62171258e-02, 1.62454975e-02, 1.62734487e-02, 1.63009890e-02,
1.63281278e-02, 1.63548743e-02, 1.63812371e-02, 1.64072250e-02,
1.64328462e-02, 1.64581086e-02, 1.64830201e-02])}
The \(g(E)\) and the resulting thermodynamic property do not look converged yet. This is due to the fact that we choose a fairly large final modification factor of \(f=\exp (0.1)\). The WL sampling usually yields converged results if the final \(f\) is \(\exp(0.0001)\) or even much lower (this requires a larger sampling time).
Excercise 6: Metropolis Monte-Carlo sampling¶
Perform a simulated annealing with a larger number of sampling steps for the MMC sampling at each temperature than it was used in the example above.
Increase the simulation cell size, e.g. a Pt/Cu(111) surface alloy with \(64\) surface sites, and repeat the simulated annealing or a single MMC sampling. How does it affect the transition temperature?
Be aware that the execution of those samplings can take up to a few days (depending on the choice of parameters).
Excercise 7: Wang-Landau sampling¶
Choose a lower threshold for the final modification factor for the WL sampling than it was used in the example above.
In the method
wang_landau_samplingof theWangLandauobject above, we do not set explizitly the flatness condition. Look at the documentation of the class WangLandau to find out which flatness conditions are used as default. The flatness condition for each iterater in the outer loop can be also read from the serialized file of theConfigurationalDensityOfStatesobject. Try to change the modification factors.Increase the simulation cell size. Is the peak of the \(C_p\) changing?
Also, here, be aware that the execution of those samplings can take up to a few days (depending on the choice of parameters).
[ ]: