Python光學(xué)仿真學(xué)習(xí)Gauss高斯光束在空間中的分布
Gauss光束強度的表達(dá)式為

如圖所示

左上圖和左下圖表示激光傳輸過程中的其束腰半徑的變化情況;右圖則表示高斯光束某一橫截面處激光的能量分布。
繪制代碼如下
import matplotlib.pyplot as plt
import numpy as np
def setLabel(ax,*args):
ax.set_xlabel(args[0])
ax.set_ylabel(args[1])
if len(args)==3:
ax.set_zlabel(args[2])
def drawGauss(w0=1,dWave=1.064):
# 軸向坐標(biāo)
z = np.linspace(-10,10,1000).reshape(1000,1)
# z處光斑半徑
w = np.sqrt(w0**2+z**2*dWave**2/np.pi**2/w0**2)
theta = np.linspace(0,np.pi*2,150).reshape(1,150)
x = w*np.cos(theta)
y = w*np.sin(theta)
fig = plt.figure()
# 三維的高斯光束等功率密度面變化圖
ax1 = fig.add_subplot(221,projection='3d')
ax1.plot_surface(z,x,y)#,cmap=plt.get_cmap('rainbow'))
ax1.set_title("waist shape changed by propagation")
setLabel(ax1,"z","x","y")
# 二維的高斯光束半徑變化圖
ax3 = fig.add_subplot(223)
ax3.plot(z,w,linewidth=1)
ax3.plot(z,-w,linewidth=0.2)
ax3.plot([z[0],z[-1]],[0,0],linewidth=0.5,linestyle=":")
ax3.set_title("waist value changed by propagation")
setLabel(ax3,"z","w")
# Gauss光束在束腰處的切片
X,Y = np.meshgrid(np.linspace(-5,5,100),np.linspace(-5,5,100))
Psi = np.exp(-(X**2+Y**2)/w0**2)/w0
ax2 = fig.add_subplot(222,projection='3d')
ax2.plot_surface(X,Y,Psi)
ax2.set_title("Intensity distribution on waist0")
setLabel(ax2,"x","y","Instensity")
# Gauss光束在束腰處的徑向切片
r = np.linspace(-5,5,200)
Psi = np.exp(-r**2/w0**2)/w0
ax4 = fig.add_subplot(224)
ax4.plot(r,Psi)
ax4.set_title("Intensity distribution on waist0")
setLabel(ax4,"r","Instensity")
plt.show()
如果沿著z軸方向,在不同的位置處對Gauss光束進(jìn)行切片處理,則不同位置處徑向功率分布如圖所示

實現(xiàn)代碼如下
import matplotlib.animation as animation
def GaussGif1d(w0=1,dWave=1.064):
zAxis = np.arange(100)
# 軸向坐標(biāo)
z = np.linspace(0,10,100)
# z處的束腰半徑
w = np.sqrt(w0**2+z**2*dWave**2/np.pi**2/w0**2)
x = np.linspace(-10,10,500)
fig = plt.figure()
ax = fig.gca(xlim=(-5,5),ylim=(0,1))
ax.grid()
line, = ax.plot([],[])
time_text = ax.text(0.1,0.9,'',transform=ax.transAxes)
# 初始化圖像
def init():
line.set_data([],[])
time_text.set_text("")
return line, time_text
# 圖像迭代
def animate(i):
wi = w[i]
Psi = np.exp(-x**2/wi**2)/wi
line.set_data(x,Psi)
time_text.set_text("z="+str(z[i]))
return line, time_text
ani = animation.FuncAnimation(fig, animate, zAxis,
interval=200, init_func=init)
ani.save('gauss.gif',writer='imagemagick')
plt.show()
以上就是Python光學(xué)仿真學(xué)習(xí)Gauss高斯光束在空間中的分布的詳細(xì)內(nèi)容,更多關(guān)于Python光學(xué)仿真Gauss高斯光束空間分布的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
基于tensorflow for循環(huán) while循環(huán)案例
這篇文章主要介紹了基于tensorflow for循環(huán) while循環(huán)案例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-06-06
Python?pandera數(shù)據(jù)驗證和清洗的庫
為了確保數(shù)據(jù)的質(zhì)量,Python Pandera 庫應(yīng)運而生。本文將深入介紹 Python Pandera,這是一個用于數(shù)據(jù)驗證和清洗的庫,并提供豐富的示例代碼,幫助大家充分利用它來提高數(shù)據(jù)質(zhì)量2024-01-01
python?中的requirements.txt?文件的使用詳情
這篇文章主要介紹了python?中的requirements.txt文件的使用詳情,文章圍繞主題展開詳細(xì)內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下2022-05-05
Python進(jìn)程的通信Queue、Pipe實例分析
這篇文章主要介紹了Python進(jìn)程的通信Queue、Pipe,結(jié)合實例形式分析了Python進(jìn)程通信Queue、Pipe基本概念、用法及操作注意事項,需要的朋友可以參考下2020-03-03
python練習(xí)之循環(huán)控制語句 break 與 continue
這篇文章主要介紹了python循環(huán)控制語句 break 與 continue,break就像是終止按鍵,不管執(zhí)行到哪一步,只要遇到break,不管什么后續(xù)步驟,直接跳出當(dāng)前循環(huán)2022-06-06
FastApi如何快速構(gòu)建一個web項目的實現(xiàn)
本文主要介紹了FastApi如何快速構(gòu)建一個web項目的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-03-03
一個非常簡單好用的Python圖形界面庫(PysimpleGUI)
這篇文章主要介紹了一個非常簡單好用的Python圖形界面庫,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12
Python利用scikit-learn實現(xiàn)近鄰算法分類的示例詳解
scikit-learn已經(jīng)封裝好很多數(shù)據(jù)挖掘的算法,這篇文章就來用scikit-learn實現(xiàn)近鄰算法分類,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下2023-02-02

