Split domains to separate files - #417
Merged
Merged
Conversation
max-models
marked this pull request as ready for review
September 28, 2026 20:35
Member
|
I propose the following structure: #418 |
**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`.
spossann
approved these changes
Sep 29, 2026
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.