Coder Social home page Coder Social logo

kklmn / xrt Goto Github PK

View Code? Open in Web Editor NEW
77.0 13.0 27.0 481.2 MB

Package xrt (XRayTracer) is a python software library for ray tracing and wave propagation in x-ray regime. It is primarily meant for modeling synchrotron sources, beamlines and beamline elements.

License: MIT License

Python 92.92% C 6.77% Cool 0.17% HTML 0.06% JavaScript 0.08%
python x-ray optics synchrotron visualization wave propagation ray-tracing qt-gui gpu-acceleration

xrt's Introduction

xrt GitHub version

DOI

Package xrt (XRayTracer) is a python software library for ray tracing and wave propagation in x-ray regime. It is primarily meant for modeling synchrotron sources, beamlines and beamline elements. Includes a GUI for creating a beamline and interactively viewing it in 3D.

xrt is also available as source distribution from https://pypi.python.org/pypi/xrt PyPI version

See the documentation on http://xrt.readthedocs.io Documentation Status
The documentation is also available off-line as zip file (63 MB).

See Detailed instructions for installing dependencies.

xrt's People

Contributors

kklmn avatar mrakitin avatar yxrmz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xrt's Issues

Beam missing in xrtGlow

bug

Above image shows my testing beamline with undulator source and KB mirror. As you can see, the beam lost before the first mirror. However, the footprints of the beam are correct as well as the final outputs. The xml file was attached below. Please change the file type to .xml, because the xml file is not supported.

testBeamline.txt

Rotation of a screen in plot_generator

I've been using plot_generator to record the size of a focused beam as a function of both screen position and screen rotation. The script works well when moving the screen but when I want to change the rotation it does not reset the angle of the screen.

Aperture Material

Has anyone had success creating a derivation of any of the aperture classes to account for the aperture material? Is a hybrid propagate/reflect method possible?

Thanks in Advance

Laterally graded multilayer and ParabolicalMirrorParam

At the moment I am interested in implementing a laterally graded multilayer on a parabolical mirror, and I am trying to understand what x and y represent in the get_t_thickness and get_b_thickness functions. As a basic test, here is the material class:

class LatGradMultilayer(Multilayer):

    def get_t_thickness(self, x, y, iPair):
        global XY  # to extract x,y values
        XY = np.array([x,y])
        return self.dti[iPair]

    def get_b_thickness(self, x, y, iPair):
        return self.dti[iPair]

With a flat mirror...

OE(BL, center=[0, 200, 0], material=mL, pitch=bragg, limPhysY=[-80, 80],
   limPhysX=[-3.5, 3.5])

...it's pretty clear what x and y are:

xy_oe

For ParabolicalMirrorParam it's not so clear:

ParabolicalMirrorParam(BL, p=200, center=[0,200,0], material=mL, pitch=bragg,
                       limPhysY=[-80, 80], limPhysX=[-3.5, 3.5], isCylindrical=True)

xy_parabolicalmirrorparam

Any help would appreciated.

The verification of the wave propagation

Is there any examples about the verification of the wave propagation caculation, especially compared with SRW simulation or experiment? It is expected to carried out this work in our team, if it has been done, I would appreciate your comment on that work.

FZP material question

Hi,
I was looking through the materials.py code in version 1.3.3 and came across the following.

In get_amplitude(self, E, beamInDotNormal, from Vacuum=True):
the if statement on line 490 is:
if self.kind in ('FZP'): return 1,1,0
so that it always returns there for a fresnel zone plate.
Later in that function, line 514 has:
elif self.kind in ('plate','lens','FZP'): ...
where this section calculates the transmission based on the material index.
It looks like line 490 always catches the FZP and returns an ideal case FZP rather than calculating the transmission change due to the material index of refraction. Is that intended?

Best,
Bernie

Cylindrical Beam Stopper

Hello,
is it possible to implement the cylindrical beam stopper inside the HOPG cylinder?

Thank you in advance

problem installing with pip on linux (into conda environment)

Hi,

I just tried to pip install xrt into a conda environment. It failed, I have the log below, the thing that looks suspicisous is errors about filenames that have / and \ in it, does xrt work on linux? Or is it Windows based? That is this line:

error: file '/tmp/pip-build-oIA7E5/xrt/xrt\xrtQook\xrtQook.pyw' does not exist

here is the whole log

Collecting xrt
  Downloading xrt-1.2.0.zip (6.4MB)
    100% |################################| 6.4MB 100kB/s 
Building wheels for collected packages: xrt
  Running setup.py bdist_wheel for xrt ... error
  Complete output from command /reg/g/psdm/sw/conda/inst/miniconda2-dev-rhel7/envs/xrt/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-oIA7E5/xrt/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpV1Ovubpip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib
  creating build/lib/xrt
  copying xrt/__init__.py -> build/lib/xrt
  copying xrt/multipro.py -> build/lib/xrt
  copying xrt/kde.py -> build/lib/xrt
  copying xrt/plotter.py -> build/lib/xrt
  copying xrt/runner.py -> build/lib/xrt
  creating build/lib/xrt/backends
  copying xrt/backends/dummy.py -> build/lib/xrt/backends
  copying xrt/backends/__init__.py -> build/lib/xrt/backends
  copying xrt/backends/shadow.py -> build/lib/xrt/backends
  creating build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/sources_synchr.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/physconsts.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/__init__.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/stages.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/waves.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/apertures.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/myopencl.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/oes.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/run.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/oes_base.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/sources.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/sources_legacy.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/sources_beams.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/screens.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/materials.py -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/sources_geoms.py -> build/lib/xrt/backends/raycing
  creating build/lib/xrt/xrtQook
  copying xrt/xrtQook/__init__.py -> build/lib/xrt/xrtQook
  creating build/lib/xrt/backends/raycing/data
  copying xrt/backends/raycing/data/Chantler.Ef -> build/lib/xrt/backends/raycing/data
  copying xrt/backends/raycing/data/f0_xop.dat -> build/lib/xrt/backends/raycing/data
  copying xrt/backends/raycing/data/Henke.Ef -> build/lib/xrt/backends/raycing/data
  copying xrt/backends/raycing/data/AtomicData.dat -> build/lib/xrt/backends/raycing/data
  copying xrt/backends/raycing/data/BrCo.Ef -> build/lib/xrt/backends/raycing/data
  copying xrt/backends/raycing/undulator.cl -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/diffract.cl -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/materials.cl -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/OE.cl -> build/lib/xrt/backends/raycing
  copying xrt/backends/raycing/xrt_complex.cl -> build/lib/xrt/backends/raycing
  creating build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/logo-xrtQt.png -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/xrQt1.ico -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/index.txt -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/GPU4.png -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/home.png -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/pythonscriptsave.png -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/run.png -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/pythonscriptsaveas.png -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/filesaveas.png -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/pythonscript.png -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/readme.png -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/filenew.png -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/fileopen.png -> build/lib/xrt/xrtQook/_icons
  copying xrt/xrtQook/_icons/filesave.png -> build/lib/xrt/xrtQook/_icons
  creating build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/filterFootprint2_I400mum_norm2.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/negative=1+fullNegative.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/ePos=1.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/invertColorMap=1_negative=1.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/filterFootprint2_I400mum.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/outline00.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/invertColorMap=0_negative=0.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/outline10.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/filterFootprint2_I400mum_norm1.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/qookSplashSmall_ani.gif -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/ePos=2.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/outline05.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/1-LEG_profile-default.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/qookTutor6.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/qookTutor7.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/qookTutor5.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/ePos=0.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/qookTutor4.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/qookTutor3.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/offset0.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/qookTutor1.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/offset5000.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/qookTutor2.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/invertColorMap=0_negative=1.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/1-LEG_profile-adhoc.png -> build/lib/xrt/xrtQook/_images
  copying xrt/xrtQook/_images/invertColorMap=1_negative=0.png -> build/lib/xrt/xrtQook/_images
  creating build/lib/xrt/xrtQook/xmls
  copying xrt/xrtQook/xmls/1crystal.xml -> build/lib/xrt/xrtQook/xmls
  copying xrt/xrtQook/xmls/guitestbl.xml -> build/lib/xrt/xrtQook/xmls
  copying xrt/xrtQook/xmls/4crystals.xml -> build/lib/xrt/xrtQook/xmls
  running build_scripts
  creating build/scripts-2.7
  error: file '/tmp/pip-build-oIA7E5/xrt/xrt\xrtQook\xrtQook.pyw' does not exist

  ----------------------------------------
  Failed building wheel for xrt
  Running setup.py clean for xrt
