Esempio n. 1
0
def test_DipoleGetB():
    erMsg = "Results from getB are unexpected"
    mockResults = array([ 1.23927518e-06,  6.18639685e-06, -1.67523560e-06]) ## Expected 3 results for this input

    # Input
    moment=[5,2,10]
    pos=(24,51,22)
    fieldPos = (.5,.5,5)

    # Run
    pm = Dipole(moment,pos)
    result = pm.getB(fieldPos)

    rounding = 4 ## Round for floating point error 
    for i in range(3):
        assert round(result[i],rounding)==round(mockResults[i],rounding), erMsg
def test_vectorMomentDipole():

    MOM = np.array([[0, 0, 2], [0, 0, 55], [11, 22, 33], [-14, 25, 36],
                    [17, -28, 39], [-10, -21, 32], [0, 12, 23], [0, -14, 25],
                    [16, 0, 27], [-18, 0, 29]])
    POSM = np.ones([10, 3])
    POSO = MOM * 0.1 * np.array([.8, -1, -1.3]) + POSM

    Bv = getBv_moment('dipole', MOM, POSM, POSO)

    Bc = []
    for mom, posM, posO in zip(MOM, POSM, POSO):
        pm = Dipole(mom, posM)
        Bc += [pm.getB(posO)]
    Bc = np.array(Bc)

    assert np.amax(abs(Bv - Bc)) < 1e-15
Esempio n. 3
0
def test_DipoleGetBAngle():
    erMsg = "Results from getB are unexpected"
    mockResults = (-0.00836643 , 0.01346,   -0.01833964) ## Expected 3 results for this input

    # Input
    moment=(0.2,32.5,5.3)
    pos=(1,0.2,3)
    axis=[0.2,1,0]
    angle=90
    fieldPos=[.5,5,.35]

    # Run
    pm = Dipole(moment,pos,angle,axis)
    result = pm.getB(fieldPos)

    rounding = 4 ## Round for floating point error 
    for i in range(3):
        assert round(result[i],rounding)==round(mockResults[i],rounding), erMsg