Repository navigation
X: Fluorescence upgrade, forward this PR and #3088 to FluoCrystal and FluoPowder - #3094
Conversation
…sation handling; better line width estimates
|
Hmm there was a merge conflict and I probably took the wrong choice of %Test values. Will look for improved numbers for ROCK and MARS |
MARS, CRISTAL: values for this branch, lost in the merge with main. ROCK: test with ROCK_dE=0.01. With dE=1 keV the monochromator output is undersampled at 1e6 rays and the monitor varies by orders of magnitude between seeds. Reference: 7.3e9 +/- 7% at 1e8 rays, dE=1. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
With ROCK_dE=0.01 and 1e7 rays the monitor error is about 2%. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@farhi two commits were pushed to this branch to get the McXtrace tests in line (419e2c4 and the one after), please check that you agree: SOLEIL_MARS, SOLEIL_CRISTAL: when SOLEIL_ROCK: the test value was not reproducible. With the default
The test line is now Only the test line changed, not the instrument defaults. With Two things for you to judge:
Runs were done on macOS with the three 🤖 Generated with Claude Code |
Following #3088 "X: Fluorescence: fix cross-section normalization, sampling, SPLIT cache and file handling"
This is a large PR. It mostly forwards #3088 to FluoCrystal and FluoPowder
Fluorescence: handle non-radiative (e.g. Auger) absorption; polarisation handling; better line width estimates.FluoCrystal: forward Fluorescence changes. See X: Fluorescence: fix cross-section normalisation, sampling, SPLIT cache and file handling #3088 and above.FluoPowder: forward Fluorescence changes. See X: Fluorescence: fix cross-section normalisation, sampling, SPLIT cache and file handling #3088 and above.Fluorescence: New features
CSb_Totalis used. The remainder after fluorescence, Rayleigh and Compton becomes a new non-radiative outcome,ABSORPTION=5(Auger and similar).my_snow covers all photo-absorption.DCSPb_RaylandDCSPb_Comptare used when (Ex,Ey,Ez) ≠ 0, with the azimuth measured from the polarisation vector. The scattered polarisation is the projection of the incoming one.FluoPowder: bug fixes and new features forwarded from Fluorescence
flag_low_z(new setting), alignflag_kisseldoc to Z≥50flag_low_z=1; better statistics for trace elements, higher variance per raytypelist to0..5(DIFFRACTION=3, TRANSMISSION=4, ABSORPTION=5)n_atoms,line_width,xs_fluo/Compton/Rayleigh, extended SPLIT cache (reuse_valid,reuse_x/y/z,reuse_kx/ky/kz,reuse_xs_*,reuse_xs_absorb)mat_densitynow fromsum_w_over_rho(volumes add) instead of mass-weighted sum of densitiesdensity/fluo_rhofor multi-element materials; affects all absolute intensitiespacking_factoronly applied when explicitly given (else forced to 1)density/mat_densityline_widthper element viafluo_line_widths(initial+final shell widths)dEhalvingnat(atoms per unit) instead of mass fractions; compound totals from cum-sum last elementxs[ABSORPTION]= CSb_Total minus processes (Auger, non-radiative); include insigma_barnand process selection; drop old(sum)/sigma_barnp-correctionmc_scatt <= 0now falls through to transmission branch instead ofABSORBp *= p_transinstead of dyingp_interact >= 0condition removed)p_interact<0only disables forcing, hollow geometry still handledXRMC_SelectFluorescenceEnergynow takes per-lineline_dE;Ef<=0→ ABSORB; new LorentziandE/2*tan(π/2*randpm1())and GaussiandE/(2√(2ln2))*randnorm()sampling; emission isotropic and unpolarised (Ex=Ey=Ez=0), noθpolarisation factor(1-s)²/(1+cos²θ)/2angular factor on fluorescencesigma_Z=CSb_Rayl,DCSb_Raylor polarisedDCSPb_Raylwith azimuth fromfluo_pol_azimuth; scattered polarisation viafluo_pol_scattered4π·dsigma/sigma_ZCSb_Compt/DCSPb_Compttreatment;ComptonEnergy(E,θ)sets final energyDCS_Comptmass-normalised variant)XRMC_SelectInteraction;alphareset fix; polarisation weighting unchangedx,y,z,kx,ky,kz,kiandreuse_valid; reuse restores last cum-sum element (old code summed all cum entries — a bug)FluoCrystal: bug fixes and new features forwarded from Fluorescence
flag_low_z; alignflag_kisseldoc to Z≥50flag_low_z=1; better statistics for trace elementstypelist now0..5(DIFFRACTION=3, TRANSMISSION=4, ABSORPTION=5); replace "SPLIT is currently BROKEN" noten_atoms,line_width,xs_fluo/Compton/Rayleigh, extended SPLIT cache (reuse_valid,reuse_x/y/z,reuse_kx/ky/kz,reuse_xs_*,reuse_xs_absorb)mat_densityfromsum_w_over_rho(volumes add) instead of mass-weighted sumfluo_rhofor multi-element materials; affects absolute intensitiespacking_factoronly applied when explicitly given (else forced to 1)density/mat_densityhkl_info.sigma_i = 0set explicitly (Compton now handled by XRayLib, notsigma_inc)#sigma_incheader value was presentline_widthper element viafluo_line_widths(initial+final shell widths)nat(atoms per unit) instead of mass fractionsxs[ABSORPTION]= CSb_Total minus processes (Auger); include insigma_barnand process selectionmc_scatt <= 0falls through to transmission instead ofABSORBp *= p_transp_interact >= 0condition removed)p_interact<0only disables forcingline_dEpassed toXRMC_SelectFluorescenceEnergy;Ef<=0→ ABSORB; new Lorentzian/Gaussian sampling; emission isotropic and unpolarised (Ex=Ey=Ez=0), oldθpolarisation factor removed(1-s)²/(1+cos²θ)/2angular factor on fluorescencesigma_Z=CSb_Rayl,DCSb_Raylor polarisedDCSPb_Raylviafluo_pol_azimuth;fluo_pol_scatteredfor outgoing polarisation4π·dsigma/sigma_Z(was/xs[RAYLEIGH]compound-sum)CSb_Compt/DCSPb_Compttreatment; fixes use of the uninitialisedEfinDCS_Compt(Z, Ef, θ)andComptonEnergy(Ef, θ)→ now usesEhkl_select, 2D-Gausskf,pmulweight, polarisation weighting); DIFFRACTION competes in the process selection;alphahandling unchangedx,y,z,kx,ky,kz,kiwithreuse_valid; cached totals restored from the last cum-sum element (old code summed all cum entries — a bug);hkl_searchresults (coh_refl,coh_xsect,tau_count) reused via cacheDISPLAY INHERIT FluorescencekeptDISPLAY INHERIT FluorescencekeptTests values
SOLEIL_CRISTAL: 620370 -> 1390520 (~ x2)SOLEIL_MARS: 134100000 -> 228635000Test_PowderN: FluoPowder 6.29534e-12 -> 2.81248e-12 closer to other references (SX and PowderN)Test_SX: 6.1e-14 -> 3.33118e-14 closer to other references (SX)SOLEIL_ROCK: 119954000000 -> 2326220000Test_Absorption: 9.36962e-10 -> 5.31547e-12 closer to other referencesDeclaration of use of AI-tools
Development OS / boundary conditions
Please describe what OS you developed and tested your additions on, and if any special dependencies are required:
PR Checklist for contributing to McStas/McXtrace
For a coherent and useful contribution to McStas/McXtrace, please fill in relevant parts of the checklist:
My contribution includes patches to an existing component file
mcdocutility and rendered a reasonable documentation page for the component (please attach as screenshot in comments!)mctestutility to test one or more instruments making use of the component (please attachmcviewtestreport as screenshot in comments)mccode-clangformattool to apply the standard McCode component indentation schememcrun --c-lint"linter" and followed advice to remove most / all warnings that are raisedMy contribution includes patches to an existing instrument file
mcdocutility and rendered a reasonable documentation page for the instrument (please attach as screenshot in comments!)mctestutility to test the instrument (please attachmcviewtestreport as screenshot in comments)mcrun --c-lint"linter" and followed advice to remove most / all warnings that are raisedMy contribution includes a new component file
mcdocutility and rendered a reasonable documentation page for the component (please attach as screenshot in comments!)mccode-clangformattool to apply the standard McCode component indentation schemecontribcomponent categoryMy contribution includes a new instrument file
mcdocutility and rendered a reasonable documentation page for the instrument (please attach as screenshot in comments!)%Test:line (or a%TestScan:line for a parameter scan) to describe expected behaviourmcrun --c-lint"linter" and followed advice to remove most / all warnings that are raisedexampleshierarchy in a folder in the style ofexamples/ESS/New_stuff/New_stuff.instrexamplefolder, but if general use I have placed it in the globaldatafolder.My work touches the code-generator in mccode/src
My work touches / adds to the runtime lib code (.c,.h etc in multiple locations
common/lib/share,mccode/nlib/share,mcstas-comps/shareormcxtrace-comps/sharelibrary and runtime file (.c,.h,.h.in) has aTest_lib_<name>instrument inexamples/libtest/(McStas and/or McXtrace), with a%Test:line where the result can be checked. If it cannot be standalone, say why in the free-form text (e.g. needs a component or external package)My PR is meant to fix a specific, existing issue
My contribution contains something else