Reflectivity and transmittivity calculation with xradyb - #62
Open
yxrmz wants to merge 6 commits into
Open
Conversation
Contributor
|
I tested compiling via Visual Studio on Windows, and via CMake in WSL2/Linux. Example 22 works in both cases without additional edits. It works well. Maybe we should think about the results when xraydb is not installed. I see that warnings are emitted indicating that it's missing, but I wonder if it might be better to error out so that we do not show results that are likely to not be what the user is expecting. |
| static const char strEr_BadOptWG[] = "Incorrect Optical Waveguide structure"; | ||
| static const char strEr_BadOptG[] = "Incorrect Optical Grating structure"; | ||
| static const char strEr_BadOptT[] = "Incorrect Optical Generic Transmission structure"; | ||
| static const char strEr_BadOptR[] = "Incorrect Reflectivity Object structure"; |
Contributor
There was a problem hiding this comment.
Maybe "Incorrect Reflectivity structure"?
| from srwpy.srwlib import * | ||
| from srwpy.uti_plot import * | ||
| from srwpy.uti_mtrl import * | ||
|
|
Contributor
There was a problem hiding this comment.
Something like:
xraydb_avail = False
try:
import ...
xraydb_avail = True
except:
....
?
|
|
||
| # Aluminum filter | ||
| filter_thick = 50.e-06 # [m] | ||
| al_delta, al_atten_len = calc_delta_atten_len('Al', photon_energy) |
Contributor
There was a problem hiding this comment.
Hard code or load values from files for when xraydb is unavailable?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds utilities for calculating SRW-compatible reflectivity and transmittivity coefficients using
xraydblibrary.This way material properties for optical elements can be defined alongside the propagation script, rather then being imported from file or pre-calculated elsewhere.
We are adding the
srwlpy.uti_mtrlmodule with the following utilities:calc_refl_arrcalc_coated_refl_arrcalc_multilayer_refl_arrcalc_delta_atten_lensrwl_opt_setup_transm_from_materialadd_matNew example is added featuring new capabilities, see
Example22. In this example we demonstrate how to add a filter made of a pre-defined material (Aluminum), bulk mirror made of a new material (B4C), a coated mirror (pre-defined Pt on Si), and a Diamond CRL array (providing custom density).Python/C++ wrapper code is modified to provide safe reflectivity array object cleanup.
xraydbis an optional depenedency. If this package is missing, or material definition is incomplete - utility functions will substitute the amplitude of 1 for reflectivity and 0 for absorption. Users can add new materials to the runtime instance of xraydb withadd_mat(Chemical composition and density are required)