oasys-elettra-kit / OASYS1-Wiser

The implementation of WISER into OASYS
MIT License
0 stars 1 forks source link

Strange error in propagating from point source to detector #81

Open capitanevs opened 1 year ago

capitanevs commented 1 year ago

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)

`