🎯要点
- 绘制三次谐波生成透射功率谱、对数对数图表示
 - 半导体曲面二次谐波生成,分析判断材料特性
 - 谐波均值估计计算边际似然(贝叶斯统计)
 - 二次谐波散射分析胶体染料分子结构
 - 交流电谐波波形傅立叶分析
 - 分析旋转各向异性谐波
 - 高次谐波非线性相互作用过程分析
 
谐波生成导图

通用谐波方程
Python 脚本建模通用谐波方程。请注意,方波仅具有奇次谐波。
  
      
       
        
        
          y 
         
        
          ( 
         
        
          t 
         
        
          ) 
         
        
          = 
         
         
         
           ∑ 
          
          
          
            k 
           
          
            = 
           
          
            1 
           
          
          
          
            N 
           
          
            + 
           
          
            1 
           
          
         
         
         
           k 
          
          
          
            − 
           
          
            1 
           
          
         
        
          sin 
         
        
           
         
        
          ( 
         
        
          2 
         
        
          ω 
         
        
          k 
         
        
          f 
         
        
          t 
         
        
          ) 
         
        
       
         y ( t )=\sum_{k=1}^{ N +1} k^{-1} \sin (2 \omega kft ) 
        
       
     y(t)=k=1∑N+1k−1sin(2ωkft)
import matplotlib.pylab as plt
import numpy as np
import argparse
VERSION = '0.2'
def factor(shape, k, i):
    if shape == "triangle":
        return (1/(k*k) * (-1)**i)
    else:
        return (1/k)
    
if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='plot harmonics',
                                 epilog='Version: ' + VERSION)
    parser.add_argument('-f','--frequency',default=4,type=int, help='specify the frequency',action='store')
    parser.add_argument('-n','--harmonics',default=0,type=int, help='specify the number of harmonics',action='store')
    parser.add_argument('-t','--type',default='odd',type=str, help='specify the type of harmonics (even, odd, or all)',action='store')
    parser.add_argument('-s','--shape',default='square',type=str, help='specify the shaping factor (square, triangle)',action='store')
    
    args = parser.parse_args()
    
    f = args.frequency
    
    if args.type == 'even':
        odd = 0
        mult = 2
    elif args.type == 'odd':
        odd = 1
        mult = 2
    else:   
        odd = 0
        mult = 1
    
    t = np.linspace(0, 1, num=8000)
    y = np.zeros(8000)
    
    for i in range(int(args.harmonics)+1):
        k = i * mult + odd
        yh = factor(args.shape,k,i) * np.sin(2 * np.pi * k *  f * t)
        y = y + yh
    
    plt.plot(t, y)
    plt.xlabel('time')
    plt.ylabel('harmonics {0}'.format(args.harmonics))
    plt.axis('tight')
    plt.show()
    print('finished')
 
脚本命令行参数:
$ python3 harmonic.py -h
usage: harmonics.py [-h] [-f FREQUENCY] [-n HARMONICS] [-t TYPE] [-s SHAPE]
plot harmonics
optional arguments:
  -h, --help            show this help message and exit
  -f FREQUENCY, --frequency FREQUENCY
                        specify the frequency
  -n HARMONICS, --harmonics HARMONICS
                        specify the number of harmonics
  -t TYPE, --type TYPE  specify the type of harmonics (even, odd, or all)
  -s SHAPE, --shape SHAPE
                        specify the shaping factor (square, triangle)
 
生成基波(正弦波)
$ python3 harmonic.py
 
生成基波(正弦波)+ 2 次谐波。我们可以看到方波正在形成,并带有大的波纹。
$ python3 harmonic.py -n 2
 
让我们调高谐波,看看我们开始近似理想的方波。
$ python3 harmonic.py -n 1000
 
产生三角波。请注意,由于谐波的缩放比例不同,方程现在有所不同。
$ python3 harmonic.py -n 1000 -s triangle
 



















