Skip to content

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

Open
AnatoleStorck wants to merge 14 commits into
yt-project:mainfrom
AnatoleStorck:add_vector_field_support_to_deposit
Open

AMR: Expand particle deposition onto the grid to vector fields.#5227
AnatoleStorck wants to merge 14 commits into
yt-project:mainfrom
AnatoleStorck:add_vector_field_support_to_deposit

Conversation

@AnatoleStorck
Copy link
Copy Markdown
Contributor

@AnatoleStorck AnatoleStorck commented Jul 23, 2025

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
Copy link
Copy Markdown
Contributor Author

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

@chrishavlin
Copy link
Copy Markdown
Contributor

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

@jzuhone
Copy link
Copy Markdown
Contributor

jzuhone commented Aug 21, 2025

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

@chummels
Copy link
Copy Markdown
Member

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

Comment thread yt/data_objects/index_subobjects/octree_subset.py Outdated
Comment thread yt/data_objects/index_subobjects/octree_subset.py Outdated
Comment thread yt/geometry/oct_container.pyx Outdated
Comment thread yt/geometry/oct_container.pyx Outdated
Comment thread yt/geometry/oct_visitors.pyx Outdated
Comment thread yt/geometry/particle_deposit_vector.pxd Outdated
Comment thread yt/geometry/particle_deposit_vector.pyx Outdated
@cphyc
Copy link
Copy Markdown
Member

cphyc commented Nov 10, 2025

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 cphyc force-pushed the add_vector_field_support_to_deposit branch from 34fba04 to 3526408 Compare November 11, 2025 11:03
@cphyc
Copy link
Copy Markdown
Member

cphyc commented Nov 11, 2025

@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
Copy link
Copy Markdown
Member

cphyc commented Nov 11, 2025

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 cphyc force-pushed the add_vector_field_support_to_deposit branch from 9ecd82c to f631aa6 Compare March 9, 2026 20:35
Copy link
Copy Markdown
Member

@cphyc cphyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now looks good to me!

@cphyc cphyc requested a review from chummels March 31, 2026 12:05
@cphyc cphyc requested a review from chrishavlin March 31, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants