A reproducible Docker environment that runs SRIM 2013 and PySRIM on modern
Python 3.11.
It follows the same idea as Christopher Ostrouchov’s original
costrouc/pysrim image, but:
- starts from a slim Debian 12 / Python 3.11 base instead of Ubuntu 16.04 / Python 3.6;
- installs the VB 6 runtime (
winetricks vb6run) in a fresh 32-bit Wine prefix, letting SRIM’s Visual-Basic executables run without crashing; - wraps Wine with
xvfb-runautomatically so SRIM can run head-less; - patches PySRIM’s deprecated
yaml.load()call for compatibility with PyYAML ≥ 6.0.
| File | Purpose |
|---|---|
| Dockerfile | Builds the complete SRIM + PySRIM stack (see below). |
my_srim.py |
Slow TRIM benchmark: 50 MeV range in 4 cm water & 60 MeV exit energy after 1 cm water. |
fast_srim.py |
Tiny SR sanity check: 10 MeV proton residual energy after 0.2 cm water; finishes fast. |
(Add your own scripts in the same directory—/workspace in the container maps
to your current host folder.)
docker build -t srim_pysrim:latest .-
System packages – installs Wine 8 (x86 + x64), Winetricks,
cabextract,unzip,xvfb,xauth, and helper tools on Debian 12 slim. -
Head-less Wine wrapper – replaces
/usr/bin/winewith a tiny script that runs
xvfb-run -a wine-bin …, so every Wine/Winetricks call has a dummy X-server. -
32-bit Wine prefix + VB6 runtime – deletes any old prefix, creates a fresh
WINEARCH=win32prefix, and runswinetricks -q vb6runto installMSVBVM60.DLLand the common VB6 OCXs SRIM needs. -
SRIM 2013 extraction – downloads
SRIM-2013-Std.efrom srim.org, unpacks it silently with7z, and stores everything in/opt/srim. -
Python layer – installs NumPy 2.3.1 and PySRIM 0.5.10 on Python 3.11, then patches a deprecated
yaml.load()call toyaml.safe_load()for PyYAML ≥ 6.
# quick SR sanity check (seconds)
docker run --rm -v ${PWD}:/workspace srim_pysrim:latest python /workspace/fast_srim.py# full TRIM benchmark (minutes)
docker run --rm -v ${PWD}:/workspace srim_pysrim:latest python /workspace/example_trim.py/opt/srim is on the container’s PATH; the default working directory inside the container is /workspace.
- Layer-width limit – SRIM’s deterministic SR tables can only handle layers
≤ 21.47 cm (2 147 483 648 Å). Use multiple thin slabs or TRIM for thicker water phantoms. - Root warnings – Wine/Winetricks complain about running as root; inside a Docker container this is safe and expected.
- Performance tips – For faster TRIM runs, lower
number_ionsin your scripts or spin up multiple containers in parallel and merge the outputs.
SRIM’s executables are launched successfully, but from the wrong working directory. PySRIM writes its inputs under <SRIM_DIR>/SR Module/... and then starts SRModule.exe; that executable expects to read its control file (e.g., SR.IN) and write outputs inside the SRIM program folder. When the process CWD isn’t <SRIM_DIR>/SR Module (for SR) or <SRIM_DIR> (for TRIM), the VB6 app aborts with Runtime error 53 (File not found) — exactly the failure observed under Wine. The “X connection to :99 broken” line is a side-effect of xvfb-run tearing down the virtual display after the Windows app exits, not the root cause.
- SRIM home page – http://www.srim.org
- costrouc/pysrim Docker image – https://github.com/costrouc/pysrim
- WineHQ FAQ on running as root – https://wiki.winehq.org/FAQ
- Winetricks documentation – https://github.com/Winetricks/winetricks
- PySRIM documentation – https://pysrim.readthedocs.io