/*******************************************************************************
* Instrument: Test_PowderN_porous
*
* %I
* Written by: Peter Willendrup
* Date: Nov 2026
* Origin: DTU
* %INSTRUMENT_SITE: Tests_samples
*
* Test of PowderN_porous: Si matrix with pore channels, water below fill_y
*
* %D
* Si cylinder with pore channels from pores.off (make with make_pores.py, e.g.
* python3 make_pores.py --radius 5e-4 --yheight 2e-3 --diameter 6e-5
*   --diameter_sigma 1e-5 --length 3e-4 --length_sigma 1e-4 --seed 1),
* water in the pores below fill_y. Water is approximated by its oxygen
* (O.txt at 0.888 g/cm^3), hydrogen adds a few % of its attenuation.
* pores="NULL" gives a plain PowderN-like sample.
*
* %Test: Test_PowderN_porous.instr -y Detector: Banana_I=1.42463e-10
*
* %P
* E0: [keV]      Mean energy
* pores: [str]   Pore mesh file, "NULL" for none
* fill_y: [m]    Water level in the pores (local y), sample spans +-0.001
* liquid: [str]  Attenuation table of the liquid in the pores below fill_y, "NULL": void pores
*
* %E
*******************************************************************************/
DEFINE INSTRUMENT Test_PowderN_porous(E0=15, string pores="pores.off", fill_y=0, string liquid="O.txt")

DEPENDENCY " -DGMESH_MAX_HITS=200 "

TRACE

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

COMPONENT Source = Source_flat(xwidth=1e-4, yheight=1e-4, dist=1, focus_xw=1.2e-3, focus_yh=2.2e-3,
  E0=E0, dE=0.01*E0)
AT (0, 0, 0) RELATIVE Origin

COMPONENT Sample = PowderN_porous(reflections="Si.laz", material="Si.txt", mat_format={0,3,0,5,0},
  radius=5e-4, yheight=2e-3, p_transmit=0.5, p_inc=0.1, p_interact=0.3, p_fill=0.1,
  pores=pores, fill_y=fill_y, fill_material=liquid, fill_density=0.888)
AT (0, 0, 1) RELATIVE Source

COMPONENT Banana = Monitor_nD(radius=0.5, yheight=0.1, options="banana, theta limits=[5 175] bins=340", restore_xray=1)
AT (0, 0, 0) RELATIVE Sample

COMPONENT Transm = PSD_monitor(xwidth=2e-3, yheight=3e-3, nx=80, ny=120, restore_xray=1, filename="transm")
AT (0, 0, 0.1) RELATIVE Sample

END
