Example #1
0
def Calculate_dmdt(mAllCell, HeffBase):
    global alphaDamping, gamFac, mu0
    H = HeffBase
    m = mAllCell

    mXH = numerix.cross(m, H, axisa=0, axisb=0)
    precisionTerm = numerix.transpose(mXH)

    mXmXH = numerix.cross(m, precisionTerm, axisa=0, axisb=0)
    dampingTerm = (alphaDamping) * numerix.transpose(mXmXH)

    constant_factor = -(gamFac * mu0) / (1 + alphaDamping**2)
    dmdt = (constant_factor) * (precisionTerm + dampingTerm)

    return dmdt
Example #2
0
 def _calcFaceTangents(self):
     faceVertexCoord = numerix.array(
         numerix.take(self.vertexCoords, self.faceVertexIDs[0], axis=1))
     tmp = self._faceCenters - faceVertexCoord
     faceTangents1 = tmp / numerix.sqrtDot(tmp, tmp)
     tmp = numerix.cross(faceTangents1, self.faceNormals, axis=0)
     faceTangents2 = tmp / numerix.sqrtDot(tmp, tmp)
     return faceTangents1, faceTangents2
Example #3
0
File: mesh.py Project: regmi/fipy
 def _calcFaceTangents(self):
     faceVertexCoord = numerix.array(numerix.take(self.vertexCoords, 
                                                  self.faceVertexIDs[0], 
                                                  axis=1))
     tmp = self.faceCenters - faceVertexCoord
     self.faceTangents1 = tmp / numerix.sqrtDot(tmp, tmp)
     tmp = numerix.cross(self.faceTangents1, self.faceNormals, axis=0)
     self.faceTangents2 = tmp / numerix.sqrtDot(tmp, tmp)
Example #4
0
def calculateFieldLikeTorque(mUnit, uAxis):
    uAxisNorm = numerix.linalg.norm(uAxis)
    uAxisUnit = uAxis / uAxisNorm
    mNorm = numerix.linalg.norm(mUnit,axis=0)
    mArray = mUnit / mNorm
    uAxisArr = numerix.tile(uAxisUnit, (len(mUnit[0]), 1))
    uAxisArr = numerix.transpose(uAxisArr)
    m_x_u = numerix.cross(mArray, uAxisArr)
    return numerix.transpose(m_x_u)
Example #5
0
    def _calcArea(self):
        """Calculate the area of the `Face`.
	
	Area is the signed sum of the area of the triangles bounded by
	each polygon edge and the origin.
	"""
        a = 0.0
        p1 = self.vertices[0].getCoordinates().copy()
        for vertex in self.vertices[2:-1]:
            p2 = vertex.getCoordinates().copy()
            a += numerix.cross(p1, p2)
            p1 = p2
        return abs(a / 2.0)
Example #6
0
 def _rightHandOrientation(self):
     faceVertexIDs = MA.filled(self.faceVertexIDs, 0)
     faceVertexCoords = numerix.take(self.vertexCoords, faceVertexIDs, axis=1)
     t1 = faceVertexCoords[:,1,:] - faceVertexCoords[:,0,:]
     t2 = faceVertexCoords[:,2,:] - faceVertexCoords[:,1,:]
     norm = numerix.cross(t1, t2, axis=0)
     ## reordering norm's internal memory for inlining
     norm = norm.copy()
     norm = norm / numerix.sqrtDot(norm, norm)
     
     faceNormals = -norm
     
     return 1 - 2 * (numerix.dot(faceNormals, self.cellDistanceVectors) < 0)
Example #7
0
File: mesh.py Project: regmi/fipy
 def _calcFaceAreas(self):
     faceVertexIDs = MA.filled(self.faceVertexIDs, -1)
     substitute = numerix.repeat(faceVertexIDs[numerix.newaxis, 0], 
                                 faceVertexIDs.shape[0], axis=0)
     faceVertexIDs = numerix.where(MA.getmaskarray(self.faceVertexIDs), substitute, faceVertexIDs)
     faceVertexCoords = numerix.take(self.vertexCoords, faceVertexIDs, axis=1)
     faceOrigins = numerix.repeat(faceVertexCoords[:,0], faceVertexIDs.shape[0], axis=0)
     faceOrigins = numerix.reshape(faceOrigins, MA.shape(faceVertexCoords))
     faceVertexCoords = faceVertexCoords - faceOrigins
     left = range(faceVertexIDs.shape[0])
     right = left[1:] + [left[0]]
     cross = numerix.sum(numerix.cross(faceVertexCoords, numerix.take(faceVertexCoords, right, 1), axis=0), 1)
     self.faceAreas = numerix.sqrtDot(cross, cross) / 2.
Example #8
0
 def _calcFaceAreas(self):
     faceVertexIDs = MA.filled(self.faceVertexIDs, -1)
     substitute = numerix.repeat(faceVertexIDs[numerix.newaxis, 0], 
                                 faceVertexIDs.shape[0], axis=0)
     faceVertexIDs = numerix.where(MA.getmaskarray(self.faceVertexIDs), 
                                   substitute, faceVertexIDs)
     faceVertexCoords = numerix.take(self.vertexCoords, faceVertexIDs, axis=1)
     faceOrigins = numerix.repeat(faceVertexCoords[:,0], faceVertexIDs.shape[0], axis=0)
     faceOrigins = numerix.reshape(faceOrigins, MA.shape(faceVertexCoords))
     faceVertexCoords = faceVertexCoords - faceOrigins
     left = range(faceVertexIDs.shape[0])
     right = left[1:] + [left[0]]
     cross = numerix.sum(numerix.cross(faceVertexCoords, 
                                       numerix.take(faceVertexCoords, right, 1), 
                                       axis=0), 
                         1)
     return numerix.sqrtDot(cross, cross) / 2.
Example #9
0
def calculateDampingTerm(mUnit, Heff):
    Precession = calculatePrecessionTerm(mUnit, Heff)
    DampingBase = numerix.cross(mUnit, Precession, axisa=0, axisb=0)
    return numerix.transpose(DampingBase)
Example #10
0
def calculatePrecessionTerm(mUnit, Heff):
    PrecessionBase = numerix.cross(mUnit, Heff, axisa=0, axisb=0)
    return numerix.transpose(PrecessionBase)
Example #11
0
def calculateDampingLikeTorque(mUnit, uAxis):
    m_x_u = calculateFieldLikeTorque(mUnit, uAxis)
    mNorm = numerix.linalg.norm(mUnit,axis=0)
    mArray = mUnit / mNorm
    m_x_m_x_u = numerix.cross(mArray, m_x_u)
    return numerix.transpose(m_x_m_x_u)