Failed to build xrt
Installing collected packages: xrt
  Running setup.py install for xrt ... error
    Complete output from command /reg/g/psdm/sw/conda/inst/miniconda2-dev-rhel7/envs/xrt/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-oIA7E5/xrt/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-mDgywh-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib
    creating build/lib/xrt
    copying xrt/__init__.py -> build/lib/xrt
    copying xrt/multipro.py -> build/lib/xrt
    copying xrt/kde.py -> build/lib/xrt
    copying xrt/plotter.py -> build/lib/xrt
    copying xrt/runner.py -> build/lib/xrt
    creating build/lib/xrt/backends
    copying xrt/backends/dummy.py -> build/lib/xrt/backends
    copying xrt/backends/__init__.py -> build/lib/xrt/backends
    copying xrt/backends/shadow.py -> build/lib/xrt/backends
    creating build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/sources_synchr.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/physconsts.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/__init__.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/stages.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/waves.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/apertures.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/myopencl.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/oes.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/run.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/oes_base.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/sources.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/sources_legacy.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/sources_beams.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/screens.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/materials.py -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/sources_geoms.py -> build/lib/xrt/backends/raycing
    creating build/lib/xrt/xrtQook
    copying xrt/xrtQook/__init__.py -> build/lib/xrt/xrtQook
    creating build/lib/xrt/backends/raycing/data
    copying xrt/backends/raycing/data/Chantler.Ef -> build/lib/xrt/backends/raycing/data
    copying xrt/backends/raycing/data/f0_xop.dat -> build/lib/xrt/backends/raycing/data
    copying xrt/backends/raycing/data/Henke.Ef -> build/lib/xrt/backends/raycing/data
    copying xrt/backends/raycing/data/AtomicData.dat -> build/lib/xrt/backends/raycing/data
    copying xrt/backends/raycing/data/BrCo.Ef -> build/lib/xrt/backends/raycing/data
    copying xrt/backends/raycing/undulator.cl -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/diffract.cl -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/materials.cl -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/OE.cl -> build/lib/xrt/backends/raycing
    copying xrt/backends/raycing/xrt_complex.cl -> build/lib/xrt/backends/raycing
    creating build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/logo-xrtQt.png -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/xrQt1.ico -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/index.txt -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/GPU4.png -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/home.png -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/pythonscriptsave.png -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/run.png -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/pythonscriptsaveas.png -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/filesaveas.png -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/pythonscript.png -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/readme.png -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/filenew.png -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/fileopen.png -> build/lib/xrt/xrtQook/_icons
    copying xrt/xrtQook/_icons/filesave.png -> build/lib/xrt/xrtQook/_icons
    creating build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/filterFootprint2_I400mum_norm2.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/negative=1+fullNegative.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/ePos=1.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/invertColorMap=1_negative=1.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/filterFootprint2_I400mum.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/outline00.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/invertColorMap=0_negative=0.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/outline10.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/filterFootprint2_I400mum_norm1.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/qookSplashSmall_ani.gif -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/ePos=2.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/outline05.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/1-LEG_profile-default.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/qookTutor6.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/qookTutor7.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/qookTutor5.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/ePos=0.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/qookTutor4.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/qookTutor3.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/offset0.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/qookTutor1.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/offset5000.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/qookTutor2.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/invertColorMap=0_negative=1.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/1-LEG_profile-adhoc.png -> build/lib/xrt/xrtQook/_images
    copying xrt/xrtQook/_images/invertColorMap=1_negative=0.png -> build/lib/xrt/xrtQook/_images
    creating build/lib/xrt/xrtQook/xmls
    copying xrt/xrtQook/xmls/1crystal.xml -> build/lib/xrt/xrtQook/xmls
    copying xrt/xrtQook/xmls/guitestbl.xml -> build/lib/xrt/xrtQook/xmls
    copying xrt/xrtQook/xmls/4crystals.xml -> build/lib/xrt/xrtQook/xmls
    running build_scripts
    creating build/scripts-2.7
    error: file '/tmp/pip-build-oIA7E5/xrt/xrt\xrtQook\xrtQook.pyw' does not exist

    ----------------------------------------
Command "/reg/g/psdm/sw/conda/inst/miniconda2-dev-rhel7/envs/xrt/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-oIA7E5/xrt/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-mDgywh-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-oIA7E5/xrt/
(xrt) (psreldev) psel701: /reg/g/psdm/sw/conda/manage $ 

Low intensity in reflection mode

I am able to measure a Bragg peak of a powder, in reflection mode. But the reflected intensity is very low. Using Glow I realized that the transmitted beam through the sample is much brighter. Since I only detect the reflected beam I lose a lot of photons (size of the receiving slit: 10 x 0.8). I varied the thickness of the sample but this did not help.
The parameter 'geom' (which belongs to the properties of powder) is set to 'Bragg reflected'. I use the 'OE' - optical element to implement the powder. Nrays and number of repetitions were increased as far as possible (Nrays: 4 10^7, repeats: 20. Intensity of the Bragg peak: 25). Is there a way to increase the reflected intensity?

undefined symbol: mem_fence

Recently I found your software and wanted to give it a try to model some powder diffraction experiments. I already was able to model my instrument but now I have troubles with the powder sample.

Whe I run the xrd example file I get the following error in the gui:

/usr/lib/python3/dist-packages/pyopencl/cffi_cl.py:1466: CompilerWarning: Built kernel retrieved from cache. Original from-source build had warnings:
Build on <pyopencl.Device 'pthread-Intel(R) Xeon(R) CPU E3-1225 V2 @ 3.20GHz' on 'Portable Computing Language' at 0x55f51b58de30> succeeded, but said:

warning: /home/----/.cache/pocl/kcache/temp_N50SFB.cl:30:5: implicit declaration of function 'mem_fence' is invalid in C99

 warn(text, CompilerWarning)
