Calculates the dipole of the Slab in the direction of the surface
        normal. Note that the Slab must be oxidation state-decorated for this
        to work properly. Otherwise, the Slab will always have a dipole of 0.
973543
def dipole(self):
        
        dipole = np.zeros(3)
        mid_pt = np.sum(self.cart_coords, axis=0) / len(self)
        normal = self.normal
        for site in self:
            charge = sum([getattr(sp, "oxi_state", 0) * amt
                          for sp, amt in site.species.items()])
            dipole += charge * np.dot(site.coords - mid_pt, normal) * normal
        return dipole
108995
def get_orientation_degrees(self):
        

        orientation = self.get_orientation_radians()
        for key, val in orientation.items():
            deg = math.degrees(val)  # Result is -180 to +180
            orientation[key] = deg + 360 if deg < 0 else deg
        return orientation
811957
def get_under_hollow(self):
        
        C0 = self.B[-1:] * (3, 3, 1)
        ads_pos = C0.positions[4]

        C = self.get_subsurface_layer() * (3, 3, 1)

        ret = 'FCC'
        if np.any([np.linalg.norm(ads_pos[:2] - ele.position[:2]) < 0.5 *
                   cradii[ele.number] for ele in C]):
            ret = 'HCP'

        return ret
104413
def unit_normal(pt_a, pt_b, pt_c):
    """"""
    x_val = np.linalg.det([[1, pt_a[1], pt_a[2]], [1, pt_b[1], pt_b[2]], [1, pt_c[1], pt_c[2]]])
    y_val = np.linalg.det([[pt_a[0], 1, pt_a[2]], [pt_b[0], 1, pt_b[2]], [pt_c[0], 1, pt_c[2]]])
    z_val = np.linalg.det([[pt_a[0], pt_a[1], 1], [pt_b[0], pt_b[1], 1], [pt_c[0], pt_c[1], 1]])
    magnitude = (x_val**2 + y_val**2 + z_val**2)**.5
    mag = (x_val/magnitude, y_val/magnitude, z_val/magnitude)
    if magnitude < 0.00000001:
        mag = (0, 0, 0)
    return mag
235257
def vecangle(v1, v2, deg=True):
    
    if np.array_equal(v1, v2):
        return 0.0
    dm = np.dot(v1, v2)
    cm = np.linalg.norm(v1) * np.linalg.norm(v2)
    angle = np.arccos(round(dm / cm, 10))  # Round here to prevent floating point errors
    return np.degrees([angle, ])[0] if deg else angle
298723
def equation(self):
        
        mat = np.zeros((self.nunknowns, self.model.neq))
        rhs = np.zeros(self.nunknowns)  # Needs to be initialized to zero
        rhs[0:self.nlayers - 1] = 0.0
        rhs[self.nlayers - 1] = self.Qc
        ieq = 0
        for e in self.model.elementlist:
            if e.nunknowns > 0:
                head = e.potinflayers(self.xc, self.yc, self.layers) / self.aq.Tcol[self.layers, :]
                mat[0:self.nlayers - 1, ieq:ieq + e.nunknowns] = head[:-1] - head[1:]
                if e == self:
                    for i in range(self.nlayers - 1):
                        mat[i, ieq + i] -= self.resfac[i]
                        mat[i, ieq + i + 1] += self.resfac[i + 1]
                    mat[self.nlayers - 1, ieq:ieq + self.nlayers] = 1.0
                ieq += e.nunknowns
            else:
                head = e.potentiallayers(self.xc, self.yc, self.layers) / self.aq.T[self.layers]
                rhs[0:self.nlayers - 1] -= head[:-1] - head[1:]
        return mat, rhs
