Skip to content

Commit 99dc2b9

Browse files
author
Emmanuel FARHI
committed
mcxtrace: fix FluoPowder on arm (1e-307 -> 0)
1 parent e6a7d2a commit 99dc2b9

3 files changed

Lines changed: 33 additions & 10 deletions

File tree

mcxtrace-comps/examples/Tests_samples/Test_SX/Test_SX.instr

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@
1414
*
1515
* Simply a model source illuminating a SX sample.
1616
* The sample itself is a Mo bulk crystal.
17+
* The idea is to compare the fluorescence and diffraction patterns:
18+
* - index=1: use Single_crystal
19+
* - index=2: use FluoCrystal
20+
* - index=3: use Fluorescence+Single_crystal in a GROUP
1721
*
1822
* %Example: index=1 Detector: psd4pi_I=1.18843e-13
19-
* %Example: index=2 Detector: psd4pi_I=4.80386e-13
23+
* %Example: index=2 Detector: psd4pi_I=6.89931e-12
24+
* %Example: index=3 Detector: psd4pi_I=4.4547e-13
2025
*
2126
* %Parameters
2227
* reflections: [str] List of powder reflections, LAU/CIF format.
23-
* index: [1] Index of the sample component to use. 1=Single_crystal, 2=FluoCrystal
28+
* index: [1] Index of the sample component to use. 1=Single_crystal, 2=FluoCrystal, 3=Fluorescence+Single_crystal in a GROUP
2429
*
2530
* %End
2631
*******************************************************************************/
@@ -58,6 +63,24 @@ EXTEND %{
5863
else Stype=type;
5964
%}
6065

66+
COMPONENT FluoG = Fluorescence(
67+
radius = .5e-4, yheight = 1e-3, material=reflections)
68+
WHEN (index == 3)
69+
AT (0, 0, 0) RELATIVE sample_pos
70+
GROUP FluSX
71+
EXTEND %{
72+
if (SCATTERED) Stype = type;
73+
%}
74+
75+
COMPONENT SX = COPY(sample)(sigma_inc=-1)
76+
WHEN (index == 3)
77+
AT (0, 0, 0) RELATIVE sample_pos
78+
GROUP FluSX
79+
EXTEND %{
80+
if (SCATTERED) Stype=DIFFRACTION;
81+
else ABSORB;
82+
%}
83+
6184
COMPONENT psd4pi = PSD_monitor_4PI(
6285
nx = 180, ny = 180, filename = "psd4pi", radius = 0.1, restore_xray = 1)
6386
AT (0, 0, 0) RELATIVE sample

mcxtrace-comps/samples/FluoPowder.comp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ do { /* while (intersect) Loop over multiple scattering events */
947947
if (intersect) { /* scattering event */
948948
int i_Z=-1, Z, line=-1;
949949
double solid_angle;
950-
double theta, dsigma, alpha;
950+
double theta, dsigma, alpha=0;
951951
double Ef, dE;
952952
double kf=k, kf_x, kf_y, kf_z; // next particle direction
953953

@@ -1027,12 +1027,12 @@ do { /* while (intersect) Loop over multiple scattering events */
10271027
{ /* relate height of detector to the height on DS cone */
10281028
arg = sin(powder_d_phi*DEG2RAD/2)/sin(2*theta);
10291029
/* If full Debye-Scherrer cone is within powder_d_phi, don't focus */
1030-
if (arg < -1 || arg > 1) alpha = 0;
1030+
if (arg < -1 || arg > 1) powder_d_phi = 0;
10311031
/* Otherwise, determine alpha to rotate from scattering plane
10321032
* into powder_d_phi focusing area */
10331033
else alpha = 2*asin(arg);
10341034
}
1035-
if (alpha) {
1035+
if (powder_d_phi) {
10361036
/* Focusing */
10371037
alpha = fabs(alpha);
10381038
alpha0 = 0.5*randpm1()*alpha;
@@ -1097,13 +1097,13 @@ do { /* while (intersect) Loop over multiple scattering events */
10971097
if (Ex!=0 || Ey!=0 || Ez!=0){
10981098
double EE=sqrt(Ex*Ex+Ey*Ey+Ez*Ez);
10991099
double s=scalar_prod(kf_x,kf_y,kf_z,Ex,Ey,Ez)/EE;
1100-
p*=(1-s)*(1-s);
1101-
}else{
1100+
p *= (1-s)*(1-s);
1101+
} else {
11021102
/*unpolarized light in - means an effective reduction according to only theta*/
1103-
p*=(1+cos(theta)*cos(theta))*0.5;
1103+
p *= (1+cos(theta)*cos(theta))*0.5;
11041104
}
11051105
if (alpha) {
1106-
p *= alpha/PI;
1106+
p *= alpha/PI;
11071107
}
11081108
n_diff++;
11091109
p_diff += p;

mcxtrace-comps/samples/PowderN.comp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ TRACE
10791079
}
10801080
if (d_phi_thread) {
10811081
/* Focusing */
1082-
alpha = fabs(alpha);
1082+
alpha = fabs(alpha);
10831083
alpha0 = 0.5*randpm1()*alpha;
10841084
if(focus_flip){
10851085
alpha0+=M_PI_2;

0 commit comments

Comments
 (0)