diff --git a/darkmagic/material.py b/darkmagic/material.py index 82ce7f9..7c92656 100644 --- a/darkmagic/material.py +++ b/darkmagic/material.py @@ -243,7 +243,7 @@ def __init__( properties.validate_for_phonons(n_atoms) - m_atoms = phonopy_file.primitive.get_masses() * const.amu_to_eV + m_atoms = phonopy_file.primitive.masses * const.amu_to_eV # NAC parameters (born effective charges and dielectric tensor) self.born = np.array( @@ -256,9 +256,9 @@ def __init__( # Create a Structure object # At some point should make careful assessment of primitive vs unit_cell # PhonoDark uses primitive, but what about when it's different from unit_cell? - positions = phonopy_file.primitive.get_scaled_positions() - lattice = np.array(phonopy_file.primitive.get_cell()) * const.Ang_to_inveV - species = phonopy_file.primitive.get_chemical_symbols() + positions = phonopy_file.primitive.scaled_positions + lattice = np.array(phonopy_file.primitive.cell) * const.Ang_to_inveV + species = phonopy_file.primitive.symbols structure = Structure(lattice, species, positions) @@ -277,7 +277,7 @@ def get_eig( Returns: A tuple containing the phonon frequencies and eigenvectors. - * The phonon frequencies are represented as a numpy array of shape (n_modes,) + * The phonon frequencies are represented as a numpy array of shape (n_k,n_modes) * The eigenvectors are represented as a numpy array of shape (n_k, n_modes, n_atoms, 3) @@ -295,6 +295,7 @@ def get_eig( mesh_dict = self.phonopy_file.get_qpoints_dict() eigenvectors_pre = mesh_dict.get("eigenvectors", None) + # print(eigenvectors_pre) # convert frequencies to correct units omega = const.THz_to_eV * mesh_dict["frequencies"] @@ -302,7 +303,7 @@ def get_eig( (len(k_points), self.n_modes, self.n_atoms, 3), dtype=complex ) # Need to reshape the eigenvectors from (n_k, n_modes, n_modes) - # to (n_k, n_atoms, n_modes, 3) + # to (n_k, n_atoms, n_modes, 3) # TODO: is this correct? if with_eigenvectors: # TODO: Should rewrite this with a reshape... for q in range(len(k_points)): diff --git a/darkmagic/v_integrals.py b/darkmagic/v_integrals.py index 39f2ac3..e8799ee 100644 --- a/darkmagic/v_integrals.py +++ b/darkmagic/v_integrals.py @@ -64,7 +64,7 @@ def g0(self): @property def g1(self): - """ + r""" Computes the g1 integral for each (q, omega) pair See Eq. C11 in EFT paper (2009.13534) @@ -115,7 +115,7 @@ def g2(self): @property def F(self): - """ + r""" Computes the very last term of Eq. (C14) in the EFT paper (2009.13534) This is the term that multiplies (1 - qhat \otimes qhat) in the g2 integral """ @@ -131,7 +131,7 @@ def F(self): @property def X(self): - """ + r""" Computes the X vector for each (q, omega) pair $$ @@ -150,7 +150,7 @@ def X(self): @property def eye_minus_qhat_qhat(self): - """ + r""" Computes the (3x3) matrix (1 - qhat \otimes qhat) for each q-point The result is a 3D array of shape (n_q, 3, 3) """ diff --git a/tests/data/hcp_He_1GPa.phonopy.yaml b/tests/data/hcp_He_1GPa.phonopy.yaml new file mode 100644 index 0000000..7b3db81 --- /dev/null +++ b/tests/data/hcp_He_1GPa.phonopy.yaml @@ -0,0 +1,744 @@ +phonopy: + version: "2.21.0" + calculator: qe + frequency_unit_conversion_factor: 108.970772 + symmetry_tolerance: 1.00000e-05 + configuration: + dim: "3 3 3" + primitive_axis: "1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0" + force_constants: "READ" + fc_format: "HDF5" + fc_symmetry: ".TRUE." + include_fc: ".TRUE." + nac: ".TRUE." + include_nac_params: ".TRUE." + cell_filename: "scf.in" + calculator: "qe" + +physical_unit: + atomic_mass: "AMU" + length: "au" + force_constants: "Ry/au^2" + +space_group: + type: "P6_3/mmc" + number: 194 + Hall_symbol: "-P 6c 2c" + +primitive_matrix: +- [ 1.000000000000000, 0.000000000000000, 0.000000000000000 ] +- [ 0.000000000000000, 1.000000000000000, 0.000000000000000 ] +- [ 0.000000000000000, 0.000000000000000, 1.000000000000000 ] + +supercell_matrix: +- [ 3, 0, 0 ] +- [ 0, 3, 0 ] +- [ 0, 0, 3 ] + +primitive_cell: + lattice: + - [ 4.852625323567155, 0.000000000000000, 0.000000000000000 ] # a + - [ -2.426312661783578, 4.202496805230615, 0.000000000000000 ] # b + - [ 0.000000000000000, 0.000000000000000, 7.918868728113626 ] # c + points: + - symbol: He # 1 + coordinates: [ 0.333333333300000, 0.666666666700000, 0.250000000000000 ] + mass: 4.002602 + - symbol: He # 2 + coordinates: [ 0.666666666700000, 0.333333333300000, 0.750000000000000 ] + mass: 4.002602 + reciprocal_lattice: # without 2pi + - [ 0.206074018355265, 0.118976889971142, 0.000000000000000 ] # a* + - [ 0.000000000000000, 0.237953779942285, 0.000000000000000 ] # b* + - [ 0.000000000000000, 0.000000000000000, 0.126280663859194 ] # c* + +unit_cell: + lattice: + - [ 4.852625323567156, 0.000000000000000, 0.000000000000000 ] # a + - [ -2.426312661783578, 4.202496805230615, 0.000000000000000 ] # b + - [ 0.000000000000000, 0.000000000000000, 7.918868728113626 ] # c + points: + - symbol: He # 1 + coordinates: [ 0.333333333300000, 0.666666666700000, 0.250000000000000 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 2 + coordinates: [ 0.666666666700000, 0.333333333300000, 0.750000000000000 ] + mass: 4.002602 + reduced_to: 2 + +supercell: + lattice: + - [ 14.557875970701467, 0.000000000000000, 0.000000000000000 ] # a + - [ -7.278937985350733, 12.607490415691844, 0.000000000000000 ] # b + - [ 0.000000000000000, 0.000000000000000, 23.756606184340878 ] # c + points: + - symbol: He # 1 + coordinates: [ 0.111111111100000, 0.222222222233333, 0.083333333333333 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 2 + coordinates: [ 0.444444444433333, 0.222222222233333, 0.083333333333333 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 3 + coordinates: [ 0.777777777766667, 0.222222222233333, 0.083333333333333 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 4 + coordinates: [ 0.111111111100000, 0.555555555566667, 0.083333333333333 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 5 + coordinates: [ 0.444444444433333, 0.555555555566667, 0.083333333333333 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 6 + coordinates: [ 0.777777777766667, 0.555555555566667, 0.083333333333333 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 7 + coordinates: [ 0.111111111100000, 0.888888888900000, 0.083333333333333 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 8 + coordinates: [ 0.444444444433333, 0.888888888900000, 0.083333333333333 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 9 + coordinates: [ 0.777777777766667, 0.888888888900000, 0.083333333333333 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 10 + coordinates: [ 0.111111111100000, 0.222222222233333, 0.416666666666667 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 11 + coordinates: [ 0.444444444433333, 0.222222222233333, 0.416666666666667 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 12 + coordinates: [ 0.777777777766667, 0.222222222233333, 0.416666666666667 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 13 + coordinates: [ 0.111111111100000, 0.555555555566667, 0.416666666666667 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 14 + coordinates: [ 0.444444444433333, 0.555555555566667, 0.416666666666667 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 15 + coordinates: [ 0.777777777766667, 0.555555555566667, 0.416666666666667 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 16 + coordinates: [ 0.111111111100000, 0.888888888900000, 0.416666666666667 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 17 + coordinates: [ 0.444444444433333, 0.888888888900000, 0.416666666666667 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 18 + coordinates: [ 0.777777777766667, 0.888888888900000, 0.416666666666667 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 19 + coordinates: [ 0.111111111100000, 0.222222222233333, 0.750000000000000 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 20 + coordinates: [ 0.444444444433333, 0.222222222233333, 0.750000000000000 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 21 + coordinates: [ 0.777777777766667, 0.222222222233333, 0.750000000000000 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 22 + coordinates: [ 0.111111111100000, 0.555555555566667, 0.750000000000000 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 23 + coordinates: [ 0.444444444433333, 0.555555555566667, 0.750000000000000 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 24 + coordinates: [ 0.777777777766667, 0.555555555566667, 0.750000000000000 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 25 + coordinates: [ 0.111111111100000, 0.888888888900000, 0.750000000000000 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 26 + coordinates: [ 0.444444444433333, 0.888888888900000, 0.750000000000000 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 27 + coordinates: [ 0.777777777766667, 0.888888888900000, 0.750000000000000 ] + mass: 4.002602 + reduced_to: 1 + - symbol: He # 28 + coordinates: [ 0.222222222233333, 0.111111111100000, 0.250000000000000 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 29 + coordinates: [ 0.555555555566667, 0.111111111100000, 0.250000000000000 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 30 + coordinates: [ 0.888888888900000, 0.111111111100000, 0.250000000000000 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 31 + coordinates: [ 0.222222222233333, 0.444444444433333, 0.250000000000000 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 32 + coordinates: [ 0.555555555566667, 0.444444444433333, 0.250000000000000 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 33 + coordinates: [ 0.888888888900000, 0.444444444433333, 0.250000000000000 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 34 + coordinates: [ 0.222222222233333, 0.777777777766667, 0.250000000000000 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 35 + coordinates: [ 0.555555555566667, 0.777777777766667, 0.250000000000000 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 36 + coordinates: [ 0.888888888900000, 0.777777777766667, 0.250000000000000 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 37 + coordinates: [ 0.222222222233333, 0.111111111100000, 0.583333333333333 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 38 + coordinates: [ 0.555555555566667, 0.111111111100000, 0.583333333333333 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 39 + coordinates: [ 0.888888888900000, 0.111111111100000, 0.583333333333333 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 40 + coordinates: [ 0.222222222233333, 0.444444444433333, 0.583333333333333 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 41 + coordinates: [ 0.555555555566667, 0.444444444433333, 0.583333333333333 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 42 + coordinates: [ 0.888888888900000, 0.444444444433333, 0.583333333333333 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 43 + coordinates: [ 0.222222222233333, 0.777777777766667, 0.583333333333333 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 44 + coordinates: [ 0.555555555566667, 0.777777777766667, 0.583333333333333 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 45 + coordinates: [ 0.888888888900000, 0.777777777766667, 0.583333333333333 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 46 + coordinates: [ 0.222222222233333, 0.111111111100000, 0.916666666666667 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 47 + coordinates: [ 0.555555555566667, 0.111111111100000, 0.916666666666667 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 48 + coordinates: [ 0.888888888900000, 0.111111111100000, 0.916666666666667 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 49 + coordinates: [ 0.222222222233333, 0.444444444433333, 0.916666666666667 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 50 + coordinates: [ 0.555555555566667, 0.444444444433333, 0.916666666666667 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 51 + coordinates: [ 0.888888888900000, 0.444444444433333, 0.916666666666667 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 52 + coordinates: [ 0.222222222233333, 0.777777777766667, 0.916666666666667 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 53 + coordinates: [ 0.555555555566667, 0.777777777766667, 0.916666666666667 ] + mass: 4.002602 + reduced_to: 28 + - symbol: He # 54 + coordinates: [ 0.888888888900000, 0.777777777766667, 0.916666666666667 ] + mass: 4.002602 + reduced_to: 28 + +nac: + born_effective_charge: + - # 1 (He) + - [ 0.000000000000000, 0.000000000000000, 0.000000000000000 ] + - [ 0.000000000000000, 0.000000000000000, 0.000000000000000 ] + - [ 0.000000000000000, 0.000000000000000, 0.000000000000000 ] + - # 2 (He) + - [ 0.000000000000000, 0.000000000000000, 0.000000000000000 ] + - [ 0.000000000000000, 0.000000000000000, 0.000000000000000 ] + - [ 0.000000000000000, 0.000000000000000, 0.000000000000000 ] + dielectric_constant: + - [ 1.065579000000000, 0.000000000000000, 0.000000000000000 ] + - [ 0.000000000000000, 1.065579000000000, 0.000000000000000 ] + - [ 0.000000000000000, 0.000000000000000, 1.065579000000000 ] + unit_conversion_factor: 2.000000 + +force_constants: + format: "compact" + shape: [ 2, 54 ] + elements: + - # (1, 1) + - [ 0.006051937407412, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, 0.006051935925923, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.006116149444445 ] + - # (1, 2) + - [ -0.001782108148148, 0.000010814412042, -0.000000000000000 ] + - [ -0.000010814412042, 0.000144228148149, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000144990555555 ] + - # (1, 3) + - [ -0.001782108148148, -0.000010814412042, -0.000000000000000 ] + - [ 0.000010814412042, 0.000144228148149, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000144990555555 ] + - # (1, 4) + - [ -0.000337355925926, 0.000844942189820, -0.000000000000000 ] + - [ 0.000823313365736, -0.001300524074077, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000144990555555 ] + - # (1, 5) + - [ -0.000337355925926, -0.000844942189820, -0.000000000000000 ] + - [ -0.000823313365736, -0.001300524074077, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000144990555555 ] + - # (1, 6) + - [ -0.000006727037037, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, -0.000006726296296, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, -0.000006460555556 ] + - # (1, 7) + - [ -0.000337355925926, 0.000823313365736, -0.000000000000000 ] + - [ 0.000844942189820, -0.001300524074077, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000144990555555 ] + - # (1, 8) + - [ -0.000006727037037, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, -0.000006726296296, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, -0.000006460555556 ] + - # (1, 9) + - [ -0.000337355925926, -0.000823313365736, -0.000000000000000 ] + - [ -0.000844942189820, -0.001300524074077, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000144990555555 ] + - # (1, 10) + - [ -0.000000179259259, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000178518518, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000000749444444 ] + - # (1, 11) + - [ -0.000000431481482, -0.000000149469570, -0.000000028888889 ] + - [ 0.000000149469570, 0.000000033703704, 0.000000377202176 ] + - [ -0.000000028888889, -0.000000377202176, -0.000000756111111 ] + - # (1, 12) + - [ -0.000000431481482, 0.000000149469570, 0.000000028888889 ] + - [ -0.000000149469570, 0.000000033703704, 0.000000377202176 ] + - [ 0.000000028888889, -0.000000377202176, -0.000000756111111 ] + - # (1, 13) + - [ -0.000000082592593, 0.000000051641541, -0.000000312720708 ] + - [ 0.000000350580681, -0.000000315185185, -0.000000215267755 ] + - [ 0.000000341609597, 0.000000161934421, -0.000000756111111 ] + - # (1, 14) + - [ -0.000000082592593, -0.000000051641541, 0.000000312720708 ] + - [ -0.000000350580681, -0.000000315185185, -0.000000215267755 ] + - [ -0.000000341609597, 0.000000161934421, -0.000000756111111 ] + - # (1, 15) + - [ 0.000000162962963, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, 0.000000162592593, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000002979444444 ] + - # (1, 16) + - [ -0.000000082592593, 0.000000350580681, -0.000000341609597 ] + - [ 0.000000051641541, -0.000000315185185, -0.000000161934421 ] + - [ 0.000000312720708, 0.000000215267755, -0.000000756111111 ] + - # (1, 17) + - [ 0.000000162962963, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, 0.000000162592593, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000002979444444 ] + - # (1, 18) + - [ -0.000000082592593, -0.000000350580681, 0.000000341609597 ] + - [ -0.000000051641541, -0.000000315185185, -0.000000161934421 ] + - [ -0.000000312720708, 0.000000215267755, -0.000000756111111 ] + - # (1, 19) + - [ -0.000000179259259, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000178518518, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000000749444444 ] + - # (1, 20) + - [ -0.000000431481482, -0.000000149469570, 0.000000028888889 ] + - [ 0.000000149469570, 0.000000033703704, -0.000000377202176 ] + - [ 0.000000028888889, 0.000000377202176, -0.000000756111111 ] + - # (1, 21) + - [ -0.000000431481482, 0.000000149469570, -0.000000028888889 ] + - [ -0.000000149469570, 0.000000033703704, -0.000000377202176 ] + - [ -0.000000028888889, 0.000000377202176, -0.000000756111111 ] + - # (1, 22) + - [ -0.000000082592593, 0.000000051641541, 0.000000312720708 ] + - [ 0.000000350580681, -0.000000315185185, 0.000000215267755 ] + - [ -0.000000341609597, -0.000000161934421, -0.000000756111111 ] + - # (1, 23) + - [ -0.000000082592593, -0.000000051641541, -0.000000312720708 ] + - [ -0.000000350580681, -0.000000315185185, 0.000000215267755 ] + - [ 0.000000341609597, -0.000000161934421, -0.000000756111111 ] + - # (1, 24) + - [ 0.000000162962963, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, 0.000000162592593, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000002979444444 ] + - # (1, 25) + - [ -0.000000082592593, 0.000000350580681, 0.000000341609597 ] + - [ 0.000000051641541, -0.000000315185185, 0.000000161934421 ] + - [ -0.000000312720708, -0.000000215267755, -0.000000756111111 ] + - # (1, 26) + - [ 0.000000162962963, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, 0.000000162592593, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000002979444444 ] + - # (1, 27) + - [ -0.000000082592593, -0.000000350580681, -0.000000341609597 ] + - [ -0.000000051641541, -0.000000315185185, 0.000000161934421 ] + - [ 0.000000312720708, -0.000000215267755, -0.000000756111111 ] + - # (1, 28) + - [ -0.000344511481482, 0.000283712592593, -0.000797116296296 ] + - [ 0.000283712592593, -0.000016910000000, 0.000460215555556 ] + - [ -0.000797116296296, 0.000460215555556, -0.001150085740745 ] + - # (1, 29) + - [ -0.000006349964647, 0.000000000589344, -0.000000000214180 ] + - [ 0.000000000589344, 0.000000822842301, -0.000000493306792 ] + - [ -0.000000000214180, -0.000000493306792, -0.000003475216882 ] + - # (1, 30) + - [ -0.000344512998316, -0.000283713181937, 0.000797116510476 ] + - [ -0.000283713181937, -0.000016909508967, 0.000460215529014 ] + - [ 0.000797116510476, 0.000460215529014, -0.001150085153485 ] + - # (1, 31) + - [ 0.000146893478322, 0.000000000631480, 0.000000000084104 ] + - [ 0.000000000631480, -0.000508314232993, -0.000920430270855 ] + - [ 0.000000000084104, -0.000920430270855, -0.001150085153485 ] + - # (1, 32) + - [ -0.000007064312912, -0.000006020660144, -0.000008494780888 ] + - [ -0.000006020660144, -0.000000113193736, -0.000004903861708 ] + - [ -0.000008494780888, -0.000004903861708, -0.000004996851852 ] + - # (1, 33) + - [ -0.000007065274569, 0.000006020028665, 0.000008494696784 ] + - [ 0.000006020028665, -0.000000113570409, -0.000004903871089 ] + - [ 0.000008494696784, -0.000004903871089, -0.000004995918595 ] + - # (1, 34) + - [ -0.000000969774619, 0.000003106775928, 0.000000427323303 ] + - [ 0.000003106775928, -0.000004556878117, 0.000000245826410 ] + - [ 0.000000427323303, 0.000000245826410, -0.000003475216882 ] + - # (1, 35) + - [ -0.000000971021728, -0.000003105954590, -0.000000427289376 ] + - [ -0.000003105954590, -0.000004555318480, 0.000000246093312 ] + - [ -0.000000427289376, 0.000000246093312, -0.000003475562886 ] + - # (1, 36) + - [ 0.000003361349949, -0.000000000821337, -0.000000000033927 ] + - [ -0.000000000821337, -0.000010540139597, 0.000009808306152 ] + - [ -0.000000000033927, 0.000009808306152, -0.000004996851852 ] + - # (1, 37) + - [ -0.000001427416889, 0.000001419181116, -0.000000000214180 ] + - [ 0.000001419181116, 0.000000213043714, -0.000000000337490 ] + - [ -0.000000000214180, -0.000000000337490, -0.000004811907582 ] + - # (1, 38) + - [ -0.000003760502988, 0.000000000589344, -0.000000000156191 ] + - [ 0.000000000589344, 0.000000827630524, 0.000000000304010 ] + - [ -0.000000000156191, 0.000000000304010, -0.000007355113786 ] + - # (1, 39) + - [ -0.000001426711501, -0.000001419770461, 0.000000000370370 ] + - [ -0.000001419770461, 0.000000213534747, 0.000000000330552 ] + - [ 0.000000000370370, 0.000000000330552, -0.000004811320330 ] + - # (1, 40) + - [ 0.000001033233819, 0.000000000631480, -0.000000000454474 ] + - [ 0.000000000631480, -0.000002246880183, -0.000000000806776 ] + - [ -0.000000000454474, -0.000000000806776, -0.000004811320330 ] + - # (1, 41) + - [ 0.000000858062546, -0.000001889004015, 0.000000000370370 ] + - [ -0.000001889004015, 0.000003040280666, -0.000000000816158 ] + - [ 0.000000000370370, -0.000000000816158, 0.000003443578616 ] + - # (1, 42) + - [ 0.000000858212000, 0.000001888372535, 0.000000000084104 ] + - [ 0.000001888372535, 0.000003039903993, -0.000000000634887 ] + - [ 0.000000000084104, -0.000000000634887, 0.000003442587372 ] + - # (1, 43) + - [ -0.000000318336911, 0.000001986746167, 0.000000000370370 ] + - [ 0.000001986746167, -0.000002615177053, 0.000000000033480 ] + - [ 0.000000000370370, 0.000000000033480, -0.000007355113786 ] + - # (1, 44) + - [ -0.000000318472909, -0.000001985924829, -0.000000000033927 ] + - [ -0.000001985924829, -0.000002613617416, 0.000000002160690 ] + - [ -0.000000000033927, 0.000000002160690, -0.000007353535290 ] + - # (1, 45) + - [ 0.000004129411572, -0.000000000821337, -0.000000000336443 ] + - [ -0.000000000821337, -0.000000231240249, -0.000000000233421 ] + - [ -0.000000000336443, -0.000000000233421, 0.000003443578616 ] + - # (1, 46) + - [ -0.000344513323853, 0.000283712670736, 0.000797116510476 ] + - [ 0.000283712670736, -0.000016908599269, -0.000460215218065 ] + - [ 0.000797116510476, -0.000460215218065, -0.001150086240565 ] + - # (1, 47) + - [ -0.000006349584796, 0.000000000511201, 0.000000000370370 ] + - [ 0.000000000511201, 0.000000824243032, 0.000000493002782 ] + - [ 0.000000000370370, 0.000000493002782, -0.000003475716707 ] + - # (1, 48) + - [ -0.000344511348864, -0.000283713181937, -0.000797116880846 ] + - [ -0.000283713181937, -0.000016909852746, -0.000460215859566 ] + - [ -0.000797116880846, -0.000460215859566, -0.001150085256585 ] + - # (1, 49) + - [ 0.000146893151726, 0.000000000661241, 0.000000000370370 ] + - [ 0.000000000661241, -0.000508313711835, 0.000920431077631 ] + - [ 0.000000000370370, 0.000920431077631, -0.001150085256585 ] + - # (1, 50) + - [ -0.000007063485646, -0.000006020660144, 0.000008494410517 ] + - [ -0.000006020660144, -0.000000113204194, 0.000004904677866 ] + - [ 0.000008494410517, 0.000004904677866, -0.000004997282320 ] + - # (1, 51) + - [ -0.000007064490054, 0.000006019998903, -0.000008494780888 ] + - [ 0.000006019998903, -0.000000113049250, 0.000004904505976 ] + - [ -0.000008494780888, 0.000004904505976, -0.000004997946192 ] + - # (1, 52) + - [ -0.000000969530115, 0.000003106775928, -0.000000427693674 ] + - [ 0.000003106775928, -0.000004557564261, -0.000000245859890 ] + - [ -0.000000427693674, -0.000000245859890, -0.000003475716707 ] + - # (1, 53) + - [ -0.000000970063852, -0.000003107631794, 0.000000427323303 ] + - [ -0.000003107631794, -0.000004555459548, -0.000000248254002 ] + - [ 0.000000427323303, -0.000000248254002, -0.000003474068853 ] + - # (1, 54) + - [ 0.000003361196713, 0.000000000855866, 0.000000000370370 ] + - [ 0.000000000855866, -0.000010540280666, -0.000009808072731 ] + - [ 0.000000000370370, -0.000009808072731, -0.000004997282320 ] + - # (2, 1) + - [ -0.000344511481482, 0.000283712592593, -0.000797116296296 ] + - [ 0.000283712592593, -0.000016910000000, 0.000460215555556 ] + - [ -0.000797116296296, 0.000460215555556, -0.001150085740745 ] + - # (2, 2) + - [ -0.000344512998316, -0.000283713181937, 0.000797116510476 ] + - [ -0.000283713181937, -0.000016909508967, 0.000460215529014 ] + - [ 0.000797116510476, 0.000460215529014, -0.001150085153485 ] + - # (2, 3) + - [ -0.000006349964647, 0.000000000589344, -0.000000000214180 ] + - [ 0.000000000589344, 0.000000822842301, -0.000000493306792 ] + - [ -0.000000000214180, -0.000000493306792, -0.000003475216882 ] + - # (2, 4) + - [ -0.000000969774619, 0.000003106775928, 0.000000427323303 ] + - [ 0.000003106775928, -0.000004556878117, 0.000000245826410 ] + - [ 0.000000427323303, 0.000000245826410, -0.000003475216882 ] + - # (2, 5) + - [ 0.000003361349949, -0.000000000821337, -0.000000000033927 ] + - [ -0.000000000821337, -0.000010540139597, 0.000009808306152 ] + - [ -0.000000000033927, 0.000009808306152, -0.000004996851852 ] + - # (2, 6) + - [ -0.000000971021728, -0.000003105954590, -0.000000427289376 ] + - [ -0.000003105954590, -0.000004555318480, 0.000000246093312 ] + - [ -0.000000427289376, 0.000000246093312, -0.000003475562886 ] + - # (2, 7) + - [ 0.000146893478322, 0.000000000631480, 0.000000000084104 ] + - [ 0.000000000631480, -0.000508314232993, -0.000920430270855 ] + - [ 0.000000000084104, -0.000920430270855, -0.001150085153485 ] + - # (2, 8) + - [ -0.000007065274569, 0.000006020028665, 0.000008494696784 ] + - [ 0.000006020028665, -0.000000113570409, -0.000004903871089 ] + - [ 0.000008494696784, -0.000004903871089, -0.000004995918595 ] + - # (2, 9) + - [ -0.000007064312912, -0.000006020660144, -0.000008494780888 ] + - [ -0.000006020660144, -0.000000113193736, -0.000004903861708 ] + - [ -0.000008494780888, -0.000004903861708, -0.000004996851852 ] + - # (2, 10) + - [ -0.000344513323853, 0.000283712670736, 0.000797116510476 ] + - [ 0.000283712670736, -0.000016908599269, -0.000460215218065 ] + - [ 0.000797116510476, -0.000460215218065, -0.001150086240565 ] + - # (2, 11) + - [ -0.000344511348864, -0.000283713181937, -0.000797116880846 ] + - [ -0.000283713181937, -0.000016909852746, -0.000460215859566 ] + - [ -0.000797116880846, -0.000460215859566, -0.001150085256585 ] + - # (2, 12) + - [ -0.000006349584796, 0.000000000511201, 0.000000000370370 ] + - [ 0.000000000511201, 0.000000824243032, 0.000000493002782 ] + - [ 0.000000000370370, 0.000000493002782, -0.000003475716707 ] + - # (2, 13) + - [ -0.000000969530115, 0.000003106775928, -0.000000427693674 ] + - [ 0.000003106775928, -0.000004557564261, -0.000000245859890 ] + - [ -0.000000427693674, -0.000000245859890, -0.000003475716707 ] + - # (2, 14) + - [ 0.000003361196713, 0.000000000855866, 0.000000000370370 ] + - [ 0.000000000855866, -0.000010540280666, -0.000009808072731 ] + - [ 0.000000000370370, -0.000009808072731, -0.000004997282320 ] + - # (2, 15) + - [ -0.000000970063852, -0.000003107631794, 0.000000427323303 ] + - [ -0.000003107631794, -0.000004555459548, -0.000000248254002 ] + - [ 0.000000427323303, -0.000000248254002, -0.000003474068853 ] + - # (2, 16) + - [ 0.000146893151726, 0.000000000661241, 0.000000000370370 ] + - [ 0.000000000661241, -0.000508313711835, 0.000920431077631 ] + - [ 0.000000000370370, 0.000920431077631, -0.001150085256585 ] + - # (2, 17) + - [ -0.000007064490054, 0.000006019998903, -0.000008494780888 ] + - [ 0.000006019998903, -0.000000113049250, 0.000004904505976 ] + - [ -0.000008494780888, 0.000004904505976, -0.000004997946192 ] + - # (2, 18) + - [ -0.000007063485646, -0.000006020660144, 0.000008494410517 ] + - [ -0.000006020660144, -0.000000113204194, 0.000004904677866 ] + - [ 0.000008494410517, 0.000004904677866, -0.000004997282320 ] + - # (2, 19) + - [ -0.000001427416889, 0.000001419181116, -0.000000000214180 ] + - [ 0.000001419181116, 0.000000213043714, -0.000000000337490 ] + - [ -0.000000000214180, -0.000000000337490, -0.000004811907582 ] + - # (2, 20) + - [ -0.000001426711501, -0.000001419770461, 0.000000000370370 ] + - [ -0.000001419770461, 0.000000213534747, 0.000000000330552 ] + - [ 0.000000000370370, 0.000000000330552, -0.000004811320330 ] + - # (2, 21) + - [ -0.000003760502988, 0.000000000589344, -0.000000000156191 ] + - [ 0.000000000589344, 0.000000827630524, 0.000000000304010 ] + - [ -0.000000000156191, 0.000000000304010, -0.000007355113786 ] + - # (2, 22) + - [ -0.000000318336911, 0.000001986746167, 0.000000000370370 ] + - [ 0.000001986746167, -0.000002615177053, 0.000000000033480 ] + - [ 0.000000000370370, 0.000000000033480, -0.000007355113786 ] + - # (2, 23) + - [ 0.000004129411572, -0.000000000821337, -0.000000000336443 ] + - [ -0.000000000821337, -0.000000231240249, -0.000000000233421 ] + - [ -0.000000000336443, -0.000000000233421, 0.000003443578616 ] + - # (2, 24) + - [ -0.000000318472909, -0.000001985924829, -0.000000000033927 ] + - [ -0.000001985924829, -0.000002613617416, 0.000000002160690 ] + - [ -0.000000000033927, 0.000000002160690, -0.000007353535290 ] + - # (2, 25) + - [ 0.000001033233819, 0.000000000631480, -0.000000000454474 ] + - [ 0.000000000631480, -0.000002246880183, -0.000000000806776 ] + - [ -0.000000000454474, -0.000000000806776, -0.000004811320330 ] + - # (2, 26) + - [ 0.000000858212000, 0.000001888372535, 0.000000000084104 ] + - [ 0.000001888372535, 0.000003039903993, -0.000000000634887 ] + - [ 0.000000000084104, -0.000000000634887, 0.000003442587372 ] + - # (2, 27) + - [ 0.000000858062546, -0.000001889004015, 0.000000000370370 ] + - [ -0.000001889004015, 0.000003040280666, -0.000000000816158 ] + - [ 0.000000000370370, -0.000000000816158, 0.000003443578616 ] + - # (2, 28) + - [ 0.006051937407412, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, 0.006051935925923, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.006116149444445 ] + - # (2, 29) + - [ -0.001782108148148, -0.000010814412042, -0.000000000000000 ] + - [ 0.000010814412042, 0.000144228148149, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000144990555555 ] + - # (2, 30) + - [ -0.001782108148148, 0.000010814412042, -0.000000000000000 ] + - [ -0.000010814412042, 0.000144228148149, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000144990555555 ] + - # (2, 31) + - [ -0.000337355925926, 0.000823313365736, -0.000000000000000 ] + - [ 0.000844942189820, -0.001300524074077, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000144990555555 ] + - # (2, 32) + - [ -0.000337355925926, -0.000823313365736, -0.000000000000000 ] + - [ -0.000844942189820, -0.001300524074077, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000144990555555 ] + - # (2, 33) + - [ -0.000006727037037, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, -0.000006726296296, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, -0.000006460555556 ] + - # (2, 34) + - [ -0.000337355925926, 0.000844942189820, -0.000000000000000 ] + - [ 0.000823313365736, -0.001300524074077, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000144990555555 ] + - # (2, 35) + - [ -0.000006727037037, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, -0.000006726296296, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, -0.000006460555556 ] + - # (2, 36) + - [ -0.000337355925926, -0.000844942189820, -0.000000000000000 ] + - [ -0.000823313365736, -0.001300524074077, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000144990555555 ] + - # (2, 37) + - [ -0.000000179259259, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000178518518, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000000749444444 ] + - # (2, 38) + - [ -0.000000431481482, 0.000000149469570, -0.000000028888889 ] + - [ -0.000000149469570, 0.000000033703704, -0.000000377202176 ] + - [ -0.000000028888889, 0.000000377202176, -0.000000756111111 ] + - # (2, 39) + - [ -0.000000431481482, -0.000000149469570, 0.000000028888889 ] + - [ 0.000000149469570, 0.000000033703704, -0.000000377202176 ] + - [ 0.000000028888889, 0.000000377202176, -0.000000756111111 ] + - # (2, 40) + - [ -0.000000082592593, 0.000000350580681, 0.000000341609597 ] + - [ 0.000000051641541, -0.000000315185185, 0.000000161934421 ] + - [ -0.000000312720708, -0.000000215267755, -0.000000756111111 ] + - # (2, 41) + - [ -0.000000082592593, -0.000000350580681, -0.000000341609597 ] + - [ -0.000000051641541, -0.000000315185185, 0.000000161934421 ] + - [ 0.000000312720708, -0.000000215267755, -0.000000756111111 ] + - # (2, 42) + - [ 0.000000162962963, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, 0.000000162592593, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000002979444444 ] + - # (2, 43) + - [ -0.000000082592593, 0.000000051641541, 0.000000312720708 ] + - [ 0.000000350580681, -0.000000315185185, 0.000000215267755 ] + - [ -0.000000341609597, -0.000000161934421, -0.000000756111111 ] + - # (2, 44) + - [ 0.000000162962963, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, 0.000000162592593, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000002979444444 ] + - # (2, 45) + - [ -0.000000082592593, -0.000000051641541, -0.000000312720708 ] + - [ -0.000000350580681, -0.000000315185185, 0.000000215267755 ] + - [ 0.000000341609597, -0.000000161934421, -0.000000756111111 ] + - # (2, 46) + - [ -0.000000179259259, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000178518518, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000000749444444 ] + - # (2, 47) + - [ -0.000000431481482, 0.000000149469570, 0.000000028888889 ] + - [ -0.000000149469570, 0.000000033703704, 0.000000377202176 ] + - [ 0.000000028888889, -0.000000377202176, -0.000000756111111 ] + - # (2, 48) + - [ -0.000000431481482, -0.000000149469570, -0.000000028888889 ] + - [ 0.000000149469570, 0.000000033703704, 0.000000377202176 ] + - [ -0.000000028888889, -0.000000377202176, -0.000000756111111 ] + - # (2, 49) + - [ -0.000000082592593, 0.000000350580681, -0.000000341609597 ] + - [ 0.000000051641541, -0.000000315185185, -0.000000161934421 ] + - [ 0.000000312720708, 0.000000215267755, -0.000000756111111 ] + - # (2, 50) + - [ -0.000000082592593, -0.000000350580681, 0.000000341609597 ] + - [ -0.000000051641541, -0.000000315185185, -0.000000161934421 ] + - [ -0.000000312720708, 0.000000215267755, -0.000000756111111 ] + - # (2, 51) + - [ 0.000000162962963, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, 0.000000162592593, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000002979444444 ] + - # (2, 52) + - [ -0.000000082592593, 0.000000051641541, -0.000000312720708 ] + - [ 0.000000350580681, -0.000000315185185, -0.000000215267755 ] + - [ 0.000000341609597, 0.000000161934421, -0.000000756111111 ] + - # (2, 53) + - [ 0.000000162962963, -0.000000000000000, -0.000000000000000 ] + - [ -0.000000000000000, 0.000000162592593, -0.000000000000000 ] + - [ -0.000000000000000, -0.000000000000000, 0.000002979444444 ] + - # (2, 54) + - [ -0.000000082592593, -0.000000051641541, 0.000000312720708 ] + - [ -0.000000350580681, -0.000000315185185, -0.000000215267755 ] + - [ -0.000000341609597, 0.000000161934421, -0.000000756111111 ] \ No newline at end of file diff --git a/tests/test_material.py b/tests/test_material.py index ce7fd6a..4cf8698 100644 --- a/tests/test_material.py +++ b/tests/test_material.py @@ -1,9 +1,14 @@ -import pytest +import os + import numpy as np -from darkmagic.material import MaterialProperties -import darkmagic.constants as const +import pytest from pytest_parametrize_cases import Case, parametrize_cases +import darkmagic.constants as const +from darkmagic.material import MaterialProperties, PhononMaterial + +TEST_DIR = os.path.dirname(os.path.abspath(__file__)) + def create_test_dict(n_atoms, rank, zeros=False): psi = ["n", "p", "e"] @@ -269,3 +274,58 @@ def test_material_properties_invalid( props = MaterialProperties(N, S, L, L_dot_S, L_tens_S, lambda_S, lambda_L, m_psi) with pytest.raises(AssertionError): props._validate_input(n_atoms) + + +@parametrize_cases( + Case( + "hcp_He", + phonopy_yaml_path=f"{TEST_DIR}/data/hcp_He_1GPa.phonopy.yaml", + n_atoms=2, + alat=4.852625323567155, + m_atom1=4.00260325415, + label1="He", + eps=np.diag([1.065579, 1.065579, 1.065579]), + bec1=np.zeros((3, 3)), + opt_freq=[2.5810436703, 2.5810436703, 6.4343430269], + dE_max=6.4343430269 * 1.5, # 1.5 * max optical phonon + q_cut=10 + * np.sqrt(4.00260325415 * 6.4343430269 * 1.5), # sqrt(max mass * dE_max) + ) +) +def test_phonon_material( + phonopy_yaml_path, + n_atoms, + alat, + m_atom1, + label1, + eps, + bec1, + opt_freq, + dE_max, + q_cut, +): + props = MaterialProperties(N=create_test_dict(2, 0)) + material = PhononMaterial("test", props, phonopy_yaml_path) + assert material.name == "test" + assert material.n_atoms == n_atoms + assert material.structure.lattice.a == alat * const.Ang_to_inveV + assert material.structure.sites[0].label == label1 + assert material.m_atoms[0] == pytest.approx(m_atom1 * const.amu_to_eV) + assert np.all(material.epsilon == eps) + assert np.all(material.born[0] == bec1) + freq, eigvec = material.get_eig([[0, 0, 0]], with_eigenvectors=True) + assert freq.shape == (1, n_atoms * 3) + assert eigvec.shape == (1, n_atoms * 3, n_atoms, 3) + # Acoustic modes + assert np.all(np.abs(freq[0, :2]) < 1e-5) + # Compare against optical frequencies at gamma point + opt_freq = np.array(opt_freq) + assert np.all(np.abs(freq[0, 3:] - opt_freq * const.THz_to_eV) < 1e-5) + # Eigvecs should have norm 1/sqrt(2) + assert np.all(np.abs(np.linalg.norm(eigvec, axis=-1) - np.sqrt(2) / 2) < 1e-5) + assert pytest.approx(material.max_dE) == dE_max * const.THz_to_eV + assert pytest.approx(material.q_cut) == q_cut * np.sqrt( + const.amu_to_eV * const.THz_to_eV + ) + + # assert np.allclose(eigvec[0, 0, 0], eigvec11)