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

Doubt in Test_grating_trans.instr #1594

Open vribgar opened 6 months ago

vribgar commented 6 months ago

Hi! I am using McXtrace for the purpose of simulating X-ray dark field images. For this I need a transmission grating (like the one in the template example Test_grating_trans.instr).

But Test_grating_trans.instr does not include any sample... so we have modified the code and inserted a sphere of ethanol.txt and radius 0.01m (Test_grating_trans_upv.instr). The problem is that we don't know if what is observed in psd_giant when there is sample is what would be expected....

With no sample: Test_grating_no_sample With sample: Testing_grating_sample

Do you have any example where the Grating_trans and an Absorption_sample have been used? When using the grid, the source type has to be Source_div?

I attach the instrument file and the results. Thank you very much for your attention!

Code Test_grating_trans_upv.instr: DEFINE INSTRUMENT Test_grating_trans(E0=1, dE=0.001, GD=1, Rx=0, Ry=0,Rz=0, int MEG=0)

DECLARE %{ %}

INITIALIZE %{ %}

TRACE

COMPONENT origin = Progress_bar() AT (0, 0, 0) RELATIVE ABSOLUTE

// insert components here (e.g. Insert -> Source -> ...) COMPONENT src_div = Source_div(xwidth=2e-8,yheight=0.15, focus_aw=0.001, focus_ah=0, E0=E0, dE=dE) AT(0,0,0) RELATIVE origin

/COMPONENT absorption_sample = Absorption_sample( material_datafile_o="ethanol.txt", radius_o=0.01, yheight_o=0) AT (0, 0, 0.7) RELATIVE origin /

COMPONENT MEG_1a = Arm() AT(0,0,1) RELATIVE origin

COMPONENT MEG_1 = Grating_trans( xwidth=0.15, yheight=0.15, gamma=0.3, period=4000e-10, zdepth=3600e-10, max_order=3, material="Au.txt" ) WHEN(MEG) AT(0,0,0) RELATIVE MEG_1a ROTATED (Rx,Ry,Rz) RELATIVE origin

COMPONENT HEG4 = Grating_trans( xwidth=0.15, yheight=0.15, gamma=0.4, period=2000e-10, zdepth=5100e-10, max_order=3, material="Au.txt" ) WHEN(!MEG) AT(0,0,0) RELATIVE MEG_1a ROTATED(Rx,Ry,Rz) RELATIVE origin

COMPONENT psd_giant = PSD_monitor(xwidth=0.2, yheight=0.2, filename="psd_giant",ny=1000,nx=1000) AT(0,0,GD) RELATIVE MEG_1a

FINALLY %{ %}

END

farhi commented 6 months ago

Hi Veronica,

It looks like Erik has tested this model in the frame of a Chandra study. We have tested the grating_reflect component, but not the one in transmission. However, it looks we actually see the fringes, which is fine to me.

Regarding your EtOH sample, it looks a bit thick (1 cm with X-rays is huge), which actually absorbs the whole beam. I would recommend to rather use the Fluorescence sample which also handles absorption and is much more realistic. The syntax is also more flexible, and you can simply enter the chemical formulae.

vribgar commented 5 months ago

Hi again! as I told you a few weeks ago, my goal is to simulate X-ray dark field images, for which I need a transmission grating (supposedly similar to the one described in test_grating_trans.instr).

I have tried using the Fluorescence sample but I can't see anything in the results obtained from the simulations (attached photo). I don't know exactly what this sample does or what it represents, since with the Mxdisplay I can't see its geometry. Captura de pantalla 2024-04-10 124031

The above simulation has been performed with the characteristics of the grid we want to use specified in the McXtrace code:

COMPONENT MEG_1 = Grating_trans( xwidth=0.15, yheight=0.15, period=32e-5, gamma=0.8, zdepth=2.56e-4,
material="Pb.txt",
max_order=3) AT (0, 0, 0.67) RELATIVE Origin

Next, I attach an image of the result obtained when we do the simulation using a grid designed by us (in Blender, saved in .ply format) with the same characteristics:

Captura de pantalla 2024-04-11 095737

I also don't know how to interpret the results because I don't know what the Fluorescence sample represents....

However, using the grid designed in Blender and considering a simple absorption sample representing a sphere, the following is obtained:

Captura de pantalla 2024-04-11 103119

Which is more similar to what would be expected from the simulation. Then the data recorded in psd2 is processed in order to obtain the X-ray dark field image.

The problem is, that when we use the grid specification COMPONENT MEG_1 = Grating_trans( .... You do NOT get the same as when we use our grid designed in Blender (which is supposed to represent the same thing). We don't know if we are misinterpreting some parameter?

I leave you the specifications of the grid, the .ply and the .dat, as well as the .instr in case you want to check: period = 0.32 mm, width of the strips = 0.256 mm, distance between strips = 0.064 mm, gamma = 0.256/0.32 = 0.8

rejilla_6.zip

DEFINE INSTRUMENT rejilla_muestra(string SFILE2="rejilla.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;

dNy=1000; dNx=1000;

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

COMPONENT source = Source_div(E0=10, dE=0.1, xwidth=2e-1, yheight=0.15, focus_aw=0.001, focus_ah=0, dist=1.3) AT(0,0,0) RELATIVE Origin / COMPONENT source1 = Source_flat(E0=30, dE=0.1, xwidth=1e-3, yheight=1e-3, focus_xw=1, focus_yh=1, dist=1.3) AT(0,0,0) RELATIVE Origin /

COMPONENT sample_mount_point = Arm() AT(0,0,0.55) RELATIVE Origin

COMPONENT absorption_sample = Absorption_sample( material_datafile_o="H2O.txt", radius_o=0.01, yheight_o=0) AT (posX,posY,posZ) RELATIVE sample_mount_point ROTATED (0, 90, 90) RELATIVE Origin

COMPONENT sample_grid=Abs_objects(objects=SFILE2) AT (0,0,0.67) RELATIVE Origin ROTATED (90, 0, 0) RELATIVE Origin

COMPONENT psd2 = PSD_monitor(restore_xray=1, nx=dNx, ny=dNy, filename="psd2.dat", xwidth=0.2, yheight=0.2) AT (0,0,1.3) RELATIVE Origin

END

Thank you very much for your attention!