Skip to content

Commit

Permalink
test_BTO
Browse files Browse the repository at this point in the history
  • Loading branch information
vdemestral committed Nov 29, 2024
1 parent cc0e0bc commit 1c6c259
Show file tree
Hide file tree
Showing 6 changed files with 248 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/aiida_vibroscopy/calculations/spectra_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def compute_clamped_pockels_tensor(
raman_tensors: np.ndarray,
nlo_susceptibility: np.ndarray,
nac_direction: None | list[float, float, float] = None,
imaginary_thr: float = -5.0 / UNITS.thz_to_cm,
imaginary_thr: float = -5.0 * 1.0e+12, # in Hz
skip_frequencies: int = 3,
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
"""Compute the clamped Pockels tensor in Cartesian coordinates.
Expand Down Expand Up @@ -481,7 +481,7 @@ def compute_clamped_pockels_tensor(

# sets the first `skip_frequencies` IR contributions to zero (i.e. the acoustic modes)
for i in range(skip_frequencies):
ir_contribution[i] = 0
ir_contribution[:, i] = 0
r_ion_inner = np.tensordot(alpha, ir_contribution, axes=([0], [1])) # (i, j, k)

r_ion_left = np.dot(dielectric_inv, np.transpose(r_ion_inner, axes=[1, 0, 2]))
Expand Down
Binary file added tests/calculations/chi2_BTO.npy
Binary file not shown.
232 changes: 232 additions & 0 deletions tests/calculations/phonopy_BTO.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
phonopy:
version: "2.20.0"
frequency_unit_conversion_factor: 15.633302
symmetry_tolerance: 1.00000e-05

space_group:
type: "R3m"
number: 160
Hall_symbol: "R 3 -2\""

primitive_matrix:
- [ 1.000000000000000, 0.000000000000000, 0.000000000000000 ]
- [ 0.000000000000000, 1.000000000000000, 0.000000000000000 ]
- [ -0.000000000000000, 0.000000000000000, 1.000000000000000 ]

supercell_matrix:
- [ 1, 0, 0 ]
- [ 0, 1, 0 ]
- [ 0, 0, 1 ]

primitive_cell:
lattice:
- [ 2.828233390000000, -1.632881309999999, 2.317152100000000 ] # a
- [ -0.000000000000000, 3.265762620000000, 2.317152100000000 ] # b
- [ -2.828233390000000, -1.632881309999999, 2.317152100000000 ] # c
points:
- symbol: Ti # 1
coordinates: [ 0.485874881699997, 0.485874881699997, 0.485874881699997 ]
mass: 47.867000
- symbol: O # 2
coordinates: [ 0.511802210799999, 0.511802210799994, 0.020713059299988 ]
mass: 15.999400
- symbol: O # 3
coordinates: [ 0.511802210799992, 0.020713059299997, 0.511802210799992 ]
mass: 15.999400
- symbol: O # 4
coordinates: [ 0.020713059299988, 0.511802210799994, 0.511802210799999 ]
mass: 15.999400
- symbol: Ba # 5
coordinates: [ 0.998107737500000, 0.998107737500000, 0.998107737500000 ]
mass: 137.327000
reciprocal_lattice: # without 2pi
- [ 0.176788804547704, -0.102069063835795, 0.143854748824358 ] # a*
- [ 0.000000000000000, 0.204138127671590, 0.143854748824358 ] # b*
- [ -0.176788804547704, -0.102069063835795, 0.143854748824358 ] # c*

unit_cell:
lattice:
- [ 2.828233390000000, -1.632881310000000, 2.317152100000000 ] # a
- [ 0.000000000000000, 3.265762620000000, 2.317152100000000 ] # b
- [ -2.828233390000000, -1.632881310000000, 2.317152100000000 ] # c
points:
- symbol: Ti # 1
coordinates: [ 0.485874881699997, 0.485874881699997, 0.485874881699997 ]
mass: 47.867000
reduced_to: 1
- symbol: O # 2
coordinates: [ 0.511802210799999, 0.511802210799994, 0.020713059299988 ]
mass: 15.999400
reduced_to: 2
- symbol: O # 3
coordinates: [ 0.511802210799992, 0.020713059299997, 0.511802210799992 ]
mass: 15.999400
reduced_to: 3
- symbol: O # 4
coordinates: [ 0.020713059299988, 0.511802210799994, 0.511802210799999 ]
mass: 15.999400
reduced_to: 4
- symbol: Ba # 5
coordinates: [ -0.001892262500000, -0.001892262500000, -0.001892262500000 ]
mass: 137.327000
reduced_to: 5

supercell:
lattice:
- [ 2.828233390000000, -1.632881310000000, 2.317152100000000 ] # a
- [ 0.000000000000000, 3.265762620000000, 2.317152100000000 ] # b
- [ -2.828233390000000, -1.632881310000000, 2.317152100000000 ] # c
points:
- symbol: Ti # 1
coordinates: [ 0.485874881699997, 0.485874881699997, 0.485874881699997 ]
mass: 47.867000
reduced_to: 1
- symbol: O # 2
coordinates: [ 0.511802210799999, 0.511802210799994, 0.020713059299988 ]
mass: 15.999400
reduced_to: 2
- symbol: O # 3
coordinates: [ 0.511802210799992, 0.020713059299997, 0.511802210799992 ]
mass: 15.999400
reduced_to: 3
- symbol: O # 4
coordinates: [ 0.020713059299988, 0.511802210799994, 0.511802210799999 ]
mass: 15.999400
reduced_to: 4
- symbol: Ba # 5
coordinates: [ 0.998107737500000, 0.998107737500000, 0.998107737500000 ]
mass: 137.327000
reduced_to: 5

nac:
born_effective_charge:
- # 1 (Ti)
- [ 6.373865475363008, 0.000000000000000, 0.000000000000000 ]
- [ -0.000000000000000, 6.373865475363008, -0.000000000000000 ]
- [ 0.000000000000000, -0.000000000000000, 5.290820424211163 ]
- # 2 (O)
- [ -3.611509378547914, -0.965953271260393, 1.191583321899472 ]
- [ -0.965953272387218, -2.496122615523766, 0.687960952061796 ]
- [ 1.009727966344990, 0.582966712837546, -2.673797013836315 ]
- # 3 (O)
- [ -1.938429234011692, 0.000000000000000, 0.000000000000000 ]
- [ 0.000000000000000, -4.169202760059988, -1.375921904123592 ]
- [ 0.000000000000000, -1.165933425675092, -2.673797013836315 ]
- # 4 (O)
- [ -3.611509378547914, 0.965953271260393, -1.191583321899472 ]
- [ 0.965953272387218, -2.496122615523766, 0.687960952061796 ]
- [ -1.009727966344990, 0.582966712837546, -2.673797013836315 ]
- # 5 (Ba)
- [ 2.787582515744512, -0.000000000000000, -0.000000000000000 ]
- [ 0.000000000000000, 2.787582515744512, 0.000000000000000 ]
- [ 0.000000000000000, -0.000000000000000, 2.730570617297783 ]
dielectric_constant:
- [ 5.854114531326300, 0.000000000000000, -0.000000000000000 ]
- [ -0.000000000000000, 5.854114531326300, -0.000000000000000 ]
- [ 0.000000000000000, -0.000000000000000, 5.353224056590000 ]
unit_conversion_factor: 14.399652

force_constants:
format: "full"
shape: [ 5, 5 ]
elements:
- # (1, 1)
- [ 7.803908830786140, -0.000000000000000, -0.000000000000000 ]
- [ -0.000000000000000, 7.803908829808064, -0.000000000000000 ]
- [ -0.000000000000000, -0.000000000000000, 10.038115969545229 ]
- # (1, 2)
- [ -1.273261932926982, 0.216043730094502, -0.248630370855589 ]
- [ 0.216043730019048, -1.522727745827036, -0.143546811542143 ]
- [ 0.690467341171053, 0.398641505565644, -2.184987743436668 ]
- # (1, 3)
- [ -1.647460651691167, 0.000000000863855, -0.000000000072468 ]
- [ 0.000000000917476, -1.148529027275805, 0.287093622958768 ]
- [ 0.000000000290330, -0.797283010628421, -2.184987743436667 ]
- # (1, 4)
- [ -1.273261934469659, -0.216043731038789, 0.248630370928057 ]
- [ -0.216043730856093, -1.522727744284358, -0.143546811416625 ]
- [ -0.690467341461382, 0.398641505062777, -2.184987743436667 ]
- # (1, 5)
- [ -3.609924311698332, 0.000000000080432, 0.000000000000000 ]
- [ -0.000000000080432, -3.609924312420865, -0.000000000000000 ]
- [ -0.000000000000000, 0.000000000000000, -3.483152739235227 ]
- # (2, 1)
- [ -1.273261932926982, 0.216043730019048, 0.690467341171053 ]
- [ 0.216043730094502, -1.522727745827036, 0.398641505565644 ]
- [ -0.248630370855589, -0.143546811542143, -2.184987743436668 ]
- # (2, 2)
- [ 8.483370305222660, 1.776974542376888, -1.958390128082150 ]
- [ 1.776974542376888, 6.431496842451849, -1.130677067352838 ]
- [ -1.958390128082150, -1.130677067352838, 6.965008966327693 ]
- # (2, 3)
- [ -1.685950876437615, -2.033666474137681, 1.354881965690746 ]
- [ -1.465600246386893, -3.706253458399304, -1.139296905932688 ]
- [ 1.664101046058503, -0.603713747518442, -2.006650676507376 ]
- # (2, 4)
- [ -4.716404754695410, 0.284033112776078, -0.309219080652899 ]
- [ -0.284033114965023, -0.675799583682251, 1.743010653269560 ]
- [ 0.309219080667572, 1.743010653607285, -2.006650676507376 ]
- # (2, 5)
- [ -0.807752741162654, -0.243384911034334, 0.222259901873250 ]
- [ -0.243384911119474, -0.526716054543258, 0.128321814450322 ]
- [ 0.233700372211665, 0.134926972806138, -0.766719869876274 ]
- # (3, 1)
- [ -1.647460651691167, 0.000000000917476, 0.000000000290330 ]
- [ 0.000000000863855, -1.148529027275805, -0.797283010628421 ]
- [ -0.000000000072468, 0.287093622958768, -2.184987743436667 ]
- # (3, 2)
- [ -1.685950876437615, -1.465600246386893, 1.664101046058503 ]
- [ -2.033666474137681, -3.706253458399304, -0.603713747518442 ]
- [ 1.354881965690746, -1.139296905932688, -2.006650676507376 ]
- # (3, 3)
- [ 5.405560116941441, -0.000000002691381, -0.000000000280844 ]
- [ -0.000000002691381, 9.509307027153861, 2.261354134219239 ]
- [ -0.000000000280844, 2.261354134219239, 6.965008966327692 ]
- # (3, 4)
- [ -1.685950878333296, 1.465600247481365, -1.664101046358318 ]
- [ 2.033666475232152, -3.706253456503623, -0.603713747674598 ]
- [ -1.354881965405605, -1.139296905751118, -2.006650676507375 ]
- # (3, 5)
- [ -0.386197710479364, 0.000000000679434, 0.000000000290330 ]
- [ 0.000000000733055, -0.948271084975129, -0.256643628397778 ]
- [ 0.000000000068170, -0.269853945494201, -0.766719869876273 ]
- # (4, 1)
- [ -1.273261934469659, -0.216043730856093, -0.690467341461382 ]
- [ -0.216043731038789, -1.522727744284358, 0.398641505062777 ]
- [ 0.248630370928057, -0.143546811416625, -2.184987743436667 ]
- # (4, 2)
- [ -4.716404754695410, -0.284033114965023, 0.309219080667572 ]
- [ 0.284033112776078, -0.675799583682251, 1.743010653607285 ]
- [ -0.309219080652899, 1.743010653269560, -2.006650676507376 ]
- # (4, 3)
- [ -1.685950878333296, 2.033666475232152, -1.354881965405605 ]
- [ 1.465600247481365, -3.706253456503623, -1.139296905751118 ]
- [ -1.664101046358318, -0.603713747674598, -2.006650676507375 ]
- # (4, 4)
- [ 8.483370309884270, -1.776974539685505, 1.958390128362995 ]
- [ -1.776974539685505, 6.431496837790240, -1.130677066866400 ]
- [ 1.958390128362995, -1.130677066866400, 6.965008966327692 ]
- # (4, 5)
- [ -0.807752742385904, 0.243384910274468, -0.222259902163580 ]
- [ 0.243384910466851, -0.526716053320007, 0.128321813947456 ]
- [ -0.233700372279835, 0.134926972688063, -0.766719869876273 ]
- # (5, 1)
- [ -3.609924311698332, -0.000000000080432, -0.000000000000000 ]
- [ 0.000000000080432, -3.609924312420865, 0.000000000000000 ]
- [ 0.000000000000000, -0.000000000000000, -3.483152739235227 ]
- # (5, 2)
- [ -0.807752741162654, -0.243384911119474, 0.233700372211665 ]
- [ -0.243384911034334, -0.526716054543258, 0.134926972806138 ]
- [ 0.222259901873250, 0.128321814450322, -0.766719869876274 ]
- # (5, 3)
- [ -0.386197710479364, 0.000000000733055, 0.000000000068170 ]
- [ 0.000000000679434, -0.948271084975129, -0.269853945494201 ]
- [ 0.000000000290330, -0.256643628397778, -0.766719869876273 ]
- # (5, 4)
- [ -0.807752742385904, 0.243384910466851, -0.233700372279835 ]
- [ 0.243384910274468, -0.526716053320007, 0.134926972688063 ]
- [ -0.222259902163580, 0.128321813947456, -0.766719869876273 ]
- # (5, 5)
- [ 5.611627505726254, 0.000000000000000, 0.000000000000000 ]
- [ 0.000000000000000, 5.611627505259259, 0.000000000000000 ]
- [ 0.000000000000000, 0.000000000000000, 5.783312348864047 ]
Binary file added tests/calculations/raman_BTO.npy
Binary file not shown.
17 changes: 14 additions & 3 deletions tests/calculations/test_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,16 @@ def test_compute_raman_susceptibility_tensors(generate_phonopy_instance, generat
assert np.abs(abs(alpha_comp) - abs(alpha_theo)) < 1e-3


def test_compute_clamped_pockels_tensor(generate_phonopy_instance, generate_third_rank_tensors):
def test_compute_clamped_pockels_tensor(generate_phonopy_instance, generate_third_rank_tensors, ndarrays_regression):
"""Test the `compute_clamped_pockels_tensor` function."""
import os

from aiida_vibroscopy.calculations.spectra_utils import compute_clamped_pockels_tensor

ph = generate_phonopy_instance()
raman, chi2 = generate_third_rank_tensors()
ph = generate_phonopy_instance('BTO')
basepath = os.path.dirname(os.path.abspath(__file__))
chi2 = np.load(os.path.join(basepath, 'chi2_BTO.npy'))
raman = np.load(os.path.join(basepath, 'raman_BTO.npy'))

pockels, pockels_el, pockels_ion = compute_clamped_pockels_tensor(
phonopy_instance=ph,
Expand All @@ -174,6 +178,13 @@ def test_compute_clamped_pockels_tensor(generate_phonopy_instance, generate_thir
print(pockels_ion)
print('\n', '================================', '\n')

results = {
'pockels': pockels,
'pockels_el': pockels_el,
'pockels_ion': pockels_ion,
}
ndarrays_regression.check(results, default_tolerance=dict(atol=1e-4, rtol=1e-4))


def test_compute_methods(generate_phonopy_instance, generate_third_rank_tensors, ndarrays_regression):
"""Test the post-processing methods with data regression techniques."""
Expand Down
Binary file not shown.

0 comments on commit 1c6c259

Please sign in to comment.