pyNLO / PyNLO

Python package for nonlinear optics
https://pynlo.readthedocs.io/en/latest/
GNU General Public License v3.0
101 stars 55 forks source link

Fixing equation for DerivedPulses.GaussianPulse #45

Closed DanHickstein closed 6 years ago

DanHickstein commented 6 years ago

According the RP-Photonics, the Gaussian pulse is given by:

image

in our case, we are taking the sqrt of this to get the E-field. But, our previous equation didn't include the square root in the exp term. This PR includes this factor.

We can verify that this approach is correct by generating and plotting a sech and a gaussian pulse, both with FWHM of 100 fs:


import matplotlib.pyplot as plt
import numpy as np
import pynlo

FWHM = 0.100

pulseG = pynlo.light.DerivedPulses.GaussianPulse(power=1, T0_ps=FWHM,      center_wavelength_nm=1550, frep_MHz=100)
pulseS = pynlo.light.DerivedPulses.SechPulse(    power=1, T0_ps=FWHM/1.76, center_wavelength_nm=1550, frep_MHz=100)

plt.plot(pulseG.T_ps, pulseG.AT,  color = 'b')
plt.plot(pulseS.T_ps, pulseS.AT,  color = 'r')

plt.xlim(-0.2,0.2)
plt.xlabel('Time (ps)')
plt.ylabel('E-field envelope')

plt.axvline(-0.05, color='k', ls='dashed', alpha=0.5)
plt.axvline( 0.05, color='k', ls='dashed', alpha=0.5)

plt.axhline( np.sqrt(0.5), color='r', ls='solid', alpha=0.2, lw=1)

plt.show()

sech and gaussian

At +/- 50 ps, both curves have a value of sqrt(0.5)=0.707.

In addition, I added some additional documentation to the SechPulse and GaussianPulse functions.

Oh, this fix is thanks to Nima :). Maybe one day he will figure out how to make a github account.

pyNLO commented 6 years ago

Thanks, this is a good catch. Note that in most uses the pulse field is energy-normalized, so the impact was less than if P_0 were used (it was a shape error, not an energy error.)