yt icon indicating copy to clipboard operation
yt copied to clipboard

AMR: Expand particle deposition onto the grid to vector fields.

Open AnatoleStorck opened this issue 5 months ago • 7 comments

PR Summary

Currently, only scalar quantites of particles can be deposited to the grid (such as mass), with final shape (Ncells,) I want to be able to deposit a vector quantity (stellar spectra of each star particle) onto the grid with shape (Ncells, spectra_length), with the main goal to build spectra for each cell (nebular continuum + emission lines, and stellar spectra.) I have not been able to make the deposition of the vector fields work yet, so any help is greatly appreciated.

PR Checklist

  • [ ] New features are documented, with docstrings and narrative docs
  • [ ] Adds a test for any bugs fixed. Adds tests for new features.

AnatoleStorck avatar Jul 23 '25 12:07 AnatoleStorck

Just to add, I am currently only considering method="sum" for deposition of vector fields

AnatoleStorck avatar Jul 23 '25 13:07 AnatoleStorck

@cphyc some octree enhancements/changes here that you might be interested in checking out when you're back from holiday :)

chrishavlin avatar Jul 23 '25 14:07 chrishavlin

@AnatoleStorck would be happy to look more at this after the test failures are addressed.

jzuhone avatar Aug 21 '25 14:08 jzuhone

I'd love to see this functionality in yt. Let me know if there are ways I can assist in testing this or debugging.

chummels avatar Aug 21 '25 15:08 chummels

Note for @AnatoleStorck and @cphyc, the particle_deposit_vector.pyx and .pxd should be removed, and merged into particle_deposit.pyx. The latter should be modified to accept a vector field in general, with the specific case of a scalar field being a vector field of dimension 1.

cphyc avatar Nov 10 '25 18:11 cphyc

@chummels this should support SPH datasets, but I have never used an SPH dataset, and I'm not sure what the particle deposition would mean for SPH? Onto what are you deposing?

Given my ignorance, I haven't really tested this, but it'd be amazing if you could give it a go

cphyc avatar Nov 11 '25 11:11 cphyc

We still have failures for AMR (non-octree) datasets. It seems that vector fields end up being stored vector-first, i.e., with shape (vector_size, nx, ny, nz, num_zones) whereas oct-based dataset have shape (nx, ny, nz, num_zones, vector_size). I'm sure there must be a transpose somewhere, but couldn't find it yet. Any help is welcome :)

cphyc avatar Nov 11 '25 16:11 cphyc