Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9fcc2dc
Started work on proper system for surface effects.
mads-bertelsen Jan 2, 2025
a8886bd
Functional refraction and reflection using physics struct created by …
mads-bertelsen Jan 2, 2025
04ed5f8
Functional system for surface effects, though only supports for simpl…
mads-bertelsen Jan 6, 2025
0ccd21c
Intreface physics system now functional for:
mads-bertelsen Jan 20, 2025
96b0905
Further bug fixes of interface system, now in good state where
mads-bertelsen Jan 23, 2025
efeb79c
Currently setups with refraction and reflection in spatially seperate
mads-bertelsen Jan 29, 2025
4debabd
Started work on proper system for surface effects.
mads-bertelsen Jan 2, 2025
c30628a
Functional refraction and reflection using physics struct created by …
mads-bertelsen Jan 2, 2025
d02b846
Functional system for surface effects, though only supports for simpl…
mads-bertelsen Jan 6, 2025
30ec823
Intreface physics system now functional for:
mads-bertelsen Jan 20, 2025
0990a4e
Further bug fixes of interface system, now in good state where
mads-bertelsen Jan 23, 2025
50e92a6
Currently setups with refraction and reflection in spatially seperate
mads-bertelsen Jan 29, 2025
43db2aa
Merge branch 'union_surface' of https://github.com/McStasMcXtrace/McC…
mads-bertelsen Sep 23, 2025
7a9f487
Fixed bugs in union-lib.c relating to calculation of normal vectors f…
mads-bertelsen Sep 23, 2025
2e24992
Fixing focusing issue in Union where ray position was not taken into …
mads-bertelsen Sep 25, 2025
17c87fd
Fix for focusing problem when processes use focus to calculate cross …
mads-bertelsen Oct 27, 2025
69bae7d
Fixed error that occured when using multiple Union_master compoments,
mads-bertelsen Oct 27, 2025
cfa51c9
Fixing headers to render with mcdoc.
mads-bertelsen Oct 27, 2025
f302890
Started work on proper system for surface effects.
mads-bertelsen Jan 2, 2025
669112b
Functional refraction and reflection using physics struct created by …
mads-bertelsen Jan 2, 2025
95b32ee
Functional system for surface effects, though only supports for simpl…
mads-bertelsen Jan 6, 2025
5a01d1a
Intreface physics system now functional for:
mads-bertelsen Jan 20, 2025
f9f7731
Further bug fixes of interface system, now in good state where
mads-bertelsen Jan 23, 2025
f184246
Currently setups with refraction and reflection in spatially seperate
mads-bertelsen Jan 29, 2025
2cfb170
Merge branch 'union_surface' of https://github.com/McStasMcXtrace/McC…
mads-bertelsen Sep 23, 2025
53c9349
Fixed bugs in union-lib.c relating to calculation of normal vectors f…
mads-bertelsen Sep 23, 2025
e0859c7
Fixing focusing issue in Union where ray position was not taken into …
mads-bertelsen Sep 25, 2025
c130d59
Fix for focusing problem when processes use focus to calculate cross …
mads-bertelsen Oct 27, 2025
c5293a2
Fixed error that occured when using multiple Union_master compoments,
mads-bertelsen Oct 27, 2025
ba05137
Fixing headers to render with mcdoc.
mads-bertelsen Oct 27, 2025
770a00b
Merge branch 'union_surface' of https://github.com/McStasMcXtrace/McC…
mads-bertelsen Oct 27, 2025
220c829
Added two examples:
mads-bertelsen Oct 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 235 additions & 0 deletions mcstas-comps/examples/Union_demos/Bispectral/Bispectral.instr
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
/*******************************************************************************
* McStas instrument definition URL=http://www.mcstas.org
*
* Instrument: Bispectral
*
* %Identification
* Written by: Mads Bertelsen (mads.bertelsen@ess.eu)
* Date: October 2025
* Origin: ESS
* %INSTRUMENT_SITE: ESS
*
* Example of bispectral extraction on ESS Butterfly moderator using Union components
*
* %Description
* Bispectral switch conisting of Si blades with supermirror coating and Cu walls,
* with different coatings. Materials are simulated using NCrystal.
*
* Example: mcrun Bispectral.instr l_min=0.5 l_max=6.0
*
* %Parameters
*
* l_min: [AA] Shortest simulated wavelength
* l_max: [AA] Longest simulated wavelength
*
* %Example: l_min=0.5 l_max=6.0 Detector: monitor_L_I=5.10776e+11
*
* %Link
* A reference/HTML link for more information
*
* %End
*******************************************************************************/

DEFINE INSTRUMENT Bispectral(
l_min = 0.5,
l_max = 6.0
)

DECLARE
%{
%}

INITIALIZE
%{
%}

TRACE
COMPONENT Origin = Progress_bar()
AT (0,0,0) ABSOLUTE

COMPONENT Source = ESS_butterfly(
sector = "S", beamline = 2,
yheight = 0.03, cold_frac = 0.5,
target_index = 2,
focus_xw = 0.07, focus_yh = 0.04,
t_performance = 1, c_performance = 1,
Lmin = l_min, Lmax = l_max,
n_pulses = 1, acc_power = 5)
AT (0,0,0) RELATIVE Origin

