Phasematching module¶
With this module you can easily calculate the phasematching of a non-ideal waveguide.
SimplePhasematchingDeltaBeta¶
-
class
pynumpm.phasematching.SimplePhasematchingDeltaBeta(waveguide: Union[pynumpm.waveguide.Waveguide, pynumpm.waveguide.RealisticWaveguide])[source]¶ Base class used for the calculation of phase matching spectra as a function of \(\Delta\beta\) for uniform waveguides.
Initialization of the class requires the following parameters:
Parameters: waveguide ( Waveguide) – Waveguide objectUsage
With idealwaveguide being a
Waveguideobject, the following code calculates its phase matching spectrum as a function of \(\Delta\beta\):idealphasematching = SimplePhasematchingDeltaBeta(waveguide=idealwaveguide) idealphasematching.deltabeta = np.arange(-1000, 1000, 1) phi = idealphasematching.calculate_phasematching(normalized=True)
-
waveguide¶ Read-only: the waveguide object used in the calculation.
-
deltabeta¶ Returns: The \(\Delta\beta\) vector used for the phase matching calculation.
-
phi¶ Returns: The phase matching complex amplitude
-
calculate_phasematching(normalized=True) → numpy.ndarray[source]¶ This function calculates the phase matching spectrum. Prior to the calculation of the phase matching spectrum, it is necessary to set the \(\Delta\beta\) vector by assigning it to the variable deltabeta.
Parameters: normalized (bool) – Sets the normalization of the phase matching amplitude. If True, the phase matching amplitude will be normalized to the unit length (i.e., the maximum will be in [0,1]). Default: False. Returns: the function returns the complex-valued phase matching spectrum.
-
plot(ax=None, normalize_to_max=False, amplitude=False, **kwargs)[source]¶ Function to plot the phase matching spectrum amplitude or intensity.
Parameters: - ax – Optional argument. Handle of the axis of the plot. Default: None
- normalize_to_max (bool) – Optional argument. If True, normalizes the plotted phase matching intensity to have the maximum to 1. Default: False
- amplitude (bool) – Optional argument. Plot the phase matching spectrum amplitude instead of the intensity. Default: False.
Returns: the axis handle of the plot
-
PhasematchingDeltaBeta¶
-
class
pynumpm.phasematching.PhasematchingDeltaBeta(waveguide: pynumpm.waveguide.RealisticWaveguide)[source]¶ This class is used to simulate phase matching spectrum of systems considering only the wavevector mismatch (\(\Delta\beta\)).
Initialization of the class requires the following parameters:
Parameters: waveguide ( RealisticWaveguide) – Waveguide object, as provided by the class waveguide.Usage
With realwaveguide being a
RealisticWaveguideobject, the following code calculates its phase matching spectrum as a function of \(\Delta\beta\):idealphasematching = PhasematchingDeltaBeta(waveguide=realwaveguide) idealphasematching.deltabeta = np.arange(-1000, 1000, 1) phi = idealphasematching.calculate_phasematching(normalized=True)
-
waveguide¶ Read-only: the waveguide object used in the calculation.
-
calculate_phasematching(normalized=True, hide_progressbar=False)[source]¶ Function that calculates the phase matching spectrum in case of inhomogeneous waveguide. Prior to the evaluation of the phase matching spectrum, it is necessary to set the \(\Delta\beta\) vector by assigning it to the variable deltabeta.
Parameters: normalized (bool) – Sets the normalization of the phase matching spectrum. If the normalization is on (True), the phase matching spectrum will be normalized to the unit length (i.e., the maximum will be in [0,1]). Default: False. Returns: the function returns the complex-valued phase matching spectrum.
-
plot(ax=None, normalize_to_max=False, amplitude=False, phase=False, add_infobox=False, **kwargs)[source]¶ Function to plot the phase matching intensity.
Parameters: - ax – Optional argument. Handle of the axis of the plot. Default: None
- normalize_to_max (bool) – Optional argument. If True, normalizes the plotted phase matching spectrum to have the maximum to 1. Default: False
- amplitude (bool) – Optional argument. Plot the phase matching spectrum amplitude instead of the intensity. Default: False.
- phase (bool) – Optional argument. Overlays to the phase matching amplitude (or intensity) the relative phase. Default: False
- add_infobox (bool) – Optional. If True, writes the main information in the plot. Default: False
Returns: the axis handle of the plot. If phase is True, then it is a list of two handles
-
SimplePhasematching1D¶
-
class
pynumpm.phasematching.SimplePhasematching1D(waveguide: Union[pynumpm.waveguide.Waveguide, pynumpm.waveguide.RealisticWaveguide], n_red: Union[Callable[[float], float], Callable[[float], Callable[[float], float]]], n_green: Union[Callable[[float], float], Callable[[float], Callable[[float], float]]], n_blue: Union[Callable[[float], float], Callable[[float], Callable[[float], float]]], order: int = 1, backpropagation: bool = False)[source]¶ Class to calculate the phase matching spectrum of an ideal waveguide, as a function of a single wavelength, i.e. having one fixed wavelength and scanning another one (the third is fixed due to energy conservation). The convention for labelling wavelength is
\[|\lambda_{red}| \geq |\lambda_{green}| \geq |\lambda_{blue}|\]i.e. according to their “energy”.
Initialization of the class requires the following parameters:
Parameters: - waveguide (
RealisticWaveguide) – Waveguide object. Use the Waveguide class in the Waveguide module to define this object. - n_red – refractive index for the “red” wavelength. It has to be a lambda function of a lambda function, i.e. n(variable_parameter)(wavelength in um)
- n_green – refractive index for the “green” wavelength. It has to be a lambda function of a lambda function, i.e. n(variable_parameter)(wavelength in um)
- n_blue – refractive index for the “blue” wavelength. It has to be a lambda function of a lambda function, i.e. n(variable_parameter)(wavelength in um)
- order – order of phase matched process. Default: 1
- backpropagation (bool) – Set to True if it is necessary to calculate a backpropagation configuration.
Usage
With idealwaveguide being a
Waveguideobject and ny and nz being the functions describing the refractive indices of the structure as a function of \(\lambda\) (see Definitions ), the following code calculates its phase matching spectrum as a function of \(\lambda_{IR}\in[1530,\,1570]\mathrm{nm}\), considering a pump \(\lambda_{green}=532\mathrm{nm}\):# Define the phase matching process thisprocess = phasematching.SimplePhasematching1D(waveguide=idealwaveguide, n_red=ny, n_green=nz, n_blue=ny, order=1) # Define the range for the scanning wavelength thisprocess.red_wavelength = np.linspace(1530e-9, 1570e-9, 5000) thisprocess.green_wavelength = 532e-9 # Calculate the phasematching spectrum phi = thisprocess.calculate_phasematching()
-
phi¶ One dimensional phase matching spectrum (complex valued function) numpy.ndarray
-
input_wavelength¶ Input (scanning) wavelength of the process. It cannot be set, it is automatically detected.
-
output_wavelength¶ Output (scanning) wavelength of the process. It cannot be set, it is automatically detected.
-
calculate_phasematching(normalized=True)[source]¶ This function is the core of the class. It calculates the phase matching spectrum of the process, considering one wavelength fixed and scanning the other two.
Parameters: normalized (bool) – If True, the phase matching spectrum is limited in [0,1]. Otherwise, the maximum depends on the waveguide length, Default: True Returns: the complex-valued phase matching spectrum
-
calculate_integral()[source]¶ Calculate the phase matching intensity integral
Returns: the phase matching intensity integral
-
plot(ax=None, normalize_to_max=False, amplitude=False, phase=False, plot_input=True, **kwargs)[source]¶ Plot the phase matching intensity/amplitude.
Parameters: - ax – Axis handle for the plot. If None, plots in a new figure. Default is None.
- normalize_to_max (bool) – Optional argument. If True, normalizes the plotted phase matching spectrum to have the maximum to 1. Default: False
- amplitude (bool) – Optional argument. Plot the phase matching spectrum amplitude instead of the intensity. Default: False.
- phase (bool) – Optional argument. Overlays to the phase matching amplitude (or intensity) the relative phase. Default: False
- plot_input (bool) – Select the x axis for the plot. If True, use the input_wavelength as input, otherwise use output_wavelength.
- kwargs –
matplotlib.pyplot.plot()**kwargs arguments
Returns: list containing the axis handle(s). If phase is True, then a list of two handles will be provided.
- waveguide (
Phasematching1D¶
-
class
pynumpm.phasematching.Phasematching1D(waveguide: pynumpm.waveguide.RealisticWaveguide, n_red: Callable[[float], Callable[[float], float]], n_green: Callable[[float], Callable[[float], float]], n_blue: Callable[[float], Callable[[float], float]], order: int = 1, backpropagation: bool = False)[source]¶ Class to calculate the 1D-phase matching spectrum, i.e. having one fixed wavelength and scanning another one (the third is fixed due to energy conservation). The convention for labelling wavelength is
\[|\lambda_{red}| \geq |\lambda_{green}| \geq |\lambda_{blue}|\]i.e. according to their “energy”.
Initialization of the class requires the following parameters:
Parameters: - waveguide (
RealisticWaveguide) – Waveguide object. Use the Waveguide class in the Waveguide module to define this object. - n_red (function of function) – refractive index for red wavelength. It must be a function of a function, i.e. n(parameter)(wavelength). The wavelength must be in micron (usual convention for Sellmeier’s equations)
- n_green (function of function) – refractive index for green wavelength. It must be a function of a function, i.e. n(parameter)(wavelength). The wavelength must be in micron (usual convention for Sellmeier’s equations)
- n_blue (function of function) – refractive index for “blue” wavelength. It must be a function of a function, i.e. n(parameter)(wavelength). The wavelength must be in micron (usual convention for Sellmeier’s equations)
- order (int) – order of phase matched process. Default: 1
- backpropagation (bool) – Set to True if it is necessary to calculate a backpropagation configuration.
Usage
With realwaveguide being a
RealisticWaveguideobject and ny and nz being the functions describing the refractive indices of the structure as a function of \(\lambda\) and a fabrication parameter \(f_0\) (see Definitions), the following code calculates its phase matching spectrum as a function of \(\lambda_{IR}\in[1530,\,1570]\mathrm{nm}\), considering a pump \(\lambda_{green}=532\mathrm{nm}\):# Define the phase matching process thisprocess = phasematching.Phasematching1D(waveguide=thiswaveguide, n_red=ny, n_green=nz, n_blue=ny) thisprocess.red_wavelength = np.linspace(1530e-9, 1570e-9, 5000) thisprocess.green_wavelength = 532e-9 phi = thisprocess.calculate_phasematching()
-
deltabeta_profile¶ Profile of the \(\Delta\beta\) error
-
noise_length_product¶ Product between the sample length and the maximum \(\Delta\beta\) variation for the process. If this value is above 10, the phase matching is likely to be noisy.
-
set_nonlinearity_profile(profile_type='constant', first_order_coeff=False, **kwargs)[source]¶ Method to set the nonlinearity profile g(z), with either a constant profile or a variety of different windowing functions.
Parameters: - profile_type (str) – Type of nonlinearity profile to consider. Possible options are [constant/gaussian/hamming/bartlett/hanning/blackman/kaiser/custom].
- first_order_coeff (bool) – Select whether to simulate the reduction of efficiency due to quasi-phase matching or not.
- kwargs – Additional parameters to specify different variables of the profile_type used. Only effective if profile_type is “gaussian”, “kaiser” or “custom”.
Returns: The function returns the nonlinearity profile of the system.
The different types of profile available are:
- constant: Uniform nonlinear profile.
- gaussian: \(g(z) = \mathrm{e}^{-\frac{(z-L/2)^2}{2\sigma^2}}\). Set the \(\sigma\) of the gaussian profile with the kwargs argument sigma_g_norm, defining the standard deviation of the gaussian profile in units of the length (defauls to 0.5, i.e. L/2).
- hamming:
numpy.hamming(). - bartlett:
numpy.bartlett(). - hanning:
numpy.hanning(). - blackman:
numpy.blackman(). - kaiser:
numpy.kaiser(). Set the \(\beta\) parameter of the Kaiser profile with the kwargs argument beta, - custom: The user can enter a custom nonlinearity profile g(z) using the keyword “profile”.
-
calculate_delta_k(wl_red=None, wl_green=None, wl_blue=None, n_red=None, n_green=None, n_blue=None)[source]¶ Overload of the method to calculate delta_k. This is necessary since this class is used to calculate the phase matching for a sample with variable dispersions.
Parameters: - wl_red (float or numpy.ndarray) – Red wavelength of the process.
- wl_green (float or numpy.ndarray) – Green wavelength of the process.
- wl_blue (float or numpy.ndarray) – Blue wavelengh of the process.
- n_red (function) – Function returning the refractive index for the red field as a function of the wavelength.
- n_green (function) – Function returning the refractive index for the green field as a function of the wavelength.
- n_blue (function) – Function returning the refractive index for the blue field as a function of the wavelength.
-
calculate_phasematching(normalized=True, hide_progressbar=False)[source]¶ This function calculates the phase matching of the process. Use Phasematching1D.red_wavelength/green_wavelength/ blue_wavelength to set the wavelengths of the process:
- For SHG calculations, set either the red_wavelength or green_wavelength as a numpy.ndarray of wavelengths (in meters). The class will detect automatically that it has received a single input and will automatically calculate the SHG.
- For other processes, set one wavelength as a numpy.ndarray and the other, fixed one as a float. The third will be calculated automatically.
This function does not support PDC calculations. Use
pynumpm.phasematching.SimplePhasematching2Dorpynumpm.phasematching.Phasematching2Dinstead.Parameters: - normalized (bool) – If True, the phase matching is limited in [0,1]. Otherwise, the maximum depends on the waveguide length. Default: True
- hide_progressbar (bool) – Parameter to disable the display of the progressbar during the calculation. Default: False
Returns: the complex-valued phase matching spectrum
- waveguide (
SimplePhasematching2D¶
-
class
pynumpm.phasematching.SimplePhasematching2D(waveguide: Union[pynumpm.waveguide.Waveguide, pynumpm.waveguide.RealisticWaveguide] = None, n_red: Union[Callable[[float], float], Callable[[float], Callable[[float], float]]] = None, n_green: Union[Callable[[float], float], Callable[[float], Callable[[float], float]]] = None, n_blue: Union[Callable[[float], float], Callable[[float], Callable[[float], float]]] = None, order: int = 1, backpropagation: bool = False)[source]¶ Class to calculate the phase matching spectrum of an ideal waveguide, as a function of a two wavelengths, labelled wavelength1 and wavelength2.
These correspond to signal and idler for a PDC process and input and *output for an SFG/DFG process.
Initialization of the class requires the following parameters: :param waveguide: Waveguide object. Use the Waveguide class in the Waveguide module to define this object. :type waveguide:
RealisticWaveguide:param n_red: refractive index for red wavelength. It must be a function of a function, i.e.n(parameter)(wavelength). The wavelength must be in micron (usual convention for Sellmeier’s equations)Parameters: - n_green (function of function) – refractive index for green wavelength. It must be a function of a function, i.e. n(parameter)(wavelength). The wavelength must be in micron (usual convention for Sellmeier’s equations)
- n_blue (function of function) – refractive index for “blue” wavelength. It must be a function of a function, i.e. n(parameter)(wavelength). The wavelength must be in micron (usual convention for Sellmeier’s equations)
- order (int) – order of phase matching. Default: 1
- backpropagation – Set to True if it is necessary to calculate a backpropagation configuration.
With idealwaveguide being a
Waveguideobject and ny and nz being the functions describing the refractive indices of the structure as a function of \(\lambda\) (see Definitions), the following code calculates its phase matching spectrum as a function of \(\lambda_{signal} = \lambda_{IR}\in[1530,\,1570]\mathrm{nm}\) and \(\lambda_{idler} = \lambda_{green}=\in[1270, 1320]\mathrm{nm}\):thisprocess = phasematching.SimplePhasematching2D(waveguide=thiswaveguide, n_red=ny, n_green=nz, n_blue=ny, order=1) # Define the range for the scanning wavelength thisprocess.red_wavelength = np.linspace(1530e-9, 1570e-9, 1000) thisprocess.green_wavelength = np.linspace(1270-9, 1320e-9, 500) # Calculate the phase matching spectrum phi = thisprocess.calculate_phasematching()
-
load_phasematching(wavelength1, wavelength2, phasematching)[source]¶ Function used to load the phase matching spectrum from an external matrix
Parameters: - wavelength1 (numpy.ndarray) – Wavelength array (in m) corresponding to the columns of the phase matching matrix
- wavelength2 (numpy.ndarray) – Wavelength array (in m) corresponding to the rows of the phase matching matrix
- phasematching – Matrix containing the complex amplitude of the phase matching spectrum
-
calculate_phasematching(normalized=True)[source]¶ Function to calculate the phase matching spectrum.
Parameters: normalized (bool) – If True, the phase matching spectrum is limited in [0,1]. Otherwise, the maximum depends on the waveguide length, Default: True Returns: the complex-valued phase matching spectrum
-
plot(ax=None, normalize_to_max=False, amplitude=False, plot_colorbar=True, **kwargs)[source]¶ Plot the phase matching intensity/amplitude.
Parameters: - ax – Axis handle for the plot. If None, plots in a new figure. Default is None.
- normalize_to_max (bool) – Optional argument. If True, normalizes the plotted phase matching spectrum to have the maximum to 1. Default: False
- amplitude (bool) – Optional argument. Plot the phase matching spectrum amplitude instead of the intensity. Default: False.
- plot_colorbar (bool) – Optional argument. Set to True to plot the colorbar.
- kwargs –
matplotlib.pyplot.plot()**kwargs arguments
Returns: list containing the axis handle(s). If phase is True, then a list of two handles will be provided.
-
plot_deltabeta_contour(ax=None, N=100, **contourkwargs)[source]¶ Function to plot the contour lines of the \(\Delta\beta\)
Parameters: - ax – Handle of the axis where the plot will be
- N – Number of lines for the contour plot
- contourkwargs – Additional parameters to be passed to matplotlib.pyplot.contour()
Phasematching2D¶
-
class
pynumpm.phasematching.Phasematching2D(waveguide: pynumpm.waveguide.RealisticWaveguide, n_red: Callable[[float], Callable[[float], float]], n_green: Callable[[float], Callable[[float], float]], n_blue: Callable[[float], Callable[[float], float]], order: int = 1, backpropagation: bool = False)[source]¶ Class to calculate the 2D-phase matching spectrum, i.e. having one fixed wavelength and scanning another one (the third is fixed due to energy conservation). The convention for labelling wavelength is
\[|\lambda_{red}| \geq |\lambda_{green}| \geq |\lambda_{blue}|\]i.e. according to their “energy”.
Initialization of the class requires the following parameters:
Parameters: - waveguide (
RealisticWaveguide) – Waveguide object. Use the Waveguide class in the Waveguide module to define this object. - n_red – refractive index for the “red” wavelength. It has to be a lambda function of a lambda function, i.e. n(variable_parameter)(wavelength in um)
- n_green – refractive index for the “green” wavelength. It has to be a lambda function of a lambda function, i.e. n(variable_parameter)(wavelength in um)
- n_blue – refractive index for the “blue” wavelength. It has to be a lambda function of a lambda function, i.e. n(variable_parameter)(wavelength in um)
- order – order of phase matching. Default: 1
- backpropagation (bool) – Set to True if it is necessary to calculate a backpropagation configuration.
Usage
With realwaveguide being a
RealisticWaveguideobject and ny and nz being the functions describing the refractive indices of the structure as a function of \(\lambda\) and a fabrication parameter \(f_0\) (see Definitions), the following code calculates its phase matching spectrum as a function of input wavelength \(\lambda_{in}\in[1530,\,1570]\mathrm{nm}\) and the output wavelength \(\lambda_{out}=\in[545,\,555]\mathrm{nm}\):# Define the phase matching process thisprocess = phasematching.Phasematching1D(waveguide=realwaveguide, n_red=ny, n_green=nz, n_blue=ny) thisprocess.red_wavelength = np.linspace(1530e-9, 1570e-9, 5000) thisprocess.blue_wavelength = np.linspace(545e-9, 545555e-9, 5000) phi = thisprocess.calculate_phasematching()
-
set_nonlinearity_profile(profile_type='constant', first_order_coeff=False, **kwargs)[source]¶ Method to set the nonlinearity profile g(z), with either a constant profile or a variety of different windowing functions.
Parameters: - profile_type (str) – Type of nonlinearity profile to consider. Possible options are [constant/gaussian/hamming/bartlett/hanning/blackman/kaiser/custom].
- first_order_coeff (bool) – Select whether to simulate the reduction of efficiency due to quasi-phase matching or not.
- kwargs – Additional parameters to specify different variables of the profile_type used. Only effective if profile_type is “gaussian”, “kaiser” or “custom”.
Returns: The function returns the nonlinearity profile of the system.
The different types of profile available are:
- constant: Uniform nonlinear profile.
- gaussian: \(g(z) = \mathrm{e}^{-\frac{(z-L/2)^2}{2\sigma^2}}\). Set the \(\sigma\) of the gaussian profile with the kwargs argument sigma_g_norm, defining the standard deviation of the gaussian profile in units of the length (defauls to 0.5, i.e. L/2).
- hamming:
numpy.hamming(). - bartlett:
numpy.bartlett(). - hanning:
numpy.hanning(). - blackman:
numpy.blackman(). - kaiser:
numpy.kaiser(). Set the \(\beta\) parameter of the Kaiser profile with the kwargs argument beta, - custom: The user can enter a custom nonlinearity profile g(z) using the keyword “profile”.
-
calculate_phasematching(normalized=True, hide_progressbar=False)[source]¶ This function is the core of the class. It calculates the 2D phase matching spectrum of the process, scanning the two user-defined wavelength ranges.
Parameters: - normalized (bool) – If True, the phase matching is limited in [0,1]. Otherwise, the maximum depends on the waveguide length, Default: True
- hide_progressbar (bool) – Parameter to disable the display of the progressbar during the calculation. Default: False
Returns: the complex-valued phase matching spectrum
-
slice_phasematching(const_wl)[source]¶ Slice the phase matching. The function interpolates the phase matching in the direction of the wavelength to be kept fixed (fix_wl) and evaluating the interpolation at the value provided (value). In this way, it is possible to cut along wavelength not present in the original grid.
Parameters: const_wl (float) – Constant wavelength where to cut the phase matching. The program detects whether it is within the signal or idler range. Return wl, phi: scanning wavelength and interpolated complex-valued phase matching spectrum.
- waveguide (