コード例 #1
0
ファイル: periodic_1D_prism.py プロジェクト: aradi/nanocut
 def __init__(self, geometry, period, **kwargs):
     """Construct Periodic1DPrism instance.
     
     Keyword args:
         shift_vector: Origin of the body.
         planes_normal: Plane definitions with normal vectors and distances.
         planes_miller: Plane definitions with miller indices and distances.
     """
     # Check for plane normals not orthogonal to axis (plane cuts axis)        
     self.periodicity = period
     axis = self.periodicity.get_axis("cartesian")
     planes_normal = self.pop_planes(geometry, kwargs)
     projections = abs(np.dot(planes_normal[:,:3], axis.transpose())) 
     if np.any(projections > EPSILON):            
         error("Some plane(s) are not parallel to axis")
         
     # Determine basal planes. Shift them with a small amount to make sure
     # atoms do not stay outside due to arithmetic errors.
     axisnorm = np.linalg.norm(axis[0])
     axis0 = axis[0] / axisnorm
     basal_planes = np.array(
         [[ axis0[0], axis0[1], axis0[2], -PERIODIC_TOLERANCE ],
          [ axis0[0], axis0[1], axis0[2], axisnorm + PERIODIC_TOLERANCE ]])
     
     # Extend planes by basal planes and call base class
     planes_normal = np.vstack(( basal_planes, planes_normal ))
     kwargs["planes_normal"] = planes_normal
     kwargs["planes_normal_coordsys"] = "cartesian"
     Polyhedron.__init__(self, geometry, period, **kwargs)
コード例 #2
0
    def __init__(self, geometry, period, **kwargs):
        """Construct Periodic1DPrism instance.
        
        Keyword args:
            shift_vector: Origin of the body.
            planes_normal: Plane definitions with normal vectors and distances.
            planes_miller: Plane definitions with miller indices and distances.
        """
        # Check for plane normals not orthogonal to axis (plane cuts axis)
        self.periodicity = period
        axis = self.periodicity.get_axis("cartesian")
        planes_normal = self.pop_planes(geometry, kwargs)
        projections = abs(np.dot(planes_normal[:, :3], axis.transpose()))
        if np.any(projections > EPSILON):
            error("Some plane(s) are not parallel to axis")

        # Determine basal planes. Shift them with a small amount to make sure
        # atoms do not stay outside due to arithmetic errors.
        axisnorm = np.linalg.norm(axis[0])
        axis0 = axis[0] / axisnorm
        basal_planes = np.array(
            [[axis0[0], axis0[1], axis0[2], -PERIODIC_TOLERANCE],
             [axis0[0], axis0[1], axis0[2], axisnorm + PERIODIC_TOLERANCE]])

        # Extend planes by basal planes and call base class
        planes_normal = np.vstack((basal_planes, planes_normal))
        kwargs["planes_normal"] = planes_normal
        kwargs["planes_normal_coordsys"] = "cartesian"
        Polyhedron.__init__(self, geometry, period, **kwargs)
コード例 #3
0
 def __init__(self, geometry, period, **kwargs):
     """Construct Periodic2DPlane instance.
     
     Keyword args:
         shift_vector: Origin of the body.
         thickness: Distance between the upper and lower plane.
     """
     self.periodicity = period
     self.thickness = kwargs.get("thickness") 
     axis1, axis2 = self.periodicity.get_axis("cartesian")
     # Surface normal vector
     surfnorm = np.cross(axis1, axis2).astype(float)
     surfnorm = surfnorm / np.linalg.norm(surfnorm)
     # Normal vector of the side planes of the polyhedron, pointing inwards
     n1 = np.cross(surfnorm, axis1)
     n1 /= np.linalg.norm(n1)
     n2 = np.cross(axis2, surfnorm)
     n2 /= np.linalg.norm(n2)
     # Distances of the side planes from the origin
     d1 = np.dot(n1, axis2)
     d2 = np.dot(n2, axis1)
     # Sign of the positive distance
     s1 = np.sign(d1)
     s2 = np.sign(d2)
     # Assemble polyhedron
     kwargs["planes_normal"] = np.array(
         [[ n1[0], n1[1], n1[2], 0.0 -s1 * PERIODIC_TOLERANCE ],
          [ n1[0], n1[1], n1[2], d1 + s1 * PERIODIC_TOLERANCE ],
          [ n2[0], n2[1], n2[2], 0.0 - s2 * PERIODIC_TOLERANCE ],
          [ n2[0], n2[1], n2[2], d2 + s2 * PERIODIC_TOLERANCE ],
          [ surfnorm[0], surfnorm[1], surfnorm[2], -self.thickness / 2.0 ],
          [ surfnorm[0], surfnorm[1], surfnorm[2], self.thickness / 2.0 ]
          ])
     kwargs["planes_normal_coordsys"] = "cartesian"
     Polyhedron.__init__(self, geometry, period, **kwargs)
