diff --git a/src/python/ImpactX.cpp b/src/python/ImpactX.cpp index b1413fd1b..c80f1dde4 100644 --- a/src/python/ImpactX.cpp +++ b/src/python/ImpactX.cpp @@ -6,6 +6,7 @@ #include "pyImpactX.H" #include +#include #include #include @@ -360,6 +361,32 @@ void init_ImpactX (py::module& m) "``0`` for silent, higher is more verbose. Default is ``1``." ) + .def("deposit_charge", + [](ImpactX & ix) { + // transform from x',y',t to x,y,z + transformation::CoordinateTransformation( + *(ix.amr_data)->m_particle_container, + CoordSystem::t); + + // Note: The following operation assume that + // the particles are in x, y, z coordinates. + + // Resize the mesh, based on `m_particle_container` extent + ix.ResizeMesh(); + + // Redistribute particles in the new mesh in x, y, z + ix.amr_data->m_particle_container->Redistribute(); + + // charge deposition + ix.amr_data->m_particle_container->DepositCharge(ix.amr_data->m_rho, ix.amr_data->refRatio()); + + // transform from x,y,z to x',y',t + transformation::CoordinateTransformation(*(ix.amr_data)->m_particle_container, + CoordSystem::s); + }, + "Deposit charge in x,y,z." + ) + .def("finalize", &ImpactX::finalize, "Deallocate all contexts and data." ) diff --git a/tests/python/test_charge_deposition.py b/tests/python/test_charge_deposition.py index 1b2037c62..8dd24c031 100755 --- a/tests/python/test_charge_deposition.py +++ b/tests/python/test_charge_deposition.py @@ -25,7 +25,6 @@ def test_charge_deposition(save_png=True): sim.n_cell = [16, 24, 32] sim.load_inputs_file(basepath + "/examples/fodo/input_fodo.in") - sim.space_charge = True sim.slice_step_diagnostics = False # Future: @@ -41,6 +40,8 @@ def test_charge_deposition(save_png=True): sim.evolve() + sim.deposit_charge() + rho = sim.rho(lev=0) rs = rho.sum_unique(comp=0, local=False)