Skip to content

Split domains to separate files - #417

Merged
max-models merged 5 commits into
develfrom
split-domains-into-separate-files
Sep 29, 2026
Merged

max-models merged 5 commits into
develfrom
split-domains-into-separate-files

Conversation

@max-models

Copy link
Copy Markdown
Member

No description provided.

@max-models
max-models marked this pull request as ready for review September 28, 2026 20:35
@max-models
max-models requested a review from spossann September 28, 2026 20:35
@spossann

Copy link
Copy Markdown
Member

I propose the following structure: #418

spossann and others added 4 commits September 29, 2026 10:08
**I propose to create folders for each mapping, where the corrsponding
kernels can live. This will be benificial for later translation to other
backends (like cuda).**

Opus 5.5:

Done. The kernels are split into one file per mapping, and the results
are bit-identical to before. Nothing is committed yet; all changes are
staged (14 renames, 24 new files, 2 modified, 1 deleted).

**Layout:**
- Each of the 14 domains now has a folder, e.g.
[domains/cuboid/](src/struphy/geometry/domains/cuboid/), holding the
class file and an `__init__.py` that re-exports the class. Existing
imports like `from struphy.geometry.domains import Cuboid` still work.
- The 9 analytical mappings each have a `<name>_kernels.py` with their
mapping and Jacobian kernels, e.g.
[cuboid_kernels.py](src/struphy/geometry/domains/cuboid/cuboid_kernels.py).
Function names are unchanged.
- The six spline kernels are in
[spline_mappings_kernels.py](src/struphy/geometry/spline_mappings_kernels.py).
- [evaluation_kernels.py](src/struphy/geometry/evaluation_kernels.py)
imports the 10 new modules. Its `kind_map` dispatch and round-off logic
are untouched.
- `mappings_kernels.py` and its compiled artifacts are deleted, and
[domains-kernels.rst](doc/sections/subsections/domains-kernels.rst) now
lists the new modules.

**Verification:**
- **Code unchanged:** all 24 functions have the same code as the
originals; only the `:meth:` docstring cross-references were updated to
the new module paths.
- **Compile:** a full Fortran recompile built all 45 kernels, including
the 10 new ones.
- **Results:** I evaluated the mapping, Jacobian, its determinant and
inverse, the metric and its inverse for all 14 domains, on a grid and at
random points. All 168 arrays are bit-identical to the baseline from
before the refactor.
- **Tests:** the geometry tests (21) and the pusher and accumulation
tests (107) pass.

**Recompile needed:** `state.yml` caches the list of kernel files, so
anyone pulling this change needs to reset it. Delete the `kernels:` key
from `src/struphy/state.yml` (or the whole file), then run `struphy
compile`. Otherwise the compile still looks for the deleted
`mappings_kernels.py` and doesn't pick up the new files. I did this
locally and saved a backup of the old state in the scratchpad.

As agreed, the two suspected Jacobian bugs are still unfixed:
`hollow_cyl_df` is missing `/poc` and `powered_ellipse_df` is missing
the factor `s`.
@max-models
max-models merged commit 5b60a77 into devel Sep 29, 2026
30 checks passed
@max-models
max-models deleted the split-domains-into-separate-files branch September 29, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants