/* Change name of instrument and input parameters with default values */ DEFINE INSTRUMENT test(Par1=1) /* The DECLARE section allows us to declare variables or small */ /* functions in C syntax. These may be used in the whole instrument. */ DECLARE %{ void FeCoVupRef(double q, double *par, double *r) { double p1 = 0.99; if (q >= 0.0218 && q<0.0559){ p1 *= -6.6785*q+1.1001; } else if (q >= 0.0559 && q<0.061){ p1 *= 6700.8*q*q-959.44*q+33.616; } else if (q >= 0.061){ p1 *= 8.55345e-29*pow(q,-22.157); } if (p1<1.0e-8){ *r=0.0; return; } else if(p1 > 0.99) { p1=0.99; } *r=p1; return; } void FeCoVdownRef(double q, double *par, double *r) { double p1 = 0.99; if (q >= 0.0022 && q<0.02){ p1 *= 5.3584e-5*pow(q,-1.5151); } else if (q >= 0.02 && q<0.061){ p1 *= 4.8242e-4*pow(q,-0.94321); }else if (q >= 0.061){ p1 *= 1.62308e-31*pow(q,23.6012); } if (p1<1.0e-8){ *r=0.0; return; } else if(p1 > 0.99) { p1=0.99; } *r=p1; return; } %} /* 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 a neutron source ! */ /* Progress_bar is an Arm displaying simulation progress. */ COMPONENT Origin = Progress_bar() AT (0,0,0) ABSOLUTE COMPONENT source1 = Source_simple( height = 0.1, width = 0.1, dist = 4.0, xw = 0.03, yh = 0.03, Lambda0 = 7.5, dLambda = 7.0) AT (0.0, 0.0, 0.001) RELATIVE Origin COMPONENT polariser1 = Pol_bender(xw = 0.03, yh = 0.03, length = 3.5, radius = 100000.0, rTopUpFunc = StdReflecFunc, rTopDownFunc = StdReflecFunc, rTopUpPar = {0.99, 0.0219, 6.07, 1.0, 0.003}, rTopDownPar = rTopUpPar, rBotUpFunc = rTopUpFunc, rBotDownFunc = rTopDownFunc, rBotUpPar = rTopUpPar, rBotDownPar = rTopUpPar, rRightUpFunc = FeCoVupRef, rRightDownFunc = FeCoVdownRef, rRightUpPar = {1.0}, rRightDownPar = {1.0}, rLeftUpFunc = rRightUpFunc, rLeftDownFunc = rRightDownFunc, rLeftUpPar = rRightUpPar, rLeftDownPar = rRightDownPar, nslits = 1, wspacer = 0.0005, drawOption = 3, //drawOption (1-3) debug=0) AT (0.0, 0.0, 4.0) RELATIVE Origin COMPONENT psd1 = PSD_monitor( nx = 100, ny = 100, filename = "PSD1.dat", xwidth = 0.1, yheight = 0.1) AT (0.0 , 0.0, 8.0) RELATIVE Origin COMPONENT lmon1 = L_monitor( nchan = 200, filename = "lmon1.dat", xwidth = 0.1, yheight = 0.1, Lmin = 0.0, Lmax = 15.0) AT (0.0, 0.0, 0.0001) RELATIVE psd1 COMPONENT polmon1 = PolLambda_monitor( xw = 0.1, yh = 0.1, nlam = 100, npol = 100, filename = "polmon1.dat", my = 1, Lmin = 0.0, Lmax = 15.0) AT (0.0, 0.0, 0.0001) RELATIVE lmon1 COMPONENT polmon2 = MeanPolLambda_monitor( xw = 0.1, yh = 0.1, nlam = 100, filename = "polmon2.dat", my = 1, Lmin = 0.0, Lmax = 15.0) AT (0.0, 0.0, 0.0001) RELATIVE polmon1 /* 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