Пример #1
0
def test_viscous():

    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
        contraction(m, lnk, 1)
        viscous(m, p0, 100)
        viscous(m, p1, 100)
        struct.register_history(step)

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

    assert_almost_equal(p0.dist(p1), 1.42, decimal=2)
Пример #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])
Пример #3
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])
Пример #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)
Пример #5
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)
Пример #6
0
def test_viscous_points():
    """
    """
    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)

    def model_update(step):

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

    for i in range(5):
        m.solve()
        model_update(i)
Пример #7
0
def test_viscous():

    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
        contraction(m, lnk, 1)
        viscous(m, p0, 100)
        viscous(m, p1, 100)
        struct.register_history(step)

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

    assert_almost_equal(p0.dist(p1), 1.42, decimal=2)
Пример #8
0
def test_structure():
    """Test points, links and attributes data structure
    """

    struct = Structure('')
    p0 = struct.add_point(0, init_pos=[2, 0, 0], color="black")

    assert_almost_equal(struct.point_df[0], [2., 0., 0., 0., 0., 0.])
    assert struct.attributes['color'][0] == 'black'

    struct = Structure('')
    p0 = Point(struct, 0, init_pos=[2, 0, 0], color="black")
    p1 = Point(struct, init_pos=[-2, 0, 0], color="red")

    struct.add_link(p0, p1)

    assert struct.point_df.shape == (2, 6)
    assert struct.link_df.shape == (1, 7)
Пример #9
0
def test_viscous_points():
    """
    """
    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)

    def model_update(step):

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

    with raises(PhysicsException):
        for i in range(5):
            m.solve()
            model_update(i)