/*******************************************************************************
* Instrument: NECSA_MIXRAD_Nikon_Tomo
*
* %Identification
* Written by: us all at Necsa
* Date: Oct 11th 2024
* Origin: Necsa, ZA
* %INSTRUMENT_SITE: NECSA
*
* Nikon XTH 225 Tomograph
*
* %Description
* This is a simple description of the MIXRAD Nikon X-ray tomograph installed at NECSA, ZA
*
* - The source voltage is 30-225 kV with a electron beam current of 1 mA.
* - Anode material: Mo; Cu; W; Ag
* - The source spot size is 1-3 um.
* - The emission cone is 25 degrees.
* - The detector is 400x400 mm, with a 200 um pixel size (2000x2000).
* - The source-sample distance is at least 61 cm.
* - The source-detector distance is 1.147 m.
*
* Example: <parameters=values>
*
* %Parameters
* Source_material:  [str] source anode, e.g. W.txt
* Emin:             [keV] minimum energy at the source
* Emax:             [keV] maximum energy at the source
* Sample_material:  [str] sample material, e.g. chemical formulae or CIF file
* sample_shape:     [str] OFF/PLY file
* Sample_rotation:  [deg] sample rotation angle around Y vertical
* Sample_distance:  [deg] sample location wrt source. detector fixed at 1.147 m
*
* %L
* https://www.necsa.co.za/service/micro-focus-x-ray-radiography-and-tomography-facility-mixrad/
* %L
* https://www.ndt.net/article/wcndt2012/papers/37_wcndtfinal00037.pdf
*
* %End
*******************************************************************************/
DEFINE INSTRUMENT NECSA_MIXRAD_Nikon_Tomo(string Source_material="W.txt",
  Emin=1, Emax=75, 
  string Sample_material="Fe2O3Au", string sample_shape="king.off",
  Sample_rotation=90, Sample_distance=0.5)
  
INITIALIZE %{
  printf("This is a Nikon XTH 225 Tomograph model, as installed at NECSA, ZA\n");
%}

TRACE

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

COMPONENT anode = Source_lab(
    width=1e-6,height=3e-6,thickness=200e-6,dist=Sample_distance,tube_current=1e-3,
    E0=225,focus_xw=0.2,focus_yh=0.2,
    material_datafile=Source_material,
    Emin=Emin, Emax=Emax)
AT(0,0,0) ABSOLUTE

COMPONENT source_energy_monitor = E_monitor(xwidth=1e-3, yheight=1e-3,
  nE=1001, Emin=Emin, Emax=Emax, restore_xray=1)
AT(0,0,300e-6) RELATIVE anode

// Sample location
COMPONENT Sample_holder = Arm()
AT (0,0,Sample_distance) RELATIVE anode

COMPONENT Sample_input = PSD_monitor(xwidth=0.2, yheight=0.2, nx=128, ny=128,
  restore_xray=1)
AT (0,0,0) RELATIVE Sample_holder

COMPONENT Sample = Fluorescence( 
  material="Mn", 
  xwidth = 0.1, yheight = 0.1, zdepth = 0.1, 
  geometry=sample_shape)
AT (0,0,0) RELATIVE Sample_holder
ROTATED (0, Sample_rotation, 0) RELATIVE Sample_holder

COMPONENT Detector = PSD_monitor(
  xwidth=0.4, yheight=0.4, nx=128, ny=128)
AT (0,0,1.147) RELATIVE anode


END
