Closed AkhilKallepalli closed 4 years ago
Dear Akhil,
1) You have to define a refractive index distribution. 2) nstep must be an integer, the command propagates the field over a distance nstep*dz. Choose dz much smaller, 8m is too long. 3) I have to do parameter checks in the routines. Next version...
The code below works without error
from LightPipes import *
import matplotlib.pyplot as plt
import numpy as np
GridSize = 2*mm
GridDimension = 512
lambda_ = 633*nm
Field = Begin(GridSize, lambda_, GridDimension)
Field = GaussBeam(Field, 100*um, LG=True, n=0, m=3, doughnut=True)
Field = RectAperture(Field, 240*um, 240*um, angle=45.0)
#F_Steps = Steps(Field, 8*m, nstep=0.01)
#You have to define a refractive index, for example:
n=(1.0 + 0.1j)*np.ones((GridDimension,GridDimension))
F_Steps = Steps(Field, 1*mm, nstep=10, refr=n)
Hope your code will work... Fred.
Dear @FredvanGoor , Thank you so much for writing back swiftly. And thank you in advance for your suggestions/help with the problem below. Something strange happens when I use this. I will share everything I can so that it may help with problem-solving. Also, I may be describing the concern with different phrases. Hope the clarification below helps.
from LightPipes import *
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
GridSize = 2*mm
GridDimension = 512
lambda_ = 633*nm
Field = Begin(GridSize, lambda_, GridDimension)
Field = GaussBeam(Field, 100*um, LG=True, n=0, m=3, doughnut=True)
I = Intensity(0, Field)
Phi = Phase(Field)
plt.figure; plt.imshow(I); plt.title('Initial Intensity')
plt.show(block=False)
plt.figure(); plt.imshow(Phi); plt.title('Initial Phase')
plt.show(block=False)
Field = RectAperture(Field, 240*um, 240*um, angle=45.0)
I = Intensity(0, Field)
plt.figure(); plt.imshow(I); plt.title('Intensity after the aperture')
plt.show(block=False)
Field = Forvard(Field, 8*cm)
I = Intensity(0, Field)
plt.figure(); plt.imshow(I); plt.title('Intensity after the aperture, after 8 cm propagation')
plt.show(block=False)
Field= Lens(Field, 8*cm)
I = Intensity(0, Field)
Field = Forvard(Field, 8*cm)
I = Intensity(0, Field)
plt.figure(); plt.imshow(I); plt.title('Intensity after the aperture, after 16 cm propagation, through a lens')
plt.show()
The above code gives me a focussed image of the beam through the rectangular aperture (at 16 cm, past a lens). Without field restriction, using Forvard()
, there is no concern whatsoever. When trying to remove the reflection from the boundary, I have a different image.
Intention: Removing reflections from the boundaries
I modified the two Forvard()
functions with the lines below, twice:
n = (1.0 + 0.1j)*np.ones((GridDimension,GridDimension))
Field = Steps(Field, 8*cm, nstep=10, refr=n) # With my interpretation from the support docs,
# the beam will propagate 8 cm in 10 steps. Is this correct?
# Or will the beam now propagate 8 * 10 = 80 cm?
Expectation:
With field restriction:
Without field restriction (as you can see, this is perfectly comparable to the result of the Forvard()
:
Dear Akhil, In Steps there is an internal loop which do Nsteps for a distance dz each. You can also make your own for loop with Steps called Nsteps times with for each call only one step. Same effect. You have to make each step much smaller with more steps, see below. Tip: look at the Command Reference on: https://opticspy.github.io/lightpipes/
from LightPipes import *
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
GridSize = 2*mm
GridDimension = 512
lambda_ = 633*nm
Field = Begin(GridSize, lambda_, GridDimension)
Field = GaussBeam(Field, 100*um, LG=True, n=0, m=3, doughnut=True)
I = Intensity(0, Field)
Phi = Phase(Field)
plt.figure; plt.imshow(I); plt.title('Initial Intensity')
plt.show(block=False)
plt.figure(); plt.imshow(Phi); plt.title('Initial Phase')
plt.show(block=False)
Field = RectAperture(Field, 240*um, 240*um, angle=45.0)
I = Intensity(Field) # no flag needed, 0=default
plt.figure(); plt.imshow(I); plt.title('Intensity after the aperture')
plt.show(block=False)
#Field = Forvard(Field, 8*cm)
n = (1.0 + 0.0j)*np.ones((GridDimension,GridDimension)) # make imaginary part = 0.0: no attenuation.
Field = Steps(Field, 0.8*mm, nstep=100, refr=n) # mke your step smaller, for example: 8cm in 100 steps
I = Intensity(0, Field)
plt.figure(); plt.imshow(I); plt.title('Intensity after the aperture, after 8 cm propagation')
plt.show(block=False)
Field= Lens(Field, 8*cm)
I = Intensity(0, Field)
#Field = Forvard(Field, 8*cm)
n = (1.0 + 0.0j)*np.ones((GridDimension,GridDimension))
Field = Steps(Field, 0.8*mm, nstep=100, refr=n) # Make your step smaller, for example: 8cm in 100 steps
I = Intensity(0, Field)
plt.figure(); plt.imshow(I); plt.title('Intensity after the aperture, after 16 cm propagation, through a lens')
plt.show()
Success with your project! Fred
Dear @FredvanGoor,
This is perfect! Thank you so much. I think the clarification I need was with the intuition of the Steps() function. Much appreciated. And thank you, also, for LightPipes :-)
Best regards, Akhil
Context: I am trying to propagate the beam in free space without reflection coming back from the boundaries. Any waves/reaching the boundaries needs to be absorbed and not propagated any further or back into the system.
At this point, I begin to have what seems to be like a variable type error. Could you please assist? I was unable to find the right syntax, if this is wrong, in the pages of the package.
Thank you in advance, Akhil