gregmoille / pyLLE

Lugiato Lefever Equation Solver in Python/Julia
Other
65 stars 39 forks source link

Analyzing the linear dispersion of the resonator #44

Closed bugwumba closed 1 year ago

bugwumba commented 1 year ago

Describe the bug When I run this code from the example, I get an error saying that no attribute exists.

To Reproduce

The Lugiato-Lefever Equation

provides a model for

spontaneous pattern formation

in nonlinear optical systems.

The patterns originate from the interactions of a coherent field,

that is injected into a resonant optical cavity,

with a Kerr medium that fills the cavity

import inspect

This is an example pyLLE program

the example begins by importing all the pacakges

import os import sys

currentdir = os.getcwd() parentdir = os.path.dirname(currentdir) sys.path.insert(0, parentdir)

This helps me turn python objects

into bit streams and back again

import pickle as pkl import time

import numpy as np import pandas as pd import plotly.graph_objs as go

The bottom code was in the example

It seems redundant, so I will

comment it oout

import plotly.graph_objs import plotly.io as pio import pyLLE from scipy import constants as cts import plotly.express as px

pio.renderers._default = "notebook" pio.templates._default = "seaborn"

Stage two of this example involes creating two dictionaries

The first dictionary is the resonator and the second is the simulations

Version 4 of this program allows the pump power and the pump frequency

to be lists to simulatre a multi-pump system

resonator = dict(

Size of the resonator

R = 23e-6,
# Intrinsic quality of the resonator
Qi = 1e6,
# ?
Qc = 1e6, 
# ?
γ = 3.2,
# This is the dispersion file
# The dispersion file is a 
# 2D .cssv that contains
# the azimuthal mode number,
# and frequency of resonance 
# in the first and second columns, respectively
#
dispfile = "./RW1000_H430.csv"

)

simulation = dict( Pin = [160e-3], f_pmp = [283e12],

Does this mean the mode number?

φ_pmp = [0],
#?
δω=[None], 
#?
Tscan = 0.7e6,
# ?
μ_sim = [-220, 220],
δω_init = 1e9 * 2 * np.pi,
δω_end = -3.5e9 * 2 * np.pi

)

THe next step is to initialize the solver.

solver = pyLLE.LLEsolver(sim = simulation, res = resonator, debug = True)

Here we analyze the linear dispersion of the resonator

fig = solver.Analyze(plot=True) fig.update_yaxes(range = [-50, 50], title = 'Dint (GHz)') fig.show()

Expected behavior I expected to see a figure containing a plot of the linear dispersion of the resonator

Error or Screenshots <class 'matplotlib.figure.Figure'> Traceback (most recent call last): File "/Users/buddyugwumba1/Documents/UCR/Graduate/Dr. Taheri/pyLLE project/pyLLE_Example.py", line 87, in fig.update_yaxes(range = [-50, 50],title = 'Dint (GHz)') AttributeError: 'Figure' object has no attribute 'update_yaxes' (project) (base) buddyugwumba1@Buddys-MacBook-Pro-2 pyLLE project % python3 pyLLE_Example.py

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

gregmoille commented 1 year ago

hi @bugwumba

you’re trying to update the axis of a matplotlib figure with plotly attribute. Your error comes from the last line of your code. I believe the matplotlib figure is created because you are not reunion the script in a jupyter environment, therefore no plotly. You could always plot things by end by creating a figure and plotting the different values of the dispersion that you can retrieved from the solver.disp object. Glad to see Hossein’s group using pyLLE ;) (saw from the orb in your error)

cheers

Greg

bugwumba commented 1 year ago

Good evening Greg,

Thanks for the help and the especially speedy response. Running your example script in juypter notebook produced the figure.

Best, Buddy Ugwumba

On Oct 28, 2022, at 1:46 PM, Gregory Moille @.***> wrote:

hi @bugwumba https://github.com/bugwumba you’re trying to update the axis of a matplotlib figure with plotly attribute. Your error comes from the last line of your code. I believe the matplotlib figure is created because you are not reunion the script in a jupyter environment, therefore no plotly. You could always plot things by end by creating a figure and plotting the different values of the dispersion that you can retrieved from the solver.disp object. Glad to see Hossein’s group using pyLLE ;) (saw from the orb in your error)

cheers

Greg

— Reply to this email directly, view it on GitHub https://github.com/gregmoille/pyLLE/issues/44#issuecomment-1295449260, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANL7LLUUSGHG4YFZSU6AETLWFQ3S5ANCNFSM6AAAAAARRM5FUU. You are receiving this because you were mentioned.

bugwumba commented 1 year ago

Hi Greg,

How are you? I hope all is well. Dr. Taheri is asking that I conduct some tests for him using a set of parameters. From your example pyLLE code, I am having trouble located where to change the parameters. These are the parameters that I need to modify and cannot locate:

  1. Center wavelength (in meters)
  2. Load quality factor
  3. The dispersion values.

I figured the dispersion values could be changed by executing the following:

dispersion = dict(

Group Index

# ng = 
# Disperion
D = [2*pi*(-3.4951e5), 2*pi*(-13.598), 2*pi*(3.8194e-5)]
# Effective index
# neff = [1.412 ... 1.936]
# Mode frequency
# freq = [148.354 ... 587.077]
# Mode frequency to match the sim domain
# freq_sim = [67.530 ... 497.761]
# Integrated dispersion at the pumps from file
# Dint
# Integrated dispersion at the pumps from fit
# Dint_sim
# Dint at the center of sim domain
# Dint0 = [-391064.774 ... -4964.929]
# Angular repetition rate
# D1 = 6.172
# Free Spectra Range at the pumps
# FSR = [982.263]
# Free Spectra Range at the center of the domain
# FSR_center = [1.760 ... 2.187]

)

Is this correct?

Best, Buddy Ugwumba

gregmoille commented 1 year ago

Hey Buddy,

The LLE is essentially agnostic to the wavelength/frequency. The only thing that matters is the frequency dependence, i.e. the dispersion of the different parameter (mostly GVD dispersion as the losses at the moment are only scalars in pyLLE) and the nonlinear coefficient which is wavelength dependent.

In pyLLE, the wavelength -- which is only addressed through the optical frequency -- matter in the computation of the dispersion to simulate a close-to-experimental dispersion.

To this extend, I would advise you to create a new dispersion file in the css format. From here you can simply define the dispersion coefficient and retrieve the frequency of resonance from the integrated dispersion and the center frequency (i..e the pump frequency). Using it in pyLLE will essentially answer to your question 1 and 3

For the loaded quality factor, in the res dictionary the parameter Qc allow you to change it.