This repository contains an implementation and validation of the Spatially Extended Non‑Linear Node (SENN) model, a computational model used for simulating neural activation during electrical stimulation.
The goal of this project is not only to run the original SENN simulation, but to verify numerical equivalence between a modern C# implementation and the original legacy Fortran code described in the reference literature.
WARNING: The .NET implementation in this repository could have small deviations and could use more accurate algorithms. When plotting the results, there can be one iteration where the graph deviates from original Fortran implementation. For the rest, more accurate graphs, the result is around 1% different or less.
The SENN model originates from the book:
Electrostimulation: Theory, Applications, and Computational Model
J. Patrick Reilly, Alan M. Diamant
The original implementation was written in Fortran 77, later compiled using Fortran 95 compilers in legacy mode. The executables distributed with the book include user interface elements that make them unsuitable for automated testing and batch simulations.
For this reason, the original Fortran source code is compiled directly, and its numerical output is used as the reference baseline.
This repository contains three main components:
-
Original Fortran SENN simulation
- Compiled on Windows using GNU Fortran (gfortran) in legacy Fortran 77 mode.
- Serves as the reference implementation without any GUI.
-
Modern C# (.NET) reimplementation
- A clean, maintainable version of the same mathematical model.
- Designed for future extension, automation, and integration.
-
Automated testing and comparison
- Python scripts execute both binaries with identical parameters.
- Outputs are compared numerically and visually.
- Resulting plots allow validation of correctness and detection of divergence.
The purpose of this workflow is to ensure that the C# model faithfully reproduces the behavior of the original Fortran simulation.
At a high level, the testing process is:
- Run the SENN simulation using the original Fortran implementation.
- Run the same simulation using the C# implementation.
- Compare outputs across multiple simulation runs.
- Generate plots and result files for analysis.
Detailed build and execution instructions are documented separately.
Step‑by‑step instructions for compiling Fortran, building the .NET executable, and running Python comparison tests are located here:
That document describes:
- How the Fortran code is compiled on Windows
- How runtime dependencies are handled
- How the C# executable is built
- How automated comparison tests are executed
This project exists to:
- Enable modern experimentation using reliable, reproducible simulations
- Provide a foundation for future numerical and biomedical research
- The Fortran code follows legacy Fortran 77 rules and behavior.
- All comparisons are performed using identical simulation parameters.
This repository is intended for developers, researchers, and students who wish to understand, validate, or extend the SENN computational model using modern tools while remaining faithful to the original scientific work.