diff --git a/mcxtrace-comps/examples/Tests_optics/Test_Filter_geom/Test_Filter_geom.instr b/mcxtrace-comps/examples/Tests_optics/Test_Filter_geom/Test_Filter_geom.instr new file mode 100644 index 0000000000..a372ed16e8 --- /dev/null +++ b/mcxtrace-comps/examples/Tests_optics/Test_Filter_geom/Test_Filter_geom.instr @@ -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 diff --git a/mcxtrace-comps/optics/Filter.comp b/mcxtrace-comps/optics/Filter.comp index 5049729ffd..f61137f49f 100644 --- a/mcxtrace-comps/optics/Filter.comp +++ b/mcxtrace-comps/optics/Filter.comp @@ -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 @@ -46,7 +49,7 @@ * %Link * Geomview and Object File Format (OFF) * %Link -* Java version of Geomview (display only) jroff.jar +* Java version of Geomview (display only) jroff.jar * %Link * qhull * %Linkink @@ -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 %{ @@ -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; } @@ -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; } diff --git a/mcxtrace-comps/sources/Source_div.comp b/mcxtrace-comps/sources/Source_div.comp index 01ce37d38d..9b5d1bb5c0 100644 --- a/mcxtrace-comps/sources/Source_div.comp +++ b/mcxtrace-comps/sources/Source_div.comp @@ -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 @@ -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 @@ -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. @@ -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 %{ @@ -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); }