OpenCL: bulding None ...
OpenCL: found 1 CPU
OpenCL: found none GPU
OpenCL: found none other accelerator
OpenCL for None: Autoselected device 0: pthread-Intel(R) Xeon(R) CPU E3-1225 V2 @ 3.20GHz
precisionOpenCL = float64
OpenCL: bulding None ...
OpenCL: found 1 CPU
OpenCL: found none GPU
OpenCL: found none other accelerator
OpenCL for None: Autoselected device 0: pthread-Intel(R) Xeon(R) CPU E3-1225 V2 @ 3.20GHz
precisionOpenCL = float64
Rays generation
/usr/bin/python3: symbol lookup error: /home/----/.cache/pocl/kcache/GI/ONBCCOFNMACGDHFMINNJLNIIMDMLHIJIFIAEH/undulator/3128-1-1/undulator.so: undefined symbol: mem_fence'

I'm working on a Debian stretch system.

Do you have any hints how to solve this problem?

Thanks
Armin

Variations in d-space

I'm interested in simulating the effect of thermal gradient in a crystal. What I have in mind is to control manually the variations of the d-spacing as a function of the local xyz OE coordinates.

I know how to alter the shape of the OE but I have not been able to find a way to change the d-spacing of the material itself. Do you think this is possible?

how to calculate the flux/s vs. Energy quantitatively

Good morning.
I successfully propagated the beam through a DCM and through a DMM by using the examples you provide on your website.
I know how to extract the data from the pickle file that corresponds to the picture below.
How can I quantify the flux (ph/s) vs. energy?

bm__DMMbeamGlobal01-1
Thank you for the help.
Angelica

Remove residual problems

In xrtQook gui, after removing a renamed "screen" by right click menu and running again, there occurs an error as follows:

Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Anaconda2\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "C:\Anaconda2\lib\site-packages\xrt\multipro.py", line 275, in run
raycing_output = raycing.run.run_process(self.card.beamLine)
File "D:/OneDrive/Codes/XRT/test/Beamline/NanoProbe/StepByStep.py", line 153, in run_process
'Screen_tmp1_BeamLocal': Screen_tmp1_BeamLocal}
NameError: global name 'Screen_tmp1_BeamLocal' is not defined

Then I checked the ".xml" file and found that the "Screen_tmp1_BeamLocal" still existed under . After deleting that line, the program runs properly.

xrtGlow fails to load a new xml after working with a previous one

Load BioXAS_Main.xml, put the virtual screen, close xrtGlow, load another xml.

QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined
Traceback (most recent call last):
File "....\xrt\gui\xrtQook_init.py", line 3366, in blRunGlow
self.blViewer.updateOEsList(self.rayPath)
File "....\xrt\gui\xrtGlow_init.py", line 687, in updateOEsList
self.changeColorAxis(None)
File "....\xrt\gui\xrtGlow_init.py", line 983, in changeColorAxis
self.customGlWidget.populateVerticesArray(self.segmentsModelRoot)
File "....\xrt\gui\xrtGlow_init.py", line 2116, in populateVerticesArray
self.populateVScreen()
File "....\xrt\gui\xrtGlow_init_.py", line 3655, in populateVScreen
vColorArray <= self.selColorMax,
TypeError: '<=' not supported between instances of 'float' and 'NoneType'

quantitative estimation of the flux

Good morning.

I have followed your suggestions and the provided examples to save and extract the data from the pickle files.

I would like to check with you the position of the normalisation factors in the output pickle file.
I have saved the plot data by using the following afterScript() function:

def afterScript(plots):
    plot = plots[3]
    flux = [plot.intensity, plot.nRaysAll, plot.nRaysSeeded, plot.nRaysAccepted]
    
    
    pickleName = prefix + savename + '.pickle'
    with open(pickleName, 'wb') as f:
        pickle.dump((flux, plot.caxis.binEdges, plot.caxis.total1D), f,
                    protocol=2)
    f.close()

My output pickle file has three components and the component [0] contains the following four numbers:

 [5900.382245718354, 20000L, 2.2894147473149932e+23, 7500000]

I used 20000 rays so the second number provides the nRaysAll.
Could you confirm that the third number is the nRaysSeededI and the last number is the **nRaysSeeded
plot4
**?

Below I also attach the plot (whose data are saved in the pickle) and the result of my renormalisation.
quantitative_flux

position of renormalization factors in the output pickle file

Good morning.

I have followed your suggestions and the provided examples to save and extract the data from the pickle files.

I would like to check with you the position of the normalisation factors in the output pickle file.
I have saved the plot data by using the following afterScript() function:


def afterScript(plots):
    plot = plots[3]
    flux = [plot.intensity, plot.nRaysAll, plot.nRaysSeeded, plot.nRaysAccepted]
    
    
    pickleName = prefix + savename + '.pickle'
    with open(pickleName, 'wb') as f:
        pickle.dump((flux, plot.caxis.binEdges, plot.caxis.total1D), f,
                    protocol=2)
    f.close()

My output pickle file has three components and the component [0] contains the following four numbers:

[5900.382245718354, 20000L, 2.2894147473149932e+23, 7500000]

I used 20000 rays so the second number provides the nRaysAll.
Could you confirm that the third number is the nRaysSeededI and the last number is the nRaysSeeded?

Below I also send you the xrt plot whose data I saved in the pickle file and the renormalized flux.

plot4

quantitative_flux

Thank you in advance for your help.

Best Greetings, Angelica Cecilia

DCM monochromatised flux vs. energy

Good morning,
I would like to plot the monochromatic flux density after at the sample, after the beam passes through a DCM.
with this script I can do it for a single energy.


-- coding: utf-8 --

"""

author = "Konstantin Klementiev", "Roman Chernikov"
date = "2020-01-22"

Created with xrtQook

"""

