Skip to content

Commit

Permalink
Add functionality to print file with the number of electrons.
Browse files Browse the repository at this point in the history
  • Loading branch information
branmedi committed Jun 20, 2024
1 parent da4bb9f commit f3c1859
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/vpic/dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ vpic_simulation::dump_ionization_states( const char *fname,
auto ionization_energy_h = Kokkos::create_mirror(sp->ionization_energy);
Kokkos::deep_copy(ionization_energy_h, sp->ionization_energy);

// Ignore electrons
if (std::string(sp->name) == "electron" || ionization_energy_h(0) == 0) {
// Ignore species with ionization energy set to 0, except for electrons
if (std::string(sp->name) != "electron" && ionization_energy_h(0) == 0) {
// Skip file creation for the "electron" species or when ionization isnt desired for a species
continue;
}
Expand Down Expand Up @@ -132,15 +132,28 @@ vpic_simulation::dump_ionization_states( const char *fname,


N_ions = ionization_states_kokkos( sp ); // Number of particles in each ionization state

// printf("N_ions: %f, %f, %f, %f, %f, %f\n", N_ions(0), N_ions(1), N_ions(2), N_ions(3), N_ions(4), N_ions(5));

auto N_ions_h = Kokkos::create_mirror(N_ions);
Kokkos::deep_copy(N_ions_h, N_ions);

if (rank() == 0 && status != fail) {
for (size_t i = 0; i < N_ions_h.extent(0); ++i) {
fileIO.print(" %lld", N_ions_h(i));
// Calculate the total number of electrons
int np_global;
if (std::string(sp->name) == "electron") {
int np = sp->np;
mp_allsum_i( &np, &np_global, 1 );
}

// Print Number of particles in each ionization state
// For electrons, print total number
if (std::string(sp->name) != "electron") {
if (rank() == 0 && status != fail) {
for (size_t i = 0; i < N_ions_h.extent(0); ++i) {
fileIO.print(" %lld", N_ions_h(i));
}
}
} else {
if (rank() == 0 && status != fail) {
fileIO.print(" %lld", np_global);
}
}

Expand Down

0 comments on commit f3c1859

Please sign in to comment.