384538
def ordering(self):
        

        if not self.is_collinear:
            warnings.warn(
                "Detecting ordering in non-collinear structures not yet implemented."
            )
            return Ordering.Unknown

        if "magmom" not in self.structure.site_properties:
            # maybe this was a non-spin-polarized calculation, or we've
            # lost the magnetic moment information
            return Ordering.Unknown

        magmoms = self.magmoms

        max_magmom = max(magmoms)

        total_magnetization = abs(sum(magmoms))

        is_potentially_ferromagnetic = np.all(magmoms >= 0) or np.all(magmoms <= 0)

        if total_magnetization > 0 and is_potentially_ferromagnetic:
            return Ordering.FM
        elif total_magnetization > 0:
            return Ordering.FiM
        elif max_magmom > 0:
            return Ordering.AFM
        else:
            return Ordering.NM
1062243
def cal_pel(self, v, temp):
        
        if (self.eqn_el is None) or (self.params_el is None):
            return np.zeros_like(v)
        params = self._set_params(self.params_el)
        return func_el[self.eqn_el](v, temp, *params,
                                    self.n, self.z, t_ref=self.t_ref,
                                    three_r=self.three_r)
456402
def get_xy_simple_dipole_dipole(dataframe, spacing=1, indices=None):
    
    if indices is None:
        indices = slice(None)
    abmn = dataframe.ix[indices, ['a', 'b', 'm', 'n']].values
    posx = np.mean(abmn[:, 0:4], axis=1)
    posz = np.abs(
        np.min(abmn[:, 0:2], axis=1) - np.max(abmn[:, 2:4], axis=1)
    ) * -0.192

    # scale the positions with the electrode spacing
    posx *= spacing
    posz *= spacing
    print(abmn.shape, posx.shape)
    print('posxz', np.vstack((abmn.T, posx, posz)).T)
    return posx, posz
1119124
def _py2round(x):
    
    if hasattr(x, '__iter__'):
        rx = np.empty_like(x)
        m = x >= 0.0
        rx[m] = np.floor(x[m] + 0.5)
        m = np.logical_not(m)
        rx[m] = np.ceil(x[m] - 0.5)
        return rx

    else:
        if x >= 0.0:
            return np.floor(x + 0.5)
        else:
            return np.ceil(x - 0.5)
39731
def b_neg(self):
        '''
        
        '''
        nb = Point(self.center)

        if self.xAxisIsMinor:
            nb.x -= self.minorRadius
        else:
            nb.y -= self.minorRadius
        return nb
1010334
def calcTemperature(self):
        
        try:
            return eq.MeanPlanetTemp(self.albedo, self.star.T, self.star.R, self.a).T_p
        except (ValueError, HierarchyError):  # ie missing value (.a) returning nan
            return np.nan
967433
def get_d(slab):
    
    sorted_sites = sorted(slab, key=lambda site: site.frac_coords[2])
    for i, site in enumerate(sorted_sites):
        if "%.6f" % (site.frac_coords[2]) == \
                        "%.6f" % (sorted_sites[i + 1].frac_coords[2]):
            continue
        else:
            d = abs(site.frac_coords[2] - \
                    sorted_sites[i + 1].frac_coords[2])
            break
    return slab.lattice.get_cartesian_coords([0, 0, d])[2]
69161
def S(self):
        
        S = np.array([[self._plane_width / self._vol_width, 0, 0],
                      [0, self._plane_height / self._vol_height, 0],
                      [0, 0, self._depth_scale / self._vol_depth]])
        return S
134490
function calculateOffsetTop(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) 
			curtop += obj.offsetTop
	} else if (obj.y)
		curtop += obj.y;
	return curtop;
}
1230918
def normalise_angle(th):
    """"""
    return th - (2.0 * np.pi) * np.floor((th + np.pi) / (2.0 * np.pi))
939753
protected void calculateRadius() {
        boundingCircleRadius = 0;
        
        for(int i=0;i<points.length;i+=2) {
            float temp = ((points[i] - center[0]) * (points[i] - center[0])) + 
                    ((points[i + 1] - center[1]) * (points[i + 1] - center[1]));
            boundingCircleRadius = (boundingCircleRadius > temp) ? boundingCircleRadius : temp;
        }
        boundingCircleRadius = (float)Math.sqrt(boundingCircleRadius);
    }