import numpy as np
import sys
sys.path.append(r"/mnt/LSDF/anka-nc-cluster/home/ws/cc1372/.local/lib/python2.7/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.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

CVD = rmats.Material(
elements=r"C",
kind=r"plate",
rho=3.52,
name=r"Diamond plate")

Si111 = rmats.CrystalSi(
hkl=[1, 1, 1],
name=r"Si111")

def build_beamline():
P23_Main = raycing.BeamLine(
alignE=10000)

P23_Main.Undulator = rsources.Undulator(
    bl=P23_Main,
    name=r"P23",
    center=[0, 0, 0],
    eE=6.083,
    eSigmaX=156.1,
    eSigmaZ=6.9,
    eEpsilonX=1.2,
    eEpsilonZ=0.012,
    betaX=20.1,
    betaZ=3.97,
    distE=r"eV",
    eMin=4855,
    eMax=4866,
    nrays=10000,
    #xPrimeMax= 0.25,
    #zPrimeMax= 0.25,
    xPrimeMaxAutoReduce= False,
    zPrimeMaxAutoReduce = False,
    K=2.68,
    period=31.4,
    n=63)

P23_Main.FEMask = rapts.RectangularAperture(
    bl=P23_Main,
    name=r"Frontend Mask",
    center=[0, 40000, 0],
    opening=[-12, 12, -5, 5])

P23_Main.DiamondFilter = roes.Plate(
    bl=P23_Main,
    name=r"Diamond Filter",
    center=[0, 47600, 0],
    material=CVD,
    pitch=1.57079632679,
    limPhysX=[-5, 5],
    limOptX=[-5, 5],
    limPhysY=[-5, 5],
    limOptY=[-5, 5],
    t=0.05)

P23_Main.SSRL_DCM = roes.DCM(
    bl=P23_Main,
    name=r"SSRL channel cut DCM",
    center=[0, 57000, r"auto"],
    bragg=[4861.64],
    material=Si111,
    material2=Si111,
    fixedOffset=20)
     
P23_Main.SampleScreen = rscreens.Screen(
    bl=P23_Main,
    name=r"Sample",
    center=[0, 60000, r"auto"])

return P23_Main

def run_process(P23_Main):
UndulatorbeamGlobal01 = P23_Main.Undulator.shine()

FEMaskbeamLocal01 = P23_Main.FEMask.propagate(
    beam=UndulatorbeamGlobal01)

C_FilterbeamGlobal01, C_FilterbeamLocal101, CVDFilterAbsorbedPower = P23_Main.DiamondFilter.double_refract(
    beam=UndulatorbeamGlobal01,
    returnLocalAbsorbed=0)

SSRL_DCMbeamGlobal01, SSRL_DCMbeamLocal101, SSRL_DCMbeamLocal201 = P23_Main.SSRL_DCM.double_reflect(
    beam=C_FilterbeamGlobal01)

SampleScreenFootprint = P23_Main.SampleScreen.expose(
    beam=SSRL_DCMbeamGlobal01)

outDict = {
    'UndulatorbeamGlobal01': UndulatorbeamGlobal01,
    'FEMaskbeamLocal01': FEMaskbeamLocal01,
    'C_FilterbeamGlobal01': C_FilterbeamGlobal01,
    'C_FilterbeamLocal101': C_FilterbeamLocal101,
    'CVDFilterAbsorbedPower': CVDFilterAbsorbedPower,
    
    'SSRL_DCMbeamGlobal01': SSRL_DCMbeamGlobal01,
    'SSRL_DCMbeamLocal101': SSRL_DCMbeamLocal101,
    'SSRL_DCMbeamLocal201': SSRL_DCMbeamLocal201,
    
    'SampleScreenFootprint': SampleScreenFootprint}
return outDict

rrun.run_process = run_process

def define_plots():
plots = []

plot01 = xrtplot.XYCPlot(
    beam=r"UndulatorbeamGlobal01",
    xaxis=xrtplot.XYCAxis(
        label=r"x"),
    yaxis=xrtplot.XYCAxis(
        label=r"z"),
    caxis=xrtplot.XYCAxis(
        label=r"energy",
        unit=r"eV"),
    aspect=r"auto",
    title=r"01 - P23 undulator source",
    fluxFormatStr=r"%g")
plots.append(plot01)

plot02 = xrtplot.XYCPlot(
    beam=r"UndulatorbeamGlobal01",
    xaxis=xrtplot.XYCAxis(
        label=r"x",limits=[-1, 1]),
    yaxis=xrtplot.XYCAxis(
        label=r"z",limits=[-0.2, 0.2]),
   caxis=xrtplot.XYCAxis(
        label=r"energy",
        unit=r"eV"),
   title=r"02 - P23 Undulator total power",
   fluxKind='power')
plots.append(plot02)

plot03 = xrtplot.XYCPlot(
    beam=r"CVDFilterAbsorbedPower",
    xaxis=xrtplot.XYCAxis(
        label=r"x"),
    yaxis=xrtplot.XYCAxis(
        label=r"y"),
    caxis=xrtplot.XYCAxis(
        label=r"energy",
        unit=r"eV"),
    title=r"03 - CVD Filter Absorbed Power",
    fluxKind=r"power",
    fluxFormatStr=r"%g")
plots.append(plot03)
     
plot05 = xrtplot.XYCPlot(
    beam=r"SampleScreenFootprint",
    xaxis=xrtplot.XYCAxis(
        label=r"x"),
    yaxis=xrtplot.XYCAxis(
        label=r"z"),
    caxis=xrtplot.XYCAxis(
        label=r"energy",
        unit=r"eV",
        limits=[4820,4890],
        offset=0),
    title=r"05 - Sample",
    fluxFormatStr=r"%g")
plots.append(plot05)
return plots

def main():
P23_Main = build_beamline()
E0 = 0.5 * (P23_Main.Undulator.eMin +
P23_Main.Undulator.eMax)
P23_Main.alignE=E0
plots = define_plots()
xrtrun.run_ray_tracing(
plots=plots,
repeats=20,
backend=r"raycing",
beamLine=P23_Main)

if name == 'main':
main()

**How can I get the flux result vs. a larger energy range?
thank you in advance for your help.

Best Greetings, Angelica**

xrt/gui/commons/myspyder.py fails if spyder is not installed + setup.py minor mods

Hello,

I found xrt/gui/commons/myspyder.py fails if spyder is not installed.

In particular here:

try:
    from spyder.config.base import get_module_source_path
except ImportError:
    from spyderlib.config.base import get_module_source_path

Probably the best is to make a dependency of xrt on spyder officially in the documentation.

I also had to change a couple of things in setup.py in order to install from source the last github version. Here what I modified:

    packages=['xrt', 'xrt.backends', 'xrt.backends.raycing',\
              'xrt.gui.commons', 'xrt.gui.xrtQook', 'xrt.gui.xrtGlow'],
    package_data={
        'xrt.backends.raycing': [os.path.join('data', '*.*'), '*.cl'],
        'xrt': ['*.cl, *.ico'],
        'xrt.gui.xrtQook': [os.path.join('_icons', '*.*'),
                            os.path.join('_images', '*.*'),
                            os.path.join('xmls', '*.*')]},
    scripts=[os.path.join('xrt', 'gui', 'xrtQookStart.pyw')],

When DoubleParaboloidLens is used, repeats seems obselete

I tried to use DoubleParaboloidLens, and realized that the script does only one of the 100 repeats. While the screen before the lens stack keeps adding more photons, the one after the lens stack stops after the first one. See below for comparison:

image

image

Bug report

For the label "Materials" of the program xrtQook, when changing any item of an already used material, the program will crash.
For example, I used CrystalSi as my DCM material. Each time I changed the "name" as shown below, the program crashed.

image

The error of using the backend of shadow operate the data from the shadow

I am sorry to disturbe you. I am interested to using the xrt operate using the backend of shadow.The problem is when I operate the code (below the paragraph) in Python3.7 without opencl but opengl,there is a error I can't solve :

(py37) D:\shadow>python 00_simple.py
('not readable',) , ignored...
Exception in Tkinter callback
Traceback (most recent call last):
  File "D:\anaconda\envs\py37\lib\tkinter\__init__.py", line 1702, in __call__
    return self.func(*args)
  File "D:\anaconda\envs\py37\lib\tkinter\__init__.py", line 746, in callit
    func(*args)
  File "D:\anaconda\envs\py37\lib\site-packages\matplotlib\backends\_backend_tk.py", line 118, in _on_timer
    TimerBase._on_timer(self)
  File "D:\anaconda\envs\py37\lib\site-packages\matplotlib\backend_bases.py", line 1194, in _on_timer
    ret = func(*args, **kwargs)
  File "D:\anaconda\envs\py37\lib\site-packages\xrt\plotter.py", line 1093, in timer_callback
    runner.dispatch_jobs()
  File "D:\anaconda\envs\py37\lib\site-packages\xrt\runner.py", line 188, in dispatch_jobs
    plot.plot_plots()
  File "D:\anaconda\envs\py37\lib\site-packages\xrt\plotter.py", line 1606, in plot_plots
    intensityStr = r'$I = $' + fluxFormatStr
UnboundLocalError: local variable 'fluxFormatStr' referenced before assignment

the running code is

import xrt.runner as xrtr

import xrt.plotter as xrtp

plot1 = xrtp.XYCPlot('star.01')

xrtr.run_ray_tracing(plot1, repeats=40, updateEvery=2, backend='shadow')

the tmp0 at the same folder of the code

In this codes, the slope error is generated by the other fille and the data is loaded by the _read_data(self)_ function, the error is added by modified the _local_z1(self, x, y)_ and _local_n1(self, x, y)_ functions.

In this codes, the slope error is generated by the other fille and the data is loaded by the read_data(self) function, the error is added by modified the local_z1(self, x, y) and local_n1(self, x, y) functions.

Hello,
Where should I look at? Which part of the code is yours? Where in the code "the slope error is R=100um"? What is "CRL’s R" and where in the code you use it?

Originally posted by @goxrt in #40 (comment)

cffi error when running xrtQoot

Dear Sir or Madam,
I am a novice to XRT. Recently, I installed the xrt-master version to learn the software. When I tried to run some examples, an error related to "cffi" always occurred (detailed information at the end). I checked the python packages and the cffi package was indeed installed. As following:

Requirement already satisfied: cffi==1.11.2 from file:///D:/Downloads/GoogleDownloads/cffi-1.11.2-cp27-cp27m-win_amd64.whl in c:\python27\lib\site-packages
Requirement already satisfied: pycparser in c:\python27\lib\site-packages (from cffi==1.11.2)

How could I solve the problem? Thank you.

detailed information:
error.txt

TypeError: not all arguments converted during string formatting

➤ pip install xrt
Collecting xrt
Downloading xrt-1.2.0.zip (6.4MB)
100% |████████████████████████████████| 6.4MB 13kB/s
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/xrt.egg-info
writing dependency_links to pip-egg-info/xrt.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/xrt.egg-info/top_level.txt
writing pip-egg-info/xrt.egg-info/PKG-INFO
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-4vyio9ge/xrt/setup.py", line 155, in
'Topic :: Scientific/Engineering :: Visualization'],
File "/home/inat/APP/anaconda3/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/inat/APP/anaconda3/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/home/inat/APP/anaconda3/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/inat/APP/anaconda3/lib/python3.5/site-packages/setuptools-23.0.0-py3.5.egg/setuptools/command/egg_info.py", line 186, in run
File "/home/inat/APP/anaconda3/lib/python3.5/site-packages/setuptools-23.0.0-py3.5.egg/setuptools/command/egg_info.py", line 397, in write_pkg_info
File "/home/inat/APP/anaconda3/lib/python3.5/distutils/dist.py", line 1107, in write_pkg_info
self.write_pkg_file(pkg_info)
File "/home/inat/APP/anaconda3/lib/python3.5/distutils/dist.py", line 1122, in write_pkg_file
file.write('Author: %s\n' % self.get_contact())
TypeError: not all arguments converted during string formatting

