Esempio n. 1
0
def test_linear_system():
    x, y, z, t, n = map(Symbol, 'xyztn')

    assert solve([x+5*y-2, -3*x+6*y-15], [x, y]) == {x: -3, y: 1}

    M = Matrix( [0,0,n*(n+1),(n+1)**2,0],
                [n+1,n+1,-2*n-1,-(n+1),0],
                [-1, 0, 1, 0, 0] )

    assert solve_linear_system(M, [x, y, z, t]) == \
           {y: 0, z: ((-t-t*n)/n).expand(), x: ((-t-t*n)/n).expand()}
Esempio n. 2
0
def test_linear_system():
    x, y, z, t, n = symbols("x, y, z, t, n")

    assert solve([x - 1, x - y, x - 2 * y, y - 1], [x, y]) is None

    assert solve([x - 1, x - y, x - 2 * y, x - 1], [x, y]) is None
    assert solve([x - 1, x - 1, x - y, x - 2 * y], [x, y]) is None

    assert solve([x + 5 * y - 2, -3 * x + 6 * y - 15], x, y) == {x: -3, y: 1}

    M = Matrix([[0, 0, n * (n + 1), (n + 1) ** 2, 0], [n + 1, n + 1, -2 * n - 1, -(n + 1), 0], [-1, 0, 1, 0, 0]])

    assert solve_linear_system(M, x, y, z, t) == {y: 0, z: t * (-n - 1) / n, x: t * (-n - 1) / n}

    assert solve([x + y + z + t, -z - t], x, y, z, t) == {x: -y, z: -t}
Esempio n. 3
0
def test_linear_system():
    x, y, z, t, n = symbols('x,y,z,t,n')

    assert solve([x - 1, x - y, x - 2 * y, y - 1], [x, y]) is None

    assert solve([x - 1, x - y, x - 2 * y, x - 1], [x, y]) is None
    assert solve([x - 1, x - 1, x - y, x - 2 * y], [x, y]) is None

    assert solve([x + 5 * y - 2, -3 * x + 6 * y - 15], x, y) == {x: -3, y: 1}

    M = Matrix([[0, 0, n * (n + 1), (n + 1)**2, 0],
                [n + 1, n + 1, -2 * n - 1, -(n + 1), 0], [-1, 0, 1, 0, 0]])

    assert solve_linear_system(M, x, y, z, t) == \
           {y: 0, z: -t*(1 + n)/n, x: -t*(1 + n)/n}
Esempio n. 4
0
def test_linear_system():
    x, y, z, t, n = symbols('xyztn')

    assert solve([x-1, x-y, x-2*y, y-1], [x,y]) is None

    assert solve([x-1, x-y, x-2*y, x-1], [x,y]) is None
    assert solve([x-1, x-1, x-y, x-2*y], [x,y]) is None

    assert solve([x+5*y-2, -3*x+6*y-15], x, y) == {x: -3, y: 1}

    M = Matrix([[0,0,n*(n+1),(n+1)**2,0],
                [n+1,n+1,-2*n-1,-(n+1),0],
                [-1, 0, 1, 0, 0]])

    assert solve_linear_system(M, x, y, z, t) == \
           {y: 0, z: -((t+t*n)/n), x: -((t+t*n)/n)}
Esempio n. 5
0
def test_linear_system():
    x, y, z, t, n = symbols('x, y, z, t, n')

    assert solve([x - 1, x - y, x - 2 * y, y - 1], [x, y]) == []

    assert solve([x - 1, x - y, x - 2 * y, x - 1], [x, y]) == []
    assert solve([x - 1, x - 1, x - y, x - 2 * y], [x, y]) == []

    assert solve([x + 5 * y - 2, -3 * x + 6 * y - 15], x, y) == {x: -3, y: 1}

    M = Matrix([[0, 0, n * (n + 1), (n + 1)**2, 0],
                [n + 1, n + 1, -2 * n - 1, -(n + 1), 0], [-1, 0, 1, 0, 0]])

    assert solve_linear_system(M, x, y, z, t) == \
        {x: -t - t/n, z: -t - t/n, y: 0}

    assert solve([x + y + z + t, -z - t], x, y, z, t) == {x: -y, z: -t}
Esempio n. 6
0
def test_linear_system():
    x, y, z, t, n = symbols('x, y, z, t, n')

    assert solve([x - 1, x - y, x - 2*y, y - 1], [x, y]) == []

    assert solve([x - 1, x - y, x - 2*y, x - 1], [x, y]) == []
    assert solve([x - 1, x - 1, x - y, x - 2*y], [x, y]) == []

    assert solve([x + 5*y - 2, -3*x + 6*y - 15], x, y) == {x: -3, y: 1}

    M = Matrix([[0, 0, n*(n + 1), (n + 1)**2, 0],
                [n + 1, n + 1, -2*n - 1, -(n + 1), 0],
                [-1, 0, 1, 0, 0]])

    assert solve_linear_system(M, x, y, z, t) == \
        {x: -t - t/n, z: -t - t/n, y: 0}

    assert solve([x + y + z + t, -z - t], x, y, z, t) == {x: -y, z: -t}
Esempio n. 7
0
def test_linear_system():
    x, y, z, t, n, a = symbols('x,y,z,t,n,a')

    assert solve([x - 1, x - y, x - 2*y, y - 1], [x,y]) is None

    assert solve([x - 1, x - y, x - 2*y, x - 1], [x,y]) is None
    assert solve([x - 1, x - 1, x - y, x - 2*y], [x,y]) is None

    assert solve([x + 5*y - 2, -3*x + 6*y - 15], x, y) == {x: -3, y: 1}

    M = Matrix([[0,0,n*(n+1),(n+1)**2,0],
                [n+1,n+1,-2*n-1,-(n+1),0],
                [-1, 0, 1, 0, 0]])

    assert solve_linear_system(M, x, y, z, t) == \
           {y: 0, z: t*(-n - 1)/n, x: t*(-n - 1)/n}

    assert solve([x + y + z + t, -z - t], x, y, z, t) == {x: -y, z: -t}

    assert solve([a(0, 0) + a(0, 1) + a(1, 0) + a(1, 1), -a(1, 0) - a(1, 1)],
        a(0, 0), a(0, 1), a(1, 0), a(1, 1)) == {a(1, 0): -a(1, 1), a(0, 0): -a(0, 1)}
Esempio n. 8
0
def test_linear_system():
    x, y, z, t, n, a = symbols('x,y,z,t,n,a')

    assert solve([x - 1, x - y, x - 2*y, y - 1], [x,y]) is None

    assert solve([x - 1, x - y, x - 2*y, x - 1], [x,y]) is None
    assert solve([x - 1, x - 1, x - y, x - 2*y], [x,y]) is None

    assert solve([x + 5*y - 2, -3*x + 6*y - 15], x, y) == {x: -3, y: 1}

    M = Matrix([[0,0,n*(n+1),(n+1)**2,0],
                [n+1,n+1,-2*n-1,-(n+1),0],
                [-1, 0, 1, 0, 0]])

    assert solve_linear_system(M, x, y, z, t) == \
           {y: 0, z: t*(-n - 1)/n, x: t*(-n - 1)/n}

    assert solve([x + y + z + t, -z - t], x, y, z, t) == {x: -y, z: -t}

    assert solve([a(0, 0) + a(0, 1) + a(1, 0) + a(1, 1), -a(1, 0) - a(1, 1)],
        a(0, 0), a(0, 1), a(1, 0), a(1, 1)) == {a(1, 0): -a(1, 1), a(0, 0): -a(0, 1)}
xe_gam_Cr = 0.490
xe_gam_Nb = 0.025

xe_del_Cr = 0.015
xe_del_Nb = 0.245

xe_lav_Cr = 0.300
xe_lav_Nb = 0.328

# Define lever rule equations
xo, yo = symbols('xo yo')
xb, yb = symbols('xb yb')
xc, yc = symbols('xc yc')
xd, yd = symbols('xd yd')

levers = solve_linear_system(Matrix( ((yo - yb, xb - xo, xb * yo - xo * yb),
                                      (yc - yd, xd - xc, xd * yc - xc * yd)) ), x, y)

def draw_bisector(weightA, weightB):
    bNb = (weightA * xe_del_Nb + weightB * xe_lav_Nb) / (weightA + weightB)
    bCr = (weightA * xe_del_Cr + weightB * xe_lav_Cr) / (weightA + weightB)
    xPrime = [simX(xe_gam_Nb, xe_gam_Cr), simX(bNb, bCr)]
    yPrime = [simY(xe_gam_Cr), simY(bCr)]
    return xPrime, yPrime

# triangle bounding three-phase coexistence
X0 = [simX(xe_gam_Nb, xe_gam_Cr), simX(xe_del_Nb, xe_del_Cr), simX(xe_lav_Nb, xe_lav_Cr), simX(xe_gam_Nb, xe_gam_Cr)]
Y0 = [simY(xe_gam_Cr),            simY(xe_del_Cr),            simY(xe_lav_Cr),            simY(xe_gam_Cr)]

# Make sublattice -> system substitutions
g_gamma = inVm * g_gamma.subs({symbols('FCC_A10CR'): XCR,
                               symbols('FCC_A10NB'): XNB,