From 92069af1be569d63c824bcb5df9259d280c92535 Mon Sep 17 00:00:00 2001 From: roch smets Date: Thu, 12 Sep 2024 08:08:41 +0200 Subject: [PATCH] change ions.density in ions.chargeDensity... doesnt work ! --- pyphare/pyphare/pharein/diagnostics.py | 3 ++- pyphare/pyphare/pharesee/plotting.py | 2 +- pyphare/pyphare/pharesee/run/run.py | 6 +++--- .../test_pharesee/test_hierarchy.py | 2 +- .../hybrid_hybrid_messenger_strategy.hpp | 2 +- src/diagnostic/detail/types/fluid.hpp | 16 ++++++++-------- src/phare/phare_init.py | 2 +- src/phare/phare_init_small.py | 2 +- src/python3/patch_level.hpp | 2 +- tests/core/data/electrons/test_electrons.cpp | 2 +- tests/core/data/ions/test_ions.cpp | 2 +- tests/diagnostic/__init__.py | 2 +- tests/diagnostic/test_diagnostics.hpp | 4 ++-- tests/diagnostic/test_diagnostics.ipp | 2 +- tests/functional/alfven_wave/alfven_wave1d.py | 2 +- tests/functional/dispersion/dispersion.py | 2 +- tests/functional/harris/harris_2d_lb.py | 4 ++-- tests/functional/shock/shock.py | 2 +- tests/functional/td/td1d.py | 2 +- tests/functional/tdtagged/td1dtagged.py | 2 +- tests/functional/translation/translat1d.py | 4 ++-- tests/simulator/refinement/test_2d_10_core.py | 2 +- tests/simulator/refinement/test_2d_2_core.py | 2 +- tests/simulator/test_advance.py | 6 +++--- tests/simulator/test_initialization.py | 4 ++-- tests/simulator/test_run.py | 2 +- 26 files changed, 42 insertions(+), 41 deletions(-) diff --git a/pyphare/pyphare/pharein/diagnostics.py b/pyphare/pyphare/pharein/diagnostics.py index 2721c9633..3c999aa26 100644 --- a/pyphare/pyphare/pharein/diagnostics.py +++ b/pyphare/pyphare/pharein/diagnostics.py @@ -222,6 +222,7 @@ def population_in_model(population): class FluidDiagnostics_(Diagnostics): fluid_quantities = [ "density", + "charge_density", "mass_density", "flux", "bulkVelocity", @@ -290,7 +291,7 @@ def __init__(self, **kwargs): if for_total_ions(**kwargs): needed_quantities = ["mass_density", "bulkVelocity", "momentum_tensor"] else: - needed_quantities = ["density", "flux", "momentum_tensor"] + needed_quantities = ["charge_density", "flux", "momentum_tensor"] for quantity in needed_quantities: kwargs["quantity"] = quantity diff --git a/pyphare/pyphare/pharesee/plotting.py b/pyphare/pyphare/pharesee/plotting.py index 180db4375..8f7614919 100644 --- a/pyphare/pyphare/pharesee/plotting.py +++ b/pyphare/pyphare/pharesee/plotting.py @@ -274,7 +274,7 @@ def finest_field_plot(run_path, qty, **kwargs): time = times[0] interpolator, finest_coords = r.GetVi(time, merged=True, interp=interp)[qty] elif qty == "rho": - file = os.path.join(run_path, "ions_density.h5") + file = os.path.join(run_path, "ions_charge_density.h5") if time is None: times = get_times_from_h5(file) time = times[0] diff --git a/pyphare/pyphare/pharesee/run/run.py b/pyphare/pyphare/pharesee/run/run.py index c965696f0..53e672d92 100644 --- a/pyphare/pyphare/pharesee/run/run.py +++ b/pyphare/pyphare/pharesee/run/run.py @@ -27,7 +27,7 @@ "EM_B": "B", "EM_E": "E", "ions_bulkVelocity": "Vi", - "ions_density": "Ni", + "ions_charge_density": "Ni", "particle_count": "nppc", } @@ -116,7 +116,7 @@ def GetMassDensity(self, time, merged=False, interp="nearest", **kwargs): return ScalarField(self._get(hier, time, merged, interp)) def GetNi(self, time, merged=False, interp="nearest", **kwargs): - hier = self._get_hierarchy(time, "ions_density.h5", **kwargs) + hier = self._get_hierarchy(time, "ions_charge_density.h5", **kwargs) return ScalarField(self._get(hier, time, merged, interp)) def GetN(self, time, pop_name, merged=False, interp="nearest", **kwargs): @@ -153,7 +153,7 @@ def GetPi(self, time, merged=False, interp="nearest", **kwargs): return self._get(Pi, time, merged, interp) # should later be a TensorField def GetPe(self, time, merged=False, interp="nearest", all_primal=True): - hier = self._get_hierarchy(time, "ions_density.h5") + hier = self._get_hierarchy(time, "ions_charge_density.h5") Te = hier.sim.electrons.closure.Te diff --git a/pyphare/pyphare_tests/test_pharesee/test_hierarchy.py b/pyphare/pyphare_tests/test_pharesee/test_hierarchy.py index f65bb39f0..908484607 100644 --- a/pyphare/pyphare_tests/test_pharesee/test_hierarchy.py +++ b/pyphare/pyphare_tests/test_pharesee/test_hierarchy.py @@ -145,7 +145,7 @@ def vthz(x, y): for quantity in ["E", "B"]: ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) return sim diff --git a/src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp b/src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp index 520d6d9ce..e47bc5779 100644 --- a/src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp +++ b/src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp @@ -539,7 +539,7 @@ namespace amr auto& J = hybridModel.state.J; auto& Vi = hybridModel.state.ions.velocity(); - auto& Ni = hybridModel.state.ions.density(); + auto& Ni = hybridModel.state.ions.chargeDensity(); Jold_.copyData(J); ViOld_.copyData(Vi); diff --git a/src/diagnostic/detail/types/fluid.hpp b/src/diagnostic/detail/types/fluid.hpp index 9da918e22..da0b5d7d3 100644 --- a/src/diagnostic/detail/types/fluid.hpp +++ b/src/diagnostic/detail/types/fluid.hpp @@ -146,7 +146,7 @@ void FluidDiagnosticWriter::createFiles(DiagnosticProperties& diagnost for (auto const& pop : this->h5Writer_.modelView().getIons()) { std::string tree{"/ions/pop/" + pop.name() + "/"}; - checkCreateFileFor_(diagnostic, fileData_, tree, "density", "flux", "momentum_tensor"); + checkCreateFileFor_(diagnostic, fileData_, tree, "charge_density", "flux", "momentum_tensor"); } std::string tree{"/ions/"}; @@ -206,8 +206,8 @@ void FluidDiagnosticWriter::getDataSetInfo(DiagnosticProperties& diagn } std::string tree{"/ions/"}; - if (isActiveDiag(diagnostic, tree, "density")) - infoDS(ions.density(), "density", patchAttributes[lvlPatchID]["ion"]); + if (isActiveDiag(diagnostic, tree, "charge_density")) + infoDS(ions.chargeDensity(), "charge_density", patchAttributes[lvlPatchID]["ion"]); if (isActiveDiag(diagnostic, tree, "mass_density")) infoDS(ions.massDensity(), "mass_density", patchAttributes[lvlPatchID]["ion"]); if (isActiveDiag(diagnostic, tree, "bulkVelocity")) @@ -275,8 +275,8 @@ void FluidDiagnosticWriter::initDataSets( } std::string tree{"/ions/"}; - if (isActiveDiag(diagnostic, tree, "density")) - initDS(path, attr["ion"], "density", null); + if (isActiveDiag(diagnostic, tree, "charge_density")) + initDS(path, attr["ion"], "charge_density", null); if (isActiveDiag(diagnostic, tree, "mass_density")) initDS(path, attr["ion"], "mass_density", null); if (isActiveDiag(diagnostic, tree, "bulkVelocity")) @@ -315,8 +315,8 @@ void FluidDiagnosticWriter::write(DiagnosticProperties& diagnostic) } std::string tree{"/ions/"}; - if (isActiveDiag(diagnostic, tree, "density")) - writeDS(path + "density", ions.density()); + if (isActiveDiag(diagnostic, tree, "charge_density")) + writeDS(path + "charge_density", ions.chargeDensity()); if (isActiveDiag(diagnostic, tree, "mass_density")) writeDS(path + "mass_density", ions.massDensity()); if (isActiveDiag(diagnostic, tree, "bulkVelocity")) @@ -344,7 +344,7 @@ void FluidDiagnosticWriter::writeAttributes( for (auto& pop : h5Writer.modelView().getIons()) { std::string tree = "/ions/pop/" + pop.name() + "/"; - checkWrite(tree, "density", pop); + checkWrite(tree, "charge_density", pop); checkWrite(tree, "flux", pop); checkWrite(tree, "momentum_tensor", pop); } diff --git a/src/phare/phare_init.py b/src/phare/phare_init.py index 2c90bce3a..d79de42b7 100644 --- a/src/phare/phare_init.py +++ b/src/phare/phare_init.py @@ -101,7 +101,7 @@ def vthz(x): ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) -for quantity in ["density", "bulkVelocity"]: +for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) pops = [ diff --git a/src/phare/phare_init_small.py b/src/phare/phare_init_small.py index b4bccc1cb..f3f8e76e1 100644 --- a/src/phare/phare_init_small.py +++ b/src/phare/phare_init_small.py @@ -104,7 +104,7 @@ def vthz(x): ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) -for quantity in ["density", "bulkVelocity"]: +for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) pops = [ diff --git a/src/python3/patch_level.hpp b/src/python3/patch_level.hpp index 28449f071..b7600a44a 100644 --- a/src/python3/patch_level.hpp +++ b/src/python3/patch_level.hpp @@ -37,7 +37,7 @@ class PatchLevel auto& ions = model_.state.ions; auto visit = [&](GridLayout& grid, std::string patchID, std::size_t /*iLevel*/) { - setPatchDataFromField(patchDatas.emplace_back(), ions.density(), grid, patchID); + setPatchDataFromField(patchDatas.emplace_back(), ions.chargeDensity(), grid, patchID); }; PHARE::amr::visitLevel(*hierarchy_.getPatchLevel(lvl_), diff --git a/tests/core/data/electrons/test_electrons.cpp b/tests/core/data/electrons/test_electrons.cpp index 1cef24a3e..421140891 100644 --- a/tests/core/data/electrons/test_electrons.cpp +++ b/tests/core/data/electrons/test_electrons.cpp @@ -368,7 +368,7 @@ TYPED_TEST(ElectronsTest, ThatElectronsDensityEqualIonDensity) electrons.update(layout); auto& Ne = electrons.density(); - auto& Ni = ions.density(); + auto& Ni = ions.chargeDensity(); if constexpr (dim == 1) { diff --git a/tests/core/data/ions/test_ions.cpp b/tests/core/data/ions/test_ions.cpp index 7fb1b1426..11769fac2 100644 --- a/tests/core/data/ions/test_ions.cpp +++ b/tests/core/data/ions/test_ions.cpp @@ -154,7 +154,7 @@ TEST_F(theIons, areSettableUponConstruction) #ifndef NDEBUG // no throw in release mode! JUST SEGFAULTS! :D TEST_F(theIons, throwIfAccessingDensityWhileNotUsable) { - EXPECT_ANY_THROW(auto& n = ions.density()(0)); + EXPECT_ANY_THROW(auto& n = ions.chargeDensity()(0)); } #endif diff --git a/tests/diagnostic/__init__.py b/tests/diagnostic/__init__.py index fb7c52d96..0bf944d61 100644 --- a/tests/diagnostic/__init__.py +++ b/tests/diagnostic/__init__.py @@ -28,7 +28,7 @@ def dump_all_diags(pops=[], flush_every=100, timestamps=None): # write_timestamps=timestamps # ) - for quantity in ["density", "bulkVelocity", "pressure_tensor"]: + for quantity in ["charge_density", "bulkVelocity", "pressure_tensor"]: ph.FluidDiagnostics( quantity=quantity, write_timestamps=timestamps, diff --git a/tests/diagnostic/test_diagnostics.hpp b/tests/diagnostic/test_diagnostics.hpp index 7fedf1895..01cf10859 100644 --- a/tests/diagnostic/test_diagnostics.hpp +++ b/tests/diagnostic/test_diagnostics.hpp @@ -125,7 +125,7 @@ void validateFluidDump(Simulator& sim, Hi5Diagnostic& hi5) checkF(layout, path, "/ions/pop/" + pop.name(), "/density"s, pop.chargeDensity()); checkVF(layout, path, "/ions/pop/" + pop.name(), "/flux"s, pop.flux()); } - checkF(layout, path, "/ions"s, "/density"s, ions.density()); + checkF(layout, path, "/ions"s, "/charge_density"s, ions.chargeDensity()); std::string tree{"/ions"}, var{"/bulkVelocity"}; auto hifile = hi5.writer.makeFile(hi5.writer.fileString(tree + var), hi5.flags_); @@ -236,7 +236,7 @@ void validateAttributes(Simulator& sim, Hi5Diagnostic& hi5) auto nbrPop = dict["simulation"]["ions"]["nbrPopulations"].template to(); EXPECT_EQ(nbrPop, expectedPopNbr); - std::vector h5FileTypes{"/EM_B", "/EM_E", "/ions/density", "/ions/bulkVelocity"}; + std::vector h5FileTypes{"/EM_B", "/EM_E", "/ions/charge_density", "/ions/bulkVelocity"}; for (std::size_t i = 0; i < nbrPop; ++i) { diff --git a/tests/diagnostic/test_diagnostics.ipp b/tests/diagnostic/test_diagnostics.ipp index b6813b165..e108c465b 100644 --- a/tests/diagnostic/test_diagnostics.ipp +++ b/tests/diagnostic/test_diagnostics.ipp @@ -14,7 +14,7 @@ void fluid_test(Simulator&& sim, std::string out_dir) { // Scoped to destruct after dump Hi5Diagnostic hi5{hierarchy, hybridModel, out_dir, NEW_HI5_FILE}; - hi5.dMan.addDiagDict(hi5.fluid("/ions/density")) + hi5.dMan.addDiagDict(hi5.fluid("/ions/charge_density")) .addDiagDict(hi5.fluid("/ions/bulkVelocity")) .addDiagDict(hi5.fluid("/ions/momentum_tensor")) .addDiagDict(hi5.fluid("/ions/pop/alpha/density")) diff --git a/tests/functional/alfven_wave/alfven_wave1d.py b/tests/functional/alfven_wave/alfven_wave1d.py index dc830ce13..1fe582bc1 100644 --- a/tests/functional/alfven_wave/alfven_wave1d.py +++ b/tests/functional/alfven_wave/alfven_wave1d.py @@ -96,7 +96,7 @@ def vthz(x): for quantity in ["E", "B"]: ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) return sim diff --git a/tests/functional/dispersion/dispersion.py b/tests/functional/dispersion/dispersion.py index ad6619984..67ab8d831 100644 --- a/tests/functional/dispersion/dispersion.py +++ b/tests/functional/dispersion/dispersion.py @@ -171,7 +171,7 @@ def vthz(x): quantity=quantity, write_timestamps=timestamps, flush_every=0 ) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics( quantity=quantity, write_timestamps=timestamps, flush_every=0 ) diff --git a/tests/functional/harris/harris_2d_lb.py b/tests/functional/harris/harris_2d_lb.py index e701e8231..3351a04bb 100644 --- a/tests/functional/harris/harris_2d_lb.py +++ b/tests/functional/harris/harris_2d_lb.py @@ -133,11 +133,11 @@ def vthxyz(x, y): for quantity in ["E", "B"]: ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) ph.FluidDiagnostics( - quantity="density", write_timestamps=timestamps, population_name="protons" + quantity="charge_density", write_timestamps=timestamps, population_name="protons" ) ph.InfoDiagnostics(quantity="particle_count") diff --git a/tests/functional/shock/shock.py b/tests/functional/shock/shock.py index 7fd0a6ec2..6cc63f297 100644 --- a/tests/functional/shock/shock.py +++ b/tests/functional/shock/shock.py @@ -107,7 +107,7 @@ def vthz(x): for quantity in ["E", "B"]: ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) return sim diff --git a/tests/functional/td/td1d.py b/tests/functional/td/td1d.py index 7a715a182..e21d9f28d 100644 --- a/tests/functional/td/td1d.py +++ b/tests/functional/td/td1d.py @@ -100,7 +100,7 @@ def vthz(x): for quantity in ["E", "B"]: ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics( quantity=quantity, write_timestamps=timestamps, diff --git a/tests/functional/tdtagged/td1dtagged.py b/tests/functional/tdtagged/td1dtagged.py index b3a240ed2..82019527e 100644 --- a/tests/functional/tdtagged/td1dtagged.py +++ b/tests/functional/tdtagged/td1dtagged.py @@ -117,7 +117,7 @@ def config(**options): for quantity in ["E", "B"]: ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) for pop in sim.model.populations: diff --git a/tests/functional/translation/translat1d.py b/tests/functional/translation/translat1d.py index 53eb7daa0..6a5321698 100644 --- a/tests/functional/translation/translat1d.py +++ b/tests/functional/translation/translat1d.py @@ -87,7 +87,7 @@ def vthz(x): for quantity in ["E", "B"]: ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) return sim @@ -182,7 +182,7 @@ def vthz(x): for quantity in ["E", "B"]: ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) return sim diff --git a/tests/simulator/refinement/test_2d_10_core.py b/tests/simulator/refinement/test_2d_10_core.py index dfb88703a..114b7296b 100644 --- a/tests/simulator/refinement/test_2d_10_core.py +++ b/tests/simulator/refinement/test_2d_10_core.py @@ -101,7 +101,7 @@ def vthz(x, y): for quantity in ["E", "B"]: ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) return sim diff --git a/tests/simulator/refinement/test_2d_2_core.py b/tests/simulator/refinement/test_2d_2_core.py index af017f60c..545f38d10 100644 --- a/tests/simulator/refinement/test_2d_2_core.py +++ b/tests/simulator/refinement/test_2d_2_core.py @@ -101,7 +101,7 @@ def vthz(x, y): for quantity in ["E", "B"]: ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) return sim diff --git a/tests/simulator/test_advance.py b/tests/simulator/test_advance.py index 569f2c873..40a673123 100644 --- a/tests/simulator/test_advance.py +++ b/tests/simulator/test_advance.py @@ -152,7 +152,7 @@ def vthz(*xyz): for quantity in ["E", "B"]: ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: FluidDiagnostics( quantity=quantity, write_timestamps=timestamps, @@ -222,7 +222,7 @@ def vthz(*xyz): h5_filename=diag_outputs + "/EM_B.h5", hier=eb_hier ) mom_hier = hierarchy_from( - h5_filename=diag_outputs + "/ions_density.h5", hier=eb_hier + h5_filename=diag_outputs + "/ions_charge_density.h5", hier=eb_hier ) mom_hier = hierarchy_from( h5_filename=diag_outputs + "/ions_bulkVelocity.h5", hier=mom_hier @@ -231,7 +231,7 @@ def vthz(*xyz): if qty == "moments" or qty == "fields": mom_hier = hierarchy_from( - h5_filename=diag_outputs + "/ions_density.h5", hier=eb_hier + h5_filename=diag_outputs + "/ions_charge_density.h5", hier=eb_hier ) mom_hier = hierarchy_from( h5_filename=diag_outputs + "/ions_bulkVelocity.h5", hier=mom_hier diff --git a/tests/simulator/test_initialization.py b/tests/simulator/test_initialization.py index 4314205f9..d545080f2 100644 --- a/tests/simulator/test_initialization.py +++ b/tests/simulator/test_initialization.py @@ -170,7 +170,7 @@ def vthz(*xyz): quantity=quantity, write_timestamps=np.zeros(time_step_nbr) ) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: FluidDiagnostics( quantity=quantity, write_timestamps=np.zeros(time_step_nbr) ) @@ -232,7 +232,7 @@ def vthz(*xyz): return particle_hier if qty == "moments": - mom_hier = hierarchy_from(h5_filename=diag_outputs + "/ions_density.h5") + mom_hier = hierarchy_from(h5_filename=diag_outputs + "/ions_charge_density.h5") mom_hier = hierarchy_from( h5_filename=diag_outputs + "/ions_bulkVelocity.h5", hier=mom_hier ) diff --git a/tests/simulator/test_run.py b/tests/simulator/test_run.py index 8480db130..c27ea8d76 100644 --- a/tests/simulator/test_run.py +++ b/tests/simulator/test_run.py @@ -146,7 +146,7 @@ def vthz(x, y): for quantity in ["E", "B"]: ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) - for quantity in ["density", "bulkVelocity"]: + for quantity in ["charge_density", "bulkVelocity"]: ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) pop = "protons"