Skip to content

Commit 4a14ee6

Browse files
committed
Expose tof simulation number of neutron configuration.
1 parent 6bf8310 commit 4a14ee6

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/ess/nmx/configurations.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ class WorkflowConfig(BaseModel):
9898
"If None, the lookup table will be computed on-the-fly.",
9999
default=None,
100100
)
101+
tof_simulation_num_neutrons: int = Field(
102+
title="Number of Neutrons for TOF Simulation",
103+
description="Number of neutrons to simulate for TOF lookup table calculation.",
104+
default=1_000_000,
105+
)
101106
tof_simulation_min_wavelength: float = Field(
102107
title="TOF Simulation Minimum Wavelength",
103108
description="Minimum wavelength for TOF simulation in Angstrom.",

src/ess/nmx/workflows.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ def _simulate_fixed_wavelength_tof(
8383
----------
8484
"""
8585
source = tof.Source(
86-
facility="ess", neutrons=neutrons, pulses=2, seed=seed, wmax=wmax, wmin=wmin
86+
facility="ess",
87+
neutrons=neutrons,
88+
pulses=1, # NMX does not use pulse-skipping.
89+
seed=seed,
90+
wmax=wmax,
91+
wmin=wmin,
8792
)
8893
nmx_det = tof.Detector(distance=max(ltotal_range), name="detector")
8994
model = tof.Model(source=source, choppers=[], detectors=[nmx_det])
@@ -290,6 +295,7 @@ def compute_lookup_table(
290295
wf[TimeOfFlightLookupTableFilename] = workflow_config.tof_lookup_table_file_path
291296
else:
292297
wf = patch_workflow_lookup_table_steps(wf=wf)
298+
wf[NumberOfSimulatedNeutrons] = workflow_config.tof_simulation_num_neutrons
293299
wmax = sc.scalar(workflow_config.tof_simulation_max_wavelength, unit='angstrom')
294300
wmin = sc.scalar(workflow_config.tof_simulation_min_wavelength, unit='angstrom')
295301
wf[TofSimulationMaxWavelength] = wmax

tests/executable_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def test_reduction_config() -> None:
9393
max_time_bin=100_000,
9494
time_bin_coordinate=TimeBinCoordinate.time_of_flight,
9595
time_bin_unit=TimeBinUnit.us,
96+
tof_simulation_num_neutrons=700_000,
9697
tof_simulation_max_wavelength=5.0,
9798
tof_simulation_min_wavelength=1.0,
9899
tof_simulation_seed=12345,

0 commit comments

Comments
 (0)