Question: Given a system of 1 2 buses, write python code to calculate the jacobaian matrix. Bus data attached. starter code given, assume bus data is

Given a system of 12 buses, write python code to calculate the jacobaian matrix. Bus data attached. starter code given, assume bus data is read in correctly, but can be rearranged so that it is in order:
# Takes in bus and line data and returns the admittance matrix
def create_admittance_matrix (bus_data, line_data):
# Creates numpy array of zeros to populate with admittances
y_matrix = np.zeros((num_buses, num_buses), dtype=complex)
for i in range(len(line_data)):
from_bus = line_data.loc[i, 'From']
to_bus = line_data.loc[i,'To']
R = line_data["Rtotal, p.u."].iloc[i]
X = line_data["Xtotal, p.u."].iloc[i]
B = line_data["Btotal, p.u."].iloc[i]
Y =(1/(R +1j*X))
B_complex =(1j*B)/2
#non-diagonals
y_matrix[from_bus-1,to_bus-1]=-Y
y_matrix[to_bus-1, from_bus-1]=-Y
#diagonals
y_matrix[from_bus-1, from_bus-1]+= Y + B_complex
y_matrix[to_bus-1, to_bus-1]+= Y + B_complex
return y_matrix
y_matrix = create_admittance_matrix (bus_data, line_data)
# Extract bus types
slack_bus = bus_data[bus_data['Type']=='S'].index
pq_buses = bus_data[bus_data['Type']=='D'].index
pv_buses = bus_data[bus_data['Type']=='G'].index
V = np.array(bus_data["V Set"])
#print(V)
theta = np.zeros(num_buses)
Given a system of 1 2 buses, write python code to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!