Skip to content

Some issues with establishing diffraction models using XRT #267

@foki-699

Description

@foki-699

Hello, I am a beginner in XRT.
While building an optical model for a pinhole, I noticed that the Airy disk radius is quite large, so diffraction effects need to be taken into account.
I would like to ask how to correctly call the wave library in XRT. I modified the code, but it fails to run.
The code was generated by xrt.
I don't know how to reference the wave library in the light transmission code.

import numpy as np
import sys
sys.path.append(r"D:\develop\anaconda\Lib\site-packages")
import xrt.backends.raycing.sources as rsources
import xrt.backends.raycing.screens as rscreens
import xrt.backends.raycing.materials as rmats
import xrt.backends.raycing.materials_elemental as rmatsel
import xrt.backends.raycing.materials_compounds as rmatsco
import xrt.backends.raycing.materials_crystals as rmatscr
import xrt.backends.raycing.oes as roes
import xrt.backends.raycing.apertures as rapts
import xrt.backends.raycing.run as rrun
import xrt.backends.raycing as raycing
import xrt.plotter as xrtplot
import xrt.runner as xrtrun
import xrt.backends.raycing.waves as waves

material01 = rmats.Material(
elements=r"Si",
kind=r"mirror",
rho=2.33,
name=None)

material02 = rmats.Material(
elements=r"W",
kind=r"mirror",
rho=19.35,
name=None)

multilayer01 = rmats.Multilayer(
tLayer=material02,
tThickness=9.6,
bLayer=material01,
bThickness=14.4,
nPairs=49,
substrate=material01,
idThickness=3.5,
name=None,
geom=r"")

def build_beamline():
beamLine = raycing.BeamLine()

beamLine.geometricSource01 = rsources.GeometricSource(
    bl=beamLine,
    name=None,
    center=[0, -0.001, 0],
    nrays=1000000,
    distx=r"flat",
    dx=20,
    distz=r"flat",
    dz=8,
    distxprime=r"flat",
    dxprime=0.022,
    distzprime=r"flat",
    dzprime=0.007,
    energies=[1000])

beamLine.gridAperture01 = rapts.GridAperture(
    bl=beamLine,
    name=None,
    center=[0, 0.001, 0],
    dx=2,
    dz=2,
    px=2.5,
    pz=2.5,
    nx=4,
    nz=4)

beamLine.roundAperture01 = rapts.RoundAperture(
    bl=beamLine,
    center=[0, 2400, 0],
    r=0.05)

beamLine.oe01 = roes.OE(
    bl=beamLine,
    name=None,
    center=[0, 5500, 0],
    pitch=0.2618,
    roll=1.57,
    limPhysX=[-45, 45],
    limPhysY=[-150, 150.0])

beamLine.screen01 = rscreens.Screen(
    bl=beamLine,
    name=None,
    center=[250, 5933, 0],
    x=[0.886, -0.5, 0])

return beamLine

def run_process(beamLine):
geometricSource01beamGlobal01 = beamLine.geometricSource01.shine()

gridAperture01beamLocal01 = beamLine.gridAperture01.propagate(
    beam=geometricSource01beamGlobal01)

roundAperture01beamLocal01 = beamLine.roundAperture01.propagate(
    beam=geometricSource01beamGlobal01)

oe01beamGlobal01, oe01beamLocal01 = beamLine.oe01.reflect(
    beam=geometricSource01beamGlobal01)

screen01beamLocal01 = beamLine.screen01.expose(
    beam=oe01beamGlobal01)

outDict = {
    'geometricSource01beamGlobal01': geometricSource01beamGlobal01,
    'gridAperture01beamLocal01': gridAperture01beamLocal01,
    'roundAperture01beamLocal01': roundAperture01beamLocal01,
    'oe01beamGlobal01': oe01beamGlobal01,
    'oe01beamLocal01': oe01beamLocal01,
    'screen01beamLocal01': screen01beamLocal01}
return outDict

rrun.run_process = run_process

def define_plots():
plots = []

plot01 = xrtplot.XYCPlot(
    beam=r"screen01beamLocal01",
    xaxis=xrtplot.XYCAxis(
        label=r"x"),
    yaxis=xrtplot.XYCAxis(
        label=r"z"),
    caxis=xrtplot.XYCAxis(
        label=r"energy",
        unit=r"eV"),
    title=r"plot01")
plots.append(plot01)
return plots

def main():
beamLine = build_beamline()
E0 = list(beamLine.geometricSource01.energies)[0]
beamLine.alignE=E0
plots = define_plots()
xrtrun.run_ray_tracing(
plots=plots,
backend=r"raycing",
repeats=20000,
beamLine=beamLine)

if name == 'main':
main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions