def test_seedname_read_coord(sisl_tmp, unit_sc, unit): f = sisl_tmp('read_coord.win', _dir) with open(f, 'w') as fh: fh.write(""" begin unit_cell_cart {} 2. 0. 0. 0. 2. 0 0 0 2. end unit_cell_cart begin atoms_cart {} C 0.5 0.5 0.5 end """.format(unit_sc, unit)) g = winSileWannier90(f).read_geometry() if len(unit) == 0: unit = 'ang' unit = units(unit.strip().capitalize(), 'Ang') if len(unit_sc) == 0: unit_sc = 'ang' unit_sc = units(unit_sc.strip().capitalize(), 'Ang') assert np.allclose(g.cell, np.identity(3) * 2 * unit_sc) assert np.allclose(g.xyz, [0.5 * unit] * 3)
def read_dynamical_matrix(self, **kwargs): """ Returns a GULP dynamical matrix model for the output of GULP Parameters ---------- cutoff: float, optional absolute values below the cutoff are considered 0. Defaults to 1e-4 eV/Ang**2. dtype: np.dtype (np.float64) default data-type of the matrix order: list of str, optional the order of which to try and read the dynamical matrix By default this is ``['got'/'gout', 'FC']``. Note that ``FC`` corresponds to the `fcSileGULP` file (``FORCE_CONSTANTS_2ND``). """ geom = self.read_geometry(**kwargs) order = kwargs.pop('order', ['got', 'FC']) for f in order: v = getattr(self, '_r_dynamical_matrix_{}'.format(f.lower()))(geom, **kwargs) if v is not None: # Convert the dynamical matrix such that a diagonalization returns eV ^ 2 scale = constant.hbar / units('Ang', 'm') / units( 'eV amu', 'J kg')**0.5 v.data *= scale**2 return DynamicalMatrix.fromsp(geom, v) return None
Returns ------- numpy.ndarray velocities per mode with final dimension ``(mode.shape[0], 3)``, the velocity unit is Ang/ps Units *may* change in future releases. """ if mode.ndim == 1: return velocity(mode.reshape(1, -1), hw, dDk, degenerate).ravel() return _velocity(mode, hw, dDk, degenerate) # dDk is in [Ang * eV ** 2] # velocity units in Ang/ps _velocity_const = units('ps', 's') / constant.hbar('eV s') def _velocity(mode, hw, dDk, degenerate): r""" For modes in an orthogonal basis """ # Along all directions v = np.empty([mode.shape[0], 3], dtype=dtype_complex_to_real(mode.dtype)) # Decouple the degenerate modes if not degenerate is None: for deg in degenerate: # Set the average frequency hw[deg] = np.average(hw[deg]) # Now diagonalize to find the contributions from individual modes