Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*******************************************************************************
* McXtrace instrument definition URL=http://www.mcxtrace.org
*
* Instrument: Test_filter_geom
*
* %Identification
* Written by: Erik Knudsen (erkn@risoe.dtu.dk)
* Date: July 5th 2011
* Origin: Risø DTU
* Version: 1.0_rc2
* %INSTRUMENT_SITE: Tests_optics
*
* Test instrument for checking the geometry options of the Filter.comp component
*
* %Description
* Test instrument for checking the Filter.comp component
* Specifically this instrument checks the geometry options and refraction
*
* %Parameters
* filter_mat: [] Chemical symbol of the filter material
* thickness: [m] thickness of the filter block
* L0: [AA] centre wavlength of the source
* DL: [AA] half width of the (uniform) wavelength distribution
* F2: [1] add a 2nd filter component further away
*
* %Example: DL=4.9 L0=5 filter_mat="Be.txt" Detector: psd2_I=0.760008
* %Example: DL=4.9 L0=5 filter_mat="Be.txt" shape=1 Detector: psd2_I=0.57936
* %Example: DL=4.9 L0=5 filter_mat="Be.txt" shape=2 Detector: psd2_I=0.415209
* %Example: DL=4.9 L0=5 filter_mat="Be.txt" refraction=1 Detector: psd2_I=0.759422
* %Example: DL=4.9 L0=5 filter_mat="Be.txt" refraction=1 shape=1 Detector: psd2_I=0.571845
* %Example: DL=4.9 L0=5 filter_mat="Be.txt" refraction=1 shape=2 Detector: psd2_I=0.40875
*
* %End
*******************************************************************************/

DEFINE INSTRUMENT Test_Filter_geom(string filter_mat="Rh.txt",thickness=100e-6,L0=1,DL=0.1, F2=0, int shape=0, refraction=0)

DECLARE
%{
%}

INITIALIZE
%{
%}


TRACE

COMPONENT Origin = Progress_bar()
AT(0,0,0) ABSOLUTE


COMPONENT Source=Source_div(
lambda0=L0,dlambda=DL, xwidth=thickness*2, yheight=thickness*2
)
AT (0,0,0) RELATIVE Origin

COMPONENT l_mon0 = L_monitor(
filename="l_mon0",nL=200,xwidth=0.1, yheight=0.1, Lmin=L0-1.1*DL, Lmax=L0+1.1*DL
)
AT (0,0,1e-6) RELATIVE Source

COMPONENT filter_box = Filter(
material_datafile=filter_mat, xwidth=thickness, yheight=0.1,zdepth=thickness, refraction=refraction
)
WHEN (shape == 0) AT (0,0,0.5) RELATIVE Source

COMPONENT filter_sphere = Filter(
material_datafile=filter_mat, radius=thickness, refraction=refraction
)
WHEN (shape == 1) AT (0,0,0.5) RELATIVE Source

COMPONENT filter_cyl = Filter(
material_datafile=filter_mat,yheight=0.1,radius=thickness, refraction=refraction
)
WHEN (shape == 2) AT (0,0,0.5) RELATIVE Source

COMPONENT psd1 = PSD_monitor(xwidth = thickness*4, yheight= thickness*4, nx=512, ny=512, filename="psd1", restore_xray=1)
AT(0,0,thickness*2) RELATIVE filter_box

COMPONENT psd2 = PSD_monitor(xwidth = thickness*4, yheight= thickness*4, nx=512, ny=512, filename="psd2", restore_xray=1)
AT(0,0,0.1) RELATIVE filter_box

COMPONENT l_mon1 = L_monitor(
filename="l_mon1",nL=200,xwidth=0.1, yheight=0.1, Lmin=L0-1.1*DL, Lmax=L0+1.1*DL
)
AT (0,0,1) RELATIVE Source



END
49 changes: 44 additions & 5 deletions mcxtrace-comps/optics/Filter.comp
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@
* Release: McXtrace 1.1
*
* Block of an attenuating material
*
*
* %Description
* A chunk of attenuating material. Attenuation is computed through
* the effective length travelled within the material.
* the effective length travelled within the material.
* No scattering is modelled at present.
*
* Filter shape may be a cylinder, a sphere, a box or any other shape.
* box/plate: xwidth x yheight x zdepth
* box/plate: xwidth x yheight x zdepth
* cylinder: radius x yheight (along Y axis)
* sphere: radius
* any shape: geometry=OFF/PLY_file
*
* Example: Filter(material_datafile="Ge.txt",
* geometry="wire.ply",xwidth=0.02,yheight=0,zdepth=0)
* Example: Filter(material_datafile="Ge.txt",xwidth=0.02,yheight=0.02, zdepth=1e-4)
* Example: Filter(material_datafile="Ge.txt",radius=1e-4,yheight=0.02)
* Example: Filter(material_datafile="Ge.txt",radius=1e-3, refraction=1)
*
* %Parameters
* INPUT PARAMETERS
Expand All @@ -46,7 +49,7 @@
* %Link
* Geomview and Object File Format (OFF) <http://www.geomview.org>
* %Link
* Java version of Geomview (display only) jroff.jar <http://www.holmes3d.net/graphics/roffview/>
* Java version of Geomview (display only) jroff.jar <http://www.holmes3d.net/graphics/roffview/>
* %Link
* qhull <http://qhull.org>
* %Linkink
Expand All @@ -60,7 +63,7 @@ DEFINE COMPONENT Filter
SETTING PARAMETERS (refraction=1,fixed_delta=0,string material_datafile="Be.txt",
string geometry=0,xwidth=0,yheight=0,zdepth=0,radius=0)

