for col in range(A_ul.rows.shape[1]):
            J.rows[row, col] = ((2 * h * nu**3) / c**2)(1 / (np.exp(
                (h * nu) / (k * t)) - 1))
            B_ul.rows[row,
                      col] = A_ul.rows[row, col] * ((c**2) / (2 * h * nu**3))
            B_lu.rows[col, row] = B_ul.rows[row, col] * ((col)**2 / (row)**2)

    #n-state system equations in matrix form
    # system_mat * n = zero_matrix
    system_mat = M(8, 8)  #new empty matrix

    for row in range(system_mat.width):
        for col in range(system_mat.height):
            # u = col, l = row
            if row > col:
                system_mat.rows[row, col] = -(A_ul.rows[col, row] + M.__mult__(
                    B_ul.rows[col, row], J.rows[row, col]))
            if row < col:
                system_mat.rows[row, col] = -(M.__mult__(
                    B_ul.rows[col, row], J.rows[row, col]))
            if row == col:
                system_mat.rows[row, col] = (np.sum(
                    B_ul.rows[col, :row != row])) * J.rows[row, col] + (np.sum(
                        A_ul.rows[col, :row != row]))

    # Ax = b => x = b*A^-1
    #where A is the system_mat and b is and 1x8 matrix of zeros solve for x
    b = M.__init__(1, 8, 0)
    A_invert = M.__invert__(system_mat)
    X = M.__mult__(b, A_invert)

    N = np.sum(X.rows)  # should equal 1
Exemplo n.º 2
0
 def test_determinant(self):
     """ Test determinant Method """
     self.assertAlmostEqual(M.determinant(m1), np.linalg.det(m1))
Exemplo n.º 3
0
 def test_lu_decomp(self):
     """ Test lu_decomposition Method """
     self.assertAlmostEqual(M.lu_decomposition(m1), np.linalg.lu(m1))
Exemplo n.º 4
0
 def test_trace(self):
     """ Test trace Method """
     self.assertAlmostEqual(M.__trace__(m1), np.trace(m1))
Exemplo n.º 5
0
 def test_invert(self):
     """ Test invert Method """
     self.assertAlmostEqual(M.__invert__(m1), np.linalg.inv(m1))
Exemplo n.º 6
0
 def test_transpose(self):
     """ Test Tran Method """
     self.assertAlmostEqual(M.__tran__(m1), m1.T)
Exemplo n.º 7
0
 def test_Mult(self):
     """ Test Mult Method """
     self.assertAlmostEqual(M.__mult__(m1, m2), np.dot(m1, m2))
Exemplo n.º 8
0
 def test_add(self):
     """ Test add Method """
     self.assertAlmostEqual(M.__add__(m1, m2), np.add(m1, m2))