Skip to content

Manually enforced treshold for detection of the imaginary part of real space force constant #94

@gjoalland13

Description

@gjoalland13

An error is raised when extracting the force tensor out of the attached dynamical matrix, when using the following code with the default img_trsh=1.0e-6:

import cellconstructor as CC, cellconstructor.Phonons
import cellconstructor.ForceTensor
PATH = "GZ"
N_POINTS = 10
HARM_DYN = "dynamical-matrix-"
SPECIAL_POINTS = {"G": [0 ,0 ,0], "Z": [0, 0.5, 0]}
NQIRR = 8

harmonic_dyn = CC.Phonons.Phonons(HARM_DYN, NQIRR)
qpath, data = CC.Methods.get_bandpath(harmonic_dyn.structure.unit_cell, PATH, SPECIAL_POINTS, N_POINTS)
harmonic_dispersion = CC.ForceTensor.get_phonons_in_qpath(harmonic_dyn, qpath)

The following issue is raised:

Traceback (most recent call last):
  File "/home/gjoalland/work/WO3/jupyter/phonon/plot_phonons.py", line 63, in <module>
    harmonic_dispersion = CC.ForceTensor.get_phonons_in_qpath(harmonic_dyn, qpath)
  File "/home/gjoalland/work/.venv-flare/lib/python3.9/site-packages/cellconstructor/ForceTensor.py", line 3072, in get_phonons_in_qpath
    t2.SetupFromPhonons(dynamical_matrix)
  File "/home/gjoalland/work/.venv-flare/lib/python3.9/site-packages/cellconstructor/ForceTensor.py", line 196, in SetupFromPhonons
    super_dyn = current_dyn.GenerateSupercellDyn(phonons.GetSupercell(), img_thr  =1e-6)
  File "/home/gjoalland/work/.venv-flare/lib/python3.9/site-packages/cellconstructor/Phonons.py", line 1921, in GenerateSupercellDyn
    dyn_supercell.dynmats[0] = self.GetRealSpaceFC(supercell_size, img_thr = img_thr)
  File "/home/gjoalland/work/.venv-flare/lib/python3.9/site-packages/cellconstructor/Phonons.py", line 2782, in GetRealSpaceFC
    fc = GetSupercellFCFromDyn(dynmat, np.array(self.q_tot), self.structure, super_structure, img_thr = img_thr)
  File "/home/gjoalland/work/.venv-flare/lib/python3.9/site-packages/cellconstructor/Phonons.py", line 4083, in GetSupercellFCFromDyn
    assert imag < img_thr, ASSERT_ERROR.format(imag)
AssertionError: 
    Error, the imaginary part of the real space force constant
    is not zero. IMAG=1.2811627450721814e-06

I fixed this error by manually changing img_thr=2.0e-6 in the ForceTensor.py file.
dynamical-matrix-0.txt
dynamical-matrix-1.txt
dynamical-matrix-2.txt
dynamical-matrix-3.txt
dynamical-matrix-4.txt
dynamical-matrix-5.txt
dynamical-matrix-6.txt
dynamical-matrix-7.txt
dynamical-matrix-8.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    CleaningClean the code or solve small issues that are not bugenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions