-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Towards full Python interface to the core C code of CLEED.
1. New cmdline script called `cleedpy-leed` and provide initial implementation. 2. Small modifications to the config module. 3. Provide preprocess module to prepare the inputs. 4. Move `mk_cg_coef` and `mk_ylm_coef` functions from test_cleed.c to leed.c. 5. Provide a working example of yaml input for the code.
- Loading branch information
1 parent
d499ca9
commit e694fef
Showing
11 changed files
with
369 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from pathlib import Path | ||
|
||
import typer | ||
|
||
from ..config import load_parameters | ||
from ..physics.constants import BOHR_TO_ANGSTROM | ||
from ..preprocess import extract_bulk_parameters, transform_cells | ||
|
||
|
||
def leed(inptut_file: Path): | ||
"""Leed CLI.""" | ||
config = load_parameters(inptut_file) | ||
transformation_matrix = transform_cells(config) | ||
|
||
bulk_parameters = extract_bulk_parameters(config, transformation_matrix) | ||
print( | ||
f"Optical potential: {bulk_parameters.vr} eV (Vr), {bulk_parameters.vi} eV (Vi)" | ||
) | ||
print(f"Temperature: {bulk_parameters.temp} K") | ||
print( | ||
f"""Bulk 2-dim. unit cell: {bulk_parameters.a[0]} | ||
{bulk_parameters.a[1]*BOHR_TO_ANGSTROM} {bulk_parameters.a[3]*BOHR_TO_ANGSTROM} | ||
{bulk_parameters.a[2]*BOHR_TO_ANGSTROM} {bulk_parameters.a[4]*BOHR_TO_ANGSTROM}""" | ||
) | ||
|
||
|
||
def cli(): | ||
"""Leed CLI.""" | ||
typer.run(leed) | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
HART = 27.2113962 # Hartree in eV | ||
BOHR = 0.529177249 # Bohr radius in Angstroms | ||
BOHR_TO_ANGSTROM = 0.529177249 # Bohr radius in Angstroms | ||
ANGSTROM_TO_BOHR = 1.0 / BOHR_TO_ANGSTROM | ||
MEL_U = 5.48579903e-4 # electron mass in amu (atomic mass units) | ||
U_MEL = 1822.88850636 # 1 amu in multiples of the electron mass | ||
KB = 3.16682941e-6 # Boltzmann constant in Hartree/K |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import numpy as np | ||
|
||
from .interface.cleed import Crystal | ||
from .physics.constants import ANGSTROM_TO_BOHR, BOHR_TO_ANGSTROM | ||
|
||
GEO_TOLERANCE = 0.0001 | ||
|
||
|
||
def transform_cells(parameters): | ||
"""Converto to right handed coordinate system.""" | ||
a1 = np.array(parameters.unit_cell.a1) | ||
a2 = np.array(parameters.unit_cell.a2) | ||
m_transformation = np.array([[1.0, 0], [0, 1.0]]) | ||
|
||
# Check the angle between a1 and a2 (1: must be >= pi/2, i.e. a1*a2 < 0). | ||
# if not: take a1 and -a2 as basic vectors and modify transformation matrix. | ||
if np.dot(a1, a2) > 0.0: | ||
a2 *= -1.0 | ||
m_transformation[1] *= -1.0 | ||
|
||
# Check the angle between a1 and a2 (2: must be < pi, i.e. a1*a2 > 0) | ||
# if not: exchange a1 and a2 and modify transformation matrix. | ||
if np.cross(a1, a2)[2] < 0.0: | ||
a1, a2 = a2, a1 | ||
m_transformation[0, 1] = m_transformation[1, 0] | ||
|
||
parameters.unit_cell.a1, parameters.unit_cell.a2 = tuple(a1), tuple(a2) | ||
|
||
return m_transformation | ||
|
||
|
||
def extract_bulk_parameters(parameters, transformation_matrix): | ||
bulk = Crystal() | ||
|
||
bulk.vr, bulk.vi = parameters.optical_potential | ||
bulk.temp = parameters.sample_temperature | ||
|
||
def to_matrix(v1, v2): | ||
"""Converts two vectors to a matrix.""" | ||
return np.array([v1, v2]) | ||
|
||
# Unit cell. | ||
a = ( | ||
to_matrix(parameters.unit_cell.a1[:2], parameters.unit_cell.a2[:2]) | ||
* ANGSTROM_TO_BOHR | ||
) | ||
bulk.a = (0.0, a[0, 0], a[1, 0], a[0, 1], a[1, 1]) | ||
|
||
# Reciprocal lattice vectors. | ||
a_recip = np.linalg.inv(a).T * 2.0 * np.pi | ||
print(a_recip / BOHR_TO_ANGSTROM) | ||
bulk.a_1 = (0.0, a_recip[0, 0], a_recip[0, 1], a_recip[1, 0], a_recip[1, 1]) | ||
|
||
# Superstructure matrix | ||
superstructure_matrix = to_matrix( | ||
parameters.superstructure_matrix.m1, parameters.superstructure_matrix.m2 | ||
) | ||
superstructure_matrix @= transformation_matrix | ||
bulk.m_super = ( | ||
0.0, | ||
superstructure_matrix[0, 0], | ||
superstructure_matrix[1, 0], | ||
superstructure_matrix[0, 1], | ||
superstructure_matrix[1, 1], | ||
) | ||
bulk.m_trans = ( | ||
0.0, | ||
transformation_matrix[0, 0], | ||
transformation_matrix[1, 0], | ||
transformation_matrix[0, 1], | ||
transformation_matrix[1, 1], | ||
) | ||
|
||
# Reciprocal superstructure matrix. | ||
reciprocal_matrix = np.linalg.inv(superstructure_matrix).T | ||
bulk.m_recip = ( | ||
0.0, | ||
reciprocal_matrix[0, 0], | ||
reciprocal_matrix[0, 1], | ||
reciprocal_matrix[1, 0], | ||
reciprocal_matrix[1, 1], | ||
) | ||
|
||
return bulk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
unit_cell: | ||
a1: [1.2450, 2.1564, 0.0] | ||
a2: [1.2450, -2.1564, 0.0] | ||
a3: [0.0000, 0.0000, -6.0990] | ||
superstructure_matrix: | ||
m1: [1.0, 0] | ||
m2: [0, 1.0] | ||
|
||
overlayers: | ||
- phase_file: "Cu_BVH" | ||
position: [0.0000, -0.0000, 6.0900] | ||
vibrational_displacement: [dr3, 0.032, 0.032, 0.032] | ||
- phase_file: "Ni_BVH" | ||
position: [1.2450, -0.7188, 4.0600] | ||
vibrational_displacement: [dr3, 0.025, 0.025, 0.025] | ||
- phase_file: "Ni_BVH" | ||
position: [1.2450, 0.7188, 2.0300] | ||
vibrational_displacement: [dr3, 0.025, 0.025, 0.025] | ||
|
||
bulk_layers: | ||
- phase_file: "Ni_BVH" | ||
position: [0.0000, 0.0000, 0.0000] | ||
vibrational_displacement: [dr3, 0.025, 0.025, 0.025] | ||
- phase_file: "Ni_BVH" | ||
position: [1.2450, -0.7188, -2.0300] | ||
vibrational_displacement: [dr3, 0.025, 0.025, 0.025] | ||
- phase_file: "Ni_BVH" | ||
position: [1.2450, 0.7188, -4.0600] | ||
vibrational_displacement: [dr3, 0.025, 0.025, 0.025] | ||
|
||
minimum_radius: | ||
- name: Ni_BVH | ||
radius: 0.9 | ||
- name: Cu_BVH | ||
radius: 0.9 | ||
|
||
optical_potential: [-8.00, 4.0] | ||
energy_range: | ||
initial: 70.0 | ||
final: 498.0 | ||
step: 4.0 | ||
|
||
polar_incidence_angle: 0.0 | ||
azimuthal_incidence_angle: 0.0 | ||
epsilon: 1.0e-2 | ||
maximum_angular_momentum: 9 |
Oops, something went wrong.