Skip to content

Commit

Permalink
Merge pull request #1759 from ebknudsen/source_div_quasi_focus
Browse files Browse the repository at this point in the history
potential fix for #1735
  • Loading branch information
ebknudsen authored Nov 14, 2024
2 parents 17c8c3f + f6debe2 commit 433c630
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
14 changes: 4 additions & 10 deletions mcstas-comps/sources/Source_div_quasi.comp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
* %P
* xwidth: [m] Width of source
* yheight: [m] Height of source
* focus_aw: [rad] Std. dev. (Gaussian) or maximal (uniform) horz. width divergence
* focus_ah: [rad] Std. dev. (Gaussian) or maximal (uniform) vert. height divergence
* focus_aw: [rad] Std. dev. (Gaussian) or maximal (uniform) horz. width divergence. focus_xw overrrides if it is more restrictive.
* focus_ah: [rad] Std. dev. (Gaussian) or maximal (uniform) vert. height divergence. focus_yh overrrides if it is more restrictive.
* focus_xw: [m] Width of sampling window
* focus_yh: [m] Height of sampling window
* dist: [m] Downstream distance to place sampling target window
Expand Down Expand Up @@ -178,20 +178,14 @@ INITIALIZE
/*check if divergence limits are compatible with focus_xw, focus_yh*/
if(focus_xw!=0){
double maxdivh=atan((xwidth+focus_xw)/dist);
if (focus_aw>maxdivh){
if (focus_aw>maxdivh || focus_aw==0 ){
focus_aw=maxdivh;
if (verbose){
fprintf(stderr,"WARNING(%s): sampling width does not support full divergence. Adjusting to focus_aw=%g rad\n",NAME_CURRENT_COMP,focus_aw);
}
}
}
if(focus_yh!=0){
double maxdivv=atan((yheight+focus_yh)/dist);
if (focus_ah>maxdivv){
if (focus_ah>maxdivv || focus_ah==0 ){
focus_ah=maxdivv;
if (verbose){
fprintf(stderr,"WARNING(%s): sampling height does not support full divergence. Adjusting to focus_ah=%g rad\n",NAME_CURRENT_COMP,focus_ah);
}
}
}

Expand Down
17 changes: 5 additions & 12 deletions mcxtrace-comps/sources/Source_div_quasi.comp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
* %Parameters
* xwidth: [m] Width of source
* yheight: [m] Height of source
* focus_aw: [rad] Std. dev. (Gaussian) or maximal (uniform) horz. width divergence
* focus_ah: [rad] Std. dev. (Gaussian) or maximal (uniform) vert. height divergence
* focus_aw: [rad] Std. dev. (Gaussian) or maximal (uniform) horz. width divergence. focus_xw overrrides if it is more restrictive.
* focus_ah: [rad] Std. dev. (Gaussian) or maximal (uniform) vert. height divergence. focus_yh overrrides if it is more restrictive.
* focus_xw: [m] Width of sampling window
* focus_yh: [m] Height of sampling window
* dist: [m] Downstream distance to place sampling target window
Expand Down Expand Up @@ -174,24 +174,17 @@ INITIALIZE
/*check if divergence limits are compatible with focus_xw, focus_yh*/
if(focus_xw!=0){
double maxdivh=atan((xwidth+focus_xw)/dist);
if (focus_aw>maxdivh){
if (focus_aw>maxdivh || focus_aw==0 ){
focus_aw=maxdivh;
if (verbose){
fprintf(stderr,"WARNING(%s): sampling width does not support full divergence. Adjusting to focus_aw=%g rad\n",NAME_CURRENT_COMP,focus_aw);
}
}
}
if(focus_yh!=0){
double maxdivv=atan((yheight+focus_yh)/dist);
if (focus_ah>maxdivv){
if (focus_ah>maxdivv || focus_ah==0 ){
focus_ah=maxdivv;
if (verbose){
fprintf(stderr,"WARNING(%s): sampling height does not support full divergence. Adjusting to focus_ah=%g rad\n",NAME_CURRENT_COMP,focus_ah);
}
}
}


%}

TRACE
Expand Down Expand Up @@ -257,7 +250,7 @@ TRACE
}else if (lambda0){
if (!dlambda){
l=lambda0;
}else if (gauss){
}else if (gauss){mcxtrace-comps/sources/Source_div_quasi.comp
l=lambda0+dlambda*randnorm();
}else{
l=randpm1()*dlambda + lambda0;
Expand Down

0 comments on commit 433c630

Please sign in to comment.