ESS pipeline exercise#
The exercise: split the students in 5 teams; each team is responsible for a part of ESS:
accelerator
target
guide
sample
detector
The teams have to write small functions that create protons, then neutrons, transport them etc.
Each team has to talk to others about the interfaces: what they receive as input and what they produce as output. In the process they have to use dictionaries, functions and numpy arrays.
At the end, a detector image and/or spectrum is produced.
from source import source_and_accelerator
from target import target
from guide import neutron_guide
from sample import sample
from detector import detector
# 1. Produce protons
protons = source_and_accelerator()
print(protons["message"])
Produced 10000 protons with energy 1000.0.
# 2. Produce neutrons
neutrons = target(protons)
print(neutrons["message"])
Target: 1010 neutrons produced from 10000 protons.
# 3. Transport neutrons
transported = neutron_guide(neutrons)
print(transported["message"])
Neutron guide: 829 neutrons survived transport.
# 4. Interact with sample
after_sample = sample(transported)
print(after_sample["message"])
Sample interaction: 645 neutrons survived.
# 5. Detect them
results = detector(after_sample)
print(results["message"])
Detector: 645 neutrons detected. Image shape: (100, 100). Spectrum bins: 50.