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

Tuesday, 30 June 2020

Python Program(Control Systems)

1 comments
Python Program(Block Diagram Reduction Method)

Block diagram reduction method is used for solving any Physical system 
with the help of Transfer Function which is ---
T(s) = Output(s) / Input(s)

where (s) --in frequency domain 

Program
import numpy as np
import math
import matplotlib.pyplot as plot

'''
                             -----------
                              |         | 
                 ----------|  G1     |---------------------|
             |                |---------|                         |
             |     ----                         --------        \|/+
--------------- |G2|------------------|  G3  |-------->O--------
                    ----                         --------        +

 This can be reduced to

                   ------------------
                 |                           |
--------------|  G1 + (G2*G3)  |-------------
                 |                           |
                       ------------------
'''
x = np.array([5,4.7,4.5,4.4,4.1,4,3.9,3.7,3.5,3.2,3,2.8,2.7,2.5,2.4,2.3,2,1.8,1.7,1.4,1.3,1])
y = np.exp(x)
'''
----------Following Program CopyRight by (Pankaj Aswal)---------
For step Input = Input1=5 Volt
----------------------------------------------------------------
'''
Input1 = 5
G1 = 1
G2= 1
G3 = 1 - y
Transfer_Function = G1 + ( G2 * G3 )
Output = Input1 * Transfer_Function
print("Transfer_Function :",Transfer_Function)
print("Output :",Output)
plot.figure()
plot.plot(Transfer_Function)
plot.xlabel('Time [s]')
plot.ylabel('Amplitude');
plot.grid(True,which='both')
plot.axhline(y=0,color='green', marker = "o")
plot.title('Transfer_Function')

plot.figure()
plot.plot(Output)
plot.xlabel('Time [s]')
plot.ylabel('Output');
plot.grid(True,which='both')
plot.axhline(y=0,color='red', marker = "o")
plot.title('Output Of Block Diagram')

plot.show()

Output:-
1.>>> 
============== RESTART: D:\Desktop\Python(TUT)\Blockdiagram.py ==============
Transfer_Function : [-146.4131591  -107.94717245  -88.0171313   -79.45086866  -58.3402876
  -52.59815003  -47.40244911  -38.44730436  -31.11545196  -22.5325302
  -18.08553692  -14.44464677  -12.87973172  -10.18249396   -9.02317638
   -7.97418245   -5.3890561    -4.04964746   -3.47394739   -2.05519997
   -1.66929667   -0.71828183]
Output : [-732.06579551 -539.73586226 -440.0856565  -397.25434332 -291.70143799
 -262.99075017 -237.01224553 -192.2365218  -155.57725979 -112.66265099
  -90.42768462  -72.22323386  -64.39865862  -50.9124698   -45.1158819
  -39.87091227  -26.94528049  -20.24823732  -17.36973696  -10.27599983
   -8.34648334   -3.59140914]

2.






























3. Cmd Output


1 comment:

  1. Great post i must say and thanks for the information.I appreciate your post and look forward to more.
    For any Data Logger Dealers

    ReplyDelete