/*******************************************************************************
* Instrument: McStas_Isotropic_Sqw
*
* %I
* Written by: Peter Willendrup
* Date: December 2018
* Origin: DTU
* %INSTRUMENT_SITE: SINE2020
*
* Wrapper instrument for use of Isotropic_Sqw in SIMRES
*
* %D
* This instrument provides an MCPL-based interface for the use of Isotropic_Sqw in the SIMRES package.
* The instrument has been developed in the context of WP8 in the SINE2020 project and is part of
* deliverable D8.8.
*
* (EU Horizon 2020 research and innovation programme under grant agreement No 654000).
*
* The default material is liquid Rb as a cylinder of radius 0.01 m x height 0.07 m 
*
* Example: McStas_Isotropic_Sqw Sqw_coh=Rb_liq_coh.sqw  Sqw_inc=Rb_liq_inc.sqw radius=0.01 yheight=0.07
*
* %P
* Sqw_coh: 	       [string] Name of the file containing the values of Q, w and S(Q,w) Coherent part; Q in Angs-1, E in meV, S(q,w) in meV-1. Use 0, NULL or "" to disable.
* Sqw_inc: 	       [string] Name of the file containing the values of Q, w and S(Q,w). Incoherent (self) part. Use 0, NULL or "" to scatter isotropically (V-like).
* geometry: 	       [string] Name of an Object File  Format  (OFF)  or  PLY file for complex geometry.
* radius:	       [m]     	Sample radius
* xwidth:	       [m]     	Sample width along x
* yheight:	       [m]	Sample height along y
* zdepth:	       [m]	Sample depth along z
* thickness:	       [m]	Thickness of hollow sample Negative value extends the hollow volume outside of the box/cylinder.
* threshold:	       [m]	Value under which S(Q,w) is not accounted for. to set according to the S(Q,w) values, i.e. not too low.
* T:	               [K]      Temperature of sample, detailed balance. Use T=0 to disable it. and T=-1 to automatically set it from non-classical S(q,w).
* d_phi:	       [deg]	Vertical focusing limit [deg]
* verbose: 	       [1]	Verbosity level (0:silent, 1:normal, 2:verbose, 3:debug). A verbosity>1 also computes dispersions and S(q,w) analysis.
* classical:           [1]	Assumes the S(q,w) data from the files is a classical S(q,w), and multiply that data by exp(hw/2kT) on up/down energy sides. Use 0 when obtained from raw experiments, 1 from molecular dynamics. Use -1 to guess from a data set including both energy sides.
* powder_barns:	       [1]	0 when |F2| data in powder file are fm^2, 1 when in barns (barns=1 for laz, barns=0 for lau type files).
* quantum_correction:  [str]    Specify the type of quantum correction to use "Boltzmann"/"Schofield","harmonic"/"Bader" or "standard"/"Frommhold" (default)
* norm:                [1]      Normalize S(q,w) when -1 (default). Use raw data when 0, multiply S(q,w) when norm>0.
* rot_x:	       [deg]	Sample rotation around x
* rot_y:	       [deg]	Sample rotation around y
* rot_z:	       [deg]	Sample rotation around z
*
* %L
* Website for the <a href="https://mctools.github.io/mcpl">MCPL</a> particle exchange format
* Website for the <a href="http://neutron.ujf.cas.cz/ restrax/">SIMRES</a> package
* Website for <a href="https://www.sine2020.eu/randd-activities/e-tools.html">WP8 in EU-SINE2020</a>
*
* %E
*******************************************************************************/
DEFINE INSTRUMENT McStas_Isotropic_Sqw(string Sqw_coh="Rb_liq_coh.sqw", string Sqw_inc="Rb_liq_inc.sqw", string geometry="", radius=0.01, xwidth=0, yheight=0.07, zdepth=0,
				 thickness=0, threshold=1e-20, T=0, d_phi=0, verbose=1, classical=-1, powder_barns=1, string quantum_correction="standard", norm=-1,
				 rot_x=0, rot_y=0, rot_z=0)

DECLARE
%{
%}

INITIALIZE
%{
%}

TRACE

COMPONENT mcpl_in = MCPL_input(filename="McStas_Isotropic_Sqw_in.mcpl")
AT(0,0,0) ABSOLUTE

COMPONENT Iso = Isotropic_Sqw(Sqw_coh=Sqw_coh, Sqw_inc=Sqw_inc, geometry=geometry,
        radius=radius, xwidth=xwidth, yheight=yheight, zdepth=zdepth,
        thickness=thickness, threshold=threshold, T=T, d_phi=d_phi, verbose=verbose,
	classical=classical, powder_barns=powder_barns,
	quantum_correction=quantum_correction, norm=norm)
AT(0,0,0) ABSOLUTE
ROTATED (rot_x,rot_y,rot_z) ABSOLUTE

COMPONENT mcpl_out = MCPL_output(filename="McStas_Isotropic_Sqw_out.mcpl")
AT(0,0,0) ABSOLUTE

FINALLY
%{
%}

END
