def doTest(self, M_file, H_file, epsilon):
        # load ref
        M     = readOMF(M_file)
        H_ref = readOMF(H_file)
        H     = VectorField(M.mesh)

        axis = VectorField(M.mesh); axis.fill((1.0/math.sqrt(3.0), 1.0/math.sqrt(3.0), 1.0/math.sqrt(3.0)))
        k = Field(M.mesh); k.fill(520e3)
        Ms = Field(M.mesh); Ms.fill(8e5)

        # calculate
        magneto.uniaxial_anisotropy(axis, k, Ms, M, H)

        # compare
        self.assertVectorFieldEqual(H_ref, H, epsilon)
Example #2
0
    def doTest(self, M_file, H_file, epsilon):
        # load ref
        M = readOMF(M_file)
        H_ref = readOMF(H_file)
        H = VectorField(H_ref.mesh)

        # setup
        stray = StrayFieldCalculator(M.mesh)
        H.fill((1.0, 2.0, 3.0))

        # calculate
        for t in range(1):
            stray.calculate(M, H)

        # compare
        self.assertVectorFieldEqual(H_ref, H, epsilon)
Example #3
0
    def do_test(self, M_file, H_file, epsilon):
        # load ref
        M     = readOMF(M_file)
        H_ref = readOMF(H_file)
        H     = VectorField(M.mesh)
        A     = Field(M.mesh); A.fill(Material.Py().A)
        Ms    = Field(M.mesh); Ms.fill(Material.Py().Ms)

        # calculate
        mesh = M.mesh
        nx, ny, nz = mesh.num_nodes
        dx, dy, dz = mesh.delta
        bcx, bcy, bcz = False, False, False
        magneto.exchange(nx, ny, nz, dx, dy, dz, bcx, bcy, bcz, Ms, A, M, H)

        # compare
        self.assertVectorFieldEqual(H_ref, H, epsilon)
Example #4
0
    def doTest(self, M_file, H_file, epsilon):
        # load ref
        M = readOMF(M_file)
        H_ref = readOMF(H_file)
        H = VectorField(M.mesh)

        axis = VectorField(M.mesh)
        axis.fill(
            (1.0 / math.sqrt(3.0), 1.0 / math.sqrt(3.0), 1.0 / math.sqrt(3.0)))
        k = Field(M.mesh)
        k.fill(520e3)
        Ms = Field(M.mesh)
        Ms.fill(8e5)

        # calculate
        magneto.uniaxial_anisotropy(axis, k, Ms, M, H)

        # compare
        self.assertVectorFieldEqual(H_ref, H, epsilon)
Example #5
0
#!/usr/bin/python
import sys
import os
import math

from magnum import readOMF, writeImage

if len(sys.argv) != 2:
    print "Usage: %s <input.omf>" % sys.argv[0]
    sys.exit(-1)
omf_file = sys.argv[1]
base, ext = os.path.splitext(omf_file)

M = readOMF(omf_file)

Ms = M.absMax()

writeImage(base + "-x.png", M, "x", color_range=(-Ms, +Ms))
writeImage(base + "-y.png", M, "y", color_range=(-Ms, +Ms))
writeImage(base + "-z.png", M, "z", color_range=(-Ms, +Ms))
writeImage(base + "-xy-angle.png", M, "xy-angle", color_range=(-math.pi, +math.pi))
writeImage(base + "-mag.png", M, "mag", color_range=(0, Ms))