Pankaj(ADS)

Featured post

Python Codes for Electric Potential

Python Codes for Electric Potential Code:- import numpy as np import math import matplotlib.pyplot as plot ''' Calculating Elect...

Python Nodal(V-I Sources)

0 comments
Python Program (Nodal Analysis)

following program contains 1 independent Voltage Source and 1 independent Current Source and three resistances R1,R2 and R3.

Python Code ----Created by(Pankaj Aswal) 

import numpy as np
import matplotlib.pyplot as plot

'''
Electrical Circuit is
+┌─ R1    ┬──R3──┬
 V              R2               I 
-└─────┴───-──┴
with following values:
'''
V = 60 
R1 = 12 
R2 = 3 
R3 = 4
I = 5
VX_nodeX = 1
VY_nodeX = 0
b_nodeX = V
VX_nodeY = -(1/R1)*12
VY_nodeY = ((1/R1) + (1/R2))*12
b_nodeY = I*12
a = np.array([[VX_nodeX, VY_nodeX],[VX_nodeY, VY_nodeY]])
b = np.array([b_nodeX,b_nodeY])
x = np.linalg.solve(a,b)
print(x)
V12 = (x[0] - x[1])/R1
print("v12: ", V12)
V4 = (x[1])/R2
print("v4: ", V4)
V3 = (x[1])-R3
print("v3: ", V3)
plot.plot(a,b)
plot.xlabel('Resistance')
plot.ylabel('Voltage')
plot.grid(True,which='both')
plot.axhline(y=0,color='g')
plot.title('Nodal Anaysis')
plot.show()

Output--------
1.[60. 24.]
v12:  3.0
v4:  8.0
v3:  20.0

2.















3.Output in Cmd

No comments:

Post a Comment