pymatgen_diffusion/neb/full_path_mapper.py
def _get_chg_between_sites_tube(self, migration_path, mask_file_seedname=None):
        """
        Calculate the amount of charge that a migrating ion has to move through in order to complete a hop

        Args:
            migration_path: MigrationPath object that represents a given hop
            mask_file_seedname(string): seedname for output of the migration path masks (for debugging and
                visualization) (Default value = None)

        Returns:
            float: The total charge density in a tube that connects two sites of a given edges of the graph

        """
        try:
            self._tube_radius
        except NameError:
            logger.warning(
                "The radius of the tubes for charge analysis need to be defined first."
            )
        ipos = migration_path.isite.frac_coords
        epos = migration_path.esite.frac_coords
        if not self.base_aeccar:
            return 0

        cart_ipos = np.dot(ipos, self.base_aeccar.structure.lattice.matrix)
        cart_epos = np.dot(epos, self.base_aeccar.structure.lattice.matrix)
        pbc_mask = np.zeros(self._uc_grid_shape, dtype=bool).flatten()
        for img in self._images:
            grid_pos = np.dot(
                self._fcoords + img, self.base_aeccar.structure.lattice.matrix
            )
            proj_on_line = np.dot(grid_pos - cart_ipos, cart_epos - cart_ipos) / (
                np.linalg.norm(cart_epos - cart_ipos)
            )
            dist_to_line = np.linalg.norm(
                np.cross(grid_pos - cart_ipos, cart_epos - cart_ipos)
                / (np.linalg.norm(cart_epos - cart_ipos)),
                axis=-1,
            )

            mask = (
                (proj_on_line >= 0)
                * (proj_on_line < np.linalg.norm(cart_epos - cart_ipos))
                * (dist_to_line < self._tube_radius)
            )
            pbc_mask = pbc_mask + mask
        pbc_mask = pbc_mask.reshape(self._uc_grid_shape)

        if mask_file_seedname:
            mask_out = VolumetricData(
                structure=self.base_aeccar.structure.copy(),
                data={"total": self.base_aeccar.data["total"]},
            )
            mask_out.structure.insert(0, "X", ipos)
            mask_out.structure.insert(0, "X", epos)
            mask_out.data["total"] = pbc_mask
            isym = self.symm_structure.wyckoff_symbols[migration_path.iindex]
            esym = self.symm_structure.wyckoff_symbols[migration_path.eindex]
            mask_out.write_file(
                "{}_{}_{}_tot({:0.2f}).vasp".format(
                    mask_file_seedname, isym, esym, mask_out.data["total"].sum()
                )
            )

        return (
            self.base_aeccar.data["total"][pbc_mask].sum()
            / self.base_aeccar.ngridpts
            / self.base_aeccar.structure.volume
        )

        Calculate the amount of charge that a migrating ion has to move through in order to complete a hop

        Args:
            migration_path: MigrationPath object that represents a given hop
            mask_file_seedname(string): seedname for output of the migration path masks (for debugging and
                visualization) (Default value = None)

        Returns:
            float: The total charge density in a tube that connects two sites of a given edges of the graph

        
Calculate the amount of charge that a migrating ion has to move through in order to complete a hop
Calculate the amount of charge that a migrating ion has to move through in order to complete a hop
def _get_chg_between_sites_tube(self, migration_path, mask_file_seedname=None):
        try:
            self._tube_radius
        except NameError:
            logger.warning(
                "The radius of the tubes for charge analysis need to be defined first."
            )
        ipos = migration_path.isite.frac_coords
        epos = migration_path.esite.frac_coords
        if not self.base_aeccar:
            return 0
        cart_ipos = np.dot(ipos, self.base_aeccar.structure.lattice.matrix)
        cart_epos = np.dot(epos, self.base_aeccar.structure.lattice.matrix)
        pbc_mask = np.zeros(self._uc_grid_shape, dtype=bool).flatten()
        for img in self._images:
            grid_pos = np.dot(
                self._fcoords + img, self.base_aeccar.structure.lattice.matrix
            )
            proj_on_line = np.dot(grid_pos - cart_ipos, cart_epos - cart_ipos) / (
                np.linalg.norm(cart_epos - cart_ipos)
            )
            dist_to_line = np.linalg.norm(
                np.cross(grid_pos - cart_ipos, cart_epos - cart_ipos)
                / (np.linalg.norm(cart_epos - cart_ipos)),
                axis=-1,
            )
            mask = (
                (proj_on_line >= 0)
                * (proj_on_line < np.linalg.norm(cart_epos - cart_ipos))
                * (dist_to_line < self._tube_radius)
            )
            pbc_mask = pbc_mask + mask
        pbc_mask = pbc_mask.reshape(self._uc_grid_shape)
        if mask_file_seedname:
            mask_out = VolumetricData(
                structure=self.base_aeccar.structure.copy(),
                data={"total": self.base_aeccar.data["total"]},
            )
            mask_out.structure.insert(0, "X", ipos)
            mask_out.structure.insert(0, "X", epos)
            mask_out.data["total"] = pbc_mask
            isym = self.symm_structure.wyckoff_symbols[migration_path.iindex]
            esym = self.symm_structure.wyckoff_symbols[migration_path.eindex]
            mask_out.write_file(
                "{}_{}_{}_tot({:0.2f}).vasp".format(
                    mask_file_seedname, isym, esym, mask_out.data["total"].sum()
                )
            )
        return (
            self.base_aeccar.data["total"][pbc_mask].sum()
            / self.base_aeccar.ngridpts
            / self.base_aeccar.structure.volume
        )
