McStasMcXtrace / McCode

The home of the McStas (neutrons) and McXtrace (x-rays) Monte-Carlo ray-tracing instrument simulation codes.
https://github.com/McStasMcXtrace/McCode/wiki
GNU General Public License v3.0
77 stars 54 forks source link

Scattering in Abs_objects #1620

Open vribgar opened 4 months ago

vribgar commented 4 months ago

Hi! We are launching simulations and using samples designed by us (in Blender 4.0), saved in .ply format and stored in a .dat file, as shown in the following code:

DEFINE INSTRUMENT CamaraTDI(string SFILE="carne_template_3.dat", string SFILE2="placa.dat",ANGLE=0, posX=0, posY=0, posZ=0, Ncount=0) DEPENDENCY " -DLOADPATH=@MCCODE_LIB@/data "

DECLARE %{ unsigned long long phid;

double deth, detw; double troh=1.4; double trow=0.6;

int dNx, dNy; %}

INITIALIZE %{ / set some geometry parameters / double s=1;

deth=sdNy1e-3; // Altura del detector 1 m detw=sdNx1e-3; // Anchura del detector 1 m

if (Ncount>0) mcset_ncount(Ncount); %}

TRACE

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

// Aumentar la energa de la fuente para mejorar la penetracion en materiales de alto Z

COMPONENT source = Source_div(E0=20, dE=0.1, xwidth=0.7, yheight=0.8, focus_aw=0.001, focus_ah=0, dist=0.625) AT(0,0,0) RELATIVE Origin

COMPONENT sample_scan=Abs_objects(objects=SFILE) AT (0,0,0.4525) RELATIVE Origin ROTATED (0, 0, 0) RELATIVE Origin

COMPONENT sample_Pb=Abs_objects(objects=SFILE2) AT (0.00025,0,0.6) RELATIVE Origin ROTATED (0, 0, 0) RELATIVE Origin

COMPONENT psd2 = PSD_monitor(restore_xray=1, nx=64, ny=6680, filename="tdi.dat", xwidth=0.0064, yheight=0.6655) AT (0,0,0.652) RELATIVE Origin

END

This is the graphical representation (XY view): Captura de pantalla 2024-05-28 142429

As you can see, the sample to scan is defined as Abs_objects:

COMPONENT sample_scan=Abs_objects(objects=SFILE) AT (0,0,0.4525) RELATIVE Origin ROTATED (0, 0, 0, 0) RELATIVE Origin

But we are really interested in measuring the scattered radiation reaching the detector. Is this being taken into account? Or are only the X-rays that are attenuated by the sample being recorded in the detector?

Thank you so much for your attention.

Regards, Verónica.

vribgar commented 4 months ago

Also, considering that we want to detect scattered radiation, should we change the type of detector? (PSD_monitor is being used)

farhi commented 3 months ago

Hello @vribgar, The Abs_object sample is not suited to "scatter" x-rays. As you envisage, this component only absorbs (removes) X-rays.

I would suggest that you try the Fluorescence sample, that has a very similar syntax, does handle absorption and scattering, and can make use of PLY/OFF just as Abs_object. In addition, the material files do not need to be prepared. A simple chemical formulae is used.

Look into the Test_Absorption example for a comparison between all absorbing components.

vribgar commented 3 weeks ago

Hello again! Could you provide an example where Fluorescence sample is used with .PLY geometries ? I have tried some examples (content of the Sferes_templ_fl.dat file from where the geometry is read):

5 esf_mod.ply C2H5OH 1 0 0.0 0 0 0 0 0 0 0 esf_1_mod.ply Ca 1 0 0.0 0 0 0 0 0 0 0 0 esf_2_mod.ply Si 1 0.0 0 0 0 0 0 0 0 0 esf_3_mod.ply Al 1 0.0 0 0 0 0 0 0 0 0 esf_4_mod.ply Pb 1 0 0.0 0 0 0 0 0 0 0 0

but I am getting problems: “Loading geometry file (OFF/PLY): Sferes_templ_fl.dat Error: Sferes_templ_fl.dat is probably not an OFF, NOFF or PLY file (interoff/off_getBlocksIndex). Requires first line to be 'OFF', '3' or 'ply'. Fluorescence: sample_scan: sample has invalid dimensions. ERROR Please check parameter values (xwidth, yheight, zdepth, radius).”

I also provide you how I am defining the Fluorescence component, in case it would be helpful to solve the problem: COMPONENT sample_scan = Fluorescence( geometry=SFILE, material=“C2H5OH,Ca,Si,Al,Pb”, focus_xw=0.1, focus_yh=0.6655, target_index=1, focus_aw=0, focus_ah=0, p_interact=0.8) AT (0,0,0.4525) RELATIVE Origin ROTATED (0, 0, 0, 0) RELATIVE Origin , where SFILE = “Sferes_templ_fl.dat”.

