Ejemplo n.º 1
0
def test_relation_iter_twoport():
    tf = bgt.new("TF", value=1)
    tf_port_0, tf_port_1 = list(tf.ports)
    mappings = ({}, {tf_port_0: 0, tf_port_1: 1}, {})
    coords = list(sympy.sympify("e_0,f_0,e_1,f_1"))
    # d1 = {0: 1, 2: -1}
    # d2 = {1: 1, 2: 1}
    relations = get_relations_iterator(tf, mappings, coords)
    for lin, nlin in relations:
        assert not nlin
Ejemplo n.º 2
0
def test_re_con_rel():
    Re = bgt.new("Re", library="BioChem", value={"R": 1, "T": 1})

    coords = list(sympy.sympify("e_0,f_0,e_1,f_1,r"))

    mappings, coords = inverse_coord_maps(*Re.basis_vectors)
    assert mappings
    assert coords

    for r in get_relations_iterator(Re, mappings, coords):
        assert r in [
            ({1: 1, 3: 1}, 0), ({1: 1}, sympy.sympify("-r*exp(e_0) + r*exp(e_1)"))
        ]
Ejemplo n.º 3
0
def test_relations_iter():
    c = bgt.new("C", value=1)
    cp, = list(c.ports)
    mappings = ({(c, 'q_0'): 0}, {cp: 0}, {})
    coords = list(sympy.sympify("dx_0,e_0,f_0,x_0, 1"))
    relations = get_relations_iterator(c, mappings, coords)

    d1 = {0: 1, 2: -1}  # dx/dt - f = 0
    d2 = {1: 1, 3: -1}  # e - x = 0$
    d1m = {0: -1, 2: 1}  # dx/dt - f = 0
    d2m = {1: -1, 3: 1}  # e - x = 0$

    for lin, nlin in relations:
        assert not nlin
        assert lin in (d1, d2, d1m, d2m)