yt-project / yt

Main yt repository
http://yt-project.org
Other
454 stars 272 forks source link

Try to project gas particles (SPH) to a mesh with octree structure #4919

Closed zsw6666 closed 1 month ago

zsw6666 commented 1 month ago

Hi, everyone! I am trying to project gas particles (SPH) to a mesh in the octree structure. The particle data contains several np.array: particle_position: (n, 3) array where n=5303345 is the number of particles particle_density: (n, 1) array I use the following code to do this job: particle_ds=yt.load_particles(particle_data) gas_ds.add_sph_fields() # to generate the fields of (‘io’, ‘smoothing_length’) and (‘io’, ‘density’). add_sph_fields only iterates 5303342 steps

right_edge=[xxx,xxx] left_edge=[xxx,xxx] particle_oct=particle_ds.octree(right_edge=right_edge,left_edge=left_edge,n_ref=10) ######################################## Then, I would like to access some fields of particle_oct: cell_density=gas_oct[‘io’, ‘density’] ######################################## This raise the following error: IndexError: boolean index did not match indexed array along dimension 0; dimension is 5303342 but corresponding boolean dimension is 5303345 ######################################## How do I fix this error and get the correct gas_oct[‘io’,‘density’]?

welcome[bot] commented 1 month ago

Hi, and welcome to yt! Thanks for opening your first issue. We have an issue template that helps us to gather relevant information to help diagnosing and fixing the issue.

zsw6666 commented 1 month ago

I just figured out that this error will be solved if I change the left_edge` and right_edge to a broader value.