# kirchhoff_exercise_01.py # This script solves a simple LES resulting from Kirchhoff's laws. # Example from NunezPhysics video tutorial: https://www.youtube.com/watch?v=zdE7xsbuNTg # R. Becker, 2021-10-23 import numpy as np # A matrix is an array of rows, which are arrays. Thus a matrix is a two dimensional array. # The numpy.array() function is used to create 2D array (aka matrix) from a list of row lists. R = np.array( [ [-1.0, -1.0, 1.0], [-6.0, 3.0, 0.0], [ 0.0, -3.0, -6.0] ]) V = np.array([0.0, -24.0, -12.0]) # Inverse matrix Rinv = np.linalg.inv(R) # Matrix vector multiplication, aka dot product I = Rinv.dot(V) # Print currents print(I)