Skip to content
8 changes: 7 additions & 1 deletion mcstas-comps/contrib/Conics_EH.comp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
* alpha: [AA] Slope of reflectivity for reflectivity curve approximation
* W: [AA^-1] Width of supermirror cut-off
* transmit: [1] Fraction of statistics to assign to transmitted beam - NOT YET IMPLEMENTED
* sigma_m: [rad] RMS meridional slope (figure) error of the mirror surfaces
* sigma_s: [rad] RMS sagittal slope (figure) error of the mirror surfaces
* mirr_thick: [m] Thickness of mirror shell surfaces - NOT YET IMPLEMENTED
* %End
*
Expand All @@ -51,7 +53,7 @@ DEFINE COMPONENT Conics_EH
SETTING PARAMETERS (
rmin=0.0031416, rmax=0.05236,focal_length_u=10, focal_length_d=10, le=0.25, lh=0.25,
int nshells=4, m=1, mirr_thick=0, int disk=1, vector radii=NULL,
R0 = 0.99, Qc = 0.021, W = 0.003, alpha = 6.07, transmit = 0)
R0 = 0.99, Qc = 0.021, W = 0.003, alpha = 6.07, transmit = 0, sigma_m=1e-6, sigma_s=250e-6)

SHARE
%{
Expand Down Expand Up @@ -106,6 +108,10 @@ INITIALIZE
addHyperboloid (focal_length_d, focal_length_d + 2.0 * cH, pi, 0, lh, m, R0, Qc, alpha, W, &s);
}
}
for (i = 0; i < s.num_c; i++) {
s.c[i].figerr_m = sigma_m;
s.c[i].figerr_s = sigma_s;
}
if (disk) {
addDisk (pm->zs, 0.0, rConic (pm->ze, *pm), &s);
}
Expand Down
8 changes: 7 additions & 1 deletion mcstas-comps/contrib/Conics_HE.comp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
* alpha: [AA] Slope of reflectivity for reflectivity curve approximation
* W: [AA^-1] Width of supermirror cut-off
* transmit: [1] Fraction of statistics to assign to transmitted beam - NOT YET IMPLEMENTED
* sigma_m: [rad] RMS meridional slope (figure) error of the mirror surfaces
* sigma_s: [rad] RMS sagittal slope (figure) error of the mirror surfaces
* mirr_thick: [m] Thickness of mirror shell surfaces - NOT YET IMPLEMENTED
* %End
*
Expand All @@ -51,7 +53,7 @@ DEFINE COMPONENT Conics_HE
SETTING PARAMETERS (
rmin=0.0031416, rmax=0.05236,focal_length_u=10, focal_length_d=10, le=0.25, lh=0.25,
int nshells=4, m=1, mirr_thick=0, int disk=1, vector radii=NULL,
R0 = 0.99, Qc = 0.021, W = 0.003, alpha = 6.07, transmit = 0)
R0 = 0.99, Qc = 0.021, W = 0.003, alpha = 6.07, transmit = 0, sigma_m=1e-6, sigma_s=250e-6)

SHARE
%{
Expand Down Expand Up @@ -106,6 +108,10 @@ INITIALIZE
addEllipsoid (-focal_length_u - 2.0 * cH, focal_length_d, pi, 0, le, m, R0, Qc, alpha, W, &s);
}
}
for (i = 0; i < s.num_c; i++) {
s.c[i].figerr_m = sigma_m;
s.c[i].figerr_s = sigma_s;
}
if (disk) {
addDisk (pm->zs, 0.0, rConic (pm->ze, *pm), &s);
}
Expand Down
8 changes: 7 additions & 1 deletion mcstas-comps/contrib/Conics_PH.comp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
* alpha: [AA] Slope of reflectivity for reflectivity curve approximation
* W: [AA^-1] Width of supermirror cut-off
* transmit: [1] Fraction of statistics to assign to transmitted beam - NOT YET IMPLEMENTED
* sigma_m: [rad] RMS meridional slope (figure) error of the mirror surfaces
* sigma_s: [rad] RMS sagittal slope (figure) error of the mirror surfaces
* mirr_thick: [m] Thickness of mirror shell surfaces - NOT YET IMPLEMENTED
*
* %L
Expand All @@ -52,7 +54,7 @@ DEFINE COMPONENT Conics_PH
SETTING PARAMETERS (
rmin=0.325,rmax=0.615, focal_length=10.070, lp=0.84, lh=0.84,
int nshells=4, m=1, mirr_thick=0, int disk=1, vector radii=NULL,
R0=0.99, Qc=0.021, W=0.003, alpha=6.07, transmit=0)
R0=0.99, Qc=0.021, W=0.003, alpha=6.07, transmit=0, sigma_m=1e-6, sigma_s=250e-6)