Thank you very much for your attention.

vribgar commented 2 weeks ago

I finally managed to launch an example, using this syntax in the instrument file:
DEFINE INSTRUMENT CamaraTDI_fl(string esf_0="esf_mod.ply", string esf_1="esf_1_mod.ply", string esf_2="esf_2_mod.ply", string esf_3="esf_3_mod.ply", string esf_4="esf_4_mod.ply", string grid="placa_grande_1.ply", ANGLE=0, posX=0, posY=0, posZ=0, Ncount=0)

DECLARE %{ unsigned long long phid;

double deth, detw; double troh=1.4; double trow=0.6;

int dNx, dNy; %}

INITIALIZE %{ / set some geometry parameters / double s=1;

deth=sdNy1e-3; // Altura del detector 1 m detw=sdNx1e-3; // Anchura del detector 1 m

if (Ncount>0) mcset_ncount(Ncount); %}

TRACE

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

// Aumentar la energa de la fuente para mejorar la penetracion en materiales de alto Z

COMPONENT source = Source_div(E0=20, dE=0.1, xwidth=0.7, yheight=0.8, focus_aw=0.001, focus_ah=0, dist=0.625) AT(0,0,0) RELATIVE Origin

//COMPONENT fluorescence_sample = Fluorescence(geometry=SFILE) //AT (0, 0, 0.4525) RELATIVE Origin ROTATED (0, 0, 0) RELATIVE Origin

//COMPONENT fluorescence_grid = Fluorescence(geometry=SFILE2) //AT (0.00025,0,0.6) RELATIVE Origin ROTATED (0, 0, 0) RELATIVE Origin

COMPONENT sample_scan_0 = Fluorescence( geometry=esf_0, material="C2H5OH", focus_xw=0.1, focus_yh=0.6655, target_index=1, focus_aw=0, focus_ah=0, p_interact=0.8) AT (0,0,0.4525) RELATIVE Origin ROTATED (0, 0, 0) RELATIVE Origin

COMPONENT sample_scan_1= Fluorescence( geometry=esf_1, material="Ca", focus_xw=0.1, focus_yh=0.6655, target_index=1, focus_aw=0, focus_ah=0, p_interact=0.8) AT (0,0,0.4525) RELATIVE Origin ROTATED (0, 0, 0) RELATIVE Origin

COMPONENT sample_scan_2 = Fluorescence( geometry=esf_2, material="Si", focus_xw=0.1, focus_yh=0.6655, target_index=1, focus_aw=0, focus_ah=0, p_interact=0.8) AT (0,0,0.4525) RELATIVE Origin ROTATED (0, 0, 0) RELATIVE Origin

COMPONENT sample_scan_3 = Fluorescence( geometry=esf_3, material="Al", focus_xw=0.1, focus_yh=0.6655, target_index=1, focus_aw=0, focus_ah=0, p_interact=0.8) AT (0,0,0.4525) RELATIVE Origin ROTATED (0, 0, 0) RELATIVE Origin

COMPONENT sample_scan_4 = Fluorescence( geometry=esf_4, material="Pb", focus_xw=0.1, focus_yh=0.6655, target_index=1, focus_aw=0, focus_ah=0, p_interact=0.8) AT (0,0,0.4525) RELATIVE Origin ROTATED (0, 0, 0) RELATIVE Origin

COMPONENT sample_Pb = Fluorescence( geometry=grid, material="Pb", focus_xw=0.1, focus_yh=0.6655, target_index=1, focus_aw=0, focus_ah=0, p_interact=0.8) AT (0.00025,0,0.6) RELATIVE Origin ROTATED (0, 0, 0) RELATIVE Origin

COMPONENT psd2 = PSD_monitor(restore_xray=1, nx=1000, ny=6680, filename="tdi.dat", xwidth=0.1, yheight=0.6655) AT (0,0,0.652) RELATIVE Origin

END

But I do not know how to interpret the results obtained:
image

Could you confirm that I have used the syntax correctly and that this is an expected result, considering I have taken into account the 'Fluorescence sample'?

Thank you so much.

farhi commented 2 weeks ago

Hello Verónica,

The fluorescence appears indeed as a background in your case. Indeed, the scattering is isotropic in spatial distribution, except for the absorption that may arise from the geometry. In order to check that the fluorescence looks right, you need to add some energy-resolved monitors. With an incoming energi of 20 keV, you should detect most of the fluorescence lines from the materials that compose your complex sample. Beware as well athat, according to your instr file, the samples are all positioned at the same location, and may "shield" each-other. I would rather start with a single material, and gradually add materials around. If you need to stack samples, better use the GROUP or the WHEN keywords.

Cheers, Emmanuel.