|
| 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: Testing placing many meshes in the same instrument file |
| 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 many overlapping |
| 25 | +* mesh components. |
| 26 | +* Test with: |
| 27 | +* mcdisplay -y -c |
| 28 | +* |
| 29 | +* %Example: pin_rad=0.0025 Detector:det_I=4.63384e-06 |
| 30 | +* |
| 31 | +* %Parameters |
| 32 | +* pin_rad: [m] Radius of source |
| 33 | +* d: [m] Distance between source and sample center |
| 34 | +* detector_x: [m] Detector Width |
| 35 | +* detector_y: [m] Detector Height |
| 36 | +* det_dist: [m] Distance between detector and sample center |
| 37 | +* crack_width: [m] Height masking crack should be raised from the original crack |
| 38 | +* |
| 39 | +* %Link |
| 40 | +* |
| 41 | +* %End |
| 42 | +********************************************************************************/ |
| 43 | + |
| 44 | +DEFINE INSTRUMENT imaging ( |
| 45 | +double pin_rad = 0.0025, // Radius of source |
| 46 | +double d = 10, // Distance between source and sample center |
| 47 | +double detector_x = 0.01, // Detector Width |
| 48 | +double detector_y = 0.04, // Detector Height |
| 49 | +double det_dist = 0.005, // Distance between detector and sample center |
| 50 | +double crack_width = 0.003 // Height masking crack should be raised from the original crack |
| 51 | +) |
| 52 | +DEPENDENCY " @NCRYSTALFLAGS@ -DFUNNEL " |
| 53 | + |
| 54 | +DECLARE |
| 55 | +%{ |
| 56 | +%} |
| 57 | + |
| 58 | +INITIALIZE |
| 59 | +%{ |
| 60 | +// Start of initialize for generated imaging |
| 61 | +%} |
| 62 | + |
| 63 | +TRACE |
| 64 | +COMPONENT Origin = Progress_bar() |
| 65 | +AT (0, 0, 0) ABSOLUTE |
| 66 | + |
| 67 | +COMPONENT source = Source_simple( |
| 68 | + radius = pin_rad, yheight = 0, |
| 69 | + xwidth = 0, dist = d, |
| 70 | + focus_xw = detector_x, focus_yh = detector_y, |
| 71 | + lambda0 = 4, dlambda = 3) |
| 72 | +AT (0, 0, 0) RELATIVE Origin |
| 73 | +ROTATED (0.0, 0.0, 0.0) RELATIVE Origin |
| 74 | + |
| 75 | +COMPONENT entry_mon = PSD_monitor( |
| 76 | + nx = 200, ny = 200, |
| 77 | + xwidth = detector_x, yheight = detector_x, |
| 78 | + restore_neutron = 1) |
| 79 | +AT (0, 0, 0.0001) RELATIVE source |
| 80 | +ROTATED (0.0, 0.0, 0.0) RELATIVE source |
| 81 | + |
| 82 | +COMPONENT arm_sample_position = Arm() |
| 83 | +AT (0, 0, d) RELATIVE source |
| 84 | +ROTATED (0, 0, 0) RELATIVE Origin |
| 85 | + |
| 86 | +COMPONENT init = Union_init() |
| 87 | +AT (0, 0, 0) RELATIVE arm_sample_position |
| 88 | +ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position |
| 89 | + |
| 90 | +COMPONENT Sample_inc = Incoherent_process( |
| 91 | + sigma = 0.4 * 2, unit_cell_volume = 24.04) |
| 92 | +AT (0, 0, 0) RELATIVE arm_sample_position |
| 93 | +ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position |
| 94 | + |
| 95 | +COMPONENT Sample_pow = Powder_process( |
| 96 | + reflections = "Fe.laz") |
| 97 | +AT (0, 0, 0) RELATIVE arm_sample_position |
| 98 | +ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position |
| 99 | + |
| 100 | +COMPONENT Sample = Union_make_material( |
| 101 | + process_string = "Sample_inc,Sample_pow", my_absorption = 10*2.56 * 2 / 24.04 * 100) |
| 102 | +AT (0, 0, 0) RELATIVE arm_sample_position |
| 103 | +ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position |
| 104 | + |
| 105 | +COMPONENT gas_process = NCrystal_process( |
| 106 | + cfg = "gasmix::H2/10bar") |
| 107 | +AT (0, 0, 0) RELATIVE Sample |
| 108 | +ROTATED (0.0, 0.0, 0.0) RELATIVE Sample |
| 109 | + |
| 110 | +COMPONENT sample_gas = Union_make_material( |
| 111 | + process_string = "gas_process", my_absorption = 21.29783693843594) |
| 112 | +AT (0, 0, 0) RELATIVE gas_process |
| 113 | +ROTATED (0.0, 0.0, 0.0) RELATIVE gas_process |
| 114 | + |
| 115 | +COMPONENT arm_crack = Arm() |
| 116 | +AT (0, 0, 0) RELATIVE arm_sample_position |
| 117 | +ROTATED (90, 0, 0) RELATIVE arm_sample_position |
| 118 | + |
| 119 | +COMPONENT masking_crack = Union_mesh( |
| 120 | + filename = "test.stl", material_string = "Sample", |
| 121 | + priority = 140, skip_convex_check = 1) |
| 122 | +AT (0, 0, 0.0005) RELATIVE arm_crack |
| 123 | +ROTATED (0, 0, 0) RELATIVE arm_crack |
| 124 | + |
| 125 | +COMPONENT crack = Union_mesh( |
| 126 | + filename = "test.stl", material_string = "sample_gas", |
| 127 | + priority = 139, skip_convex_check = 1, |
| 128 | + coordinate_scale = 0.0009811453007353597) |
| 129 | +AT (0, 0, 0) RELATIVE arm_crack |
| 130 | +ROTATED (0, 0, 0) RELATIVE arm_crack |
| 131 | + |
| 132 | +COMPONENT logger_space_zx = Union_logger_2D_space( |
| 133 | + D_direction_1 = "z", D1_min = -0.05, |
| 134 | + D1_max = 0.05, n1 = 300, |
| 135 | + D_direction_2 = "x", D2_min = -0.05, |
| 136 | + D2_max = 0.05, n2 = 300, |
| 137 | + filename = "logger_zx.dat") |
| 138 | +AT (0, 0, 0) RELATIVE arm_sample_position |
| 139 | +ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position |
| 140 | + |
| 141 | +COMPONENT logger_space_zy = Union_logger_2D_space( |
| 142 | + D_direction_1 = "z", D1_min = -0.05, |
| 143 | + D1_max = 0.05, n1 = 300, |
| 144 | + D_direction_2 = "y", D2_min = -0.05, |
| 145 | + D2_max = 0.05, n2 = 300, |
| 146 | + filename = "logger_zy.dat") |
| 147 | +AT (0, 0, 0) RELATIVE arm_sample_position |
| 148 | +ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position |
| 149 | + |
| 150 | +COMPONENT Sample_environment = Union_master( |
| 151 | + verbal = 1) |
| 152 | +AT (0, 0, 0) RELATIVE arm_sample_position |
| 153 | +ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position |
| 154 | + |
| 155 | +COMPONENT stop = Union_stop() |
| 156 | +AT (0, 0, 0) RELATIVE arm_sample_position |
| 157 | +ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position |
| 158 | + |
| 159 | +COMPONENT det = PSD_monitor( |
| 160 | + nx = 1000, ny = 1000, |
| 161 | + filename = "det", xwidth = detector_x, |
| 162 | + yheight = detector_y) |
| 163 | +AT (0, 0, 0.034 / 2 + det_dist) RELATIVE arm_sample_position |
| 164 | +ROTATED (0.0, 0.0, 0.0) RELATIVE arm_sample_position |
| 165 | + |
| 166 | +FINALLY |
| 167 | +%{ |
| 168 | +// Start of finally for generated imaging |
| 169 | +%} |
| 170 | + |
| 171 | +END |
0 commit comments