Skip to content

Commit

Permalink
Merge pull request #7 from Jiemin-Li/loc_jl
Browse files Browse the repository at this point in the history
change the physical constants by using scipy.constants and modify the description a bit
  • Loading branch information
awalter-bnl authored Oct 3, 2024
2 parents 7ee147d + c2265fa commit c696d9f
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions src/test_data/arpes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np
from scipy.interpolate import CubicHermiteSpline, RegularGridInterpolator
from scipy.ndimage import zoom
import scipy.constants as sci_const
import time
import xarray as xr

Expand Down Expand Up @@ -133,7 +134,7 @@ def generate_symmetry_lines(symmetry_point_energies, lattice_constant=2.5):
Parameters
----------
symmetry_point_energies : [float, float, float]
symmetry_point_energies : [float, float, float], in the unit of eV.
Binding energies of the [0,0], [lattice_constant,
lattice_constant/sqrt(3)] and [lattice_constant,0] high symmetry
points.
Expand Down Expand Up @@ -328,7 +329,7 @@ def fermi(binding_energy, temperature=300, fermi_energy=0, zero_offset=0):
fermi_energy : float,
The binding energy of the Fermi level (in eV), default is 0.
zero_offset : float,
The 'zero' offset to shift the zero values by, default is 0.
The 'zero' offset to shift the zero values by (in eV), default is 0.
Returns
-------
Expand All @@ -337,7 +338,7 @@ def fermi(binding_energy, temperature=300, fermi_energy=0, zero_offset=0):
"""

kb = 8.617333262e-05 # Boltzmans constant in eV/K
kb = sci_const.Boltzmann/sci_const.elementary_charge # Boltzmans constant in eV/K
amplitude = 1 / (np.exp(-(binding_energy - fermi_energy) / (kb *
temperature))+1)
amplitude = (amplitude + zero_offset) / (1 + zero_offset)
Expand All @@ -346,8 +347,8 @@ def fermi(binding_energy, temperature=300, fermi_energy=0, zero_offset=0):


def perpendicular_momentum(photon_energy, parallel_momentum,
binding_energy=0, inner_potential=15,
work_function=5):
binding_energy=0.0, inner_potential=15.0,
work_function=5.0):
"""Converts photon energies to perpendicular momentum.
This function converts photon energy (energies) to perpendicular
Expand All @@ -366,9 +367,9 @@ def perpendicular_momentum(photon_energy, parallel_momentum,
"""

h_bar = 1.054571817E-34 # in J.s
m_e = 9.1093837E-31 # in Kg or J.s^2/m^2 (E=mc^2)
A_hbar = np.sqrt(2 * m_e) / h_bar # in J^(-1/2).m^(-1)
# h_bar = sci_const.hbar # in J.s
# m_e = sci_const.m_e # in Kg or J.s^2/m^2 (E=mc^2)
A_hbar = np.sqrt(2 * sci_const.m_e) / sci_const.hbar # in J^(-1/2).m^(-1)

Eph = photon_energy * 1.6E-19 # convert from eV to J
k_para = parallel_momentum*1E10 # convert from Ang to m
Expand Down Expand Up @@ -518,7 +519,8 @@ def __init__(self, symmetry_point_energies,

def energy(self, kx, ky, kz):
"""
Returns the binding energy for the $k_{x}$, $k_{y}$, $k_{z}$ values.
Returns the binding energy in eV for the $k_{x}$, $k_{y}$, $k_{z}$
values.
Used to provide the energy of the band at the given momentum
co-ordinates.
Expand All @@ -530,7 +532,7 @@ def energy(self, kx, ky, kz):
Returns
-------
Eb : float
Eb : float, in the unit of eV.
The binding energy for the given kx, ky, kz value.
"""

Expand Down Expand Up @@ -593,13 +595,13 @@ def spectra(self, ranges, noise=0.04, temperature=300,
noise : float, optional.
The noise level for the returned spectra.
temperature : float, optional.
The temperature of the sample (in K) used to generate the intensity
drop across the Fermi level.
The temperature (in K) of the sample (in K) used to generate the
intensity drop across the Fermi level.
work_function : float, optional.
work function in eV used to determine the photo-emission horizon.
default_Eph : float, optional.
The photon energy to use in the determination of the photoemission
horizon if it isn't included in ranges.
The photon energy (in eV) to use in the determination of the
photoemission horizon if it isn't included in ranges.
max_angle : float, optional.
The maximum emission angle, in degrees, to use in the determination
of the photoemission horizon.
Expand Down Expand Up @@ -692,8 +694,8 @@ def _generate_interpolation(self, ranges, g_width=0.4, l_width=0.3):
values are in inverse Angstroms and the energies are in eV.
g_width, l_width : float, optional.
The widths of the gaussian (g_width) and lorentzian(l_width)
broadening of the spectra (in eV) returned by self.spectra(...).
The widths (in eV) of the gaussian (g_width) and lorentzian(l_width)
broadening of the spectra returned by self.spectra(...).
Returns
-------
Expand Down Expand Up @@ -743,8 +745,8 @@ def _intensity(self, kx, Eb, Eband, g_width=0.4, l_width=0.3):
(in eV) and band energy (in eV) for which to calculate the
spectral intensity.
g_width, l_width : float, optional.
The widths of the gaussian (g_width) and lorentzian(l_width)
broadening of the spectra (in eV).
The widths (in eV) of the gaussian (g_width) and lorentzian(l_width)
broadening of the spectra.
Returns
-------
Expand Down Expand Up @@ -786,8 +788,8 @@ class Bands:
brillouin zone in Angstroms, default is approximately equal to that
for graphene (2.5, 3.4).
g_width, l_width : float or [float, ...], optional.
The widths of the gaussian (g_width) and lorentzian(l_width)
broadening of the spectra (in eV). If a list is given then it must
The widths (in eV) of the gaussian (g_width) and lorentzian(l_width)
broadening of the spectra. If a list is given then it must
have the same length as there are elements in symmetry_energies.
Attributes
Expand Down Expand Up @@ -933,11 +935,11 @@ def spectra(self, ranges, noise=0.04, temperature=300, default_Eph=45,
noise : float, optional.
The noise level for the returned spectra.
temperature : float, optional.
The temperature of the sample (in K) used to generate the intensity
drop across the Fermi level.
The temperature (in K) of the sample (in K) used to generate the
intensity drop across the Fermi level.
default_Eph : float, optional.
The photon energy to use in the determination of the photoemission
horizon if it isn't included in ranges.
The photon energy (in eV) to use in the determination of the
photoemission horizon if it isn't included in ranges.
as_xarray : Bool, optional.
Indicates if the returned spectra should be provided as an xarray
or as a numpy array and coordinates dictionary.
Expand Down Expand Up @@ -1046,9 +1048,10 @@ def detector_image(self, Eb=0., ky=None, Eph=40, T=300, noise=0.015,

if isinstance(ky, (float, int)): # if a constant ky image is requested.
# create non-used detector regions with k range>k horizon(2).
ranges = {'kx': [-3.8, 3.8, initial_resolution[0]], 'ky': ky, 'Eph': Eph}
ranges = {'kx': [-3.8, 3.8, initial_resolution[0]], 'ky': ky,
'Eph': Eph}
if isinstance(Eb, (list, tuple)):
ranges['Eb'] = [*Eb, initial_resolution[1]] # start finish tuple
ranges['Eb'] = [*Eb, initial_resolution[1]] # start finish tuple
else:
ranges['Eb'] = [12, -0.5, initial_resolution[1]]
# generate the left/right detector region not without spectra.
Expand All @@ -1062,8 +1065,8 @@ def detector_image(self, Eb=0., ky=None, Eph=40, T=300, noise=0.015,
'Eb': Eb, 'Eph': Eph}
# generate the left/right detector region not without spectra.
if added_points[0]:
added_range = noise * 0.2 * np.random.rand(initial_resolution[0],
added_points[1]) / 2
added_range = noise * 0.2 * np.random.rand(initial_resolution[0]
,added_points[1]) / 2

# generate the spectra.
image, axes_coords = self.spectra(ranges, temperature=T,
Expand Down

0 comments on commit c696d9f

Please sign in to comment.