From 3327402317e547b330933059250ea28166eb5b3d Mon Sep 17 00:00:00 2001 From: Brandon Medina Date: Tue, 10 Sep 2024 11:52:29 -0600 Subject: [PATCH] Changed things to fix restarts and make things faster. --- src/species_advance/species_advance.cc | 20 ++++------- src/species_advance/species_advance.h | 16 +++++---- src/species_advance/standard/advance_p.cc | 18 +++++----- .../standard/ionization_states.cc | 20 +++++------ src/vpic/dump.cc | 18 ++++------ src/vpic/vpic.h | 4 +-- test/integrated/legacy/accel.deck | 9 +++-- test/integrated/legacy/cyclo.deck | 9 +++-- test/integrated/legacy/inbndj.deck | 9 +++-- test/integrated/legacy/interpe.deck | 9 +++-- test/integrated/to_completion/dump.deck | 9 +++-- .../to_completion/reconnection_test.deck | 18 +++++----- test/integrated/to_completion/simple.deck | 9 +++-- test/unit/energy_comparison/weibel_driver.cc | 9 +++-- .../field_ionization_benchmark.cxx | 33 +++++++++---------- test/unit/legacy_comparison/hydro_p.cc | 6 ++-- test/unit/legacy_comparison/rho_p.cc | 9 +++-- 17 files changed, 101 insertions(+), 124 deletions(-) diff --git a/src/species_advance/species_advance.cc b/src/species_advance/species_advance.cc index e34c4b49..75dcbd5d 100644 --- a/src/species_advance/species_advance.cc +++ b/src/species_advance/species_advance.cc @@ -30,12 +30,9 @@ checkpt_species( const species_t * sp ) { CHECKPT_PTR( sp->pb_diag ); #ifdef FIELD_IONIZATION - size_t ionization_energy_size = sp->ionization_energy.size(); - CHECKPT_VAL(size_t, ionization_energy_size); - checkpt_data( sp->ionization_energy.data(), - sp->ionization_energy.size() * sizeof(double), - sp->ionization_energy.size() * sizeof(double), - 1, 1, 128 ); + checkpt_data( sp->ionization_energy, + sp->n_energy * sizeof(double), + sp->n_energy * sizeof(double), 1, 1, 128 ); #endif } @@ -52,11 +49,7 @@ restore_species( void ) { RESTORE_PTR( sp->pb_diag ); #ifdef FIELD_IONIZATION - size_t ionization_energy_size; - RESTORE_VAL(size_t, ionization_energy_size); - - double *ionization_energies = (double *)restore_data(); - std::copy(ionization_energies, ionization_energies + ionization_energy_size, sp->ionization_energy.data()); + sp->ionization_energy = (double *)restore_data(); #endif return sp; @@ -127,7 +120,7 @@ species( const char * name, #ifndef FIELD_IONIZATION float q, #else - Kokkos::View ionization_energy, + int n_energy, float qn, float qm, float ql, @@ -156,10 +149,11 @@ species( const char * name, #ifndef FIELD_IONIZATION sp->q = q; #else - sp->ionization_energy = ionization_energy; + sp->n_energy = n_energy; sp->qn = qn; sp->qm = qm; sp->ql = ql; + sp->ionization_energy = new double[n_energy]; #endif sp->m = m; diff --git a/src/species_advance/species_advance.h b/src/species_advance/species_advance.h index 995a5768..3e95f645 100644 --- a/src/species_advance/species_advance.h +++ b/src/species_advance/species_advance.h @@ -100,10 +100,10 @@ class species_t { #ifndef FIELD_IONIZATION short int q; // Species particle charge #else - Kokkos::View ionization_energy; // Species ionization energies - float qn; // principal quantum number - float qm; // magnetic quantum number - float ql; // angular momentum quantum number + int n_energy; // Species number of ionization energies + float qn; // principal quantum number + float qm; // magnetic quantum number + float ql; // angular momentum quantum number #endif float m; // Species particle rest mass @@ -203,6 +203,10 @@ class species_t { Kokkos::View clean_up_from; Kokkos::View clean_up_to; + #ifdef FIELD_IONIZATION + double * ionization_energy; + #endif + // Init Kokkos Particle Arrays species_t(int n_particles, int n_pmovers) { @@ -292,7 +296,7 @@ species( const char * name, #ifndef FIELD_IONIZATION float q, #else - Kokkos::View ionization_energy, + int n_energy, float qn, float qm, float ql, @@ -361,7 +365,7 @@ energy_p_kokkos( const species_t * RESTRICT sp, const interpolator_array_t * RESTRICT ia ); #ifdef FIELD_IONIZATION -Kokkos::View +Kokkos::View ionization_states_kokkos( const species_t * RESTRICT sp ); double diff --git a/src/species_advance/standard/advance_p.cc b/src/species_advance/standard/advance_p.cc index c345d8af..568c8e99 100644 --- a/src/species_advance/standard/advance_p.cc +++ b/src/species_advance/standard/advance_p.cc @@ -949,7 +949,7 @@ advance_p_kokkos_unified_ionize( ERROR(( "Conversion factors and laser wavelength needs to be passed as grid variables when field ionization is enabled." )); } - if( (sp!=sp_e || sp->ionization_energy(0)) && n == 0 ) + if( (sp!=sp_e || sp->ionization_energy[0]) && n == 0 ) { ERROR(( "Quantum numbers need to be passed to species struct when field ionization is enabled." )); } @@ -1096,7 +1096,7 @@ advance_p_kokkos_unified_ionize( haz[LANE] = qdt_2mc*( (fez[LANE] + dx[LANE]*fdezdx[LANE] ) + dy[LANE]*(fdezdy[LANE] + dx[LANE]*fd2ezdxdy[LANE]) ); // ***** Field Ioization ***** - if (charge[LANE] != sp->ionization_energy.extent(0)){ + if (charge[LANE] != sp->n_energy){ // Declate varviables bool multiphoton_ionised = false; float K; @@ -1104,7 +1104,7 @@ advance_p_kokkos_unified_ionize( // Check if the particle is fully ionized already short int N_ionization = abs(charge[LANE]); // Current ionization state of the particle short int N_ionization_before = N_ionization; // save variable to compare with ionization state after ionization algorithm - short int N_ionization_levels = sp->ionization_energy.extent(0); + short int N_ionization_levels = sp->n_energy; // code units float hax_c = (fex[LANE] + dy[LANE]*fdexdy[LANE] ) + dz[LANE]*(fdexdz[LANE] + dy[LANE]*fd2exdydz[LANE]); @@ -1132,7 +1132,7 @@ advance_p_kokkos_unified_ionize( while (ionization_flag == 1 && t_ionize <= dt && N_ionization < N_ionization_levels) { // Get the appropriate ionization energy - float epsilon_eV = sp->ionization_energy(int(N_ionization)); // [eV], ionization energy + float epsilon_eV = sp->ionization_energy[int(N_ionization)]; // [eV], ionization energy float epsilon_au = epsilon_eV/27.2; // atomic units, ionization energy // Calculate stuff @@ -2175,20 +2175,20 @@ advance_p_kokkos_gpu_ionize( Kokkos::View count("count"); Kokkos::deep_copy(count, sp_e->np); - Kokkos::View epsilon_eV_list_d("epsilon_eV_list_d", sp->ionization_energy.extent(0)); - Kokkos::deep_copy(epsilon_eV_list_d, sp->ionization_energy); + Kokkos::View epsilon_eV_list_d("epsilon_eV_list_d", sp->n_energy); + Kokkos::deep_copy(epsilon_eV_list_d, Kokkos::View(sp->ionization_energy, sp->n_energy)); float n = sp->qn; // principal quantum number float m = sp->qm; // magnetic quantum number float l = sp->ql; // angular momentum quantum number float lambda_SI = g->lambda; - short int N_ionization_levels = sp->ionization_energy.extent(0); + short int N_ionization_levels = sp->n_energy; if( t_to_SI == 0 || l_to_SI == 0 || q_to_SI == 0 || m_to_SI == 0 || lambda_SI == 0) { ERROR(( "Conversion factors and laser wavelength needs to be passed as grid variables when field ionization is enabled." )); } - if( (sp!=sp_e || sp->ionization_energy(0) != 0) && n == 0 ) + if( (sp!=sp_e || sp->ionization_energy[0] != 0) && n == 0 ) { ERROR(( "Quantum numbers need to be passed to species struct when field ionization is enabled." )); } @@ -2898,7 +2898,7 @@ advance_p( /**/ species_t * RESTRICT sp, #endif KOKKOS_TIC(); #ifdef FIELD_IONIZATION - if (sp != sp_e && sp->ionization_energy(0) != 0){ + if (sp != sp_e && sp->ionization_energy[0] != 0){ ADVANCE_P_IONIZE( sp->k_p_d, sp->k_p_i_d, diff --git a/src/species_advance/standard/ionization_states.cc b/src/species_advance/standard/ionization_states.cc index 7fd36fb6..5480d0c0 100644 --- a/src/species_advance/standard/ionization_states.cc +++ b/src/species_advance/standard/ionization_states.cc @@ -4,7 +4,7 @@ // This function calculates the number of particles in each ionization state. #ifdef FIELD_IONIZATION -Kokkos::View +Kokkos::View ionization_states_kokkos(const species_t* RESTRICT sp) { if(!sp) ERROR(("Bad args")); @@ -12,32 +12,28 @@ ionization_states_kokkos(const species_t* RESTRICT sp) { const long long int np = sp->np; const k_particles_t& k_particles = sp->k_p_d; - const int N_states = sp->ionization_energy.extent(0)+1; // Include charge state 0 + const int N_states = sp->n_energy+1; // Include charge state 0 - Kokkos::View charge_counts("charge_counts", N_states); - auto charge_counts_h = Kokkos::create_mirror(charge_counts); - Kokkos::deep_copy(charge_counts_h,charge_counts); + Kokkos::View charge_counts_h("charge_counts_h", N_states); + Kokkos::View charge_counts("charge_counts", N_states); + Kokkos::deep_copy(charge_counts,charge_counts_h); - Kokkos::View global_charge_counts("global_charge_counts", N_states); - auto global_charge_counts_h = Kokkos::create_mirror(global_charge_counts); - Kokkos::deep_copy(global_charge_counts_h,global_charge_counts); + Kokkos::View global_charge_counts_h("global_charge_counts_h", N_states); // Calculate (local) number of particles in each charge state Kokkos::parallel_for("ionization_states_kokkos", np, KOKKOS_LAMBDA(const int n) { long long int charge = k_particles(n, particle_var::charge); - Kokkos::atomic_increment(&charge_counts(charge)); + Kokkos::atomic_increment(&charge_counts(charge)); }); Kokkos::fence(); Kokkos::deep_copy(charge_counts_h,charge_counts); - // Perform MPI reductuion over ranks for (int i = 0; i < N_states; ++i) { mp_allsum_i( &charge_counts_h(i), &global_charge_counts_h(i), 1 ); }; - Kokkos::deep_copy(global_charge_counts,global_charge_counts_h); // Return the global charge state - return global_charge_counts; + return global_charge_counts_h; } #endif diff --git a/src/vpic/dump.cc b/src/vpic/dump.cc index 9971153e..d22fe0b4 100644 --- a/src/vpic/dump.cc +++ b/src/vpic/dump.cc @@ -84,9 +84,7 @@ void vpic_simulation::dump_ionization_states( const char *fname, int append ) { - Kokkos::View N_ions; - auto N_ions_h = Kokkos::create_mirror(N_ions); - Kokkos::deep_copy(N_ions_h,N_ions); + Kokkos::View N_ions_h; species_t *sp; FileIO fileIO; @@ -97,7 +95,7 @@ vpic_simulation::dump_ionization_states( const char *fname, // Iterate over each species LIST_FOR_EACH(sp, species_list) { // Ignore species with ionization energy set to 0, except for electrons - if (std::string(sp->name) != "electron" && sp->ionization_energy(0) == 0) { + if (std::string(sp->name) != "electron" && sp->n_energy == 0) { // Skip file creation for the "electron" species or when ionization isnt desired for a species continue; } @@ -116,7 +114,7 @@ vpic_simulation::dump_ionization_states( const char *fname, if (append == 0) { // Dynamically generate the layout string std::string layoutString = "%% Layout\n%% Number of particles in each ionization state\n%% step"; - for (size_t i = 0; i <= sp->ionization_energy.extent(0); ++i) { + for (size_t i = 0; i <= sp->n_energy; ++i) { layoutString += " " + std::to_string(i) + "+"; } fileIO.print(layoutString.c_str()); @@ -127,17 +125,13 @@ vpic_simulation::dump_ionization_states( const char *fname, } } // if rank - - N_ions = ionization_states_kokkos( sp ); // Number of particles in each ionization state - - auto N_ions_h = Kokkos::create_mirror(N_ions); - Kokkos::deep_copy(N_ions_h, N_ions); - - // Calculate the total number of electrons + // Calculate the total number of electrons and ions int np_global; if (std::string(sp->name) == "electron") { int np = sp->np; mp_allsum_i( &np, &np_global, 1 ); + } else { + N_ions_h = ionization_states_kokkos( sp ); // Number of particles in each ionization state } // Print Number of particles in each ionization state diff --git a/src/vpic/vpic.h b/src/vpic/vpic.h index ec890186..1b4278f8 100644 --- a/src/vpic/vpic.h +++ b/src/vpic/vpic.h @@ -524,7 +524,7 @@ class vpic_simulation { #if !defined(FIELD_IONIZATION) double q, #else - Kokkos::View ionization_energy, + int n_energy, double qn, // quantum numbers n,m,l double qm, double ql, @@ -546,7 +546,7 @@ class vpic_simulation { #if !defined(FIELD_IONIZATION) (float)q, #else - (Kokkos::View)ionization_energy, + (int) n_energy, (float)qn, (float)qm, (float)ql, diff --git a/test/integrated/legacy/accel.deck b/test/integrated/legacy/accel.deck index 8afa43b0..299bcb42 100644 --- a/test/integrated/legacy/accel.deck +++ b/test/integrated/legacy/accel.deck @@ -71,12 +71,11 @@ begin_initialization { grid->l_to_SI = 1; grid->q_to_SI = 1; grid->m_to_SI = 1; - Kokkos::View ionization_energy("my_kokkos_view", 1); - double ionization_energy_values[] = {0}; // in eV - ionization_energy(0) = ionization_energy_values[0]; - this_sp = define_species( "test_species", ionization_energy, 1,0,0, 1., npart, npart, 0, 0 ); + this_sp = define_species( "test_species", 1, 1,0,0, 1., npart, npart, 0, 0 ); + this_sp->ionization_energy[0] = 0; // electron needs to be defined when FI is enabled - species_t * electron = define_species("electron", ionization_energy, 0,0,0, 1., npart, npart, 0, 0); + species_t * electron = define_species("electron", 1, 0,0,0, 1., npart, npart, 0, 0); + electron->ionization_energy[0] = 0; #else this_sp = define_species( "test_species", 1., 1., npart, npart, 0, 0 ); #endif diff --git a/test/integrated/legacy/cyclo.deck b/test/integrated/legacy/cyclo.deck index 31c919f2..36494e44 100644 --- a/test/integrated/legacy/cyclo.deck +++ b/test/integrated/legacy/cyclo.deck @@ -47,12 +47,11 @@ begin_initialization { grid->l_to_SI = 1; grid->q_to_SI = 1; grid->m_to_SI = 1; - Kokkos::View ionization_energy("my_kokkos_view", 1); - double ionization_energy_values[] = {0}; // in eV - ionization_energy(0) = ionization_energy_values[0]; - this_sp = define_species( "test_species", ionization_energy, 1,0,0, 1, npart, npart, 0, 0 ); + this_sp = define_species( "test_species", 1, 1,0,0, 1, npart, npart, 0, 0 ); + this_sp->ionization_energy[0] = 0; // electron needs to be defined when FI is enabled - species_t * electron = define_species("electron",ionization_energy, 0,0,0, 1., npart, npart, 0, 0); + species_t * electron = define_species("electron",1, 0,0,0, 1., npart, npart, 0, 0); + electron->ionization_energy[0] = 0; #else this_sp = define_species( "test_species", 2, 1, npart, npart, 0, 0 ); #endif diff --git a/test/integrated/legacy/inbndj.deck b/test/integrated/legacy/inbndj.deck index 16a6ed32..d352c09f 100644 --- a/test/integrated/legacy/inbndj.deck +++ b/test/integrated/legacy/inbndj.deck @@ -39,12 +39,11 @@ begin_initialization { grid->l_to_SI = 1; grid->q_to_SI = 1; grid->m_to_SI = 1; - Kokkos::View ionization_energy("my_kokkos_view", 1); - double ionization_energy_values[] = {0}; // in eV - ionization_energy(0) = ionization_energy_values[0]; - this_sp = define_species( "test_species", ionization_energy, 1,0,0, 1., NPART, NPART, 0, 0 ); + this_sp = define_species( "test_species", 1, 1,0,0, 1., NPART, NPART, 0, 0 ); + this_sp->ionization_energy[0] = 0; // electron needs to be defined when FI is enabled - species_t * electron = define_species("electron", ionization_energy, 0,0,0, 1., NPART, NPART, 0, 0); + species_t * electron = define_species("electron", 1, 0,0,0, 1., NPART, NPART, 0, 0); + electron->ionization_energy[0] = 0; #else this_sp = define_species( "test_species", 2., 1., NPART, NPART, 0, 0 ); #endif diff --git a/test/integrated/legacy/interpe.deck b/test/integrated/legacy/interpe.deck index 05a73625..08fc8bc4 100644 --- a/test/integrated/legacy/interpe.deck +++ b/test/integrated/legacy/interpe.deck @@ -49,12 +49,11 @@ begin_initialization { grid->l_to_SI = 1; grid->q_to_SI = 1; grid->m_to_SI = 1; - Kokkos::View ionization_energy("my_kokkos_view", 1); - double ionization_energy_values[] = {0}; // in eV - ionization_energy(0) = ionization_energy_values[0]; - this_sp = define_species( "test_species", ionization_energy, 1,0,0, 2, npart, npart, 0, 0 ); + this_sp = define_species( "test_species", 1, 1,0,0, 2, npart, npart, 0, 0 ); + this_sp->ionization_energy[0] = 0; // electron needs to be defined when FI is enabled - species_t * electron = define_species("electron", ionization_energy, 0,0,0, 1., npart, npart, 0, 0); + species_t * electron = define_species("electron", 1, 0,0,0, 1., npart, npart, 0, 0); + electron->ionization_energy[0] = 0; #else this_sp = define_species( "test_species", 2, 2, npart, npart, 0, 0 ); #endif diff --git a/test/integrated/to_completion/dump.deck b/test/integrated/to_completion/dump.deck index 3a253405..c465a103 100644 --- a/test/integrated/to_completion/dump.deck +++ b/test/integrated/to_completion/dump.deck @@ -146,11 +146,10 @@ begin_initialization { grid->l_to_SI = 1; grid->q_to_SI = 1; grid->m_to_SI = 1; - Kokkos::View ionization_energy("my_kokkos_view", 1); - double ionization_energy_values[] = {0}; // in eV - ionization_energy(0) = ionization_energy_values[0]; - ion = define_species( "ion", ionization_energy, 1,0,0, mi, 1.5*Ni/nproc(), -1, 40, 1 ); - electron = define_species( "electron", ionization_energy, 1,0,0, me, 1.5*Ne/nproc(), -1, 20, 1 ); + ion = define_species( "ion", 1, 1,0,0, mi, 1.5*Ni/nproc(), -1, 40, 1 ); + electron = define_species( "electron", 1, 1,0,0, me, 1.5*Ne/nproc(), -1, 20, 1 ); + ion->ionization_energy[0] = 0; + electron->ionization_energy[0] = 0; #else ion = define_species( "ion", ec, mi, 1.5*Ni/nproc(), -1, 40, 1 ); electron = define_species( "electron", -ec, me, 1.5*Ne/nproc(), -1, 20, 1 ); diff --git a/test/integrated/to_completion/reconnection_test.deck b/test/integrated/to_completion/reconnection_test.deck index c965323a..b2adffe3 100644 --- a/test/integrated/to_completion/reconnection_test.deck +++ b/test/integrated/to_completion/reconnection_test.deck @@ -224,15 +224,17 @@ begin_initialization { grid->l_to_SI = 1; grid->q_to_SI = 1; grid->m_to_SI = 1; - Kokkos::View ionization_energy("my_kokkos_view", 1); - double ionization_energy_values[] = {0}; // in eV - ionization_energy(0) = ionization_energy_values[0]; - electron1 = define_species("electron1", ionization_energy, 1,0,0, me, nmax, nmovers, electron_sort_interval, sort_method); - electron2 = define_species("electron2", ionization_energy, 1,0,0, me, nmax, nmovers, electron_sort_interval, sort_method); - ion1 = define_species("ion1", ionization_energy, 1,0,0, mi, nmax, nmovers, ion_sort_interval, sort_method); - ion2 = define_species("ion2", ionization_energy, 1,0,0, mi, nmax, nmovers, ion_sort_interval, sort_method); + electron1 = define_species("electron1", 1, 1,0,0, me, nmax, nmovers, electron_sort_interval, sort_method); + electron2 = define_species("electron2", 1, 1,0,0, me, nmax, nmovers, electron_sort_interval, sort_method); + ion1 = define_species("ion1", 1, 1,0,0, mi, nmax, nmovers, ion_sort_interval, sort_method); + ion2 = define_species("ion2", 1, 1,0,0, mi, nmax, nmovers, ion_sort_interval, sort_method); + ion1->ionization_energy[0] = 0; + ion2->ionization_energy[0] = 0; + electron2->ionization_energy[0] = 0; + electron2->ionization_energy[0] = 0; // electron needs to be defined when FI is enabled - species_t *electron = define_species("electron", ionization_energy, 0,0,0, me, nmax, nmovers, electron_sort_interval, sort_method); + species_t *electron = define_species("electron", 1, 0,0,0, me, nmax, nmovers, electron_sort_interval, sort_method); + electron->ionization_energy[0] = 0; #else electron1 = define_species("electron1",-ec, me, nmax, nmovers, electron_sort_interval, sort_method); electron2 = define_species("electron2",-ec, me, nmax, nmovers, electron_sort_interval, sort_method); diff --git a/test/integrated/to_completion/simple.deck b/test/integrated/to_completion/simple.deck index 1f12591c..e4882195 100644 --- a/test/integrated/to_completion/simple.deck +++ b/test/integrated/to_completion/simple.deck @@ -141,11 +141,10 @@ begin_initialization { grid->l_to_SI = 1; grid->q_to_SI = 1; grid->m_to_SI = 1; - Kokkos::View ionization_energy("my_kokkos_view", 1); - double ionization_energy_values[] = {0}; // in eV - ionization_energy(0) = ionization_energy_values[0]; - ion = define_species( "ion", ionization_energy, 1,0,0, mi, 1.5*Ni/nproc(), -1, 40, 1 ); - electron = define_species( "electron", ionization_energy, 1,0,0, me, 1.5*Ne/nproc(), -1, 20, 1 ); + ion = define_species( "ion", 1, 1,0,0, mi, 1.5*Ni/nproc(), -1, 40, 1 ); + electron = define_species( "electron", 1, 1,0,0, me, 1.5*Ne/nproc(), -1, 20, 1 ); + ion->ionization_energy[0] = 0; + electron->ionization_energy[0] = 0; #else ion = define_species( "ion", ec, mi, 1.5*Ni/nproc(), -1, 40, 1 ); electron = define_species( "electron", -ec, me, 1.5*Ne/nproc(), -1, 20, 1 ); diff --git a/test/unit/energy_comparison/weibel_driver.cc b/test/unit/energy_comparison/weibel_driver.cc index b0feea70..4ac9167f 100644 --- a/test/unit/energy_comparison/weibel_driver.cc +++ b/test/unit/energy_comparison/weibel_driver.cc @@ -187,11 +187,10 @@ vpic_simulation::user_initialization( int num_cmdline_arguments, grid->l_to_SI = 1; grid->q_to_SI = 1; grid->m_to_SI = 1; - Kokkos::View ionization_energy("my_kokkos_view", 1); - double ionization_energy_values[] = {0}; // in eV - ionization_energy(0) = ionization_energy_values[0]; - ion = define_species("ion", ionization_energy, 1,0,0, mi,2.4*Ne/nproc(),-1,0,0); //(GY) - electron = define_species("electron", ionization_energy, 0,0,0, me,2.4*Ne/nproc(),-1,0,0); //turn off sorting (GY) + ion = define_species("ion", 1, 1,0,0, mi,2.4*Ne/nproc(),-1,0,0); //(GY) + electron = define_species("electron", 1, 0,0,0, me,2.4*Ne/nproc(),-1,0,0); //turn off sorting (GY) + ion->ionization_energy[0] = 0; + electron->ionization_energy[0] = 0; #else ion = define_species("ion", ec,mi,2.4*Ne/nproc(),-1,0,0); //(GY) electron = define_species("electron",-ec,me,2.4*Ne/nproc(),-1,0,0); //turn off sorting (GY) diff --git a/test/unit/field_ionization/field_ionization_benchmark.cxx b/test/unit/field_ionization/field_ionization_benchmark.cxx index ab47b1ab..9df2e3f5 100644 --- a/test/unit/field_ionization/field_ionization_benchmark.cxx +++ b/test/unit/field_ionization/field_ionization_benchmark.cxx @@ -250,26 +250,16 @@ vpic_simulation::user_initialization( int num_cmdline_arguments, double ql = 0; // I1 - carbon - const int num_elements_I1 = 6; - Kokkos::View ionization_energy_I1("my_kokkos_view", num_elements_I1); + const int n_energy_I1 = 6; double ionization_energy_I1_values[] = {11.26030, 24.38332, 47.8878, 64.4939, 392.087, 489.99334}; // in eV - for (int i = 0; i < num_elements_I1; ++i) { - ionization_energy_I1(i) = ionization_energy_I1_values[i]; - } + // I2 - hydrogen - const int num_elements_I2 = 1; - Kokkos::View ionization_energy_I2("my_kokkos_view", num_elements_I2); + const int n_energy_I2 = 1; double ionization_energy_I2_values[] = {13.6}; // in eV - for (int i = 0; i < num_elements_I2; ++i) { - ionization_energy_I2(i) = ionization_energy_I2_values[i]; - } + // electron - const int num_elements_electron = 1; - Kokkos::View ionization_energy_electron("my_kokkos_view", num_elements_electron); + const int n_energy_electron = 1; double ionization_energy_electron_values[] = {0}; // in eV - for (int i = 0; i < num_elements_electron; ++i) { - ionization_energy_electron(i) = ionization_energy_electron_values[i]; - } double c2 = c_SI*c_SI; // In 3 dimensions, the average energy is 3 halves the temperature @@ -575,14 +565,20 @@ vpic_simulation::user_initialization( int num_cmdline_arguments, sim_log("Setting up ions. "); if ( I1_present ) { #if defined(FIELD_IONIZATION) - ion_I1 = define_species("I1", ionization_energy_I1, qn,qm,ql, m_I1_c, max_local_np_i1, max_local_nm_i1, 80, 0); + ion_I1 = define_species("I1", n_energy_I1, qn,qm,ql, m_I1_c, max_local_np_i1, max_local_nm_i1, 80, 0); + for (int i = 0; i < n_energy_I1; i++) { + ion_I1->ionization_energy[i] = ionization_energy_I1_values[i]; + } #else ion_I1 = define_species("I1", Z_I1*e_c, m_I1_c, max_local_np_i1, max_local_nm_i1, 80, 0); #endif } if ( I2_present ) { #if defined(FIELD_IONIZATION) - ion_I2 = define_species("I2", ionization_energy_I2, qn,qm,ql, m_I2_c, max_local_np_i2, max_local_nm_i2, 80, 0); + ion_I2 = define_species("I2", n_energy_I2, qn,qm,ql, m_I2_c, max_local_np_i2, max_local_nm_i2, 80, 0); + for (int i = 0; i < n_energy_I2; i++) { + ion_I2->ionization_energy[i] = ionization_energy_I2_values[i]; + } #else ion_I2 = define_species("I2", q_I2, m_I2_c, max_local_np_i2, max_local_nm_i2, 80, 0); #endif @@ -600,7 +596,8 @@ vpic_simulation::user_initialization( int num_cmdline_arguments, // Electrons need to be defined last in input deck when field ionization is enabled species_t *electron; #if defined(FIELD_IONIZATION) - electron = define_species("electron", ionization_energy_electron, 0,0,0, m_e_c,max_local_np_e, max_local_nm_e, 20, 0); + electron = define_species("electron", n_energy_electron, 0,0,0, m_e_c,max_local_np_e, max_local_nm_e, 20, 0); + electron->ionization_energy[0] = ionization_energy_electron_values[0]; #else electron = define_species("electron", -1.*e_c, m_e_c, max_local_np_e, max_local_nm_e, 20, 0); #endif diff --git a/test/unit/legacy_comparison/hydro_p.cc b/test/unit/legacy_comparison/hydro_p.cc index 1004eb8e..048f9858 100644 --- a/test/unit/legacy_comparison/hydro_p.cc +++ b/test/unit/legacy_comparison/hydro_p.cc @@ -51,10 +51,8 @@ vpic_simulation::user_initialization( int num_cmdline_arguments, species_t * sp_temp; species_t * sp; #if defined(FIELD_IONIZATION) - Kokkos::View ionization_energy("my_kokkos_view", 1); - double ionization_energy_values[] = {0}; // in eV - ionization_energy(0) = ionization_energy_values[0]; - sp = define_species( "test_species", ionization_energy, 0,0,0, 1., npart, npart, 0, 0); + sp = define_species( "test_species", 1, 0,0,0, 1., npart, npart, 0, 0); + sp->ionization_energy[0] = 0; #else sp = define_species( "test_species", 1., 1., npart, npart, 0, 0 ); #endif diff --git a/test/unit/legacy_comparison/rho_p.cc b/test/unit/legacy_comparison/rho_p.cc index 211729aa..2868733d 100644 --- a/test/unit/legacy_comparison/rho_p.cc +++ b/test/unit/legacy_comparison/rho_p.cc @@ -48,12 +48,11 @@ vpic_simulation::user_initialization( int num_cmdline_arguments, grid->l_to_SI = 1; grid->q_to_SI = 1; grid->m_to_SI = 1; - Kokkos::View ionization_energy("my_kokkos_view", 1); - double ionization_energy_values[] = {0}; // in eV - ionization_energy(0) = ionization_energy_values[0]; - sp = define_species( "test_species", ionization_energy, 1,0,0, 1., npart, npart, 0, 0); + sp = define_species( "test_species", 1, 1,0,0, 1., npart, npart, 0, 0); + sp->ionization_energy[0] = 0; // electron needs to be defined when FI is enabled - species_t * electron = define_species("electron",ionization_energy, 0,0,0, 1., npart, npart, 0, 0); + species_t * electron = define_species("electron",1, 0,0,0, 1., npart, npart, 0, 0); + electron->ionization_energy[0] = 0; #else sp = define_species( "test_species", 1., 1., npart, npart, 0, 0 ); #endif