Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange error in propagating from point source to detector #81

Open
capitanevs opened this issue May 7, 2023 · 0 comments
Open

Strange error in propagating from point source to detector #81

capitanevs opened this issue May 7, 2023 · 0 comments

Comments

@capitanevs
Copy link
Collaborator

This code is not working.
I did not have time to understand why.

`from LibWiser.EasyGo import *
import LibWiser.FermiSource

#%% DEFAULT SETTINGS: You can change parameter here or in a similar dictionary
#%=============================================================================
BeamlineName = ''
SettingsDefault = {#chosen to mimic a plane wave on slits at 70m
'Lambda' : 633e-9,
'Waist0' : 1e-15,
'DetectorSize' : 50e-3,
'NSamples' : 8000,
'DetectorDefocus' : 0,
'UseCustomSampling' : True,
'SlitSize' : 10e-6,
'SlitDistance' : 50,
'DeltaZ' : 100e-3
}

#=============================================================================
S = SettingsDefault
DetectorSize = S['DetectorSize']
NSamples = S['NSamples']
FresnelNumber = S['SlitSize']**2 / S['Lambda'] / S['DeltaZ']
print("FresnelNumber = %0.1e" % FresnelNumber)
#%% LAYOUT: creating Foundation.Optical element objects
#%=============================================================================

#---SOURCE (H,V)
#------------------------------------------------------------
DeltaSource = 0
s = OpticalElement(
Name = 's',
IsSource = True,
CoreOpticsElement = Optics.SourceGaussian(
Lambda = S['Lambda'],
Waist0 = S['Waist0'],
Orientation = Optics.OPTICS_ORIENTATION.ISOTROPIC),
PositioningDirectives = Foundation.PositioningDirectives(
ReferTo = 'absolute',
XYCentre = [0,0],
Angle = 0)
)
#---slits_v
#------------------------------------------------------------

slits_v = OpticalElement(
Name = 'slits_v',
CoreOpticsElement = Optics.Slits(
L = S['SlitSize'],
Orientation = Optics.OPTICS_ORIENTATION.VERTICAL),
PositioningDirectives = Foundation.PositioningDirectives(
PlaceWhat = 'centre',
PlaceWhere = 'centre',
ReferTo = 'source',
Distance = S['SlitDistance'] ) )
#---Detector
#------------------------------------------------------------
det_v= OpticalElement(
Name = 'det_v',
CoreOpticsElement = Optics.Detector(
L = DetectorSize,
AngleGrazing = np.deg2rad(90),
Orientation = Optics.OPTICS_ORIENTATION.VERTICAL),
PositioningDirectives = Foundation.PositioningDirectives(
PlaceWhat = 'centre',
PlaceWhere = 'centre',
ReferTo = 'source',
Distance = S['SlitDistance'] + S['DeltaZ']))

Create Beamlinee beamline starting from Beamlinee Beamline Elements Objects

#------------------------------------------------------------------------------------------------
Beamline = None
Beamline = Foundation.BeamlineElements()
Beamline.Append(s)

Beamline.Append(slits_v)

Beamline.Append(det_v)
Beamline.RefreshPositions()
print(Beamline) #
Beamline.Name = BeamlineName
#%% Settings: UseFigureError
#==========================================================
Beamline.ComputeFields()
Beamline.PlotIntensity()

d = S['SlitSize']
z = S['DeltaZ']
Lambda = S['Lambda']
NF = d**2 /Lambda/z
x0 = Lambda * z / d
print('NF = %0.2f' % NF)

R = s.CoreOptics.RCurvature(S['SlitDistance'])
z_eff = (1/z + 1/R)**-1
x0_g = Lambda * z_eff / d

#%% Add constant field
E = det_v.ComputationData.Field
plot(abs(E+10)**2)

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant