Ejemplo n.º 1
0
def test_projection():
    struct = Structure('')
    p0 = struct.add_point(0, init_pos=[0, 0, 0])
    p1 = struct.add_point(1, init_pos=[2, 0, 0])
    lnk = struct.add_link(p0, p1)
    struct.update_geometry()
    m = Model(struct)

    viscous(m, p0, 1)
    viscous(m, p1, 1)

    def model_update(step):

        m.Bvect *= 0
        spring(m, lnk, 0.1, 1)
        struct.register_history(step)

    for i in range(30):
        m.solve()
        model_update(i)

    struct.end_history()
    struct.project(0, 1)

    assert set(['x_proj', 'y_proj', 'z_proj']).issubset(set(struct.point_hist.loc[0].columns))
    assert_almost_equal(struct.point_hist.loc[0]['x_proj'].values, [0, -2])
Ejemplo n.º 2
0
def test_projection():
    struct = Structure('')
    p0 = struct.add_point(0, init_pos=[0, 0, 0])
    p1 = struct.add_point(1, init_pos=[2, 0, 0])
    lnk = struct.add_link(p0, p1)
    struct.update_geometry()
    m = Model(struct)

    viscous(m, p0, 1)
    viscous(m, p1, 1)

    def model_update(step):

        m.Bvect *= 0
        spring(m, lnk, 0.1, 1)
        struct.register_history(step)

    for i in range(30):
        m.solve()
        model_update(i)

    struct.end_history()
    struct.project(0, 1)

    assert set(['x_proj', 'y_proj',
                'z_proj']).issubset(set(struct.point_hist.loc[0].columns))
    assert_almost_equal(struct.point_hist.loc[0]['x_proj'].values, [0, -2])
Ejemplo n.º 3
0
def test_history():
    """
    """
    struct = Structure('')
    p0 = struct.add_point(0, init_pos=[0, 0, 0])
    p1 = struct.add_point(1, init_pos=[2, 0, 0])
    lnk = struct.add_link(p0, p1)
    struct.update_geometry()
    m = Model(struct)

    viscous(m, p0, 1)
    viscous(m, p1, 1)

    def model_update(step):

        m.Bvect *= 0
        spring(m, lnk, 0.1, 1)
        struct.register_history(step)

    for i in range(30):
        m.solve()
        model_update(i)

    struct.end_history()

    assert struct.point_hist.shape == (30, 2, 6)
    assert isinstance(struct.point_hist, pd.Panel)
Ejemplo n.º 4
0
def test_history():
    """
    """
    struct = Structure('')
    p0 = struct.add_point(0, init_pos=[0, 0, 0])
    p1 = struct.add_point(1, init_pos=[2, 0, 0])
    lnk = struct.add_link(p0, p1)
    struct.update_geometry()
    m = Model(struct)

    viscous(m, p0, 1)
    viscous(m, p1, 1)

    def model_update(step):

        m.Bvect *= 0
        spring(m, lnk, 0.1, 1)
        struct.register_history(step)

    for i in range(30):
        m.solve()
        model_update(i)

    struct.end_history()

    assert struct.point_hist.shape == (30, 2, 6)
    assert isinstance(struct.point_hist, pd.Panel)