Introduce indexed ray transfer APIs and tests#503
Conversation
… cleaning imports
jacklovell
left a comment
There was a problem hiding this comment.
Very cool. If I understand this correctly, it's a generalisation of the existing ray transfer objects where a callable function replaces the voxel map, and this function returns the voxel index at a given point in space. As well as the 3D application in https://doi.org/10.1063/5.0225703 (which you should cite somewhere in the documentation by the way), I can see the possibility of application to axisymmetric voxels of arbitrary poloidal cross section without having to approximate them with a rectangular grid.
I think a demo would be highly beneficial, as it's hard to see a concrete use case from the docstrings alone. Perhaps you could adapt Vlad's Space Invaders demos to showcase the new tools.
|
Thank you for your review!
I will try to work out these ideas with AI assistance for now. |
|
Analytically-defined voxels will make a nice demo, agreed. For example, flux-aligned axisymmetric voxels for the generomak equilibrium defined in ( And yes, voxels defined by triangular or tetrahedral meshes would also be a good illustration, showing the ability to extend beyond regular rectilinear grids. |
…yTransferEmitter` class
Summary
This PR introduces a general index-function-based ray transfer API by adding indexed emitter and integrator classes, replacing mesh-specific naming with functionality-based naming.
Key Changes
IndexedRayTransferIntegratorIndexedRayTransferEmitterDiscrete3DMesh-backedindex_functionbehaviornumpy.ndindexpatternsUnit Test
test_evaluate_functionIndexedRayTransferEmitterworks correctly withNumericalIntegratorand maps contributions to the correct bins viaindex_function.bins=27. A diagonal ray crosses the volume. The index function maps in-domain points to 0..26 and returns -1 outside.atol=0.001.test_default_integratorIndexedRayTransferEmitteris created without an integrator argument under the same ray/volume setup as above.IndexedRayTransferIntegratorby default, and the resulting spectrum matches the same expected vector (atol=0.001).test_discrete3dmesh_as_index_functionDiscrete3DMeshcan be used as an equivalent index function source.Discrete3DMeshis built from a 4x4x4 vertex grid over 3x3x3 cells; each cube is split into 6 tetrahedra. Cell values follow the same indexing rule as the reference index function.atol=0.001.Executed:
Result:
test_default_integrator: oktest_discrete3dmesh_as_index_function: oktest_evaluate_function: okExample Usage
Compatibility and Risk
Reviewer Notes
Checklist
Benchmark
The appendix in this paper (https://doi.org/10.1063/5.0225703) compared the raytransfer of
Discrete3Dmeshes with that of regular grids, showing that the geometry matrix calculation for rectangular grids' raytransfer was much faster than theDiscrete3Done.