Skip to content

Commit 4c19eec

Browse files
committed
Add Hidden cylinder test instrument
1 parent 5e97d6d commit 4c19eec

File tree

1 file changed

+164
-0
lines changed

1 file changed

+164
-0
lines changed
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
/********************************************************************************
2+
*
3+
* McStas, neutron ray-tracing package
4+
* Copyright (C) 1997-2008, All rights reserved
5+
* Risoe National Laboratory, Roskilde, Denmark
6+
* Institut Laue Langevin, Grenoble, France
7+
*
8+
* This file was written by McStasScript, which is a
9+
* python based McStas instrument generator written by
10+
* Mads Bertelsen in 2019 while employed at the
11+
* European Spallation Source Data Management and
12+
* Software Centre
13+
*
14+
* Instrument: Hidden_Cylinder
15+
*
16+
* %Identification
17+
* Written by: Daniel Lomholt Christensen
18+
* Date: 15:54:48 on January 20, 2026
19+
* Origin: UCPH@NBI, Funded by ACTNXT
20+
* %INSTRUMENT_SITE: Tests_union
21+
*
22+
*
23+
* %Description
24+
* A small test instrument testing the placement of one cylinder with a low priority
25+
* fully inside another cylinder with a higher priority. This was added to test
26+
* for an mcdisplay error that used to occur, when a cylinder is completely
27+
* enclosed in another cylinder.
28+
* To test this simply do
29+
* a "mcdisplay Hidden_Cylinder.instr -c -y"
30+
*
31+
* %Example: pin_rad=0.0025 Detector: det_I=3.42884e-06
32+
*
33+
* %Parameters
34+
* pin_rad: [m] Radius of source
35+
* d: [m] Distance between source and sample center
36+
* detector_x: [m] Detector Width
37+
* detector_y: [m] Detector Height
38+
* det_dist: [m] Distance between detector and sample center
39+
*
40+
* %Link
41+
*
42+
* %End
43+
********************************************************************************/
44+
45+
DEFINE INSTRUMENT imaging (
46+
double pin_rad = 0.0025, // Radius of source
47+
double d = 10, // Distance between source and sample center
48+
double detector_x = 0.01, // Detector Width
49+
double detector_y = 0.04, // Detector Height
50+
double det_dist = 0.005 // Distance between detector and sample center
51+
)
52+
53+
DECLARE
54+
%{
55+
%}
56+
57+
INITIALIZE
58+
%{
59+
%}
60+
61+
TRACE
62+
COMPONENT Origin = Progress_bar()
63+
AT (0, 0, 0) ABSOLUTE
64+
65+
COMPONENT source = Source_simple(
66+
radius = pin_rad, yheight = 0,
67+
xwidth = 0, dist = d,
68+
focus_xw = detector_x, focus_yh = detector_y,
69+
lambda0 = 4, dlambda = 3)
70+
AT (0, 0, 0) RELATIVE Origin
71+
ROTATED (0.0, 0.0, 0.0) RELATIVE Origin
72+
73+
COMPONENT entry_mon = PSD_monitor(
74+
nx = 200, ny = 200,
75+
xwidth = detector_x, yheight = detector_x,
76+
restore_neutron = 1)
77+
AT (0, 0, 0.0001) RELATIVE source
78+
ROTATED (0.0, 0.0, 0.0) RELATIVE source
79+
80+
COMPONENT arm_sample_position = Arm()
81+
AT (0, 0, d) RELATIVE source
82+
ROTATED (0, 0, 0) RELATIVE Origin
83+
84+
COMPONENT init = Union_init()
85+
AT (0, 0, 0) RELATIVE arm_sample_position
86+
ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position
87+
88+
COMPONENT Sample_inc = Incoherent_process(
89+
sigma = 0.4 * 2, unit_cell_volume = 24.04)
90+
AT (0, 0, 0) RELATIVE arm_sample_position
91+
ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position
92+
93+
COMPONENT Sample_pow = Powder_process(
94+
reflections = "Fe.laz")
95+
AT (0, 0, 0) RELATIVE arm_sample_position
96+
ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position
97+
98+
COMPONENT Sample = Union_make_material(
99+
process_string = "Sample_inc,Sample_pow", my_absorption = 10*2.56 * 2 / 24.04 * 100)
100+
AT (0, 0, 0) RELATIVE arm_sample_position
101+
ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position
102+
103+
COMPONENT gas_process = Incoherent_process(
104+
sigma = 0.4 * 2, unit_cell_volume = 240000.04)
105+
AT (0, 0, 0) RELATIVE arm_sample_position
106+
ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position
107+
108+
COMPONENT sample_gas = Union_make_material(
109+
process_string = "gas_process", my_absorption = 21.29783693843594)
110+
AT (0, 0, 0) RELATIVE Sample
111+
ROTATED (0.0, 0.0, 0.0) RELATIVE Sample
112+
113+
COMPONENT sample_cyl_metal = Union_cylinder(
114+
material_string = "Sample", priority = 50,
115+
radius = 0.005 / 2, yheight = 0.034)
116+
AT (0, 0, 0) RELATIVE arm_sample_position
117+
ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position
118+
119+
COMPONENT sample_cyl_gas = Union_cylinder(
120+
material_string = "sample_gas", priority = 51,
121+
radius = 0.009 / 2, yheight = 0.053,
122+
visualize = 1)
123+
AT (0, 0, 0) RELATIVE arm_sample_position
124+
ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position
125+
126+
COMPONENT logger_space_zx = Union_logger_2D_space(
127+
D_direction_1 = "z", D1_min = -0.05,
128+
D1_max = 0.05, n1 = 300,
129+
D_direction_2 = "x", D2_min = -0.05,
130+
D2_max = 0.05, n2 = 300,
131+
filename = "logger_zx.dat")
132+
AT (0, 0, 0) RELATIVE arm_sample_position
133+
ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position
134+
135+
COMPONENT logger_space_zy = Union_logger_2D_space(
136+
D_direction_1 = "z", D1_min = -0.05,
137+
D1_max = 0.05, n1 = 300,
138+
D_direction_2 = "y", D2_min = -0.05,
139+
D2_max = 0.05, n2 = 300,
140+
filename = "logger_zy.dat")
141+
AT (0, 0, 0) RELATIVE arm_sample_position
142+
ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position
143+
144+
COMPONENT Sample_environment = Union_master(
145+
verbal = 1)
146+
AT (0, 0, 0) RELATIVE arm_sample_position
147+
ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position
148+
149+
COMPONENT stop = Union_stop()
150+
AT (0, 0, 0) RELATIVE arm_sample_position
151+
ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position
152+
153+
COMPONENT det = PSD_monitor(
154+
nx = 1000, ny = 1000,
155+
filename = "det", xwidth = detector_x,
156+
yheight = detector_y)
157+
AT (0, 0, 0.034 / 2 + det_dist) RELATIVE arm_sample_position
158+
ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position
159+
160+
FINALLY
161+
%{
162+
%}
163+
164+
END

0 commit comments

Comments
 (0)