SHARE
%{
Expand Down Expand Up @@ -99,6 +101,10 @@ INITIALIZE
pm = addParaboloid (focal_length + 2.0 * cH, pi, -lp, 0, m, R0, Qc, alpha, W, &s);
addHyperboloid (focal_length, focal_length + 2.0 * cH, pi, 0, lh, m, R0, Qc, alpha, W, &s);
}
for (i = 0; i < s.num_c; i++) {
s.c[i].figerr_m = sigma_m;
s.c[i].figerr_s = sigma_s;
}
if (disk) {
addDisk (pm->zs, 0.0, rConic (pm->ze, *pm), &s);
}
Expand Down
8 changes: 7 additions & 1 deletion mcstas-comps/contrib/Conics_PP.comp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
* alpha: [AA] Slope of reflectivity for reflectivity curve approximation
* W: [AA^-1] Width of supermirror cut-off
* transmit: [1] Fraction of statistics to assign to transmitted beam - NOT YET IMPLEMENTED
* sigma_m: [rad] RMS meridional slope (figure) error of the mirror surfaces
* sigma_s: [rad] RMS sagittal slope (figure) error of the mirror surfaces
* mirr_thick: [m] Thickness of mirror shell surfaces - NOT YET IMPLEMENTED
* %End
*
Expand All @@ -51,7 +53,7 @@ DEFINE COMPONENT Conics_PP
SETTING PARAMETERS (
rmin=0.0031416, rmax=0.05236, focal_length_u=10.070, focal_length_d=10.070, lp1=0.84, lp2=0.84,
int nshells=4, m=1, mirr_thick=0, int disk=1, vector radii=NULL,
R0 = 0.99, Qc = 0.021, W = 0.003, alpha = 6.07, transmit = 0)
R0 = 0.99, Qc = 0.021, W = 0.003, alpha = 6.07, transmit = 0, sigma_m=1e-6, sigma_s=250e-6)

