Skip to content

Conversation

@PhilipDeegan
Copy link
Member

replaces #921

rebased to master
plotting stuff removed

@coderabbitai
Copy link

coderabbitai bot commented Jul 6, 2025

📝 Walkthrough

Walkthrough

This change replaces the use of "density" (number density) with "charge_density" (charge density) throughout the codebase for ions and their diagnostics. It introduces explicit separation between particle density and charge density in C++ core classes, updates Python and test code to request and process "charge_density", and adds supporting utilities and tests for these new conventions.

Changes

File(s) Change Summary
.gitignore Added .gdbinit to ignored files.
pyphare/pyphare/pharein/diagnostics.py Added "charge_density" to valid fluid diagnostic quantities.
pyphare/pyphare/pharesee/hierarchy/init.py, pyphare/pyphare/pharesee/hierarchy/fromfunc.py Added func parameter to hierarchy_from; introduced new module for generating mass/charge density profiles from functions and hierarchies.
pyphare/pyphare/pharesee/hierarchy/hierarchy.py Changed ghost cell count retrieval in plot1d to use a direct attribute.
pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py Added "charge_density" mapping to field_qties.
pyphare/pyphare/pharesee/plotting.py Changed charge density file reference to ions_charge_density.h5.
pyphare/pyphare/pharesee/run/run.py Replaced all references to ions_density.h5 with ions_charge_density.h5 and updated related logic.
pyphare/pyphare_tests/test_pharesee/test_hierarchy.py Changed fluid diagnostics to use "charge_density" instead of "density".
src/amr/level_initializer/hybrid_level_initializer.hpp Replaced ion moment computation from number density to charge density.
src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp Updated ghost filling and copying to use both particle and charge density.
src/amr/physical_models/hybrid_model.hpp Set model ion density to use charge density.
src/amr/tagging/default_hybrid_tagger_strategy.hpp Tagging now uses charge density instead of number density.
src/core/data/electrons/electrons.hpp All electron logic now uses ion charge density instead of number density.
src/core/data/ions/ion_population/ion_population.hpp Split density into particleDensity_ and chargeDensity_; updated all accessors and logic.
src/core/data/ions/ions.hpp Removed conditional logic for same masses; replaced density with charge density; updated all computations and accessors.
src/core/numerics/interpolator/interpolator.hpp Interpolator now deposits both particle and charge density.
src/core/numerics/ion_updater/ion_updater.hpp Ion updater now handles both particle and charge density; calls updated accordingly.
src/core/numerics/moments/moments.hpp Moments logic now handles both particle and charge density; updated all relevant code.
src/diagnostic/detail/types/fluid.hpp Fluid diagnostics now support and output "charge_density" for ions and populations.
src/phare/phare_init.py, src/phare/phare_init_small.py Fluid diagnostics now request "charge_density" instead of "density".
src/python3/patch_level.hpp Patch data population now uses charge density.
tests/core/data/electrons/test_electrons.cpp Expanded and renamed test fields; all references now use charge density.
tests/core/data/ion_population/test_ion_population_fixtures.hpp Changed internal identifier from "_rho" to "_particleDensity".
tests/core/data/ions/test_ions.cpp Test now expects exception on charge density access, not number density.
tests/core/numerics/interpolator/test_main.cpp Tests now check both particle and charge density deposition.
tests/core/numerics/ion_updater/test_updater.cpp All ion density fields split into particle and charge density; tests updated accordingly.
tests/diagnostic/init.py Fluid diagnostics now include "charge_density" and "mass_density".
tests/diagnostic/test_diagnostics.hpp, tests/diagnostic/test_diagnostics.ipp Tests now validate "charge_density" instead of "density"; updated expected files and attributes.
tests/functional/alfven_wave/alfven_wave1d.py, tests/functional/dispersion/dispersion.py, tests/functional/shock/shock.py, tests/functional/td/td1d.py, tests/functional/tdtagged/td1dtagged.py, tests/functional/translation/translat1d.py All fluid diagnostics now request "charge_density" instead of "density".
tests/simulator/initialize/CMakeLists.txt, tests/simulator/initialize/density_check.py Added new test and script to check initialization of charge and mass densities in 1D/2D; compares simulation output to analytical profiles.
tests/simulator/refinement/test_2d_10_core.py, tests/simulator/refinement/test_2d_2_core.py Fluid diagnostics updated to request "charge_density".
tests/simulator/test_advance.py, tests/simulator/test_initialization.py, tests/simulator/test_run.py All references to "density" and ions_density.h5 replaced by "charge_density" and ions_charge_density.h5 in diagnostics and test logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PythonSim
    participant CppCore
    participant Diagnostics
    participant HDF5
    participant TestSuite

    User->>PythonSim: Configure simulation with FluidDiagnostics("charge_density")
    PythonSim->>CppCore: Initialize ion populations
    CppCore->>CppCore: Compute particleDensity and chargeDensity for each population
    CppCore->>Diagnostics: Write "charge_density" and "mass_density" to HDF5
    Diagnostics->>HDF5: Store charge_density datasets
    TestSuite->>PythonSim: Load simulation results
    PythonSim->>Diagnostics: Read "charge_density" from HDF5
    TestSuite->>TestSuite: Compare to analytical charge_density profiles
Loading

Suggested labels

feature, refactoring, python, test

Suggested reviewers

  • nicolasaunai

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 817a526 and 4bbc4d5.

📒 Files selected for processing (3)
  • .gitignore (1 hunks)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (2 hunks)
  • src/amr/physical_models/hybrid_model.hpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • .gitignore
  • src/amr/physical_models/hybrid_model.hpp
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: build (macos-14)
  • GitHub Check: build (macos-13)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (ubuntu-latest, clang)
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (cpp)
  • GitHub Check: build (ubuntu-latest, gcc)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

return compute_hier_from(compute_, hier, **kwargs)


def hierarchy_from_func(func, hier, **kwargs):

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns

Mixing implicit and explicit returns may indicate an error as implicit returns always return None.

def hierarchy_from_func1d(func, hier, **kwargs):
assert hier.ndim == 1

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns Note

Mixing implicit and explicit returns may indicate an error, as implicit returns always return None.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (1)
src/core/data/ions/ions.hpp (1)

111-144: Add explicit zero-density guards in computeBulkVelocity to avoid division by zero

The current code unconditionally divides the accumulated flux by massDensity_, which may be zero in some cells, leading to NaNs or infinities and breaking physical consistency. You need to handle zero-density cases per cell, for example by defaulting the bulk velocity to zero (or another physically appropriate value) when density is zero.

Please update src/core/data/ions/ions.hpp in computeBulkVelocity() (around lines 138–143) like so:

-    std::transform(std::begin(vx), std::end(vx), std::begin(massDensity_), std::begin(vx),
-                   std::divides<Float>{});
+    std::transform(std::begin(vx), std::end(vx), std::begin(massDensity_), std::begin(vx),
+                   [](Float fluxVal, Float rho) {
+                       return rho != 0 ? fluxVal / rho : Float{0};
+                   });
 
