/*******************************************************************************
*         McXtrace instrument definition URL=http://www.mcxtrace.org
*
* Instrument: Pump_probe
*
* %Identification
* Written by: Erik B Knudsen
* Date: 2013
* Origin: DTU Fysik
* Version: 0.2
* %INSTRUMENT_SITE: DTU
*
* Design study of a pump and probe type instrument. The sample is an excitable molecule
*
* Instrument short description
*
* %Description
* Instrument longer description (type, elements, usage...)
*
* %Example: Pump_probe.instr Dt=2e-9 Detector: 1dpsd_I=1.7077e-28
*
* %Parameters
* excitation_prob: [1] Fraction of the molecules in solution that are excited at t=0.
* Dt: [1] Time delay between laser pulse exciting the sample and the x-ray pulse.
* PMN: [deg.] Minimum scatterign angle to be sampled
* PMX: [deg.] Maximum scattering angle to be sampled
* 
* %End
*******************************************************************************/

/* Change name of instrument and input parameters with default values */
DEFINE INSTRUMENT Pump_probe(excitation_prob=0.2, Dt=100e-9, PMN=0, PMX=45)

/* The DECLARE section allows us to declare variables or  small      */
/* functions in C syntax. These may be used in the whole instrument. */
DECLARE
%{
%}

/* The INITIALIZE section is executed when the simulation starts     */
/* (C code). You may use them as component parameter values.         */
INITIALIZE
%{
%}

/* Here comes the TRACE section, where the actual      */
/* instrument is defined as a sequence of components.  */
TRACE

/* The Arm() class component defines reference points and orientations  */
/* in 3D space. Every component instance must have a unique name. Here, */
/* Origin is used. This Arm() component is set to define the origin of  */
/* our global coordinate system (AT (0,0,0) ABSOLUTE). It may be used   */
/* for further RELATIVE reference, Other useful keywords are : ROTATED  */
/* EXTEND GROUP PREVIOUS. Also think about adding an xray source !    */
/* Progress_bar is an Arm displaying simulation progress.               */
COMPONENT Origin = Progress_bar()
AT (0,0,0) ABSOLUTE

COMPONENT src=Source_pt(focus_xw=1e-4,focus_yh=1e-4,dist=10,E0=7.5, dE=0.0005, gauss=1, flux=1)
AT(0,0,0) RELATIVE Origin

COMPONENT emon_src=E_monitor(filename="emon_src",xwidth=0.01,yheight=0.01,Emin=7.49,Emax=7.51)
AT(0,0,1e-3) RELATIVE PREVIOUS

COMPONENT lmon_src=L_monitor(filename="lmon_src",xwidth=0.01,yheight=0.01, Lmin=0.8,Lmax=10)
AT(0,0,1e-3) RELATIVE PREVIOUS

COMPONENT ap1 = Slit(
  xwidth = 2e-2, yheight = 2e-2)
AT (0, 0, 10) RELATIVE src

COMPONENT pulse_shape_chop = Chopper_simple(
  t0 = -0.5/M_C, T = 20e-6, tau = 100e-12, xwidth = 1e-4,
  yheight = 1e-4, isfirst = 1)
AT (0, 0, 0.5) RELATIVE ap1

COMPONENT sample_pos = Arm()
  AT (0,0,0.5) RELATIVE PREVIOUS

COMPONENT sample=Molecule_2state(
  nq=512,state_0_file="Fe_bpy_GS_DFT.txt",state_1_file="Fe_bpy_ES_DFT.txt",radius=0.01,
  psimin=PMN*DEG2RAD, psimax=PMX*DEG2RAD, etamin=-1*DEG2RAD,etamax=1*DEG2RAD,
  t_relax=600e-12, delta_t=Dt, excitation_yield=excitation_prob
)
AT(0,0,0) RELATIVE sample_pos
EXTEND
%{
  if (!SCATTERED) ABSORB;
%}

COMPONENT psd4pi=PSD_monitor_4PI(
  restore_xray=1,radius=0.3,filename="4pi.dat")
AT(0,0,0) RELATIVE PREVIOUS

COMPONENT bananapsd=Monitor_nD(
  options="banana theta limits=[0,45] bins=201", filename="bananapsd", radius=0.49, yheight=0.02)
AT(0,0,0) RELATIVE PREVIOUS

COMPONENT  1dpsd=PSD_monitor(
  restore_xray=1,yheight=0.02,xwidth=0.5,nx=200,ny=1,filename="linepsd.dat")
AT(0.25,0,.5) RELATIVE PREVIOUS




/* This section is executed when the simulation ends (C code). Other    */
/* optional sections are : SAVE                                         */
FINALLY
%{
%}
/* The END token marks the instrument definition end */
END