Arbitrary orientation of apertures

Please add arbitrary orientation of beamline apertures. As of now, apertures can lie only in vertical plane. It is inconvenient in case of not horizontal dispersion planes.

Mosaic crystals

Hello,
I was curious if there is an easy way to implement mosaic crystals. It seems like it needs to be a version of the Power material, with a limited distribution of crystal orientations.

Perhaps the easiest way would be to make a new class from OE and define local_n to return the atomic plane normal directions with a random spread around the nominal direction.

function mL.get_Bragg_angle()

Good afternoon,
I used the function mL.get_Bragg_angle() to calculate the multilayer Bragg angle that corresponds to 8440 eV in the example "Scanning of Double Multilayer Monochromator" available in the gallery of plots and scripts 2. X-ray optics available on adthedocs.io/gallery2.html (the graph is pasted hereafter).
The calculated angle is of 0.9352 deg and it is different from the value depicted in the graph of 0.999 deg, despite the multilayer is the same (same materials, same thickness, same substrate).
Did you apply the refraction correction to the calculated angle to get 0.999deg?

thank you for the help in advance!
Angelica

beamGlobal vs screen (plotting)

Probably not an issue for most, but I just wanted to get it on record to avoid future confusions.
I am currently checking various optical elements and their effects on pulse duration. Instead of analytically calculating, I wanted to simulate it. The way to do that is to check the path differences of the rays. The "oebeamGlobal" plot of an asymmetrically cut Bragg crystal gives less than half the value of a "screenbeamLocal" plot of a screen positioned at the same place of the optical element. The beam size, energy, etc. plots are identical, but not the path. Is that a feature I am missing or a bug?

problem relates to the unit of the intensity

Hi, I am using the following code to save plot, and analyze the intensity profile, refering to the example. I wonder if I save the data using "Ixy = plot.total2D", what kind of the unit is used? I tried to compute the total flux from the data, but got wrong reslut, however, the saved picture displayed right value for flux. Thanks.

for ic, dq in enumerate(dFocus):         
    plot = xrtp.XYCPlot(
        'beamFSMExp_{0:02d}'.format(ic), (1,), aspect='auto',
        xaxis=xrtp.XYCAxis(r'$x$', u'µm', bins=xbins, ppb=xppb),
        yaxis=xrtp.XYCAxis(r'$z$', u'µm', bins=zbins, ppb=zppb),
        fluxKind='s', title='{0}-Is_4s{1:02d}'.format(prefix,ic))
    plot.xaxis.limits = [imageExtent[0], imageExtent[1]]
    plot.yaxis.limits = [imageExtent[2], imageExtent[3]]
    plot.textPanel = plot.fig.text(
        0.88, 0.8, u'f{0:+.0f} mm'.format(dq),
        transform=plot.fig.transFigure, size=12, color='r', ha='center')
    plots.append(plot)

Adding slope errors to CRLs (double paraboloid lens)

Hi, I have tried to add slope errors to CRLs, and assumed every surface had the same slope error. The slope error is added according to mirrors (see the following codes). In order to know whether it works right, I add the slope error to change the CRL’s R to another value (for example, R of CRLs is 100um, the slope error is R=100um, and then the final R will be 50um). But unfortunately, the result is absolutely wrong.
#------------------------------------------------------------#
class DoubleParaboloidLens_Distorted(roe.DoubleParaboloidLens):

hiddenMethods = roe.DoubleParaboloidLens.hiddenMethods + ['double_refract']  # ?

def __init__(self, *args, **kwargs):
    kwargs = self.__pop_kwargs(**kwargs)
    roe.DoubleParaboloidLens.__init__(self, *args, **kwargs)
    self.read_data()

def __pop_kwargs(self, **kwargs):
    self.fname1 = kwargs.pop('fname1')  # fname1 and fname2 is the ANSYS data file, the mirror surface profile.
    self.fname2 = kwargs.pop('fname2')
    self.fname3 = kwargs.pop('fname3')
    self.get_distorted_surface = kwargs.pop('get_distorted_surface')
    return kwargs

def assign_auto_material_kind(self, material):
    material.kind = 'lens'

