The Union test instrument Test_inhomogenous_process.instr has a string valued Instrument parameter sample which is used to control the possible interactions of a neutron ray in the simulation runtime.
The sample Instrument parameter is static during the lifetime of the simulation, so the result of the following check is static as well
|
) WHEN (!str_comp((const char*)"thin", (const char*)sample)) |
Since the WHEN expression is evaluated in TRACE, this same expression is run as many times as there are rays, e.g., mcncount.
A compiler may be clever enough to recognize that the result of this expression is constant, but we can help it by moving such statements to the INITIALIZE block of the instrument file.
The Union test instrument
Test_inhomogenous_process.instrhas a string valued Instrument parametersamplewhich is used to control the possible interactions of a neutron ray in the simulation runtime.The
sampleInstrument parameter is static during the lifetime of the simulation, so the result of the following check is static as wellMcCode/mcstas-comps/examples/Tests_union/Test_inhomogenous_process/Test_inhomogenous_process.instr
Line 194 in 7f0994c
Since the
WHENexpression is evaluated inTRACE, this same expression is run as many times as there are rays, e.g.,mcncount.A compiler may be clever enough to recognize that the result of this expression is constant, but we can help it by moving such statements to the
INITIALIZEblock of the instrument file.