Smith Chart Generator in Python

  1 #!/usr/bin/env python3.5                                                        
  2                                                                                 
  3 import matplotlib.pyplot as plt                                                 
  4 import numpy as np                                                              
  5                                                                                 
  6 fig, ax = plt.subplots()                                                        
  7                                                                                 
  8 outer_circle = plt.Circle((0, 0), 1.0, facecolor='white', edgecolor='blue')     
  9                                                                                 
 10 zl_i = np.linspace(-500.0, 500.0, 10000)                                        
 11 zl_r = np.linspace(0.0, 500.0, 10000)                                           
 12                                                                                 
 13 for _zl_r in [0.1, 0.5, 1.0, 4.0]:                                              
 14     plt.plot(((_zl_r ** 2) + (zl_i ** 2) - 1) / \                               
 15             ((_zl_r ** 2) + (zl_i ** 2) + (2 * _zl_r) + 1), \                   
 16             (2 * zl_i) / ((_zl_r ** 2) + (zl_i ** 2) + (2 * _zl_r) + 1), \      
 17             color = 'blue')                                                     
 18                                                                                 
 19 for _zl_i in [0.1, 0.5, 1.0, 4.0, -0.1, -0.5, -1.0, -4.0]:                      
 20     plt.plot(((zl_r ** 2) + (_zl_i ** 2) - 1) / \                               
 21             ((zl_r ** 2) + (_zl_i ** 2) + (2 * zl_r) + 1), \                    
 22             (2 * _zl_i) / ((zl_r ** 2) + (_zl_i ** 2) + (2 * zl_r) + 1), \      
 23             color = 'blue')                                                     
 24                                                                                 
 25 ax.add_patch(outer_circle)                                                      
 26                                                                                 
 27 plt.xlim([-1, 1])                                                               
 28 plt.ylim([-1, 1])                                                               
 29 plt.show()

 



Comments

Popular Posts