-    std::transform(std::begin(vy), std::end(vy), std::begin(massDensity_), std::begin(vy),
-                   std::divides<Float>{});
+    std::transform(std::begin(vy), std::end(vy), std::begin(massDensity_), std::begin(vy),
+                   [](Float fluxVal, Float rho) {
+                       return rho != 0 ? fluxVal / rho : Float{0};
+                   });
 
-    std::transform(std::begin(vz), std::end(vz), std::begin(massDensity_), std::begin(vz),
-                   std::divides<Float>{});
+    std::transform(std::begin(vz), std::end(vz), std::begin(massDensity_), std::begin(vz),
+                   [](Float fluxVal, Float rho) {
+                       return rho != 0 ? fluxVal / rho : Float{0};
+                   });

This ensures zero-density cells produce well-defined bulk velocities in line with the physics requirements.

🧹 Nitpick comments (4)
src/amr/tagging/default_hybrid_tagger_strategy.hpp (1)

39-39: API change is correct, but consider the unused variable.

The change from model.state.ions.density() to model.state.ions.chargeDensity() correctly reflects the API refactoring. However, the variable N is declared but never used in the tagging logic. Consider whether this variable should be removed or if density-based tagging criteria are planned for future implementation.

tests/functional/harris/harris_2d_lb.py (2)

75-75: Improve variable naming for clarity.

The parameter name l is ambiguous and could be confused with the number 1.

-    def S(y, y0, l):
-        return 0.5 * (1.0 + np.tanh((y - y0) / l))
+    def S(y, y0, width):
+        return 0.5 * (1.0 + np.tanh((y - y0) / width))

189-189: Modernize super() calls for Python 3.

Use the more concise Python 3 style super() without arguments.

-        super(HarrisTest, self).__init__(*args, **kwargs)
+        super().__init__(*args, **kwargs)
-        super(HarrisTest, self).tearDown()
+        super().tearDown()

Also applies to: 193-193

tests/simulator/initialize/density_check.py (1)

279-279: Remove leftover debug comment.

Remove the file path comment that appears to be debug information:

-    # /home/smets/codes/far/PHARE/tests/simulator/initialize
-
 if __name__ == "__main__":
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09e9954 and 9f9e3f4.