def read_data(self):
    if self.get_distorted_surface is None:
        return
    self.warpX, self.warpY, self.warpZ = Read_distorted_surface(self.fname1, self.fname2, self.fname3)
    self.warpNX, self.warpNY = len(self.warpX), len(self.warpY)
    self.limPhysX0 = np.min(self.warpX), np.max(self.warpX)
    self.limPhysY0 = np.min(self.warpY), np.max(self.warpY)
    self.get_surface_limits()
    self.warpA, self.warpB = np.gradient(self.warpZ)
    dx = self.warpX[1] - self.warpX[0]
    dy = self.warpY[1] - self.warpY[0]
    self.warpA = np.arctan(self.warpA / dx)
    self.warpB = np.arctan(self.warpB / dy)

    self.warpSplineZ = ndimage.spline_filter(self.warpZ)
    self.warpSplineA = ndimage.spline_filter(self.warpA)
    self.warpSplineB = ndimage.spline_filter(self.warpB)

def local_z1(self, x, y):
    """Determines the normal vector of OE at (x, y) position."""
    z = (x ** 2 + y ** 2) / (4 * self.focus)
    coords = np.array(
        [(x - self.limPhysX0[0]) /
         (self.limPhysX0[1] - self.limPhysX0[0]) * (self.warpNX - 1),
         (y - self.limPhysY[0]) /
         (self.limPhysY0[1] - self.limPhysY0[0]) * (self.warpNY - 1)])

    z = z + ndimage.map_coordinates(self.warpSplineZ, coords, prefilter=True)
    if self.zmax is not None:
        z[z > self.zmax] = self.zmax
    return z

def local_z2(self, x, y):
    return self.local_z1(x, y)


def local_n1(self, x, y):
    Ax = -self.warpSplineA
    By = -self.warpSplineB
    coords = np.array(
        [(x - self.limPhysX0[0]) /
         (self.limPhysX0[1] - self.limPhysX0[0]) * (self.warpNX - 1),
         (y - self.limPhysY0[0]) /
         (self.limPhysY0[1] - self.limPhysY0[0]) * (self.warpNY - 1)])
    a0 = ndimage.map_coordinates(Ax, coords, prefilter=True)
    b0 = ndimage.map_coordinates(By, coords, prefilter=True)
    if self.zmax is not None:
        z = (x ** 2 + y ** 2) / (4 * self.focus)
        z = z + ndimage.map_coordinates(self.warpSplineZ, coords, prefilter=True)

        a = -x / (2 * self.focus) + a0  # -dz/dx  
        b = -y / (2 * self.focus) + b0  # -dz/dy  

        if isinstance(a, np.ndarray):
            a[z > self.zmax] = 0
        if isinstance(b, np.ndarray):
            b[z > self.zmax] = 0

        c = np.ones_like(x)
        norm = (a ** 2 + b ** 2 + 1) ** 0.5
    return [a / norm, b / norm, c / norm]

def local_n2(self, x, y):
    return self.local_n1(x, y)

coherence fraction calculation

In order to evaluate the coherence of the source, two methods are used. The first one is to calculate by the euqation (λ/2π)^2/(ε_V * ε_H). And the other one is by the mode decomposition method and = β0/Σβi, which is generated by the example "test_coherent_fraction_stack.py". However, it is found that these two values are very different:
(1) (λ/2π)^2/(ε_V*ε_H) = (19.7pm. rad)^2/(44.9um * 22.807urad * 6.272um * 5.014urad)= 1.2%
these data are also computed by the XRT.
(2) β0/Σβi = 21% for mode -decomposition method.
this difference also appears when I repeat the simulations in the paper “Coherence properties of the high-energy fourth-generation X-ray synchrotron sources”, which also use the XRT to calculate the coherent fraction.
I wonder if I have make misunderstanding on these calculations.

np.float128 error in xrtGlow

I'm running Windows 10, Anaconda 5.1.0, and the xrt master from github. I installed pyopencl and pyopengl from Gohlke. When I run xrtQookStart, open the lens3.xml example, and start xrtGlow, I get the following error:

Traceback (most recent call last):

  File "..\..\xrt\gui\xrtGlow\__init__.py", line 2191, in paintGL
    pModel = np.array(gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX))[:-1, :-1]

  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\python2\lib\site-packages\OpenGL\latebind.py", line 45, in __call__
    return self._finalCall( *args, **named )

  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\python2\lib\site-packages\OpenGL\wrapper.py", line 664, in wrapperCall
    cArgs = tuple(calculate_cArgs( pyArgs ))

  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\python2\lib\site-packages\OpenGL\wrapper.py", line 467, in calculate_cArgs
    yield converter( pyArgs, index, self )

  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\python2\lib\site-packages\OpenGL\converters.py", line 251, in __call__
    return super( SizedOutputOrInput,self ).__call__( pyArgs, index, baseOperation )

  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\python2\lib\site-packages\OpenGL\converters.py", line 196, in __call__
    return self.arrayType.zeros( self.getSize(pyArgs) )

  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\python2\lib\site-packages\OpenGL\arrays\arraydatatype.py", line 177, in zeros
    return cls.returnHandler().zeros( dims, typeCode or cls.typeConstant )

  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\python2\lib\site-packages\OpenGL\arrays\arraydatatype.py", line 80, in get_output_handler
    self.output_handler = self.handler_by_plugin_name( preferred )

  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\python2\lib\site-packages\OpenGL\arrays\arraydatatype.py", line 67, in handler_by_plugin_name
    return plugin.load()

  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\python2\lib\site-packages\OpenGL\plugins.py", line 16, in load
    return importByName( self.import_path )

  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\python2\lib\site-packages\OpenGL\plugins.py", line 38, in importByName
    module = __import__( ".".join(moduleName), {}, {}, moduleName)

  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\python2\lib\site-packages\OpenGL\arrays\numpymodule.py", line 68, in <module>
    class NumpyHandler( formathandler.FormatHandler ):

  File "C:\Users\user\AppData\Local\Continuum\Anaconda3\envs\python2\lib\site-packages\OpenGL\arrays\numpymodule.py", line 93, in NumpyHandler
    numpy.float128,

AttributeError: ("'module' object has no attribute 'float128'", 'Failure in cConverter <OpenGL.converters.SizedOutputOrInput object at 0x00000000118315C8>', (GL_MODELVIEW_MATRIX, <object object at 0x00000000116F2780>), 1, <OpenGL.platform.baseplatform.glGetDoublev object at 0x0000000011A0FE08>)

Then I only see a black screen in the xrtGlow window, and keep getting these float128 errors when I enable optical elements.

I tried Python 3.6 64-bit, Python 2.7 64-bit, and Python 2.7 32-bit versions of Anaconda with the most recent matching versions of pyopencl and pyopengl from Gohlke, and got the same error. Of course if I use the versions in conda-forge, I get a NullFunctionError: Attempt to call an undefined function glutBitmapCharacter, check for bool(glutBitmapCharacter) before calling error similar to what is mentioned in #14.

Have no access to plots.flux or plots.power

If I use plots.flux or plots.power in my generator code flux or power values are always zero.
Only if I use plots.intensity it seems to work.
How intensity is defined? Is it a flux density?

multilayer energy peak

Good afternoon,
I used the function mL.get_Bragg_angle() to calculate the multilayer Bragg angle that corresponds to 8440 eV in the example "Scanning of Double Multilayer Monochromator" available in the gallery of plots and scripts 2. X-ray optics available on adthedocs.io/gallery2.html (the graph is pasted hereafter).
The calculated angle is of 0.9352 deg and it is different from the value depicted in the graph of 0.999 deg, despite the multilayer is the same (same materials, same thickness, same substrate).
Did you apply the refraction correction to the calculated angle to get 0.999deg?

example_multilayer

thank you for the help in advance!
Angelica