SHARE
%{
Expand Down Expand Up @@ -95,6 +97,10 @@ INITIALIZE
pm = addParaboloid (-focal_length_u, pi, -lp1, 0, m, R0, Qc, alpha, W, &s);
addParaboloid (focal_length_d, pi, 0, lp2, m, R0, Qc, alpha, W, &s);
}
for (i = 0; i < s.num_c; i++) {
s.c[i].figerr_m = sigma_m;
s.c[i].figerr_s = sigma_s;
}
if (disk) {
addDisk (pm->zs, 0.0, rConic (pm->ze, *pm), &s);
}
Expand Down
10 changes: 5 additions & 5 deletions mcstas-comps/contrib/FlatEllipse_finite_mirror.comp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* The component relies on an updated version of conic.h from MIT.
*
* %P
* sourceDist: [m] Distance used for calculating the spacing of the mirrors
* sourceDist: [m] Distance used for calculating the spacing of the mirrors, 0: use LStart
* LStart: [m] Left focal point
* LEnd: [m] Right focal point
* lStart: [m] z-Value of the mirror start
Expand Down Expand Up @@ -86,7 +86,7 @@ SHARE
double*
get_r_at_z0 (int number, double z_0, double r_0, double z_extract, double LStart, double LEnd, double lStart, double lEnd) {
int n = number;
double* r_zExtracts = malloc (n * sizeof (double_t)); /* n is an array of 10 integers */
double* r_zExtracts = malloc (n * sizeof (double)); /* n is an array of 10 integers */
if (!r_zExtracts) {
fprintf (stderr, "NMO comp function get_r_at_z0: malloc() failed. Exit! \n");
exit (-1);
Expand Down Expand Up @@ -143,6 +143,9 @@ DECLARE

INITIALIZE
%{
if (sourceDist == 0) { // default: mirror spacing is calculated for a source at the left focal point
sourceDist = LStart;
}
if (rfront_inner_file && strlen (rfront_inner_file) && strcmp (rfront_inner_file, "NULL") && strcmp (rfront_inner_file, "0")) {
if (Table_Read (&rsTable, rfront_inner_file, 1) <= 0) { /* read 1st block data from file into pTable */
exit (fprintf (stderr, "FlatEllipse_finite_mirror: %s: can not read file %s\n", NAME_CURRENT_COMP, rfront_inner_file));
Expand All @@ -163,9 +166,6 @@ INITIALIZE
rfront_inner = get_r_at_z0 (nummirror, 0, r_0, lStart, sourceDist, LEnd, lStart, lEnd);
// calculate the r-distances of all mirrors at the entry of the NMO, we will need this later
}
if (sourceDist == 0) { // obsolete?
sourceDist = LStart;
}
silicon = (mirror_width == 0) ? 0 : -1; // neutron starts in air by default

// Load Reflectivity Data File TODO
Expand Down
14 changes: 9 additions & 5 deletions mcstas-comps/contrib/Mirror_conic.comp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
* unaffected. Compare with Mirror(transmit=1).
* conic=1: the mirror is a conic.h ConicSurf cylinder of (very large) radius 1 km,
* handled by reflectNeutronConic(), which always reflects and weights by R.
* Compare with Mirror(transmit=0). Note that reflectNeutronConic() absorbs
* neutrons beyond m times the critical angle of Ni (hard cut-off) and
* applies a small hard-coded figure error to the surface normal.
* Compare with Mirror(transmit=0). A Gaussian figure (slope) error can be
* applied via sigma_m and sigma_s; the default is 0 here, whereas the
* Conics_* components default to the conic.h values of 1 and 250 urad.
*
* Example: Mirror_conic(length=1, yheight=0.1, m=2)
*
Expand All @@ -44,13 +44,15 @@
* m: [1] m-value of material
* W: [AA^-1] Width of supermirror cut-off
* conic: [1] 0: use FlatSurf/reflectNeutronFlat(), 1: use ConicSurf/reflectNeutronConic()
* sigma_m: [rad] RMS meridional slope (figure) error, conic=1 only
* sigma_s: [rad] RMS sagittal slope (figure) error, conic=1 only
*
* %E
*******************************************************************************/

DEFINE COMPONENT Mirror_conic

SETTING PARAMETERS (length=1, yheight=0.1, R0=0.99, Qc=0.021, alpha=6.07, m=2, W=0.003, int conic=0)
SETTING PARAMETERS (length=1, yheight=0.1, R0=0.99, Qc=0.021, alpha=6.07, m=2, W=0.003, int conic=0, sigma_m=0, sigma_s=0)

SHARE
%{
Expand Down Expand Up @@ -78,6 +80,8 @@ SHARE
c->alpha = par[2];
c->m = par[3];
c->W = par[4];
c->figerr_m = par[5];
c->figerr_s = par[6];
c->type = PARA;
}
%}
Expand All @@ -95,7 +99,7 @@ INITIALIZE
coordinates; the local mirror plane x=0 is mapped to x=xshift. */
xshift = 1e3;

double par[5] = { R0, Qc, alpha, m, W };
double par[7] = { R0, Qc, alpha, m, W, sigma_m, sigma_s };
mirror_conic_init (&fs, &cs, xshift, length, yheight, par);
%}

Expand Down
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/NMO.comp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* NMO.comp contains no actual code, uses INHERIT of all sections from FlatEllipse_finite_mirror
*
* %P
* sourceDist: [m] Distance used for calculating the spacing of the mirrors
* sourceDist: [m] Distance used for calculating the spacing of the mirrors, 0: use LStart
* LStart: [m] Left focal point
* LEnd: [m] Right focal point
* lStart: [m] z-Value of the mirror start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
* %D
* Example instrument that shows some ways of using the Conics pair components
*
* %Example: Test_Conics_pairs OPTIC=1 Detector: psd_i_I=6.91402e-13
* %Example: Test_Conics_pairs OPTIC=1 Detector: psd_i_reflections_2_I=6.91402e-13
* %Example: Test_Conics_pairs OPTIC=2 fs=100000 Detector: psd_i_I=2.85546e-21
* %Example: Test_Conics_pairs OPTIC=2 fs=100000 Detector: psd_i_reflections_2_I=2.85515e-21
* %Example: Test_Conics_pairs OPTIC=3 Detector: psd_i_I=6.91402e-13
* %Example: Test_Conics_pairs OPTIC=4 ssize=1e-4 Detector: psd_i_I=8.66267e-09
* %Example: Test_Conics_pairs quadratic=1 Detector: psd_i_I=5.03026e-13
* %Example: Test_Conics_pairs quadratic=1 fs=8 fi=6 Detector: psd_i_I=1.26085e-12
* %Example: Test_Conics_pairs OPTIC=2 quadratic=1 fs=100000 Detector: psd_i_I=2.09716e-21
* %Example: Test_Conics_pairs OPTIC=3 quadratic=1 Detector: psd_i_I=5.03026e-13
* %Example: Test_Conics_pairs OPTIC=3 quadratic=1 fs=8 fi=6 Detector: psd_i_I=9.00287e-13
* %Example: Test_Conics_pairs OPTIC=4 quadratic=1 ssize=1e-4 Detector: psd_i_I=6.56678e-09
* %Example: Test_Conics_pairs OPTIC=1 Detector: psd_i_I=6.71864e-13
* %Example: Test_Conics_pairs OPTIC=1 Detector: psd_i_reflections_2_I=6.71864e-13
* %Example: Test_Conics_pairs OPTIC=2 fs=100000 Detector: psd_i_I=2.75574e-21
* %Example: Test_Conics_pairs OPTIC=2 fs=100000 Detector: psd_i_reflections_2_I=2.75574e-21
* %Example: Test_Conics_pairs OPTIC=3 Detector: psd_i_I=6.71864e-13
* %Example: Test_Conics_pairs OPTIC=4 ssize=1e-4 Detector: psd_i_I=8.42691e-09
* %Example: Test_Conics_pairs quadratic=1 Detector: psd_i_I=4.93027e-13
* %Example: Test_Conics_pairs quadratic=1 fs=8 fi=6 Detector: psd_i_I=1.2236e-12
* %Example: Test_Conics_pairs OPTIC=2 quadratic=1 fs=100000 Detector: psd_i_I=2.03618e-21
* %Example: Test_Conics_pairs OPTIC=3 quadratic=1 Detector: psd_i_I=4.93027e-13
* %Example: Test_Conics_pairs OPTIC=3 quadratic=1 fs=8 fi=6 Detector: psd_i_I=8.80918e-13
* %Example: Test_Conics_pairs OPTIC=4 quadratic=1 ssize=1e-4 Detector: psd_i_I=6.41135e-09
*
* %P
* OPTIC: [ ] Flag to choose between 1: EH pair, 2: PH pair, 3: HE pair, 4: PP pair
Expand All @@ -38,13 +38,15 @@
* rmin: [m] Radius of the innermost shell
* rmax: [m] Radius of the outermost shell
* quadratic: [ ] Use the quadratic shell-radius mode instead of the radii vector
* sigma_m: [rad] RMS meridional slope (figure) error of the mirrors
* sigma_s: [rad] RMS sagittal slope (figure) error of the mirrors
*
* %L
* <reference/HTML link>
*
* %E
*******************************************************************************/
DEFINE INSTRUMENT Test_Conics_pairs(int OPTIC=1, ssize=1e-6, fs=10, fi=10, R0=0.99, m=3, W=0.003, alpha=6.07, int nshells=4, rmin=0.0031416, rmax=0.05236, int quadratic=0)
DEFINE INSTRUMENT Test_Conics_pairs(int OPTIC=1, ssize=1e-6, fs=10, fi=10, R0=0.99, m=3, W=0.003, alpha=6.07, int nshells=4, rmin=0.0031416, rmax=0.05236, int quadratic=0, sigma_m=1e-6, sigma_s=250e-6)

DECLARE
%{
Expand Down Expand Up @@ -102,7 +104,7 @@ COMPONENT psd_o0 = PSD_monitor(xwidth=0.12, yheight=0.12, restore_neutron=1,
filename="psd_o0")
AT(0,0,fs) RELATIVE PREVIOUS

COMPONENT cEH = Conics_EH(R0=R0,alpha=alpha,W=W,m=m,
COMPONENT cEH = Conics_EH(R0=R0,alpha=alpha,W=W,m=m, sigma_m=sigma_m, sigma_s=sigma_s,
nshells=nshells, focal_length_u=fs, focal_length_d=fi, radii=radii, le=0.25, lh=0.25, disk=1
)
WHEN(OPTIC==1 && !quadratic) AT(0,0,fs) RELATIVE ss
Expand All @@ -111,7 +113,7 @@ EXTEND
number_of_reflections = SCATTERED - 1;
%}

COMPONENT cEH_quadratic = Conics_EH(R0=R0,alpha=alpha,W=W,m=m,
COMPONENT cEH_quadratic = Conics_EH(R0=R0,alpha=alpha,W=W,m=m, sigma_m=sigma_m, sigma_s=sigma_s,
nshells=nshells, focal_length_u=fs, focal_length_d=fi, rmin=rmin, rmax=rmax, le=0.25, lh=0.25, disk=1
)
WHEN(OPTIC==1 && quadratic) AT(0,0,fs) RELATIVE ss
Expand All @@ -120,7 +122,7 @@ EXTEND
number_of_reflections = SCATTERED - 1;
%}

COMPONENT cPH = Conics_PH(R0=R0,alpha=alpha,W=W,m=m,
COMPONENT cPH = Conics_PH(R0=R0,alpha=alpha,W=W,m=m, sigma_m=sigma_m, sigma_s=sigma_s,
nshells=nshells, focal_length=fi, radii=radii, lp=0.25, lh=0.25, disk=0
)
WHEN(OPTIC==2 && !quadratic) AT(0,0,fs) RELATIVE ss
Expand All @@ -129,7 +131,7 @@ EXTEND
number_of_reflections = SCATTERED - 1;
%}

COMPONENT cPH_quadratic = Conics_PH(R0=R0,alpha=alpha,W=W,m=m,
COMPONENT cPH_quadratic = Conics_PH(R0=R0,alpha=alpha,W=W,m=m, sigma_m=sigma_m, sigma_s=sigma_s,
nshells=nshells, focal_length=fi, rmin=rmin, rmax=rmax, lp=0.25, lh=0.25, disk=0
)
WHEN(OPTIC==2 && quadratic) AT(0,0,fs) RELATIVE ss
Expand All @@ -138,7 +140,7 @@ EXTEND
number_of_reflections = SCATTERED - 1;
%}

COMPONENT cHE = Conics_HE(R0=R0,alpha=alpha,W=W,m=m,
COMPONENT cHE = Conics_HE(R0=R0,alpha=alpha,W=W,m=m, sigma_m=sigma_m, sigma_s=sigma_s,
nshells=nshells, focal_length_u=fs, focal_length_d=fi, radii=radii, le=0.25, lh=0.25, disk=1
)
WHEN(OPTIC==3 && !quadratic) AT(0,0,fs) RELATIVE ss
Expand All @@ -147,7 +149,7 @@ EXTEND
number_of_reflections = SCATTERED - 1;
%}

COMPONENT cHE_quadratic = Conics_HE(R0=R0,alpha=alpha,W=W,m=m,
COMPONENT cHE_quadratic = Conics_HE(R0=R0,alpha=alpha,W=W,m=m, sigma_m=sigma_m, sigma_s=sigma_s,
nshells=nshells, focal_length_u=fs, focal_length_d=fi, rmin=rmin, rmax=rmax, le=0.25, lh=0.25, disk=1
)
WHEN(OPTIC==3 && quadratic) AT(0,0,fs) RELATIVE ss
Expand All @@ -156,7 +158,7 @@ EXTEND
number_of_reflections = SCATTERED - 1;
%}

COMPONENT cPP = Conics_PP(R0=R0,alpha=alpha,W=W,m=m,
COMPONENT cPP = Conics_PP(R0=R0,alpha=alpha,W=W,m=m, sigma_m=sigma_m, sigma_s=sigma_s,
nshells=nshells, focal_length_u=fs, focal_length_d=fi, radii=radii, lp1=0.25, lp2=0.25, disk=0
)
WHEN(OPTIC==4 && !quadratic) AT(0,0,fs) RELATIVE ss
Expand All @@ -165,7 +167,7 @@ EXTEND
number_of_reflections = SCATTERED - 1;
%}

COMPONENT cPP_quadratic = Conics_PP(R0=R0,alpha=alpha,W=W,m=m,
COMPONENT cPP_quadratic = Conics_PP(R0=R0,alpha=alpha,W=W,m=m, sigma_m=sigma_m, sigma_s=sigma_s,
nshells=nshells, focal_length_u=fs, focal_length_d=fi, rmin=rmin, rmax=rmax, lp1=0.25, lp2=0.25, disk=0
)
WHEN(OPTIC==4 && quadratic) AT(0,0,fs) RELATIVE ss
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
* COMP=2: Mirror, transmit=0 (reference for COMP=3)
* COMP=3: Mirror_conic, conic=1 (ConicSurf, reflectNeutronConic)
*
* COMP=0 and COMP=1 should agree exactly. COMP=3 agrees with COMP=2 except above
* the cut-off: reflectNeutronConic() absorbs neutrons with grazing angles beyond
* m times the critical angle of Ni, whereas Mirror keeps the tail of width W.
* COMP=0 and COMP=1 should agree exactly, and so should COMP=2 and COMP=3 when
* no figure error is applied (sigma_m=sigma_s=0).
*
* %Example: COMP=0 Detector: L_refl_I=8.98208e-07
* %Example: COMP=1 Detector: L_refl_I=8.98208e-07
* %Example: COMP=0 Detector: L_trans_I=7.01789e-07
* %Example: COMP=1 Detector: L_trans_I=7.01789e-07
* %Example: COMP=2 Detector: L_refl_I=8.9763e-07
* %Example: COMP=3 Detector: L_refl_I=8.83094e-07
* %Example: COMP=3 Detector: L_refl_I=8.9763e-07
*
* %P
* COMP: [1] Mirror implementation, see description
Expand All @@ -43,10 +42,12 @@
* W: [AA^-1] Width of supermirror cut-off
* Lmin: [AA] Minimum source wavelength
* Lmax: [AA] Maximum source wavelength
* sigma_m: [rad] RMS meridional slope (figure) error, COMP=3 only
* sigma_s: [rad] RMS sagittal slope (figure) error, COMP=3 only
*
* %E
*******************************************************************************/
DEFINE INSTRUMENT Test_Mirror_conic(int COMP=0, theta=1, length=1, m=2, R0=0.99, Qc=0.0217, alpha=6.07, W=0.003, Lmin=1, Lmax=11)
DEFINE INSTRUMENT Test_Mirror_conic(int COMP=0, theta=1, length=1, m=2, R0=0.99, Qc=0.0217, alpha=6.07, W=0.003, Lmin=1, Lmax=11, sigma_m=0, sigma_s=0)

DECLARE
%{
Expand Down Expand Up @@ -104,7 +105,7 @@ AT (0, 0, length/2) RELATIVE mirror_arm
ROTATED (0, 90, 0) RELATIVE mirror_arm

COMPONENT mirror_conic_conic = Mirror_conic(length=length, yheight=0.1, conic=1,
R0=R0, Qc=Qc, alpha=alpha, m=m, W=W)
R0=R0, Qc=Qc, alpha=alpha, m=m, W=W, sigma_m=sigma_m, sigma_s=sigma_s)
WHEN (COMP==3)
AT (0, 0, 0) RELATIVE mirror_arm

Expand Down
Loading
Loading