Skip to content

Refactoring_code_structure#75

Merged
cwoolfo1 merged 6 commits intouwplasma:mainfrom
cwoolfo1:refactoring_code_structure
Mar 17, 2026
Merged

Refactoring_code_structure#75
cwoolfo1 merged 6 commits intouwplasma:mainfrom
cwoolfo1:refactoring_code_structure

Conversation

@cwoolfo1
Copy link
Member

Updating the structure of the main code base for easier readability:

Subfolders

  • deposition: contains charge and current deposition algorithms
    -particles: contains particle species classes and initialization algorithms.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the PyPIC3D codebase into clearer subpackages by moving particle-related logic into PyPIC3D/particles and charge/current deposition logic into PyPIC3D/deposition, updating imports across the project accordingly.

Changes:

  • Moved particle species + initialization code from PyPIC3D/particle.py into PyPIC3D/particles/species_class.py and PyPIC3D/particles/particle_initialization.py.
  • Moved deposition utilities (rho, J_from_rhov, Esirkepov, shapes) into PyPIC3D/deposition/* and updated all import sites (solvers, initialization, CLI, tests).
  • Removed legacy top-level modules (PyPIC3D/J.py, PyPIC3D/rho.py, PyPIC3D/shapes.py, PyPIC3D/particle.py) and reformatted a few sections for readability.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/particle_test.py Updates imports to new particles/ and deposition/ modules.
tests/electrostatic_yee_test.py Updates particle_species import to new location.
PyPIC3D/solvers/electrostatic_yee.py Switches compute_rho import to deposition.rho.
PyPIC3D/initialization.py Updates imports for particle init + deposition modules under new subpackages.
PyPIC3D/diagnostics/fluid_quantities.py Updates shapes import to deposition.shapes.
PyPIC3D/boris.py Updates shapes import to deposition.shapes.
PyPIC3D/main.py Updates compute_rho import to deposition.rho.
PyPIC3D/init.py Switches package imports to new subpackages (but needs cleanup/fixes per comments).
PyPIC3D/particles/species_class.py New home for particle_species implementation (moved from particle.py).
PyPIC3D/particles/particle_initialization.py New home for particle initialization + TOML loading (moved from particle.py).
PyPIC3D/particles/flat_particles.py Formatting/readability tweaks.
PyPIC3D/deposition/shapes.py New home for deposition shape functions (moved from shapes.py).
PyPIC3D/deposition/rho.py New home for compute_rho (moved from rho.py).
PyPIC3D/deposition/J_from_rhov.py New home for J_from_rhov (moved from J.py).
PyPIC3D/deposition/Esirkepov.py New home for Esirkepov_current (moved from J.py).
PyPIC3D/shapes.py Deleted (migrated to PyPIC3D/deposition/shapes.py).
PyPIC3D/rho.py Deleted (migrated to PyPIC3D/deposition/rho.py).
PyPIC3D/J.py Deleted (migrated to PyPIC3D/deposition/*).
PyPIC3D/particle.py Deleted (migrated to PyPIC3D/particles/*).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +16 to +19
from .deposition import shapes
from .deposition import Esirkepov
from .deposition import J_from_rhov
from .deposition import rho
from .deposition import shapes
from .deposition import Esirkepov
from .deposition import J_from_rhov
from .deposition import rho
cwoolfo1 and others added 2 commits March 17, 2026 11:26
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the PyPIC3D codebase into clearer subpackages by moving particle-related logic into PyPIC3D/particles/ and deposition algorithms into PyPIC3D/deposition/, then updating internal code and tests to use the new import paths.

Changes:

  • Moved particle species class + TOML-based particle initialization into PyPIC3D/particles/.
  • Moved charge/current deposition + shape functions into PyPIC3D/deposition/.
  • Updated imports across solvers, initialization, CLI entrypoints, diagnostics, and tests to match the new structure.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/particle_test.py Updated imports to new particles/ + deposition/ module locations.
tests/electrostatic_yee_test.py Updated particle_species import path.
PyPIC3D/solvers/electrostatic_yee.py Updated compute_rho import path to deposition/.
PyPIC3D/shapes.py Removed (migrated to PyPIC3D/deposition/shapes.py).
PyPIC3D/rho.py Removed (migrated to PyPIC3D/deposition/rho.py).
PyPIC3D/particles/species_class.py Added new location for particle_species implementation.
PyPIC3D/particles/particle_initialization.py Added new location for particle initialization/TOML loading utilities.
PyPIC3D/particles/flat_particles.py Formatting-only changes in periodic wrapping logic.
PyPIC3D/particle.py Removed (split into species_class.py + particle_initialization.py).
PyPIC3D/initialization.py Updated imports for particle loading + deposition routines.
PyPIC3D/diagnostics/fluid_quantities.py Updated shape-function import to deposition/shapes.py.
PyPIC3D/deposition/shapes.py Added new location for shape/weighting functions.
PyPIC3D/deposition/rho.py Added new location for charge deposition (compute_rho).
PyPIC3D/deposition/J_from_rhov.py Added new location for J_from_rhov.
PyPIC3D/deposition/Esirkepov.py Added new location for Esirkepov current deposition.
PyPIC3D/boris.py Updated shape-function import to deposition/shapes.py.
PyPIC3D/main.py Updated compute_rho import path to deposition/.
PyPIC3D/init.py Updated top-level imports to include new subpackages/modules.
PyPIC3D/J.py Removed (migrated to PyPIC3D/deposition/).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

inverse_total_debye = 0

for toml_key in particle_keys:
N_particles = config[toml_key]["N_particles"]
Comment on lines +138 to +144
weight = compute_macroparticle_weight(
config, particle_keys, simulation_parameters, world, constants
)

for toml_key in particle_keys:
key1, key2, key3 = jax.random.key(i), jax.random.key(i + 1), jax.random.key(i + 2)
i += 3
Comment on lines +8 to +10
from PyPIC3D.particles.particle_initialization import (
initial_particles
)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@cwoolfo1 cwoolfo1 merged commit 6743e04 into uwplasma:main Mar 17, 2026
1 check passed
@cwoolfo1 cwoolfo1 deleted the refactoring_code_structure branch March 17, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants