Skip to content

Commit d8283d2

Browse files
authored
Merge pull request #108 from scipp/dream-high-flux
Add dream high-resolution config
2 parents b889857 + 57013f1 commit d8283d2

3 files changed

Lines changed: 55 additions & 6 deletions

File tree

src/tof/facilities/ess/dream.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Pre-configured chopper and detector parameters for Dream.
55
"""
66

7+
import copy
8+
79
from ...chopper import Chopper
810
from ...detector import Detector
911
from ...model import make_beamline
@@ -73,6 +75,19 @@
7375
}
7476

7577

78+
dream_high_resolution = copy.deepcopy(dream_high_flux)
79+
dream_high_resolution["PSC1"]["frequency"]["value"] = 15 * 14.0
80+
dream_high_resolution["PSC1"]["phase"]["value"] = 25 - 180
81+
dream_high_resolution["PSC2"]["frequency"]["value"] = 14 * 14.0
82+
dream_high_resolution["PSC2"]["phase"]["value"] = 100.5
83+
dream_high_resolution["OC"]["frequency"]["value"] = 14.0
84+
dream_high_resolution["OC"]["phase"]["value"] = 297.0 - 180.0 - 90.0
85+
dream_high_resolution["BC"]["frequency"]["value"] = 112.0
86+
dream_high_resolution["BC"]["phase"]["value"] = 200.0 - 180.0
87+
dream_high_resolution["T0"]["frequency"]["value"] = 28.0
88+
dream_high_resolution["T0"]["phase"]["value"] = 270.0 - 180.0
89+
90+
7691
def dream(
7792
high_flux=False, high_resolution=False
7893
) -> dict[str, list[Chopper] | list[Detector]]:
@@ -81,6 +96,5 @@ def dream(
8196
if high_flux:
8297
return make_beamline(dream_high_flux)
8398
if high_resolution:
84-
# TODO: Add high-resolution configuration
85-
raise NotImplementedError("High-resolution configuration not yet implemented.")
99+
return make_beamline(dream_high_resolution)
86100
raise ValueError("Either high_flux or high_resolution must be True.")

src/tof/facilities/ess/odin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@
157157

158158

159159
odin_pulse_skipping = copy.deepcopy(odin_non_pulse_skipping)
160-
odin_pulse_skipping["BP_1"]["frequency"] = {"value": 7.0, "unit": "Hz"}
161-
odin_pulse_skipping["BP_1"]["phase"] = {"value": 31.080, "unit": "deg"}
162-
odin_pulse_skipping["BP_2"]["frequency"] = {"value": 7.0, "unit": "Hz"}
163-
odin_pulse_skipping["BP_2"]["phase"] = {"value": 44.224, "unit": "deg"}
160+
odin_pulse_skipping["BP_1"]["frequency"]["value"] = 7.0
161+
odin_pulse_skipping["BP_1"]["phase"]["value"] = 31.080
162+
odin_pulse_skipping["BP_2"]["frequency"]["value"] = 7.0
163+
odin_pulse_skipping["BP_2"]["phase"]["value"] = 44.224
164164

165165

166166
def odin(

tests/facilities/ess_test.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright (c) 2025 Scipp contributors (https://github.com/scipp)
3+
4+
5+
import pytest
6+
7+
import tof
8+
9+
10+
@pytest.mark.parametrize("mode", ['high_flux', 'high_resolution'])
11+
def test_run_dream_model(mode):
12+
source = tof.Source(facility='ess', neutrons=100_000, pulses=2)
13+
14+
match mode:
15+
case 'high_flux':
16+
params = {"high_flux": True}
17+
case 'high_resolution':
18+
params = {"high_resolution": True}
19+
20+
dream_params = tof.facilities.ess.dream(**params)
21+
model = tof.Model(source=source, **dream_params)
22+
results = model.run()
23+
assert len(results.choppers) > 0
24+
assert len(results.detectors) > 0
25+
26+
27+
@pytest.mark.parametrize("pulse_skipping", [True, False])
28+
@pytest.mark.parametrize("facility", ['ess', 'ess-odin'])
29+
def test_run_odin_model(pulse_skipping, facility):
30+
source = tof.Source(facility=facility, neutrons=100_000, pulses=2)
31+
odin_params = tof.facilities.ess.odin(pulse_skipping=pulse_skipping)
32+
model = tof.Model(source=source, **odin_params)
33+
results = model.run()
34+
assert len(results.choppers) > 0
35+
assert len(results.detectors) > 0

0 commit comments

Comments
 (0)