コード例 #4
0
    def atoms_inside(self, atoms):
        """Decides which atoms are inside the body (see Body class)."""

        atoms_inside_body = Polyhedron.atoms_inside(self, atoms)
        atoms_inside_body *= self.periodicity.mask_unique(
            atoms - self.shift_vector, atoms_inside_body)
        return atoms_inside_body
コード例 #5
0
ファイル: periodic_1D_prism.py プロジェクト: aradi/nanocut
 def atoms_inside(self, atoms):
     """Decides which atoms are inside the body (see Body class)."""
     
     atoms_inside_body = Polyhedron.atoms_inside(self, atoms)
     atoms_inside_body *= self.periodicity.mask_unique(
         atoms - self.shift_vector, atoms_inside_body)
     return atoms_inside_body
コード例 #6
0
    def __init__(self, geometry, period, **kwargs):
        """Construct Periodic3DSupercell instance.
        
        Keyword args:
            shift_vector: Origin of the body.
            thickness: Distance between the upper and lower plane.
        """
        self.periodicity = period

        axis1, axis2, axis3 = self.periodicity.get_axis("cartesian")
        # Normal vector of the side planes of the polyhedron
        n12 = np.cross(axis1, axis2)
        n23 = np.cross(axis2, axis3)
        n31 = np.cross(axis3, axis1)
        n12 /= np.linalg.norm(n12)
        n23 /= np.linalg.norm(n23)
        n31 /= np.linalg.norm(n31)
        # Distances of the side planes from the origin
        d12 = np.dot(n12, axis3)
        d23 = np.dot(n23, axis1)
        d31 = np.dot(n31, axis2)
        # Sign of positive distance
        s12 = np.sign(d12)
        s23 = np.sign(d23)
        s31 = np.sign(d31)
        # Assemble polyhedron
        kwargs["planes_normal"] = np.array([
            [n12[0], n12[1], n12[2], -s12 * PERIODIC_TOLERANCE],
            [n23[0], n23[1], n23[2], -s23 * PERIODIC_TOLERANCE],
            [n31[0], n31[1], n31[2], -s31 * PERIODIC_TOLERANCE],
            [n12[0], n12[1], n12[2], d12 + s12 * PERIODIC_TOLERANCE],
            [n23[0], n23[1], n23[2], d23 + s23 * PERIODIC_TOLERANCE],
            [n31[0], n31[1], n31[2], d31 + s31 * PERIODIC_TOLERANCE],
        ])
        kwargs["planes_normal_coordsys"] = "cartesian"
        Polyhedron.__init__(self, geometry, period, **kwargs)
コード例 #7
0
 def __init__(self, geometry, period, **kwargs):
     """Construct Periodic3DSupercell instance.
     
     Keyword args:
         shift_vector: Origin of the body.
         thickness: Distance between the upper and lower plane.
     """
     self.periodicity = period
     
     axis1, axis2, axis3 = self.periodicity.get_axis("cartesian")
     # Normal vector of the side planes of the polyhedron
     n12 = np.cross(axis1, axis2)
     n23 = np.cross(axis2, axis3)
     n31 = np.cross(axis3, axis1)
     n12 /= np.linalg.norm(n12)
     n23 /= np.linalg.norm(n23)
     n31 /= np.linalg.norm(n31)
     # Distances of the side planes from the origin
     d12 = np.dot(n12, axis3)
     d23 = np.dot(n23, axis1)
     d31 = np.dot(n31, axis2)
     # Sign of positive distance 
     s12 = np.sign(d12)
     s23 = np.sign(d23)
     s31 = np.sign(d31)
     # Assemble polyhedron
     kwargs["planes_normal"] = np.array(
         [[ n12[0], n12[1], n12[2], -s12 * PERIODIC_TOLERANCE ],
          [ n23[0], n23[1], n23[2], -s23 * PERIODIC_TOLERANCE ],
          [ n31[0], n31[1], n31[2], -s31 * PERIODIC_TOLERANCE ],
          [ n12[0], n12[1], n12[2], d12 + s12 * PERIODIC_TOLERANCE ],
          [ n23[0], n23[1], n23[2], d23 + s23 * PERIODIC_TOLERANCE ],
          [ n31[0], n31[1], n31[2], d31 + s31 * PERIODIC_TOLERANCE ],
          ])
     kwargs["planes_normal_coordsys"] = "cartesian"
     Polyhedron.__init__(self, geometry, period, **kwargs)