def _get_chg_between_sites_tube ( self , migration_path , mask_file_seedname = None ) : try : self . _tube_radius except NameError : logger . warning ( "The radius of the tubes for charge analysis need to be defined first." ) ipos = migration_path . isite . frac_coords epos = migration_path . esite . frac_coords if not self . base_aeccar : return 0 cart_ipos = np . dot ( ipos , self . base_aeccar . structure . lattice . matrix ) cart_epos = np . dot ( epos , self . base_aeccar . structure . lattice . matrix ) pbc_mask = np . zeros ( self . _uc_grid_shape , dtype = bool ) . flatten ( ) for img in self . _images : grid_pos = np . dot ( self . _fcoords + img , self . base_aeccar . structure . lattice . matrix ) proj_on_line = np . dot ( grid_pos - cart_ipos , cart_epos - cart_ipos ) / ( np . linalg . norm ( cart_epos - cart_ipos ) ) dist_to_line = np . linalg . norm ( np . cross ( grid_pos - cart_ipos , cart_epos - cart_ipos ) / ( np . linalg . norm ( cart_epos - cart_ipos ) ) , axis = - 1 , ) mask = ( ( proj_on_line >= 0 ) * ( proj_on_line < np . linalg . norm ( cart_epos - cart_ipos ) ) * ( dist_to_line < self . _tube_radius ) ) pbc_mask = pbc_mask + mask pbc_mask = pbc_mask . reshape ( self . _uc_grid_shape ) if mask_file_seedname : mask_out = VolumetricData ( structure = self . base_aeccar . structure . copy ( ) , data = { "total" : self . base_aeccar . data [ "total" ] } , ) mask_out . structure . insert ( 0 , "X" , ipos ) mask_out . structure . insert ( 0 , "X" , epos ) mask_out . data [ "total" ] = pbc_mask isym = self . symm_structure . wyckoff_symbols [ migration_path . iindex ] esym = self . symm_structure . wyckoff_symbols [ migration_path . eindex ] mask_out . write_file ( "{}_{}_{}_tot({:0.2f}).vasp" . format ( mask_file_seedname , isym , esym , mask_out . data [ "total" ] . sum ( ) ) ) return ( self . base_aeccar . data [ "total" ] [ pbc_mask ] . sum ( ) / self . base_aeccar . ngridpts / self . base_aeccar . structure . volume )
Calculate the amount of charge that a migrating ion has to move through in order to complete a hop
Calculate the amount of charge that a migrating ion has to move through in order to complete a hop
"""
        Calculate the amount of charge that a migrating ion has to move through in order to complete a hop

        Args:
            migration_path: MigrationPath object that represents a given hop
            mask_file_seedname(string): seedname for output of the migration path masks (for debugging and
                visualization) (Default value = None)

        Returns:
            float: The total charge density in a tube that connects two sites of a given edges of the graph

        """
The total charge density in a tube that connects two sites of a given edges of the graph
The total charge density in a tube that connects two sites of a given edges of the graph
float
self
migration_path
MigrationPath object that represents a given hop
MigrationPath object that represents a given hop
mask_file_seedname
seedname for output of the migration path masks (for debugging and
visualization) (Default value = None)
seedname for output of the migration path masks ( for debugging and visualization ) ( Default value = None )