wave caculation and coherence analysis issue

Hi, I am now trying using the coherence analysis. The results seem to be different from the theoretical. In my simulaiton, I made following setting:

(1) uniformRayDensity = True
filamentBeam = True
(2) The wave generated by the source are directly projected on the screen:
waveOnScreen = beamLine.fsmExp.prepare_wave(
beamLine.source, beamLine.fsmExpX, beamLine.fsmExpZ)
beamSource = beamLine.source.shine(wave = waveOnScreen, fixedEnergy=E0, withAmplitudes=True)
outDict['beamFSMExp_{0:02d}'.format(ic)] = waveOnScreen
(3) The field is computed following the exmaple of the XRT.

I don’t understand how the “Es = complexPlotPCAs.field3D” works, I tried to find this code in the source file but unsuccessfulll. Is the Es from the beamLine.source.shine for each repeat?
In addition, for the wave simulation, I really don’t catch the difference between the filamentBeam =true and false. Are they same if we have a very many repeats. Thanks

DCM monochromatic flux vs. energy

Good morning,
I would like to plot the monochromatic flux vs. Energy at the sample position, after the beam passes through a DCM.
with this script I can do it for a single energy, extracting the flux from the histogram.
How can I do in a larger energy range?
Many thanks, Angelica


# -*- coding: utf-8 -*-
"""

__author__ = "Konstantin Klementiev", "Roman Chernikov"
__date__ = "2020-01-22"

Created with xrtQook


"""

import numpy as np
import sys
sys.path.append(r"/mnt/LSDF/anka-nc-cluster/home/ws/cc1372/.local/lib/python2.7/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.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

CVD = rmats.Material(
    elements=r"C",
    kind=r"plate",
    rho=3.52,
    name=r"Diamond plate")

Si111 = rmats.CrystalSi(
    hkl=[1, 1, 1],
    name=r"Si111")

def build_beamline():
    P23_Main = raycing.BeamLine(
        alignE=10000)
 
    P23_Main.Undulator = rsources.Undulator(
        bl=P23_Main,
        name=r"P23",
        center=[0, 0, 0],
        eE=6.083,
        eSigmaX=156.1,
        eSigmaZ=6.9,
        eEpsilonX=1.2,
        eEpsilonZ=0.012,
        betaX=20.1,
        betaZ=3.97,
        distE=r"eV",
        eMin=4855,
        eMax=4866,
        nrays=10000,
        #xPrimeMax= 0.25,
        #zPrimeMax= 0.25,
        xPrimeMaxAutoReduce= False,
        zPrimeMaxAutoReduce = False,
        K=2.68,
        period=31.4,
        n=63)
  
    P23_Main.FEMask = rapts.RectangularAperture(
        bl=P23_Main,
        name=r"Frontend Mask",
        center=[0, 40000, 0],
        opening=[-12, 12, -5, 5])

    P23_Main.DiamondFilter = roes.Plate(
        bl=P23_Main,
        name=r"Diamond Filter",
        center=[0, 47600, 0],
        material=CVD,
        pitch=1.57079632679,
        limPhysX=[-5, 5],
        limOptX=[-5, 5],
        limPhysY=[-5, 5],
        limOptY=[-5, 5],
        t=0.05)

    P23_Main.SSRL_DCM = roes.DCM(
        bl=P23_Main,
        name=r"SSRL channel cut DCM",
        center=[0, 57000, r"auto"],
        bragg=[4861.64],
        material=Si111,
        material2=Si111,
        fixedOffset=20)
         
    P23_Main.SampleScreen = rscreens.Screen(
        bl=P23_Main,
        name=r"Sample",
        center=[0, 60000, r"auto"])

    return P23_Main

def run_process(P23_Main):
    UndulatorbeamGlobal01 = P23_Main.Undulator.shine()

    FEMaskbeamLocal01 = P23_Main.FEMask.propagate(
        beam=UndulatorbeamGlobal01)

    C_FilterbeamGlobal01, C_FilterbeamLocal101, CVDFilterAbsorbedPower = P23_Main.DiamondFilter.double_refract(
        beam=UndulatorbeamGlobal01,
        returnLocalAbsorbed=0)

    SSRL_DCMbeamGlobal01, SSRL_DCMbeamLocal101, SSRL_DCMbeamLocal201 = P23_Main.SSRL_DCM.double_reflect(
        beam=C_FilterbeamGlobal01)

    SampleScreenFootprint = P23_Main.SampleScreen.expose(
        beam=SSRL_DCMbeamGlobal01)

    outDict = {
        'UndulatorbeamGlobal01': UndulatorbeamGlobal01,
        'FEMaskbeamLocal01': FEMaskbeamLocal01,
        'C_FilterbeamGlobal01': C_FilterbeamGlobal01,
        'C_FilterbeamLocal101': C_FilterbeamLocal101,
        'CVDFilterAbsorbedPower': CVDFilterAbsorbedPower,
        
        'SSRL_DCMbeamGlobal01': SSRL_DCMbeamGlobal01,
        'SSRL_DCMbeamLocal101': SSRL_DCMbeamLocal101,
        'SSRL_DCMbeamLocal201': SSRL_DCMbeamLocal201,
        
        'SampleScreenFootprint': SampleScreenFootprint}
    return outDict

rrun.run_process = run_process


def define_plots():
    plots = []

    plot01 = xrtplot.XYCPlot(
        beam=r"UndulatorbeamGlobal01",
        xaxis=xrtplot.XYCAxis(
            label=r"x"),
        yaxis=xrtplot.XYCAxis(
            label=r"z"),
        caxis=xrtplot.XYCAxis(
            label=r"energy",
            unit=r"eV"),
        aspect=r"auto",
        title=r"01 - P23 undulator source",
        fluxFormatStr=r"%g")
    plots.append(plot01)
    
    plot02 = xrtplot.XYCPlot(
        beam=r"UndulatorbeamGlobal01",
        xaxis=xrtplot.XYCAxis(
            label=r"x",limits=[-1, 1]),
        yaxis=xrtplot.XYCAxis(
            label=r"z",limits=[-0.2, 0.2]),
       caxis=xrtplot.XYCAxis(
            label=r"energy",
            unit=r"eV"),
       title=r"02 - P23 Undulator total power",
       fluxKind='power')
    plots.append(plot02)
    
    plot03 = xrtplot.XYCPlot(
        beam=r"CVDFilterAbsorbedPower",
        xaxis=xrtplot.XYCAxis(
            label=r"x"),
        yaxis=xrtplot.XYCAxis(
            label=r"y"),
        caxis=xrtplot.XYCAxis(
            label=r"energy",
            unit=r"eV"),
        title=r"03 - CVD Filter Absorbed Power",
        fluxKind=r"power",
        fluxFormatStr=r"%g")
    plots.append(plot03)
         
    plot05 = xrtplot.XYCPlot(
        beam=r"SampleScreenFootprint",
        xaxis=xrtplot.XYCAxis(
            label=r"x"),
        yaxis=xrtplot.XYCAxis(
            label=r"z"),
        caxis=xrtplot.XYCAxis(
            label=r"energy",
            unit=r"eV",
            limits=[4820,4890],
            offset=0),
        title=r"05 - Sample",
        fluxFormatStr=r"%g")
    plots.append(plot05)
    return plots


def main():
    P23_Main = build_beamline()
    E0 = 0.5 * (P23_Main.Undulator.eMin +
                P23_Main.Undulator.eMax)
    P23_Main.alignE=E0
    plots = define_plots()
    xrtrun.run_ray_tracing(
        plots=plots,
        repeats=20,
        backend=r"raycing",
        beamLine=P23_Main)


if __name__ == '__main__':
    main()

harmonic rejection caculation in ray tracing

Hi, I want to evaluate the harmonic rejection ratio in the ray tracing program. In this calculation, high harmonic photons are generated by the undulator, and the DCM works at low energy (for bragg-angle). However, I found the rm.CrystalSi(hkl=(1, 1, 1)) in DCM can not give the reflection for the high harmonic photons. I wonder if it is possible to perform this evaluation in this way. Thanks!
regards
Fugui

[Plans] Use external crystal diffraction profile

Hello,

This is not a feature request, just for a better understanding of your future plans. I see that you will include TT theory for bent crystals:

dynamical theory of x-ray diffraction for bent crystals – TT theory

This is a very good idea. If possible, I would suggest to let the user have the possibility to input the crystal reflectivity as an array that could be in the form (\DeltaTheta, Reflectivity_sigma, Reflectivity_pi). Then the ray tracer engine would simply rescale each ray intensity to the reflectivity.

In fact, one could obtain the diffraction profile using, for example,

  • CRYSTAL: multilamellar method works nicely for the perpendicular strain field;
  • pytakagitaupin: 1D Takagi-Taupin for the vertical strain field, plus analytical for the radial one... still in early stage of development.

Thanks for your comments,
Mauro

Model of the distortion of the DCM

The distortion of the DCM will cause the change of the resolution and flux of the transimitted light. I wonder if the XRT can perform this analysis now. thanks

Energy distribution

I would like to define a source with discrete energies and associated relative probabilities. Would it be correct to add a new energy distribution in 'xrt.backends.raycing.sources.make_energy' given by a function 'random.choices(energies, probabilities)'?

Qt platform

Just now, I installed the newest XRT version on a my new computer( Windows 10 system, without Qt). When I tried xrtQookStart.pyw, it reported an error : This application failed to start because it could not find or load the Qt platform plugin "windows" in "". I checked the problem on the website. It seems that the problem can be solved by packaging the "..../Qt/..../plugins/platforms" folder with XRT. Does it correct, or should I have to install Qt? Thank you.

Multiple order reflections

Dear developers,

Is there any way to calculate several order reflections in one simulation run?
Thank you in advance.

flux density calculation issue

Hi, I am now using "I0, l1, l2, l3 = source.intensities_on_mesh(energy, theta, psi)" to calculate the spectrum of the flux density. It seems there is oscillation for high harmonic peak as shown in the bottom picture, which is not shown by SPECTRA. Would you please help me check it? The code is simple and is given below:
source = rs.Undulator(
eE = 6.0, eI = 0.2, eEspread = 0.00111,
eEpsilonX = 0.02755, eEpsilonZ = 0.002755,
betaX = 10.12, betaZ = 9.64, distE='BW', eN=51,
K = 0.55, period=35,n=142)
energy = np.linspace(16000, 18000, 1000)
theta = np.linspace(-1, 1, 21) * 10e-6 # 20 µrad opening
psi = np.linspace(-1, 1, 21) * 10e-6 # 20 µrad opening
dtheta, dpsi = theta[1] - theta[0], psi[1] - psi[0]
tmpKy = source.Ky
source.Ky = 2.8759
source.reset()
print(source.E1)
print(source.Ky)
I0, l1, l2, l3 = source.intensities_on_mesh(energy, theta, psi)
flux = I0.sum(axis=(1, 2)) * dtheta * dpsi
flux_density = I0[:,10, 10]*1e-6

XRT:
Flux and Flux density
SPECTRA:
SPECTRA

EllipticalMirrorParam(OE) parameters setting

Hi,
I want to make sure if we deal with the EllipticalMirrorParam(OE) properly.
We've found that if the main optical axis has a deflection angle, e.g.beam reflected from one single crystal, the next EllipticalMirrorParm's pitch angle should not be set as the same as the plane mirror or toroidal mirror. Instead, pitch angle of EllipticalMirrorParm was set to be the "desired" pitch to the deflected main optical axis. In addiation, we have to set extraPitch to rotate the mirror local coordinate system to be parallel to the deflected main optical axis.
We guess that it may be related to the fact that pitch parameter in EllipticalMirrorParam(OE) play an important role in other auxiliary parameters calculation.
May I ask is there anything wrong with our approach?

Laterally graded multilayer

Hi guys,

I'm trying to implement a laterally graded multilayer. What I have been doing so far is to create a subclass of Multlayer and redefined get_t_thickness(self, x, y, iPair) and get_b_thickness(self, x, y, iPair). See below:

`class LMultilayer(rmats.Multilayer):

def __init__(self, *args, **kwargs):
	self.tError = kwargs.pop('tError', 10)  # R meridional
	rmats.Multilayer.__init__(self, *args, **kwargs)

def get_t_thickness(self, x, y, iPair) :
	f = np.random.normal(size=len(x))*self.tError + 1 
	return self.dti[iPair] * f
	
def get_b_thickness(self, x, y, iPair):
	f = np.random.normal(size=len(x))*self.tError + 1 
	return self.dbi[iPair] * f `

I then go on and use the LMultilayer class but so far I'm not able to see any difference in reflected intensity despite creating variations in the d-spacing of each pairs.

Do you know what could be missing? Or alternatively could you provide a short example of laterally graded multilayer?

xrtGlow not starting (OpenGL error)

Hello,

I wanted to give a try to xrtGlow and I got the following OpenGL error when starting the 3D view from xrtQook. I have simply run the xrtQook tutorial.

Here my system (conda environment on a windows machine):

  • Windows-10
  • Python 3.6.3
  • Qt 5.6.2
  • PyQt5 5.6
  • pyopencl 2018.1.1
  • OpenGL 3.1.1a1
  • xrt 1.3.0beta (fetched from github today)

Here the trace:

(py36) C:\Users\rovezzi\local\xrt\xrt\gui>python xrtQookStart.pyw
Class crystalSi01 successfully initialized.
Class bendingMagnet01 successfully initialized.
Class oe01 successfully initialized.
Class screen01 successfully initialized.
Class crystalSi01 successfully initialized.
Class bendingMagnet01 successfully initialized.
Class oe01 successfully initialized.
Class screen01 successfully initialized.
25275 rays of 100000
50488 rays of 100000
75685 rays of 100000
100638 rays of 100000
OE1 pitch: 0.199049781904
Screen1 center: [0, 21000, 420.54685697964965]
Traceback (most recent call last):
  File "C:\Users\rovezzi\AppData\Local\conda\envs\py36\lib\site-packages\xrt\gui\xrtGlow\__init__.py", line 3285, in initializeGL
    gl.glutInit()
  File "C:\Users\rovezzi\AppData\Local\conda\envs\py36\lib\site-packages\OpenGL\GLUT\special.py", line 333, in glutInit
    _base_glutInit( ctypes.byref(count), holder )
  File "C:\Users\rovezzi\AppData\Local\conda\envs\py36\lib\site-packages\OpenGL\platform\baseplatform.py", line 407, in __call__
    self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling

I know nothing about OpenGL, so any help is welcome.

Thanks,
Mauro

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.