oasys-kit / shadow3 Goto Github PK
View Code? Open in Web Editor NEWOfficial repository for shadow3 (x-ray-tracer engine)
License: MIT License
Official repository for shadow3 (x-ray-tracer engine)
License: MIT License
F_POLAR=0 makes corrupted beam when running gen_source twice (or more times) in the same python session
In "Distances Summary" there is a warning:
Warning: SHADOW did not run, therefore autosetting angles are not consideredTotal deflection angle H = 0.000073 rad = 0.004 deg
Total deflection angle V = 0.000073 rad = 0.004 deg
I open an issue in shadow3
do it in python. Use macro_fresnelzoneplate.ws as template and test case
I have installed shadow3-18.5.30.tar.gz on anaconda python (anaconda version 1.7.2 python version 3.7.0) on redhat linux Entrerprise with gcc, g++ and gfortran 4.8.5-4 installed. during the of shadow 3 installation i need to install xraylib 4.0.0 and PyHamcrest-2.0.2.
Installation was successful but simple test program is not working
import os
import Shadow
beam = Shadow.Beam()
src = Shadow.Source()
beam.genSource(src)
oe1 = Shadow.OE()
beam.traceOE(oe1,1)
In the last line i got error
At line 416 of file src/fortran/stringio.f90
Internal Error: get_unit(): Bad internal unit KIND
Can not find solution from online resources
882530f is causing ShadowToolsPrivate.py to no longer run on Python 2. The print usage needs this line at the top of the file put back in:
from __future__ import print_function
Hello,
I am trying to install ShadowOui using OASYS and have encountered the following error when attempting to install shadow3:
"build\temp.win-amd64-3.8\shadow3c.lib : fatal error LNK1136: invalid or corrupt file"
From what I can tell, it appears like there is an issue with my C++ compiler that I am unaware how to fix. I am currently using VisualStudio build tools with the following installed:
MSVC v142 - VS 2019 C++ x64/86 build tools
Windows 10 SDK (10.0.18362.0) - but have also tried using v 10.0.14393.0
Windows Universal CRT SDK
I am using a Windows 10 machine with MinGW-W64 GCC-7.3.0 for the fortran compiler and the miniconda installer with python 3.8.5. I have also tried using other GCC versions (8.1, 6.4) but the newer version gives a different error like has been described in other issues.
Here is the full output during installation just in case it provides any useful information.
shadow3_lnk1136.txt
with gfortran 8 the compilation of shadow_variables.f90 (and others) fails with the following error:
Error: Component 'file_xxx' of BIND(C) type at (1) must have length one
This is a change of behaviour in the char C/Fortran interface. See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84885
See also this discussion:
@srio The footprint plot on the optical element does not work with the 'beam' instance, only via file.
This fails:
Shadow.ShadowTools.plotxy(beam, 1, 2, nbins=101, nolost=2, title="Footprint", ref=0)
This works:
Shadow.ShadowTools.plotxy('mirr.01', 1, 2, nbins=101, nolost=2, title="Footprint", ref=0)
This means that one is obliged to write files to look at the footprint.
@lucarebuffi it would be nice to have a 'footprint plot' tab in ShadowOui.
From: CARADOC-DAVIES, Tom
Sent: Saturday, September 5, 2020 4:08:23 PM
To: Rebuffi, Luca
Subject: Shadow bug? [SEC=UNCLASSIFIED]
Hi Luca,
I think I have found a minor bug. I am modelling CRLs in my beamline layout.
I am using the compound refractive lens widget to model 1D vertical and horizontal lenses.
This has the option for number of lenses and number of empty slots.
If I set number of lenses to zero on both CRL widgets in the Info widget distance summary table 4 CRLS are incorrectly listed (see attached).
They are not affecting the ray traced beam but seem to be incorrectly listed in the table? I would assume they should not be on the list as they are out of beam?
When I add lenses they appear as expected but I cannot get rid of the 4 “phantom” lenses.
I attached my model if you want to reproduce the error (apologies for the complex model).
Cheers,
Tom
Running Shadowoui, the "info" postprocessor does not show the top view and side view anymore.
In the output, the error is "Failed to append: object not understood: <class 'Shadow.ShadowLibExtensions.Source'>. "
Please help me out.
Thanks
Noticed by Xianbo, a screen/slit (empty element) modifies the beam in col 5.
See effect of oe3 (empty).
If suppressed, OK.
If col6 copied, OK.
otherwise NOT OK.
#
# Python script to run shadow3. Created automatically with ShadowTools.make_python_script_from_list().
#
import Shadow
import numpy
# write (1) or not (0) SHADOW files start.xx end.xx star.xx
iwrite = 0
#
# initialize shadow3 source (oe0) and beam
#
beam = Shadow.Beam()
oe0 = Shadow.Source()
oe1 = Shadow.OE()
oe2 = Shadow.OE()
oe3 = Shadow.OE()
oe4 = Shadow.OE()
#
# Define variables. See meaning of variables in:
# https://raw.githubusercontent.com/srio/shadow3/master/docs/source.nml
# https://raw.githubusercontent.com/srio/shadow3/master/docs/oe.nml
#
oe0.FDISTR = 3
oe0.F_PHOT = 0
oe0.HDIV1 = 0.0
oe0.HDIV2 = 0.0
oe0.ISTAR1 = 1001
oe0.NPOINT = 100000
oe0.PH1 = 25000.0
oe0.SIGDIX = 1e-10
oe0.SIGDIZ = 3.7e-06
oe0.SIGMAX = 0.0
oe0.SIGMAZ = 0.0046
oe0.VDIV1 = 0.0
oe0.VDIV2 = 0.0
oe1.DUMMY = 0.1
oe1.FCYL = 1
oe1.FHIT_C = 1
oe1.FMIRR = 2
oe1.RLEN1 = 200.0
oe1.RLEN2 = 200.0
oe1.RWIDX1 = 10.0
oe1.RWIDX2 = 10.0
oe1.T_IMAGE = 24700.0
oe1.T_INCIDENCE = 89.856761
oe1.T_REFLECTION = 89.856761
oe1.T_SOURCE = 35300.0
oe2.DUMMY = 0.1
oe2.F_REFRAC = 2
oe2.F_SCREEN = 1
oe2.I_SLIT = numpy.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
oe2.N_SCREEN = 1
oe2.RX_SLIT = numpy.array([1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
oe2.RZ_SLIT = numpy.array([0.002, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
oe2.T_IMAGE = 118695.0
oe2.T_INCIDENCE = 0.0
oe2.T_REFLECTION = 180.0
oe2.T_SOURCE = 0.0
oe3.DUMMY = 0.1
oe3.F_REFRAC = 2
oe3.F_SCREEN = 1
oe3.N_SCREEN = 1
oe3.T_IMAGE = 0.0
oe3.T_INCIDENCE = 0.0
oe3.T_REFLECTION = 180.0
oe3.T_SOURCE = 0.0
oe4.DUMMY = 0.1
oe4.FCYL = 1
oe4.FHIT_C = 1
oe4.FMIRR = 2
oe4.F_ANGLE = 1
oe4.F_DEFAULT = 0
oe4.RLEN1 = 150.0
oe4.RLEN2 = 150.0
oe4.RWIDX1 = 1.0
oe4.RWIDX2 = 1.0
oe4.SIMAG = 305.0
oe4.SSOUR = 119695.0
oe4.THETA = 89.856761
oe4.T_IMAGE = 305.0
oe4.T_INCIDENCE = 89.856761
oe4.T_REFLECTION = 89.856761
oe4.T_SOURCE = 1000.0
#Run SHADOW to create the source
if iwrite:
oe0.write("start.00")
beam.genSource(oe0)
if iwrite:
oe0.write("end.00")
beam.write("begin.dat")
#
#run optical element 1
#
print(" Running optical element: %d"%(1))
if iwrite:
oe1.write("start.01")
beam.traceOE(oe1,1)
if iwrite:
oe1.write("end.01")
beam.write("star.01")
#
#run optical element 2
#
print(" Running optical element: %d"%(2))
if iwrite:
oe2.write("start.02")
beam.traceOE(oe2,2)
if iwrite:
oe2.write("end.02")
beam.write("star.02")
#
#run optical element 3
#
print(" Running optical element: %d"%(3))
if iwrite:
oe3.write("start.03")
ray_before = beam.rays.copy()
beam.traceOE(oe3,3)
beam.rays[:,5] = ray_before[:,5]
ray_after = beam.rays.copy()
for i in range(6):
print(">>>>>>>>>>>>>>>>>>>>>",i,(ray_after-ray_before)[:,i])
if iwrite:
oe3.write("end.03")
beam.write("star.03")
#
#run optical element 4
#
print(" Running optical element: %d"%(4))
if iwrite:
oe4.write("start.04")
beam.traceOE(oe4,4)
if iwrite:
oe4.write("end.04")
beam.write("star.04")
Shadow.ShadowTools.plotxy(beam,1,3,nbins=101,nolost=1,title="Real space")
# Shadow.ShadowTools.plotxy(beam,1,4,nbins=101,nolost=1,title="Phase space X")
# Shadow.ShadowTools.plotxy(beam,3,6,nbins=101,nolost=1,title="Phase space Z")
Dear Srio,
I want to raytrace the high energy laue monochromator, but how to set the anticlastic curvature optics? I think I can use a external file at the modified surface option. and I also found that there is pole location parameter for the torodal mirror , is that for a anticlastic curvature? and if so,how to use it? I try to set it but i don't know whether it is right or not. Thank you very much!
Best regards!
Yajun Tong
SSRF, China
Hello,
I have a problem when tracing a wiggler source using shadowoui. The sizes of source it gives are different from that of Spectra with the same parameters. It gives 118 micron x 35 micron with two distinct spots as shown below while the Spectra gives 1940 micron x 160 micron.
Is there a problem here in my settings?
Thank you for any help,
Zimeng Wang
On 8/13/22 1:41 AM, Samuel Gleason wrote:
Dear Manuel,
I have a small question about choosing the torus pole location.
I attach a file with two mirrors that represent different pieces of a bicycle-tire torus.
The first mirror is the 'bottom' of the tire, that is, a concave/concave surface.
The second mirror is the 'top' of the tire, that is, a convex/convex surface.
I've rotated the second mirror 180 degrees about its sagittal axis, expecting that this would make the two mirrors equivalent.
Instead, the beam now intersects the rotated mirror far away from the pole.
Are you able to explain why this is the case?
I asked Ruben Reininger, but he was also confused.
Thanks very much!
Sam Geason
Compound refractive lenses calculation present an image that is not centered at (0,0) as expected, but shifted vertically. This is more evident with a high number of lenses.
Effect of energy spread: it would be good to include energy spread in the calculation of divergence
Dear Sergey,
yes there is a problem in Laue symmetric, an undesirable switch that makes that it does not work correctly for symmetric Laue or asymmetric if angle is set at exactly 90.0 deg. The temporary solution is to set Laue asymmetric and set the angle near but not exactly at symmetric position, for example 90.001 deg.
I hope this answers your question.
Best regards,
Manuel
On 25.01.2020 10:08, Sergey Rashchenko wrote:
DEAR MANUEL,
Thank you for your efforts in developing Oasys!
Currently I am trying to study dispersion introduced into reflected
beam by Laue monochromator, and faced an unexpected behavior of SHADOW
(see attached workspace):
when I trace a parallel beam from a point source through symmetric
Laue crystal, no dispersion appears in the reflected beam in contrary
to theory (see also attached screenshots). I also checked symmetric
and asymmetric Bragg cases - they seem to give correct results. Is
this a bug, or just my misunderstanding of theory?SINCERELY,
SERGEY V. RASHCHENKO, PH.D.Budker Institute of Nuclear Physics
Novosibirsk, Russia
Hello,
Trying to simulate simple angles scans in Bragg and Laue configurations for SI100, SI111 and SI220 crystals.
I have a ligth source (WIggler at 15 kEv with +/- 5ev distribution) connected to plane crystal set up in either Bragg or Lauer configuration. (Shown bellow)
I get expected results for SI111 and SI220, but for SI100 the intensity values explode (e.g. I get intensity >10000 at any incidence angle including computed Bragg/Laue configuration.
The crystal data is generated using Bragg tool. Is this a known issue? Or is there a solution/workaround I should try?
Result for SI100 at bragg angle
Result for SI111 at bragg angle
Thank you.
on the way...
It comes some confusions when I go through my simulation of paraboloid mirror. I will list them below.
In my spectrometer layout design, I hope to make all the symmetry axes of meridional-oriental O.E. (e.g. focus mirror, grating) are coincident with the symmetry axis of the dual parabolic mirrors and the center light when the source is stable. However in the reference frame logic of SHADOW, when the source movement is taken into consideration, the layout seems to be so strange. In other words, I do not want my layout to be influenced by the movement of source. What parameter should I set extra to achieve my goal?
Thank you so much!
parabolic collimate mirror.zip
On 8/25/22 10:28 AM, Yu Xiaojiang wrote:
Dear Manuel
I test the reflectivity with graphite 002 and Si 111 for two configurations, finding the angles on the plane crystals of graphite are same in two configures, but reflectivity is difference, NOT expected.
For Si 111, angles are different, so the different reflectivity is just expected.
Do you think the problem is from Shadow code?
Please see the setup in the workspace attached (please check in CRYSTAL widget, graphite is chosen, my crystal list in the xraylib may be different from you).
Best regards
Xiaojian
graphite_reflectivity.zip
chac:~/Oasys/OASYS_VE % python
Python 3.4.0 (default, Jun 19 2015, 14:20:21)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import Shadow
>>> oe = Shadow.OE()
>>> oe.FILE_REFL=b'aaaaaaaaaaaaa'
>>> oe.write("tmp.01")
fixing poolOE for Fortran
fixed poolOE for Fortran
>>> oe.load("tmp.01")
...
7ffddc745000-7ffddc747000 r--p 00000000 00:00 0 [vvar]
7ffddc747000-7ffddc749000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted (core dumped)
Request by Yasushi Kagoshima [email protected]:
Dear Dr. Manuel Sanchez del Rio
I am a professor in X-Ray physics.
I struggle to figure out how to simulate DuMond diagram by SHADOW.
In your paper
(http://www.esrf.eu/computing/scientific/people/srio/publications/SPIE98_rt-xtals.pdf
[1]), you said thatDu Mond diagram can be easily done with ray tracing.
I can not figure out how to simulate Du Mond diagram by SHADOW.
Could you please advise me?
Thank you very much for your help.
it seems that the calculated FWHM is a bit underestimated
Eg, Gaussian source 1umx1um 1e6 rays 501 bins gives 2.32, 2.29
Some great examples already given in the src/examples. And by using the functions of the C API we can create personalized scripts. But how can we use the subroutines in the shadow_preprocessors, like BRAGG or PreSURFACE in our C scripts?
This may be an old question already asked by others before, but it still keeps making me puzzled when I use the example01.c to simulate a Crystal diffraction.
Thanks, if there could be any tips~
(Also reported in oasys-kit/ShadowOui)
When testing schemes with collimating lens installed before asymmetrically cut crystal, I found an unexpected behavior: lens widgets that use PreRefl data, followed by asymmetrically cut crystal produce a strange diagonal strike in beam cross-section, which I cannot explain physically. In addition, when using the 'ideal lens' widget instead (but with the same focal distance), the resulting beam cross-section is OK (see also .ows with example here: Test.zip).
Using python API, when shadow exit with stop because of some error, it crashes python and the user interface on top.
Question by J. Dvorak. Answers in bold.
test: I set up a very simple geometric source, working in mm units using OASYS
point source, +H div = -H div = + V div = -V div = 0.001 rad, with a flat angular distribution
put a screen 1000 mm away, with a very short output plane, so that the OASYS plot shows the beam footprint at essentially the position of the screen
In this case, the beam footprint on the screen should appear as follows:
Test 1: Go under 'Optical Element Movement' and set it to 'Yes'
I find that none of the three translations or rotations have any effect.
It is normal. May be not logic. It has an explanation: the slit in ShadowOui, is in fact defined accompanying an “empty optical element” that you do not see in the interface. Moving an “empty element” does not make any effect.
Test 2: Go under 'Source Movement' and set it to 'Yes'. I set 'angle of incidence' to 0 (not quite sure what this does. angle relative to what?) and set the 'distance from OE' to +1000 mm. It is not explicitly stated in which reference frame this is, however, I assume this puts the source at -1000 mm in the OE reference frame, so I have reproduced the above configuration. I then get the same footprint on the screen as above.
It would be helpful if it explicitly says what reference frame the 'distance to OE' refers to.
The menu you refer to:
concerns the placement of the source (previous continuation plane) from the element itself. Therefore, in some way you should "copy" some information you already introduced (distance and incident angle).
Here there is a "complication" because you are using a slit as a testing element. In principle, one should use an optical element for that, with the referente frame as stated in the
Shadow3 primer
Therefore, you are applying the movements on an "empty element", and this is why you get weird effects. You should think in something like:
'z rotation' keeps image centered, but skews it. It acts like a rotation about the y axis. Furthermore, it does not act like a rotation of the source, it acts like a rotation of the OE reference frame.
in OE reference frame
x translation – seems to work correctly
y translation – should keep image centered, but make it larger or smaller, however, it acts as a z translation
z translation – acts like a y translation, making the image larger or smaller. Furthermore, if my interpretation of 'distance for OE' is correct, it has the
wrong sign. Moving +500 mm in the y direction in the OE reference frame should make the distance between the source and OE shorter,
and reduce the image size on the screen by 0.5 mm. It has the opposite effect.
in Source reference frame
x translation – seems to work correctly
y translation – in this very simple system, the +y direction in the source and OE reference frame are identical. In this case, if I set y offset to +500 mm,
the distance between the source and screen should decrease, and the image should be centered but smaller by 0.5 mm. This works correctly.
z translation – seems to work correctly
Please check the movements and you will see that it make sense now. I agree that is not trivial, the problem is that you have chosen a slit as your element, and we implemented it in ShadowOui linked to en empty element that you do not see. It is on top of this empty element that the movements are applied.
Hello @srio, what is the license for this project? Is it BSD 3-Clause or similar? Could you please kindly add the corresponding license file? Thank you!
from the two possible intersection of a ray with a conic, shadow selects one. It was explained here:
http://ftp.esrf.fr/pub/scisoft/shadow/user_contributions/hyperbola_fixes_2008-10-22.txt
In the case of highly demagnifying KBs, for example, p>>, and one solution is at -t1 and the other is at t2~p, so |-t1-p| < |t2-p| so it takes -t1 (wrong solution).
Temporary solution: place a screen close and upstream to the mirror.
Permanent solution: change the way of selecting t in
https://github.com/srio/shadow3/blob/master/src/fortran/shadow_kernel.f90
Change:
IF ( ABS(TPAR1-T_SOURCE).LE.ABS(TPAR2-T_SOURCE) ) THEN
TPAR=TPAR1
ELSE
TPAR=TPAR2
END IF
to:
IF ( ABS( abs(TPAR1)-abs(T_SOURCE)).LE.ABS(abs(TPAR2)-abs(T_SOURCE)) ) THEN
TPAR=TPAR1
ELSE
TPAR=TPAR2
END IF
and make a lot of tests...
Hello.
Please help me with modeling the reflection from parabolic mirrors.
I take geometrical source with wavelenght 1.54A and try to focusing.
And i got good results for focusing by parabolic mirror with small distances. For example, source distance 14cm, Image 29 and paraboloid parameter 30 cm.
Are these results correct ? Can I use small distances ?
parabolic mirror.zip
And how I can set roughnes if I only have image from atomic-force microscope with some data like RMS, without any special files ?
ubuntu 20.04
python 3.8.8
pip 21.1.1
setuptools 56.1.0
python setup.py build
Traceback (most recent call last):
File "setup.py", line 103, in <module>
setup(
File "...lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "...lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "...lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "...lib/python3.8/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "...lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "...lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "...lib/python3.8/site-packages/numpy/distutils/command/build_clib.py", line 122, in run
dispatch_hpath = os.path.join(self.get_finalized_command("build_src").build_src, dispatch_hpath)
File "...lib/python3.8/distutils/cmd.py", line 103, in __getattr__
raise AttributeError(attr)
AttributeError: build_src
self.get_finalized_command("build_src")
returns a NullCommand
instance due to
cmdclass={
'build_clib': BuildClib,
'build_src': NullCommand,
},
In some LINUX installations of OASYS (using miniconda) the OASYS application bombs when running a system contaning source and at least one optical element:
Exit from SETSOUR
Call to IMREF
Exit from IMREF
Call to OPTAXIS
At line 416 of file src/fortran/stringio.f90
Internal Error: get_unit(): Bad internal unit KIND
The problem is related to using an old compiler for creating the shadow3 binaries.
For example, this is bad:
gurb:/nobackup/srio/OASYS1.1 % gfortran --version
GNU Fortran (Debian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
This is good:
chac:~/OASYS1/shadow3/dist % gfortran --version
GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
Quick solution:
overwrite the installation with a working compiled version (wheel). For example:
pip install http://ftp.esrf.eu/pub/scisoft/shadow3/wheels/shadow3-18.5.30-cp36-cp36m-linux_x86_64.whl--upgrade
Developer solution:
Install shadow3 in your system, compile it and test it:
git clone http://github.com/oasys-kit/shadow3
cd shadow3
python setup.py clean build
pip install . --upgrade
cd tests
python test_lens.py
If this fails, you need to upgrade your compiler.
Note that simple "pip install shadow3" may fail as it may download sources and build them in your system.
I am trying to upgrade the adds-on to OASYS-kit. The message reminds to upgrade pip. After upgrading the pip to the latest, the OASYS-kit still refuses to upgrade and keep warning.
Please help me out,
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.