COMPONENT Start_of_bi = Arm()
AT (0.026,0,2.0306) RELATIVE Source

COMPONENT focus_center = Arm()
AT (-0.008,0,0) RELATIVE Start_of_bi

COMPONENT init = Union_init()
AT (0,0,0) ABSOLUTE

// Union materials, always placed relative to ABSOLUTE
COMPONENT Cu_total = NCrystal_process(
cfg = "Cu_sg225.ncmat;temp=10C")
AT (0,0,0) ABSOLUTE

COMPONENT Cu = Union_make_material(
process_string = "Cu_total", my_absorption = 32.0067,
refraction_SLD = 6.53513E-06)
AT (0,0,0) ABSOLUTE

COMPONENT Si_total = NCrystal_process(
cfg = "Si_sg227.ncmat;dir1=@crys_hkl:1,0,0@lab:1,0,0;dir2=@crys_hkl:0,1,0@lab:0,1,0;mos=5.0arcmin;temp=10C")
AT (0,0,0) ABSOLUTE

COMPONENT Si = Union_make_material(
process_string = "Si_total", my_absorption = 0.85412,
refraction_SLD = 2.07241E-06)
AT (0,0,0) ABSOLUTE

// Union surfaces
COMPONENT m2_mirror = Mirror_surface(
m = 2, alpha=3.0)
AT (0,0,0) ABSOLUTE

COMPONENT m4_mirror = Mirror_surface(
m = 4, alpha=3.0)
AT (0,0,0) ABSOLUTE

// Union geometries
COMPONENT Cu_box = Union_box(
material_string = "Cu", priority = 100,
xwidth = 0.075, xwidth2 = 0.06,
yheight = 0.042, zdepth = 0.31)
AT (-0.0037,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,1.4,0) RELATIVE Start_of_bi

COMPONENT Vacuum_box = Union_box(
material_string = "Vacuum", priority = 101,
xwidth = 0.075 - 0.016, xwidth2 = 0.06 - 0.016, // Subtracting double wall thickness
yheight = 0.034, zdepth = 0.31+1E-5, // Slight extra depth to avoid parallel faces
plus_x_surface = "m4_mirror", // Super-mirror coating on left wall, but not right (right wall can still reflect below critical angle of Vacuum - Cu interface)
plus_y_surface="m2_mirror", minus_y_surface="m2_mirror") // Super-mirror coating on top/bottom
AT (0,0,0) RELATIVE Cu_box

// Array of Si blades at slight angle, rays from hot source are mainly transmitted, rays from cold source are reflected
COMPONENT si_blade_0 = Union_box(
material_string = "Si", priority = 110,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (-0.021,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT si_blade_1 = Union_box(
material_string = "Si", priority = 111,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (-0.017625,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT si_blade_2 = Union_box(
material_string = "Si", priority = 112,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (-0.014250,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT si_blade_3 = Union_box(
material_string = "Si", priority = 113,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (-0.010875,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT si_blade_4 = Union_box(
material_string = "Si", priority = 114,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (-0.007500,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT si_blade_5 = Union_box(
material_string = "Si", priority = 115,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (-0.004125,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT si_blade_6 = Union_box(
material_string = "Si", priority = 116,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (-0.000750,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT si_blade_7 = Union_box(
material_string = "Si", priority = 117,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (0.0026250,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT si_blade_8 = Union_box(
material_string = "Si", priority = 118,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (0.006,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT si_blade_9 = Union_box(
material_string = "Si", priority = 119,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (0.009375,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT si_blade_10 = Union_box(
material_string = "Si", priority = 120,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (0.012750,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT si_blade_11 = Union_box(
material_string = "Si", priority = 121,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (0.016125,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT si_blade_12 = Union_box(
material_string = "Si", priority = 122,
xwidth = 0.0005, yheight = 0.035,
zdepth = 0.3, minus_x_surface = "m4_mirror")
AT (0.0195,0,0.1485) RELATIVE Start_of_bi
ROTATED (0,0.74,0) RELATIVE Start_of_bi

COMPONENT master = Union_master(
enable_refraction=1, enable_reflection=1) // control parameters to enable/disable refraction and reflection effects
AT (0,0,0) ABSOLUTE

COMPONENT stop = Union_stop()
AT (0,0,0) ABSOLUTE

COMPONENT monitor_Div_L = DivLambda_monitor(
xwidth = 0.045, yheight = 0.04,
maxdiv_h = 2.5, nh = 300,
Lmin = l_min, Lmax = l_max, nL = 300,
restore_neutron = 1)
AT (0,0,0.32) RELATIVE Start_of_bi

COMPONENT monitor_L = L_monitor(
xwidth = 0.045, yheight = 0.04,
Lmin = l_min, Lmax = l_max, nL = 500,
restore_neutron = 1)
AT (0,0,0.32) RELATIVE Start_of_bi

COMPONENT monitor_PSD = PSD_monitor(
nx = 300, ny = 300,
xwidth = 0.06, yheight = 0.06,
restore_neutron = 1)
AT (0,0,0.32) RELATIVE Start_of_bi

FINALLY
%{
%}

END
Loading
Loading