📒 Files selected for processing (45)
  • .gitignore (1 hunks)
  • pyphare/pyphare/pharein/diagnostics.py (1 hunks)
  • pyphare/pyphare/pharesee/hierarchy/__init__.py (2 hunks)
  • pyphare/pyphare/pharesee/hierarchy/fromfunc.py (1 hunks)
  • pyphare/pyphare/pharesee/hierarchy/hierarchy.py (1 hunks)
  • pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py (1 hunks)
  • pyphare/pyphare/pharesee/plotting.py (1 hunks)
  • pyphare/pyphare/pharesee/run/run.py (3 hunks)
  • pyphare/pyphare_tests/test_pharesee/test_hierarchy.py (1 hunks)
  • src/amr/level_initializer/hybrid_level_initializer.hpp (1 hunks)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (2 hunks)
  • src/amr/physical_models/hybrid_model.hpp (1 hunks)
  • src/amr/tagging/default_hybrid_tagger_strategy.hpp (1 hunks)
  • src/core/data/electrons/electrons.hpp (4 hunks)
  • src/core/data/ions/ion_population/ion_population.hpp (5 hunks)
  • src/core/data/ions/ions.hpp (9 hunks)
  • src/core/numerics/interpolator/interpolator.hpp (3 hunks)
  • src/core/numerics/ion_updater/ion_updater.hpp (4 hunks)
  • src/core/numerics/moments/moments.hpp (2 hunks)
  • src/diagnostic/detail/types/fluid.hpp (5 hunks)
  • src/phare/phare_init.py (1 hunks)
  • src/phare/phare_init_small.py (1 hunks)
  • src/python3/patch_level.hpp (2 hunks)
  • tests/core/data/electrons/test_electrons.cpp (8 hunks)
  • tests/core/data/ion_population/test_ion_population_fixtures.hpp (1 hunks)
  • tests/core/data/ions/test_ions.cpp (1 hunks)
  • tests/core/numerics/interpolator/test_main.cpp (15 hunks)
  • tests/core/numerics/ion_updater/test_updater.cpp (12 hunks)
  • tests/diagnostic/__init__.py (1 hunks)
  • tests/diagnostic/test_diagnostics.hpp (4 hunks)
  • tests/diagnostic/test_diagnostics.ipp (1 hunks)
  • tests/functional/alfven_wave/alfven_wave1d.py (1 hunks)
  • tests/functional/dispersion/dispersion.py (1 hunks)
  • tests/functional/harris/harris_2d_lb.py (1 hunks)
  • tests/functional/shock/shock.py (1 hunks)
  • tests/functional/td/td1d.py (1 hunks)
  • tests/functional/tdtagged/td1dtagged.py (1 hunks)
  • tests/functional/translation/translat1d.py (2 hunks)
  • tests/simulator/initialize/CMakeLists.txt (1 hunks)
  • tests/simulator/initialize/density_check.py (1 hunks)
  • tests/simulator/refinement/test_2d_10_core.py (1 hunks)
  • tests/simulator/refinement/test_2d_2_core.py (1 hunks)
  • tests/simulator/test_advance.py (3 hunks)
  • tests/simulator/test_initialization.py (2 hunks)
  • tests/simulator/test_run.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.hpp`: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.

**/*.hpp: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • src/amr/level_initializer/hybrid_level_initializer.hpp
  • src/amr/tagging/default_hybrid_tagger_strategy.hpp
  • src/python3/patch_level.hpp
  • src/amr/physical_models/hybrid_model.hpp
  • tests/core/data/ion_population/test_ion_population_fixtures.hpp
  • src/core/numerics/ion_updater/ion_updater.hpp
  • src/diagnostic/detail/types/fluid.hpp
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp
  • tests/diagnostic/test_diagnostics.hpp
  • src/core/numerics/moments/moments.hpp
  • src/core/data/electrons/electrons.hpp
  • src/core/numerics/interpolator/interpolator.hpp
  • src/core/data/ions/ion_population/ion_population.hpp
  • src/core/data/ions/ions.hpp
🧠 Learnings (32)
📓 Common learnings
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#888
File: src/hdf5/detail/h5/h5_file.hpp:78-79
Timestamp: 2024-10-09T08:32:15.667Z
Learning: Avoid commenting on draft PRs for the user PhilipDeegan.
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#888
File: src/hdf5/detail/h5/h5_file.hpp:78-79
Timestamp: 2024-09-05T17:02:58.784Z
Learning: Avoid commenting on draft PRs for the user PhilipDeegan.
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#888
File: pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py:566-568
Timestamp: 2024-09-09T13:57:02.285Z
Learning: Avoid commenting on draft PRs for PhilipDeegan unless explicitly requested.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#784
File: tests/simulator/test_restarts.py:333-339
Timestamp: 2024-07-26T22:04:34.160Z
Learning: PhilipDeegan has indicated a preference for minimal and efficient code, even after making changes to get a function working. There may be opportunities to remove or optimize parts of the code such as sleep/wait/advances.
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#784
File: tests/simulator/test_restarts.py:333-339
Timestamp: 2024-10-09T08:32:15.667Z
Learning: PhilipDeegan has indicated a preference for minimal and efficient code, even after making changes to get a function working. There may be opportunities to remove or optimize parts of the code such as sleep/wait/advances.
src/phare/phare_init_small.py (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
tests/functional/td/td1d.py (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
tests/simulator/test_run.py (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
src/amr/level_initializer/hybrid_level_initializer.hpp (1)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
tests/functional/tdtagged/td1dtagged.py (3)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE simulations, velocity calculations must account for per-population densities that can be strictly zero in given cells. Simple zero-return solutions for division by zero are inadequate as they don't reflect the correct physics.
src/phare/phare_init.py (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
tests/functional/translation/translat1d.py (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
tests/simulator/initialize/CMakeLists.txt (2)
Learnt from: nicolasaunai
PR: PHAREHUB/PHARE#591
File: res/cmake/options.cmake:73-75
Timestamp: 2025-02-07T14:35:14.630Z
Learning: In CMake configuration for PHARE, `lowResourceTests` and `highResourceTests` options must be mutually exclusive and cannot be enabled simultaneously.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
tests/simulator/refinement/test_2d_10_core.py (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
pyphare/pyphare_tests/test_pharesee/test_hierarchy.py (4)
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#910
File: pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py:7-7
Timestamp: 2024-10-18T13:23:32.074Z
Learning: In the `pyphare.pharesee.hierarchy` module, importing `PatchHierarchy` and `format_timestamp` from `hierarchy.py` into `hierarchy_utils.py` is acceptable as long as `hierarchy.py` does not import `hierarchy_utils.py`, thereby avoiding a cyclic import.
Learnt from: nicolasaunai
PR: PHAREHUB/PHARE#891
File: tests/simulator/test_advance.py:50-50
Timestamp: 2024-09-19T17:16:57.787Z
Learning: In the `getHierarchy()` function, use random initialization for `model_init` by default instead of setting a fixed seed.
Learnt from: nicolasaunai
PR: PHAREHUB/PHARE#891
File: tests/simulator/test_advance.py:50-50
Timestamp: 2024-10-09T08:32:15.667Z
Learning: In the `getHierarchy()` function, use random initialization for `model_init` by default instead of setting a fixed seed.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
src/amr/tagging/default_hybrid_tagger_strategy.hpp (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
tests/functional/dispersion/dispersion.py (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
tests/simulator/refinement/test_2d_2_core.py (1)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
src/amr/physical_models/hybrid_model.hpp (1)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
tests/simulator/test_initialization.py (1)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
tests/diagnostic/__init__.py (1)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
src/core/numerics/ion_updater/ion_updater.hpp (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
src/diagnostic/detail/types/fluid.hpp (1)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
pyphare/pyphare/pharesee/hierarchy/__init__.py (3)
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#910
File: pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py:7-7
Timestamp: 2024-10-18T13:23:32.074Z
Learning: In the `pyphare.pharesee.hierarchy` module, importing `PatchHierarchy` and `format_timestamp` from `hierarchy.py` into `hierarchy_utils.py` is acceptable as long as `hierarchy.py` does not import `hierarchy_utils.py`, thereby avoiding a cyclic import.
Learnt from: nicolasaunai
PR: PHAREHUB/PHARE#891
File: tests/simulator/test_advance.py:50-50
Timestamp: 2024-09-19T17:16:57.787Z
Learning: In the `getHierarchy()` function, use random initialization for `model_init` by default instead of setting a fixed seed.
Learnt from: nicolasaunai
PR: PHAREHUB/PHARE#891
File: tests/simulator/test_advance.py:50-50
Timestamp: 2024-10-09T08:32:15.667Z
Learning: In the `getHierarchy()` function, use random initialization for `model_init` by default instead of setting a fixed seed.
pyphare/pyphare/pharesee/hierarchy/hierarchy.py (1)
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#910
File: pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py:7-7
Timestamp: 2024-10-18T13:23:32.074Z
Learning: In the `pyphare.pharesee.hierarchy` module, importing `PatchHierarchy` and `format_timestamp` from `hierarchy.py` into `hierarchy_utils.py` is acceptable as long as `hierarchy.py` does not import `hierarchy_utils.py`, thereby avoiding a cyclic import.
src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
tests/diagnostic/test_diagnostics.hpp (1)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
pyphare/pyphare/pharesee/run/run.py (1)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
src/core/numerics/moments/moments.hpp (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
src/core/data/electrons/electrons.hpp (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
src/core/data/ions/ion_population/ion_population.hpp (3)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE simulations, velocity calculations must account for per-population densities that can be strictly zero in given cells. Simple zero-return solutions for division by zero are inadequate as they don't reflect the correct physics.
tests/core/numerics/ion_updater/test_updater.cpp (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
pyphare/pyphare/pharesee/hierarchy/fromfunc.py (1)
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#910
File: pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py:7-7
Timestamp: 2024-10-18T13:23:32.074Z
Learning: In the `pyphare.pharesee.hierarchy` module, importing `PatchHierarchy` and `format_timestamp` from `hierarchy.py` into `hierarchy_utils.py` is acceptable as long as `hierarchy.py` does not import `hierarchy_utils.py`, thereby avoiding a cyclic import.
tests/simulator/initialize/density_check.py (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
tests/core/numerics/interpolator/test_main.cpp (2)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
src/core/data/ions/ions.hpp (3)
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: The bulk velocity calculation in PHARE must maintain physical consistency across both ion and electron calculations. Zero density cases need special handling that preserves the physics, particularly since the calculations are used in level initialization, ion updates, and electron physics.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE's physics simulations, handling of zero density cells in velocity calculations must be based on physical requirements rather than simple numerical fixes. The solution must account for population-specific behavior in the bulk velocity computation.
Learnt from: rochSmets
PR: PHAREHUB/PHARE#921
File: src/core/data/ions/ions.hpp:138-142
Timestamp: 2025-02-06T10:52:56.461Z
Learning: In PHARE simulations, velocity calculations must account for per-population densities that can be strictly zero in given cells. Simple zero-return solutions for division by zero are inadequate as they don't reflect the correct physics.
🧬 Code Graph Analysis (4)
src/amr/level_initializer/hybrid_level_initializer.hpp (2)
src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (6)
  • ions (393-407)
  • ions (393-394)
  • ions (420-461)
  • ions (420-421)
  • ions (469-474)
  • ions (469-470)
src/core/numerics/ion_updater/ion_updater.hpp (4)
  • ions (58-59)
  • ions (62-62)
  • ions (73-73)
  • ions (75-75)
tests/simulator/test_initialization.py (1)
pyphare/pyphare/pharesee/hierarchy/__init__.py (1)
  • hierarchy_from (13-46)
src/diagnostic/detail/types/fluid.hpp (3)
src/diagnostic/detail/h5typewriter.hpp (9)
  • checkCreateFileFor_ (135-142)
  • checkCreateFileFor_ (135-136)
  • diagnostic (32-32)
  • diagnostic (34-35)
  • diagnostic (39-41)
  • diagnostic (54-69)
  • diagnostic (54-54)
  • diagnostic (91-115)
  • diagnostic (91-95)
src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (6)
  • ions (393-407)
  • ions (393-394)
  • ions (420-461)
  • ions (420-421)
  • ions (469-474)
  • ions (469-470)
tests/core/numerics/ion_updater/test_updater.cpp (2)
  • ions (325-353)
  • ions (325-325)
tests/simulator/initialize/density_check.py (7)
pyphare/pyphare/pharesee/run/run.py (3)
  • Run (35-292)
  • GetMassDensity (112-114)
  • GetNi (116-118)
tests/diagnostic/__init__.py (1)
  • all_timestamps (8-12)
pyphare/pyphare/pharesee/hierarchy/__init__.py (1)
  • hierarchy_from (13-46)
pyphare/pyphare/pharesee/hierarchy/fromfunc.py (4)
  • ions_mass_density_func1d (6-16)
  • ions_charge_density_func1d (19-30)
  • ions_mass_density_func2d (47-59)
  • ions_charge_density_func2d (62-74)
pyphare/pyphare/pharein/maxwellian_fluid_model.py (1)
  • MaxwellianFluidModel (8-303)
pyphare/pyphare/pharein/electron_model.py (1)
  • ElectronModel (22-35)
pyphare/pyphare/simulator/simulator.py (1)
  • reset (259-269)
🪛 Ruff (0.11.9)
tests/functional/harris/harris_2d_lb.py

75-75: Ambiguous variable name: l

(E741)

🪛 Flake8 (7.2.0)
tests/functional/harris/harris_2d_lb.py

[error] 75-75: ambiguous variable name 'l'

(E741)

🪛 Pylint (3.3.7)
tests/functional/harris/harris_2d_lb.py

[refactor] 189-189: Consider using Python 3 style super() without arguments

(R1725)


[refactor] 193-193: Consider using Python 3 style super() without arguments

(R1725)

pyphare/pyphare/pharesee/hierarchy/fromfunc.py

[refactor] 92-92: Either all return statements in a function should return an expression, or none of them should.

(R1710)

tests/simulator/initialize/density_check.py

[error] 3-3: No name 'simulator' in module 'pyphare'

(E0611)


[error] 4-4: No name 'pharesee' in module 'pyphare'

(E0611)


[error] 6-6: No name 'pharein' in module 'pyphare'

(E0611)


[error] 8-8: No name 'pharein' in module 'pyphare'

(E0611)


[error] 11-11: No name 'pharein' in module 'pyphare'

(E0611)


[error] 17-17: No name 'pharesee' in module 'pyphare'

(E0611)


[error] 18-18: No name 'pharesee' in module 'pyphare'

(E0611)


[error] 19-19: No name 'pharesee' in module 'pyphare'

(E0611)


[error] 20-20: No name 'pharesee' in module 'pyphare'

(E0611)


[error] 21-21: No name 'pharesee' in module 'pyphare'

(E0611)


[refactor] 196-196: Too many local variables (17/15)

(R0914)


[error] 216-216: Possibly using variable 'dset_h' before assignment

(E0606)


[error] 216-216: Possibly using variable 'dset_H' before assignment

(E0606)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: build (macos-13)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (macos-14)
  • GitHub Check: build (ubuntu-latest, gcc)
  • GitHub Check: build (ubuntu-latest, clang)
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (cpp)
🔇 Additional comments (85)
.gitignore (1)

25-25: Ignoring .gdbinit keeps personal debugger settings out of the repo
Standard practice; no issues spotted.

pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py (1)

39-39: Good addition for charge density support.

The new mapping follows the existing pattern and enables hierarchy utilities to properly recognize and handle charge density fields alongside existing density types.

tests/functional/td/td1d.py (1)

103-103: Consistent with refactoring to explicit density types.

The change from "density" to "charge_density" aligns with the broader codebase refactoring and ensures tests validate the new explicit density diagnostic types.

tests/functional/shock/shock.py (1)

110-110: Maintains consistency across functional tests.

The update to "charge_density" is consistent with the refactoring effort and ensures all functional tests use the same explicit density diagnostic types.

src/phare/phare_init_small.py (1)

107-107: Correctly updates initialization script diagnostics.

The change ensures initialization scripts use the new explicit charge density diagnostics, maintaining consistency between examples and the broader refactoring effort.

src/phare/phare_init.py (1)

104-104: Completes consistent refactoring across initialization scripts.

The update to "charge_density" in the main initialization script ensures all diagnostic setups use explicit density types, completing the coordinated refactoring effort.

tests/functional/alfven_wave/alfven_wave1d.py (1)

99-99: LGTM: Diagnostic quantity updated to use charge density

The change from "density" to "charge_density" aligns with the broader refactoring to explicitly handle charge density diagnostics.

tests/functional/dispersion/dispersion.py (1)

174-174: LGTM: Consistent diagnostic quantity update

The change to "charge_density" maintains consistency with the broader refactoring across the test suite.

tests/simulator/test_run.py (1)

145-145: LGTM: Test updated for charge density diagnostics

The change correctly updates the diagnostic quantity to "charge_density", maintaining consistency with the refactoring.

src/amr/level_initializer/hybrid_level_initializer.hpp (1)

101-101: LGTM: Method call updated for explicit charge density computation

The change from computeDensity() to computeChargeDensity() improves code expressiveness by being explicit about the type of density being computed. This aligns with the broader refactoring to distinguish between particle and charge densities.

src/amr/physical_models/hybrid_model.hpp (1)

157-157: LGTM: Field name updated for explicit charge density handling

The change from densityName() to chargeDensityName() improves code expressiveness by being explicit about the charge density field. This enhances code clarity and aligns with the systematic refactoring to distinguish between different density types.

tests/core/data/ions/test_ions.cpp (1)

157-157: LGTM! Correctly updated API call for the refactoring.

The change from ions.density()(0) to ions.chargeDensity()(0) correctly reflects the API refactoring to distinguish charge density from particle density.

tests/simulator/refinement/test_2d_10_core.py (1)

104-104: LGTM! Correctly updated diagnostic quantity name.

The change from "density" to "charge_density" properly reflects the refactoring to explicitly distinguish charge density in fluid diagnostics.

pyphare/pyphare/pharesee/plotting.py (1)

277-277: LGTM! Correctly updated data file naming convention.

The change from "ions_density.h5" to "ions_charge_density.h5" properly aligns with the refactoring to explicitly distinguish charge density data files.

tests/diagnostic/test_diagnostics.ipp (1)

17-17: LGTM! Correctly updated diagnostic path.

The change from hi5.fluid("/ions/density") to hi5.fluid("/ions/charge_density") properly reflects the refactoring of diagnostic paths to explicitly use charge density terminology.

tests/functional/tdtagged/td1dtagged.py (1)

123-123: LGTM! Consistent with charge density refactoring.

The change from "density" to "charge_density" aligns with the systematic refactoring across the codebase to explicitly distinguish between particle density and charge density in fluid diagnostics.

tests/simulator/initialize/CMakeLists.txt (1)

23-24: LGTM! Good addition of density validation test.

The new test execution for density_check.py appropriately validates the charge and mass density initialization, which is essential given the refactoring from generic density to specific density types.

pyphare/pyphare/pharein/diagnostics.py (1)

225-225: LGTM! Core enabler for charge density diagnostics.

Adding "charge_density" to the fluid_quantities list enables this diagnostic quantity throughout the codebase, supporting the systematic refactoring from generic density to explicit charge density.

tests/functional/translation/translat1d.py (2)

90-90: LGTM! Consistent diagnostic quantity update.

The change to "charge_density" in the fluid diagnostics is consistent with the systematic refactoring across the codebase.


185-185: LGTM! Consistent diagnostic quantity update.

The change to "charge_density" in the fluid diagnostics maintains consistency with the refactoring pattern applied across all test configurations.

pyphare/pyphare_tests/test_pharesee/test_hierarchy.py (1)

148-148: LGTM! Consistent with systematic refactoring.

The update to "charge_density" in the fluid diagnostics maintains consistency with the broader refactoring pattern applied across all tests and maintains proper test coverage for the new diagnostic quantities.

tests/simulator/refinement/test_2d_2_core.py (1)

104-104: LGTM! Diagnostic quantity update aligns with density refactoring.

The change from "density" to "charge_density" is consistent with the broader refactoring to distinguish between particle and charge densities throughout the codebase.

tests/core/data/ion_population/test_ion_population_fixtures.hpp (1)

53-53: LGTM! Field identifier update aligns with density refactoring.

The change from "_rho" to "_particleDensity" properly reflects the new naming conventions introduced in the refactoring that distinguishes particle density from charge density.

tests/diagnostic/__init__.py (2)

31-36: LGTM! Comprehensive expansion of diagnostic coverage.

The addition of both "charge_density" and "mass_density" to the top-level fluid diagnostics provides complete coverage of the new density types introduced in the refactoring.


44-44: LGTM! Population-specific charge density diagnostics added.

Adding "charge_density" alongside the existing "density" for population-specific diagnostics maintains comprehensive diagnostic coverage while supporting the new density distinctions.

src/python3/patch_level.hpp (2)

40-40: LGTM! Method call updated to use charge density API.

The change from ions.density() to ions.chargeDensity() correctly uses the new API introduced in the density refactoring.


62-62: LGTM! Population method call updated to charge density API.

The change from pop.density() to pop.chargeDensity() properly uses the new population-specific charge density method.

tests/simulator/test_initialization.py (2)

173-173: LGTM! Diagnostic quantity updated for density refactoring.

The change from "density" to "charge_density" correctly updates the test to use the new diagnostic quantity name introduced in the refactoring.


235-237: LGTM! Diagnostic file reference updated for new naming convention.

The change from "ions_density.h5" to "ions_charge_density.h5" correctly updates the filename to match the new diagnostic file naming convention introduced in the refactoring.

tests/simulator/test_advance.py (2)

155-155: LGTM: Diagnostic update is consistent with the refactoring.

The change from "density" to "charge_density" correctly aligns with the broader codebase refactoring that introduces explicit charge density diagnostics.


225-225: LGTM: HDF5 filename updates are consistent.

The filename changes from "ions_density.h5" to "ions_charge_density.h5" correctly reflect the new charge density diagnostic output files.

Also applies to: 234-234

pyphare/pyphare/pharesee/hierarchy/hierarchy.py (1)

436-436: LGTM: Direct ghost cell access simplifies the implementation.

The change from layout.nbrGhostFor(qty) to patch.patch_datas[qty].ghosts_nbr directly accesses ghost cell counts from patch data, which is consistent with the updated data handling in the charge density refactoring.

src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (3)

443-447: LGTM: Interpolation correctly handles both particle and charge densities.

The separation of density into particleDensity and chargeDensity variables and their inclusion in the interpolation call correctly implements the new physics data model while maintaining computational consistency.


454-454: LGTM: Level ghost particle interpolation properly updated.

The interpolation calls for level ghost particles (both old and new) correctly pass both particle and charge densities, ensuring consistent moment computation across the AMR hierarchy.

Also applies to: 457-457


578-578: LGTM: PrepareStep correctly uses charge density.

The change from ions.density() to ions.chargeDensity() in the prepareStep method is consistent with the refactoring and ensures the messenger uses the appropriate density field for electromagnetic calculations.

src/core/numerics/ion_updater/ion_updater.hpp (2)

161-161: LGTM: Interpolator calls correctly updated for dual density fields.

The interpolator calls have been systematically updated to pass both particleDensity() and chargeDensity() parameters, which correctly reflects the separation of these physical quantities.

Also applies to: 184-185, 273-274


110-110: Approve computeChargeDensity zero–density behavior
The new computeChargeDensity() implementation explicitly zeroes chargeDensity_ and then sums each population’s charge density. Any cells with zero population density remain zero in the result, matching the original behavior and preserving physical consistency. No additional special‐case handling is required here.

pyphare/pyphare/pharesee/hierarchy/__init__.py (1)

14-14: LGTM: Function extension follows established patterns.

The addition of the func parameter and corresponding logic properly extends the hierarchy_from function to support functional hierarchy generation. The conditional logic is correctly positioned and the import is appropriately placed.

Also applies to: 18-18, 43-44

tests/diagnostic/test_diagnostics.hpp (2)

125-125: LGTM: Test validation correctly updated for charge density.

The changes from density() to chargeDensity() are consistent with the broader refactoring and correctly validate the new charge density fields.

Also applies to: 128-128


229-229: expectedPopAttrFiles correctly reflects 6 per-population file types
The loop in tests/diagnostic/test_diagnostics.hpp (lines 247–253) calls h5FileTypes.emplace_back exactly six times (domain, levelGhost, patchGhost, density, charge_density, flux), so

constexpr std::size_t expectedPopAttrFiles = 6;

is accurate. No changes required.

src/core/numerics/moments/moments.hpp (2)

18-20: LGTM: Moment reset correctly handles dual density fields.

The separation of the single density().zero() operation into separate particleDensity().zero() and chargeDensity().zero() operations is correct and ensures both fields are properly initialized.


44-46: LGTM: Interpolation calls systematically updated for dual densities.

The addition of separate particleDensity and chargeDensity variables and their consistent use in all interpolation calls correctly implements the dual density moment computation.

Also applies to: 51-51, 56-56, 61-61

src/diagnostic/detail/types/fluid.hpp (3)

149-150: LGTM: File creation logic correctly extended for charge density.

The addition of "charge_density" to the diagnostic file creation checks for both populations and ions is systematic and consistent with the broader refactoring.

Also applies to: 154-155


202-204: Note the semantic change in density handling.

For populations, "density" now refers to particleDensity() while "charge_density" refers to chargeDensity(). For ions, only chargeDensity() is used. This semantic shift is consistent but worth noting for future reference.

Also applies to: 212-213


274-275: LGTM: Dataset operations consistently handle charge density.

The initialization, writing, and attribute handling for charge density datasets are systematically implemented across all relevant methods, maintaining consistency with the existing patterns.

Also applies to: 283-284, 315-317, 325-326, 355-355

tests/core/numerics/interpolator/test_main.cpp (6)

517-517: LGTM: Charge density grid addition is correct.

The addition of the rho_c grid for charge density alongside the existing rho grid properly supports the dual-density interpolation model. The grid initialization and usage are consistent.

Also applies to: 533-533


523-527: Clear documentation of test setup.

The updated comment effectively explains the test configuration where particles are arranged to produce particle density of 1 and charge density of 2, making the test expectations clear.


652-652: Correct interpolator call signature update.

The interpolator call properly includes both rho and rho_c parameters, correctly implementing the new dual-density interface.


670-670: Proper test assertion for charge density.

The test correctly validates that rho_c at the target index equals 2.0, ensuring the charge density deposition works as expected.


699-699: Consistent 2D test structure.

The 2D test fixture correctly includes the rho_c grid and passes it to the interpolator, maintaining consistency with the 1D test pattern.

Also applies to: 706-706, 720-720


541-560: Charge values yield the correct normalized density of 2.0

All three interpolation orders produce a weighted‐average charge of 2.0 once you divide the raw deposition by the sum of the weights at the target cell:

  • Order 1:
    • Raw sum = 1.0⋅2.0 + 0.4⋅1.85 + 0.6⋅2.1 = 4.0
    • Total weight = 1.0 + 0.4 + 0.6 = 2.0
    • 4.0 / 2.0 = 2.0

  • Order 2:
    • Raw sum = 1.0⋅2.0 + 0.2⋅3.2 + 0.8⋅1.7 + 1.0⋅2.0 = 6.0
    • Total weight = 1.0 + 0.2 + 0.8 + 1.0 = 3.0
    • 6.0 / 3.0 = 2.0

  • Order 3:
    • Raw sum = 1.0⋅2.0 + 1.0⋅2.0 + 1.0⋅2.0 + 0.1⋅3.35 + 0.9⋅1.85 = 8.0
    • Total weight = 1.0 + 1.0 + 1.0 + 0.1 + 0.9 = 4.0
    • 8.0 / 4.0 = 2.0

No changes are required—the test’s expected 2.0 charge density is correct.

pyphare/pyphare/pharesee/run/run.py (3)

30-30: Consistent file naming convention update.

The change from "ions_density" to "ions_charge_density" in the quantities mapping correctly reflects the new diagnostic file naming convention.


117-117: GetNi method correctly updated for charge density.

The method now loads ion charge density from the appropriately named file, maintaining the semantic meaning of "Ni" as ion density in the physics context.


154-154: Electron pressure calculation uses correct density.

The GetPe method correctly uses charge density for electron pressure calculation, which is physically appropriate since electron pressure depends on charge-weighted ion density.

src/core/numerics/interpolator/interpolator.hpp (3)

472-475: Clear parameter naming for dual-density interface.

The parameter names particleDensity and chargeDensity clearly distinguish the two density types, improving code readability and reducing potential confusion.


490-496: Correct physics implementation for dual deposition.

The deposition logic properly implements the physics:

  • Particle density: deposits constant weight (1.0) representing particle count
  • Charge density: deposits particle charge representing charge contribution

This correctly separates particle counting from charge-weighted quantities.


509-513: Consistent forwarding operator signature.

The rvalue reference forwarding operator correctly maintains the same dual-density interface, ensuring consistent API usage for both lvalue and rvalue particle ranges.

src/core/data/electrons/electrons.hpp (3)

68-68: Correct density accessor update for electron models.

The density() methods now correctly return ion charge density instead of particle density. This is physically appropriate since electron models require charge-weighted ion density for quasi-neutrality and current calculations.

Also applies to: 81-81


115-115: Physics-correct electron velocity calculation.

The bulk velocity computation correctly uses ion charge density (ions_.chargeDensity()) in the electron velocity formula: Ve = Vi - J/Ne. This maintains physical consistency since current density J is charge-based and requires charge density for proper normalization.

Also applies to: 122-122, 129-131


214-214: Appropriate electron pressure calculation.

The isothermal electron pressure closure correctly uses ion charge density (ions_.chargeDensity()) for computing Pe = Ne * Te. This maintains quasi-neutrality assumptions where electron density equals ion charge density.

tests/functional/harris/harris_2d_lb.py (2)

137-138: Correct usage of charge_density diagnostics.

The fluid diagnostics correctly use "charge_density" instead of the deprecated generic "density", properly exercising the updated diagnostic infrastructure introduced in this PR.

Also applies to: 140-142


40-148: Well-structured simulation configuration.

The simulation setup comprehensively covers all aspects needed for a Harris current sheet test: appropriate domain size, AMR configuration, initial conditions with hyperbolic tangent profiles, and comprehensive diagnostics. The optional load balancing integration is well-implemented.

src/core/data/ions/ion_population/ion_population.hpp (4)

29-39: Constructor initialization looks good.

The initialization of particleDensity_ and chargeDensity_ fields follows the established naming convention and properly uses the HybridQuantity::Scalar::rho centering.


48-56: Resource state checks properly updated.

Both isUsable() and isSettable() correctly include the new particleDensity_ and chargeDensity_ fields in their validation logic.


79-83: Accessor methods properly implement const-correctness.

The split into separate particleDensity() and chargeDensity() accessors with both const and non-const variants follows best practices.


100-104: Resource management properly updated.

The getCompileTimeResourcesViewList() correctly includes both density fields in the resource tuple, maintaining consistency with the ResourcesUser interface pattern.

Also applies to: 127-128

pyphare/pyphare/pharesee/hierarchy/fromfunc.py (3)

6-30: 1D density computation functions are well-implemented.

The functions correctly compute mass-weighted and charge-weighted densities by summing contributions from multiple ion populations. Good use of numpy for efficiency.


47-74: 2D density functions correctly handle coordinate meshgrids.

The functions properly use np.meshgrid(y, x) to create coordinate arrays and sum across the population dimension. The implementation is consistent with the 1D versions.


33-89: Hierarchy wrapper functions properly integrate with the framework.

The hierarchy_from_func1d and hierarchy_from_func2d functions correctly extract coordinates from patch data and return the expected data structure for compute_hier_from.

tests/core/numerics/ion_updater/test_updater.cpp (3)

214-219: Test buffer struct properly updated for dual density model.

The addition of separate particleDensity and chargeDensity fields for each population correctly reflects the refactored ion data model.


241-254: Constructor and buffer management correctly updated.

The constructors properly initialize all density fields with descriptive names, and setBuffers() correctly assigns them using structured bindings. The updates maintain consistency with the refactored ion data structures.

Also applies to: 278-291, 325-353


543-543: Test methods comprehensively updated for new density model.

All test methods correctly use the split density fields. The interpolation calls properly pass both particleDensity and chargeDensity, and density validation appropriately checks particleDensity against the prescribed functions.

Also applies to: 556-567, 577-588, 615-626, 669-673

tests/core/data/electrons/test_electrons.cpp (2)

151-153: Test fixture members properly expanded for new density model.

The addition of separate particle and charge density fields for ions and protons, along with distinct tensor fields, correctly supports testing of the refactored electron model.

Also applies to: 166-167, 196-205


164-187: Test logic correctly validates electron-ion charge density equality.

The test properly uses ions.chargeDensity() to validate that electron density equals ion charge density, maintaining the physical correctness of the charge neutrality condition.

Also applies to: 247-247, 276-277, 323-324, 373-373

tests/simulator/initialize/density_check.py (3)

1-32: Test setup and imports look appropriate.

The global parameters and matplotlib backend configuration are suitable for automated testing. The pylint import errors appear to be false positives related to the PHARE module structure.


58-111: Simulation configurations are comprehensive and well-structured.

Both 1D and 2D configurations properly set up multi-population simulations with appropriate diagnostics for validating the new density model. Good coverage of both fluid-level and population-level quantities.

Also applies to: 140-193


198-201: Good practice resetting simulator state between tests.

Properly clearing the global simulation state with reset() and setting ph.global_vars.sim = None ensures clean test isolation.

src/core/data/ions/ions.hpp (8)

44-45: Constructor initialization looks good.

The dual initialization of massDensity_ and chargeDensity_ properly reflects the new density model.


60-65: Density accessor methods are well-implemented.

The const and non-const overloads for both density types maintain proper const-correctness.


75-91: Charge density computation is correctly implemented.

The accumulation pattern using std::transform with std::plus is efficient and clear.


102-108: Mass density calculation correctly weights particle densities.

The lambda properly accumulates mass-weighted particle densities from each population.


175-176: Resource usability checks properly updated.

Both density fields are correctly included in the usability validation.


189-190: Settability validation correctly includes both densities.

The method properly ensures all density fields are settable.


214-215: Resource view list properly updated.

Both density fields are correctly exposed for resource management.


238-240: Member variables correctly declared.

The charge and mass density fields are properly defined with consistent types.

Comment on lines +92 to +97
def hierarchy_from_func(func, hier, **kwargs):
if hier.ndim == 1:
return hierarchy_from_func1d(func, hier, **kwargs)
if hier.ndim == 2:
return hierarchy_from_func2d(func, hier, **kwargs)

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling for unsupported dimensions.

The function implicitly returns None for dimensions other than 1 or 2. This should explicitly raise an error to provide clear feedback.

Add explicit error handling:

 def hierarchy_from_func(func, hier, **kwargs):
     if hier.ndim == 1:
         return hierarchy_from_func1d(func, hier, **kwargs)
     if hier.ndim == 2:
         return hierarchy_from_func2d(func, hier, **kwargs)
+    raise ValueError(f"Unsupported dimension: {hier.ndim}. Only 1D and 2D are supported.")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def hierarchy_from_func(func, hier, **kwargs):
if hier.ndim == 1:
return hierarchy_from_func1d(func, hier, **kwargs)
if hier.ndim == 2:
return hierarchy_from_func2d(func, hier, **kwargs)
def hierarchy_from_func(func, hier, **kwargs):
if hier.ndim == 1:
return hierarchy_from_func1d(func, hier, **kwargs)
if hier.ndim == 2:
return hierarchy_from_func2d(func, hier, **kwargs)
+ raise ValueError(f"Unsupported dimension: {hier.ndim}. Only 1D and 2D are supported.")
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 92-92: Either all return statements in a function should return an expression, or none of them should.

(R1710)

🤖 Prompt for AI Agents
In pyphare/pyphare/pharesee/hierarchy/fromfunc.py around lines 92 to 97, the
function hierarchy_from_func currently returns None implicitly for hier.ndim
values other than 1 or 2. Add explicit error handling by raising a ValueError
with a clear message indicating that only 1D and 2D hierarchies are supported.
This will provide clear feedback when unsupported dimensions are passed.

Comment on lines +202 to +218
def assert_close_enough(h, H):
for lvl_h, lvl_H in zip(h.levels(time).values(), H.levels(time).values()):
for patch_h, patch_H in zip(lvl_h.patches, lvl_H.patches):
pd_h = patch_h.patch_datas["value"]
pd_H = patch_H.patch_datas["value"]
ghosts_num = pd_h.ghosts_nbr[0]

if pd_H.ndim == 1:
dset_h = pd_h.dataset[ghosts_num:-ghosts_num]
dset_H = pd_H.dataset[ghosts_num:-ghosts_num]
if pd_H.ndim == 2:
dset_h = pd_h.dataset[ghosts_num:-ghosts_num, ghosts_num:-ghosts_num]
dset_H = pd_H.dataset[ghosts_num:-ghosts_num, ghosts_num:-ghosts_num]

std = np.std(dset_h - dset_H)
print("dim = {}, sigma(user v - actual v) = {}".format(pd_H.ndim, std))
assert( std < 0.06 ) # empirical value obtained from print just above
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix potential undefined variables and use proper assertions.

The function has undefined variable issues if pd_H.ndim is neither 1 nor 2. Also, use proper test assertions instead of bare assert.

Fix the conditional logic and assertion:

 def assert_close_enough(h, H):
     for lvl_h, lvl_H in zip(h.levels(time).values(), H.levels(time).values()):
         for patch_h, patch_H in zip(lvl_h.patches, lvl_H.patches):
             pd_h = patch_h.patch_datas["value"]
             pd_H = patch_H.patch_datas["value"]
             ghosts_num = pd_h.ghosts_nbr[0]

             if pd_H.ndim == 1:
                 dset_h = pd_h.dataset[ghosts_num:-ghosts_num]
                 dset_H = pd_H.dataset[ghosts_num:-ghosts_num]
-            if pd_H.ndim == 2:
+            elif pd_H.ndim == 2:
                 dset_h = pd_h.dataset[ghosts_num:-ghosts_num, ghosts_num:-ghosts_num]
                 dset_H = pd_H.dataset[ghosts_num:-ghosts_num, ghosts_num:-ghosts_num]
+            else:
+                raise ValueError(f"Unsupported patch data dimension: {pd_H.ndim}")

             std = np.std(dset_h - dset_H)
             print("dim = {}, sigma(user v - actual v) = {}".format(pd_H.ndim, std))
-            assert( std < 0.06 )  # empirical value obtained from print just above
+            np.testing.assert_less(std, 0.06, f"Standard deviation {std} exceeds threshold")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def assert_close_enough(h, H):
for lvl_h, lvl_H in zip(h.levels(time).values(), H.levels(time).values()):
for patch_h, patch_H in zip(lvl_h.patches, lvl_H.patches):
pd_h = patch_h.patch_datas["value"]
pd_H = patch_H.patch_datas["value"]
ghosts_num = pd_h.ghosts_nbr[0]
if pd_H.ndim == 1:
dset_h = pd_h.dataset[ghosts_num:-ghosts_num]
dset_H = pd_H.dataset[ghosts_num:-ghosts_num]
if pd_H.ndim == 2:
dset_h = pd_h.dataset[ghosts_num:-ghosts_num, ghosts_num:-ghosts_num]
dset_H = pd_H.dataset[ghosts_num:-ghosts_num, ghosts_num:-ghosts_num]
std = np.std(dset_h - dset_H)
print("dim = {}, sigma(user v - actual v) = {}".format(pd_H.ndim, std))
assert( std < 0.06 ) # empirical value obtained from print just above
def assert_close_enough(h, H):
for lvl_h, lvl_H in zip(h.levels(time).values(), H.levels(time).values()):
for patch_h, patch_H in zip(lvl_h.patches, lvl_H.patches):
pd_h = patch_h.patch_datas["value"]
pd_H = patch_H.patch_datas["value"]
ghosts_num = pd_h.ghosts_nbr[0]
if pd_H.ndim == 1:
dset_h = pd_h.dataset[ghosts_num:-ghosts_num]
dset_H = pd_H.dataset[ghosts_num:-ghosts_num]
elif pd_H.ndim == 2:
dset_h = pd_h.dataset[ghosts_num:-ghosts_num, ghosts_num:-ghosts_num]
dset_H = pd_H.dataset[ghosts_num:-ghosts_num, ghosts_num:-ghosts_num]
else:
raise ValueError(f"Unsupported patch data dimension: {pd_H.ndim}")
std = np.std(dset_h - dset_H)
print("dim = {}, sigma(user v - actual v) = {}".format(pd_H.ndim, std))
np.testing.assert_less(std, 0.06, f"Standard deviation {std} exceeds threshold")
🧰 Tools
🪛 Pylint (3.3.7)

[error] 216-216: Possibly using variable 'dset_h' before assignment

(E0606)


[error] 216-216: Possibly using variable 'dset_H' before assignment

(E0606)

🤖 Prompt for AI Agents
In tests/simulator/initialize/density_check.py around lines 202 to 218, the
function assert_close_enough does not handle cases where pd_H.ndim is not 1 or
2, leading to potential undefined variables dset_h and dset_H. Also, it uses
bare assert statements which should be replaced with proper test framework
assertions. Fix this by adding an else clause to handle unexpected ndim values,
raising an error or skipping, and replace bare assert with a proper assertion
method like self.assertTrue or pytest's assert with a clear message.

auto& Bz = model.state.electromag.B.getComponent(PHARE::core::Component::Z);

auto& N = model.state.ions.density();
auto& N = model.state.ions.chargeDensity();

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable N is not used.
auto static _ions(Args&... args)
{
auto const& [Fi, Nibuffer, NiProtons, Vi, M, protons_M, pack]
auto const& [ionFlux, ionChargeDensity, ionMassDensity, protonParticleDensity,

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable (unnamed local variable) is not used.
{
auto const& [V, m, d, md] = ions.getCompileTimeResourcesViewList();
d.setBuffer(&Nibuffer);
auto const& [V, m, d_c, d_m] = ions.getCompileTimeResourcesViewList();

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable (unnamed local variable) is not used.
{
{
auto const& [V, m, d, md] = ions.getCompileTimeResourcesViewList();
auto const& [V, m, cd, md] = ions.getCompileTimeResourcesViewList();

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable (unnamed local variable) is not used.
{
auto const& [F, M, d, particles] = pops[0].getCompileTimeResourcesViewList();
d.setBuffer(&protonDensity);
auto const& [F, M, d, c, particles] = pops[0].getCompileTimeResourcesViewList();

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable (unnamed local variable) is not used.
{
auto const& [F, M, d, particles] = pops[1].getCompileTimeResourcesViewList();
d.setBuffer(&alphaDensity);
auto const& [F, M, d, c, particles] = pops[1].getCompileTimeResourcesViewList();

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable (unnamed local variable) is not used.
auto& Bz = model.state.electromag.B.getComponent(PHARE::core::Component::Z);

auto& N = model.state.ions.density();
auto& N = model.state.ions.chargeDensity();

Check notice

Code scanning / CodeQL

Unused local variable

Variable N is not used.
auto static _ions(Args&... args)
{
auto const& [Fi, Nibuffer, NiProtons, Vi, M, protons_M, pack]
auto const& [ionFlux, ionChargeDensity, ionMassDensity, protonParticleDensity,

Check notice

Code scanning / CodeQL

Unused local variable

Variable (unnamed local variable) is not used.
{
auto const& [V, m, d, md] = ions.getCompileTimeResourcesViewList();
d.setBuffer(&Nibuffer);
auto const& [V, m, d_c, d_m] = ions.getCompileTimeResourcesViewList();

Check notice

Code scanning / CodeQL

Unused local variable

Variable (unnamed local variable) is not used.
d.setBuffer(&NiProtons);
Fi.set_on(F);
protons_M.set_on(m);
auto const& [F, m, Np, Nc, poppack] = pops[0].getCompileTimeResourcesViewList();

Check notice

Code scanning / CodeQL

Unused local variable

Variable (unnamed local variable) is not used.
{
{
auto const& [V, m, d, md] = ions.getCompileTimeResourcesViewList();
auto const& [V, m, cd, md] = ions.getCompileTimeResourcesViewList();

Check notice

Code scanning / CodeQL

Unused local variable

Variable (unnamed local variable) is not used.
{
auto const& [F, M, d, particles] = pops[0].getCompileTimeResourcesViewList();
d.setBuffer(&protonDensity);
auto const& [F, M, d, c, particles] = pops[0].getCompileTimeResourcesViewList();

Check notice

Code scanning / CodeQL

Unused local variable

Variable (unnamed local variable) is not used.
{
auto const& [F, M, d, particles] = pops[1].getCompileTimeResourcesViewList();
d.setBuffer(&alphaDensity);
auto const& [F, M, d, c, particles] = pops[1].getCompileTimeResourcesViewList();

Check notice

Code scanning / CodeQL

Unused local variable

Variable (unnamed local variable) is not used.
@PhilipDeegan PhilipDeegan merged commit 4556f63 into PHAREHUB:master Jul 8, 2025
13 checks passed
@PhilipDeegan PhilipDeegan deleted the charge branch July 8, 2025 17:53
PhilipDeegan added a commit to PhilipDeegan/PHARE that referenced this pull request Jul 11, 2025
PhilipDeegan added a commit to PhilipDeegan/PHARE that referenced this pull request Jul 11, 2025
PhilipDeegan added a commit to PhilipDeegan/PHARE that referenced this pull request Jul 16, 2025
PhilipDeegan added a commit to PhilipDeegan/PHARE that referenced this pull request Jul 16, 2025
PhilipDeegan pushed a commit to PhilipDeegan/PHARE that referenced this pull request Jul 16, 2025
PhilipDeegan pushed a commit to PhilipDeegan/PHARE that referenced this pull request Jul 16, 2025
PhilipDeegan pushed a commit to PhilipDeegan/PHARE that referenced this pull request Jul 16, 2025
This was referenced Sep 17, 2025
PhilipDeegan added a commit to PhilipDeegan/PHARE that referenced this pull request Oct 8, 2025
UCaromel pushed a commit to UCaromel/PHARE that referenced this pull request Oct 14, 2025
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.

3 participants