Skip to content

Commit

Permalink
change ions.density in ions.chargeDensity... doesnt work !
Browse files Browse the repository at this point in the history
  • Loading branch information
rochSmets committed Sep 12, 2024
1 parent 12fca6b commit 92069af
Show file tree
Hide file tree
Showing 26 changed files with 42 additions and 41 deletions.
3 changes: 2 additions & 1 deletion pyphare/pyphare/pharein/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def population_in_model(population):
class FluidDiagnostics_(Diagnostics):
fluid_quantities = [
"density",
"charge_density",
"mass_density",
"flux",
"bulkVelocity",
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyphare/pyphare/pharesee/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions pyphare/pyphare/pharesee/run/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"EM_B": "B",
"EM_E": "E",
"ions_bulkVelocity": "Vi",
"ions_density": "Ni",
"ions_charge_density": "Ni",
"particle_count": "nppc",
}

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pyphare/pyphare_tests/test_pharesee/test_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions src/diagnostic/detail/types/fluid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void FluidDiagnosticWriter<H5Writer>::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/"};
Expand Down Expand Up @@ -206,8 +206,8 @@ void FluidDiagnosticWriter<H5Writer>::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"))
Expand Down Expand Up @@ -275,8 +275,8 @@ void FluidDiagnosticWriter<H5Writer>::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"))
Expand Down Expand Up @@ -315,8 +315,8 @@ void FluidDiagnosticWriter<H5Writer>::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"))
Expand Down Expand Up @@ -344,7 +344,7 @@ void FluidDiagnosticWriter<H5Writer>::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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/phare/phare_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion src/phare/phare_init_small.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion src/python3/patch_level.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GridLayout>(*hierarchy_.getPatchLevel(lvl_),
Expand Down
2 changes: 1 addition & 1 deletion tests/core/data/electrons/test_electrons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/core/data/ions/test_ions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/diagnostic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/diagnostic/test_diagnostics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down Expand Up @@ -236,7 +236,7 @@ void validateAttributes(Simulator& sim, Hi5Diagnostic& hi5)
auto nbrPop = dict["simulation"]["ions"]["nbrPopulations"].template to<std::size_t>();
EXPECT_EQ(nbrPop, expectedPopNbr);

std::vector<std::string> h5FileTypes{"/EM_B", "/EM_E", "/ions/density", "/ions/bulkVelocity"};
std::vector<std::string> h5FileTypes{"/EM_B", "/EM_E", "/ions/charge_density", "/ions/bulkVelocity"};

for (std::size_t i = 0; i < nbrPop; ++i)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/diagnostic/test_diagnostics.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void fluid_test(Simulator&& sim, std::string out_dir)

{ // Scoped to destruct after dump
Hi5Diagnostic<Hierarchy, HybridModel> 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"))
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/alfven_wave/alfven_wave1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/dispersion/dispersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/harris/harris_2d_lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/shock/shock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/td/td1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/tdtagged/td1dtagged.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/translation/translat1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/simulator/refinement/test_2d_10_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/simulator/refinement/test_2d_2_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/simulator/test_advance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/simulator/test_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion tests/simulator/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 92069af

Please sign in to comment.