/* X-ray parameters: (x,y,z,kx,ky,kz,phi,t,Ex,Ey,Ez,p) */
/* X-ray parameters: (x,y,z,kx,ky,kz,phi,t,Ex,Ey,Ez,p) */

SHARE
%{
Expand Down Expand Up @@ -223,6 +226,24 @@ TRACE
nz = 1.0;
};
break;
case SPHERE:
nx = x;
ny = y;
nz = z;
NORM (nx, ny, nz);
break;
case CYLINDER:
if (fabs (y - yheight * 0.5) < FLT_EPSILON || fabs (y + yheight * 0.5) < FLT_EPSILON) {
x = 0.0;
y = 1.0;
z = 0.0;
} else {
nx = x;
nz = z;
ny = 0.0;
NORM (nx, ny, nz);
}
break;
default:
1;
}
Expand Down Expand Up @@ -265,6 +286,24 @@ TRACE
nz = 1.0;
};
break;
case SPHERE:
nx = x;
ny = y;
nz = z;
NORM (nx, ny, nz);
break;
case CYLINDER:
if (fabs (y - yheight * 0.5) < FLT_EPSILON || fabs (y + yheight * 0.5) < FLT_EPSILON) {
x = 0.0;
y = 1.0;
z = 0.0;
} else {
nx = x;
nz = z;
ny = 0.0;
NORM (nx, ny, nz);
}
break;
default:
1;
}
Expand Down
12 changes: 6 additions & 6 deletions mcxtrace-comps/sources/Source_div.comp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Component: Source_div
*
* %Identification
* Written by: Erik Knudsen
* Written by: Erik Knudsen
* Date: November 11, 2009
* Origin: Risoe
* Release: McXtrace 0.1
Expand All @@ -21,9 +21,9 @@
* in the range [-focus_ax,focus_ay]. If gauss is set, the focux_ax,focus_ay is considered
* the standard deviation of the gaussian profile.
* Currently focussing is only active for flat profile. The "focus window" is defined by focus_xw,focus_yh and dist.
* The spectral intensity profile is uniformly distributed in the energy interval defined by e0+-dE/2 or
* The spectral intensity profile is uniformly distributed in the energy interval defined by e0+-dE/2 or
* by wavelength lambda0+-dlambda/2
*
*
* Example: Source_div(xwidth=0.1, yheight=0.1, focus_aw=2, focus_ah=2, E0=14, dE=2, gauss=0)
*
* %Parameters
Expand All @@ -35,7 +35,7 @@
* focus_yh: [m] Height of sampling window
* dist: [m] Downstream distance to place sampling target window
* E0: [keV] Mean energy of X-rays.
* dE: [keV] Energy half spread of X-rays. If gauss==0 dE is the half-spread, i.e. E\in[E0-dE,E0+dE], if gauss!=0 it's interpreted as the standard dev.
* dE: [keV] Energy half spread of X-rays. If gauss==0 dE is the half-spread, i.e. E\in[E0-dE,E0+dE], if gauss!=0 it's interpreted as the standard dev.
* lambda0: [AA] Mean wavelength of X-rays (only relevant for E0=0).
* dlambda: [AA] Wavelength half spread of X-rays.
* gauss: [1] Criterion: 0: uniform, 1: Gaussian distribution of energy/wavelength.
Expand All @@ -57,7 +57,7 @@ SETTING PARAMETERS (string spectrum_file="NULL", xwidth=0, yheight=0, dist=0,
focus_xw=0, focus_yh=0,focus_aw=0, focus_ah=0, focus_ar=0, radius=0,
E0=0, dE=0, lambda0=0, dlambda=0, flux=0, gauss=0, gauss_a=0, int randomphase=1, phase=0, int verbose=0)

/* X-ray parameters: (x,y,z,kx,ky,kz,phi,t,Ex,Ey,Ez,p) */
/* X-ray parameters: (x,y,z,kx,ky,kz,phi,t,Ex,Ey,Ez,p) */

SHARE
%{
Expand Down Expand Up @@ -133,7 +133,7 @@ INITIALIZE
pmul *= 1.0 / ((double)mcget_ncount ());

if (dist == 0 && (focus_xw != 0 || focus_yh != 0)) {
fprintf (stderr, "ERROR (%s): Cannot have focus sampling window (focus_xw x focus_yh) = (%g x %g) with dist=0.\n", NAME_CURRENT_COMP);
fprintf (stderr, "ERROR (%s): Cannot have focus sampling window (focus_xw x focus_yh) = (%g x %g) with dist=0.\n", NAME_CURRENT_COMP, focus_xw, focus_yh);
exit (-1);
}

Expand Down
Loading