Beispiel #1
0
def create_network_branch_matrices_mesh(num_branches, branch_resistance, test_current):
    """
    Create the Y, J, E network branch matrices of the resistive mesh given by the provided number of branches, branch
    resistance and test current.

    :param num_branches: the number of branches in the mesh
    :param branch_resistance: the resistance of each branch in the mesh
    :param test_current: the test current to apply to the mesh
    :return: the Y, J, E network branch matrices
    """
    Y = Matrix.diagonal([1 / branch_resistance if branch < num_branches - 1 else 0 for branch in range(num_branches)])
    # Negative test current here because we assume current is coming OUT of the test current node.
    J = Matrix.column_vector([0 if branch < num_branches - 1 else -test_current for branch in range(num_branches)])
    E = Matrix.column_vector([0 for _ in range(num_branches)])
    return Y, J, E
Beispiel #2
0
def csv_to_network_branch_matrices(filename):
    """
    Converts a CSV file to Y, J, E network matrices.

    :param filename: the name of the CSV file
    :return: the Y, J, E network matrices
    """
    with open(filename, 'r') as csv_file:
        reader = csv.reader(csv_file)
        J = []
        Y = []
        E = []
        for row in reader:
            J_k = float(row[0])
            R_k = float(row[1])
            E_k = float(row[2])
            J.append(J_k)
            Y.append(1 / R_k)
            E.append(E_k)
        Y = Matrix.diagonal(Y)
        J = Matrix.column_vector(J)
        E = Matrix.column_vector(E)
        return Y, J, E