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...

Mesh Analysis(2-V Source)

0 comments
Python Program (Mesh Analysis)

following Program contains the calculation of mesh currents in Circuit having 2-Independent Voltage Sources and 3-Resistances R1,R2,R3.

Instruction By Owner
you can change the numeric values of Constants for desired Output

Program

import numpy as np
import matplotlib.pyplot as plot

'''
Electrical Circuit is
+┌─ R1  ┬─R3──┬+
  V1          R2        V2 
- └────┴────┴ -
with following values:
'''
V1 = 60 
R1 = 12 
R2 = 3 
R3 = 4
V2 = 10
'''
COPYRIGHT---OWNER---PANKAJ ASWAL
Mesh 1 refers to the Voltage source V1
direction of current I1 in +ive polarity with respect to V1

Mesh 2 refers to the Voltage source V2
direction of current I2 in -ive polarity with respect to V2
'''

V1_meshX = 60
V2_meshY = -10
V1_meshX1 = (R1+R2)
V1_meshX2 = -(R2)
V2_meshY1 = -(R2) 
V2_meshY2 = (R2+R3)
a = np.array([[V1_meshX1, V1_meshX2],[V2_meshY1, V2_meshY2]])
x = np.linalg.det(a)
print(x)
b = np.array([[V1_meshX, V1_meshX2],[V2_meshY, V2_meshY2]])
y = np.linalg.det(b)
print(y)
c = np.array([[V1_meshX1, V1_meshX],[V2_meshY1, V2_meshY]])
z = np.linalg.det(c)
print(z)
I1 = y/x 
print("I1: ", I1)
I2 = z/x
print("I2: ", I2)
plot.plot(V1,I1)
plot.xlabel('Mesh Voltage V1')
plot.ylabel('Mesh Current I1')
plot.grid(True,which='both')
plot.axhline(y=0,color='r')
plot.title('Mesh Anaysis')
plot.show()
plot.plot(V2,I2)
plot.xlabel('Mesh Voltage V2')
plot.ylabel('Mesh Current I2')
plot.grid(True,which='both')
plot.axhline(y=0,color='g')
plot.title('Mesh Anaysis')
plot.show()

Output
1.
95.99999999999999
390.00000000000006
30.000000000000004
I1:  4.062500000000001
I2:  0.3125000000000001

2.















3. Output in Cmd

No comments:

Post a Comment