From 97bc8ad9b5a2467a50ca06ec2ae4f8fb2a175eef Mon Sep 17 00:00:00 2001 From: AlexanderSinn Date: Sun, 25 Aug 2024 20:04:08 +0200 Subject: [PATCH 01/76] laser ion --- .../plasma/PlasmaParticleContainer.H | 40 +++- .../plasma/PlasmaParticleContainer.cpp | 172 ++++++++++++++++++ .../plasma/PlasmaParticleContainerInit.cpp | 69 +++++++ 3 files changed, 280 insertions(+), 1 deletion(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.H b/src/particles/plasma/PlasmaParticleContainer.H index 6cdc6795d9..c1aa201d05 100644 --- a/src/particles/plasma/PlasmaParticleContainer.H +++ b/src/particles/plasma/PlasmaParticleContainer.H @@ -102,6 +102,27 @@ public: const Fields& fields, const amrex::Real background_density_SI); + /** Initialize ADK prefactors of Laser ionizable plasmas + * + * \param[in] geom Geometry of the simulation, to get the cell size + * \param[in] product_pc The electron plasma PC that this Ion Plasma ionizes to + * \param[in] background_density_SI background plasma density (only needed for normalized units) + */ + void InitLaserIonization (const amrex::Geometry& geom, PlasmaParticleContainer* product_pc, + const amrex::Real background_density_SI); + + /** Calculates Ionization Probability from a Laser and generates new Plasma Particles + * + * \param[in] lev MR level + * \param[in] geom Geometry of the simulation, to get the cell size + * \param[in] fields the general field class + * \param[in] background_density_SI background plasma density (only needed for normalized units) + */ + void LaserIonization (const int lev, + const amrex::Geometry& geom, + const Fields& fields, + const amrex::Real background_density_SI); + /** Reorder particles to speed-up current deposition * \param[in] islice zeta slice index */ @@ -149,6 +170,8 @@ public: */ void InSituWriteToFile (int step, amrex::Real time, const amrex::Geometry& geom); + // init: + amrex::Parser m_parser; /**< owns data for m_density_func */ amrex::ParserExecutor<3> m_density_func; /**< Density function for the plasma */ amrex::Real m_min_density {0.}; /**< minimal density at which particles are injected */ @@ -174,10 +197,16 @@ public: amrex::Real m_temperature_in_ev {0.}; /**< Temperature of the plasma in eV */ /** whether to add a neutralizing background of immobile particles of opposite charge */ bool m_neutralize_background = true; + + // general: + amrex::Real m_mass = 0; /**< mass of each particle of this species */ amrex::Real m_charge = 0; /**< charge of each particle of this species, per Ion level */ - int m_init_ion_lev = -1; /**< initial Ion level of each particle */ int m_n_subcycles = 1; /**< number of subcycles in the plasma particle push */ + + // ionization: + + int m_init_ion_lev = -1; /**< initial Ion level of each particle */ bool m_can_ionize = false; /**< whether this plasma can ionize */ std::string m_product_name = ""; /**< name of Ionization product plasma */ PlasmaParticleContainer* m_product_pc = nullptr; /**< Ionization product plasma */ @@ -187,10 +216,19 @@ public: amrex::Gpu::DeviceVector m_adk_exp_prefactor; /** to calculate Ionization probability with ADK formula */ amrex::Gpu::DeviceVector m_adk_power; + + /** to calculate laser Ionization probability with ADK formula */ + amrex::Gpu::DeviceVector m_laser_adk_prefactor; + + // plasma sorting/reordering: + /** After how many slices the particles are reordered. 0: off */ int m_reorder_period = 0; /** 2D reordering index type. 0: cell, 1: node, 2: both */ amrex::IntVect m_reorder_idx_type = {0, 0, 0}; + + // in-situ diagnostic: + /** How often the insitu plasma diagnostics should be computed and written * Default is 0, meaning no output */ int m_insitu_period {0}; diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 6e0b249f84..59d350fc0f 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -451,6 +451,178 @@ IonizationModule (const int lev, } } +void +PlasmaParticleContainer:: +LaserIonization (const amrex::Geometry& geom, + const amrex::Real background_density_SI) +{ + if (!m_can_ionize) return; + HIPACE_PROFILE("PlasmaParticleContainer::LaserIonization()"); + + using namespace amrex::literals; + using Complex = amrex::GpuComplex; + + const PhysConst phys_const = get_phys_const(); + + // Loop over particle boxes with both ion and electron Particle Containers at the same time + for (amrex::MFIter mfi_ion = MakeMFIter(0, DfltMfi); mfi_ion.isValid(); ++mfi_ion) + { + // Extract properties associated with physical size of the box + const amrex::Real dx_inv = geom.InvCellSize(0); + const amrex::Real dy_inv = geom.InvCellSize(1); + + // Offset for converting positions to indexes + amrex::Real const x_pos_offset = GetPosOffset(0, geom, slice_fab.box()); + const amrex::Real y_pos_offset = GetPosOffset(1, geom, slice_fab.box()); + + const int depos_order_xy = Hipace::m_depos_order_xy; + + auto& plevel_ion = GetParticles(0); + auto index = std::make_pair(mfi_ion.index(), mfi_ion.LocalTileIndex()); + if(plevel_ion.find(index) == plevel_ion.end()) continue; + auto& ptile_elec = m_product_pc->DefineAndReturnParticleTile(0, + mfi_ion.index(), mfi_ion.LocalTileIndex()); + auto& ptile_ion = plevel_ion.at(index); + + auto& soa_ion = ptile_ion.GetStructOfArrays(); // For momenta and weights + + const amrex::Real clightsq = 1.0_rt / ( phys_const.c * phys_const.c ); + // calcuation of E0 in SI units for denormalization + const amrex::Real wp = std::sqrt(static_cast(background_density_SI) * + PhysConstSI::q_e*PhysConstSI::q_e / + (PhysConstSI::ep0 * PhysConstSI::m_e) ); + const amrex::Real E0 = Hipace::m_normalized_units ? + wp * PhysConstSI::m_e * PhysConstSI::c / PhysConstSI::q_e : 1; + const amrex::Real pi_inv_3 = 3 / MathConst::pi; + + int * const ion_lev = soa_ion.GetIntData(PlasmaIdx::ion_lev).data(); + const amrex::Real * const x_prev = soa_ion.GetRealData(PlasmaIdx::x_prev).data(); + const amrex::Real * const y_prev = soa_ion.GetRealData(PlasmaIdx::y_prev).data(); + const amrex::Real * const uxp = soa_ion.GetRealData(PlasmaIdx::ux_half_step).data(); + const amrex::Real * const uyp = soa_ion.GetRealData(PlasmaIdx::uy_half_step).data(); + const amrex::Real * const psip =soa_ion.GetRealData(PlasmaIdx::psi_half_step).data(); + const auto * idcpup = soa_ion.GetIdCPUData().data(); + + // Make Ion Mask and load ADK prefactors + // Ion Mask is necessary to only resize electron particle tile once + amrex::Gpu::DeviceVector ion_mask(ptile_ion.numParticles(), 0); + uint8_t* AMREX_RESTRICT p_ion_mask = ion_mask.data(); + amrex::Gpu::DeviceScalar num_new_electrons(0); + uint32_t* AMREX_RESTRICT p_num_new_electrons = num_new_electrons.dataPtr(); + amrex::Real* AMREX_RESTRICT adk_prefactor = m_adk_prefactor.data(); + amrex::Real* AMREX_RESTRICT adk_exp_prefactor = m_adk_exp_prefactor.data(); + amrex::Real* AMREX_RESTRICT adk_power = m_adk_power.data(); + amrex::Real* AMREX_RESTRICT laser_adk_prefactor = m_laser_adk_prefactor.data(); + + long num_ions = ptile_ion.numParticles(); + + amrex::ParallelForRNG(num_ions, + [=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine) { + + if (amrex::ConstParticleIDWrapper(idcpup[ip]) < 0 || + amrex::ConstParticleCPUWrapper(idcpup[ip]) != lev) return; + + // avoid temp slice + const amrex::Real xp = x_prev[ip]; + const amrex::Real yp = y_prev[ip]; + + const amrex::Real A = 0; + const amrex::Real A_dzeta = 0; + const amrex::Real A_dx = 0; + + const Complex E1 = i * A - A_dzeta; + const Complex E2 = - A_dx; + + const amrex::Real Ep = std::abs(std::sqrt( std::abs(E1*E1) + std::abs(E2*E2) )*E0); + + // Compute probability of ionization p + const amrex::Real gammap = (1.0_rt + uxp[ip] * uxp[ip] * clightsq + + uyp[ip] * uyp[ip] * clightsq + + psip[ip]* psip[ip] ) / ( 2.0_rt * psip[ip] ); + const int ion_lev_loc = ion_lev[ip]; + // gamma / (psi + 1) to complete dt for QSA + amrex::Real w_dtau_dc = gammap / psip[ip] * adk_prefactor[ion_lev_loc] * + std::pow(Ep, adk_power[ion_lev_loc]) * + std::exp( adk_exp_prefactor[ion_lev_loc]/Ep ); + + amrex::Real w_dtau_ac = w_dtau_dc * std::sqrt(Ep * laser_adk_prefactor[ion_lev_loc]); + + amrex::Real p = 1._rt - std::exp( - w_dtau_ac ); + + amrex::Real random_draw = amrex::Random(engine); + if (random_draw < p) + { + ion_lev[ip] += 1; + p_ion_mask[ip] = 1; + amrex::Gpu::Atomic::Add( p_num_new_electrons, 1u ); + } + }); + amrex::Gpu::streamSynchronize(); + + if (num_new_electrons.dataValue() == 0) continue; + + if(Hipace::m_verbose >= 3) { + amrex::Print() << "Number of ionized Plasma Particles: " + << num_new_electrons.dataValue() << "\n"; + } + + + // resize electron particle tile + const auto old_size = ptile_elec.numParticles(); + const auto new_size = old_size + num_new_electrons.dataValue(); + ptile_elec.resize(new_size); + + // Load electron soa and aos after resize + auto arrdata_ion = ptile_ion.GetStructOfArrays().realarray(); + auto arrdata_elec = ptile_elec.GetStructOfArrays().realarray(); + auto int_arrdata_elec = ptile_elec.GetStructOfArrays().intarray(); + auto idcpu_elec = ptile_elec.GetStructOfArrays().GetIdCPUData().data(); + + const int init_ion_lev = m_product_pc->m_init_ion_lev; + + amrex::Gpu::DeviceScalar ip_elec(0); + uint32_t * AMREX_RESTRICT p_ip_elec = ip_elec.dataPtr(); + + amrex::ParallelFor(num_ions, + [=] AMREX_GPU_DEVICE (long ip) { + + if(p_ion_mask[ip] != 0) { + const long pid = amrex::Gpu::Atomic::Add( p_ip_elec, 1u ); + const long pidx = pid + old_size; + + // Copy ion data to new electron + amrex::ParticleIDWrapper{idcpu_elec[pidx]} = 2; // only for valid/invalid + amrex::ParticleCPUWrapper{idcpu_elec[pidx]} = lev; // current level + arrdata_elec[PlasmaIdx::x ][pidx] = arrdata_ion[PlasmaIdx::x ][ip]; + arrdata_elec[PlasmaIdx::y ][pidx] = arrdata_ion[PlasmaIdx::y ][ip]; + + arrdata_elec[PlasmaIdx::w ][pidx] = arrdata_ion[PlasmaIdx::w ][ip]; + arrdata_elec[PlasmaIdx::ux ][pidx] = 0._rt; + arrdata_elec[PlasmaIdx::uy ][pidx] = 0._rt; + // later we could consider adding a finite temperature to the ionized electrons + arrdata_elec[PlasmaIdx::psi ][pidx] = 1._rt; + arrdata_elec[PlasmaIdx::x_prev ][pidx] = arrdata_ion[PlasmaIdx::x_prev][ip]; + arrdata_elec[PlasmaIdx::y_prev ][pidx] = arrdata_ion[PlasmaIdx::y_prev][ip]; + arrdata_elec[PlasmaIdx::ux_half_step ][pidx] = 0._rt; + arrdata_elec[PlasmaIdx::uy_half_step ][pidx] = 0._rt; + arrdata_elec[PlasmaIdx::psi_half_step][pidx] = 1._rt; +#ifdef HIPACE_USE_AB5_PUSH +#ifdef AMREX_USE_GPU +#pragma unroll +#endif + for (int iforce = PlasmaIdx::Fx1; iforce <= PlasmaIdx::Fpsi5; ++iforce) { + arrdata_elec[iforce][pidx] = 0._rt; + } +#endif + int_arrdata_elec[PlasmaIdx::ion_lev][pidx] = init_ion_lev; + } + }); + + // synchronize before ion_mask and ip_elec go out of scope + amrex::Gpu::streamSynchronize(); + } +} + void PlasmaParticleContainer::InSituComputeDiags (int islice) { diff --git a/src/particles/plasma/PlasmaParticleContainerInit.cpp b/src/particles/plasma/PlasmaParticleContainerInit.cpp index 1a5376f09f..7d1b332c4c 100644 --- a/src/particles/plasma/PlasmaParticleContainerInit.cpp +++ b/src/particles/plasma/PlasmaParticleContainerInit.cpp @@ -452,3 +452,72 @@ InitIonizationModule (const amrex::Geometry& geom, PlasmaParticleContainer* prod amrex::Gpu::copy(amrex::Gpu::hostToDevice, h_adk_exp_prefactor.begin(), h_adk_exp_prefactor.end(), m_adk_exp_prefactor.begin()); } + +void +PlasmaParticleContainer:: +InitLaserIonization (const amrex::Geometry& geom, PlasmaParticleContainer* product_pc, + const amrex::Real background_density_SI) +{ + HIPACE_PROFILE("PlasmaParticleContainer::InitLaserIonization()"); + + using namespace amrex::literals; + + if (!m_can_ionize) return; + + const bool normalized_units = Hipace::m_normalized_units; + if (normalized_units) { + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(background_density_SI!=0, + "For ionization with normalized units, a background plasma density != 0 must " + "be specified via 'hipace.background_density_SI'"); + } + + m_product_pc = product_pc; + amrex::ParmParse pp(m_name); + std::string physical_element; + getWithParser(pp, "element", physical_element); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(ion_map_ids.count(physical_element) != 0, + "There are no ionization energies available for this element. " + "Please update src/utils/IonizationEnergiesTable.H using write_atomic_data_cpp.py"); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE((std::abs(product_pc->m_charge / m_charge +1) < 1e-3), + "Ion and Ionization product charges have to be opposite"); + // Get atomic number and ionization energies from file + const int ion_element_id = ion_map_ids[physical_element]; + const int ion_atomic_number = ion_atomic_numbers[ion_element_id]; + amrex::Vector h_ionization_energies(ion_atomic_number); + const int offset = ion_energy_offsets[ion_element_id]; + for(int i=0; i(background_density_SI) * + PhysConstSI::q_e*PhysConstSI::q_e / + (PhysConstSI::ep0 * PhysConstSI::m_e) ); + const amrex::Real dt = normalized_units ? geom.CellSize(2)/wp : geom.CellSize(2)/phys_const.c; + + m_laser_adk_prefactor.resize(ion_atomic_number); + + amrex::Gpu::PinnedVector h_laser_adk_prefactor(ion_atomic_number); + + for (int i=0; i Date: Wed, 28 Aug 2024 21:01:12 +0200 Subject: [PATCH 02/76] fix abs --- src/particles/plasma/PlasmaParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 59d350fc0f..7f7c1cc111 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -533,7 +533,7 @@ LaserIonization (const amrex::Geometry& geom, const Complex E1 = i * A - A_dzeta; const Complex E2 = - A_dx; - const amrex::Real Ep = std::abs(std::sqrt( std::abs(E1*E1) + std::abs(E2*E2) )*E0); + const amrex::Real Ep = std::sqrt( std::abs(E1*E1) + std::abs(E2*E2) )*E0; // Compute probability of ionization p const amrex::Real gammap = (1.0_rt + uxp[ip] * uxp[ip] * clightsq From 85fb03dc945559aaa5d5e51a72599ca0fad5bf6b Mon Sep 17 00:00:00 2001 From: AlexanderSinn Date: Wed, 25 Sep 2024 13:24:25 +0200 Subject: [PATCH 03/76] gather directly from laser --- docs/source/run/parameters.rst | 3 + src/Hipace.cpp | 5 +- src/particles/particles_utils/FieldGather.H | 139 ++++++++++-------- src/particles/plasma/MultiPlasma.H | 10 +- src/particles/plasma/MultiPlasma.cpp | 19 ++- .../plasma/PlasmaParticleContainer.H | 29 ++-- .../plasma/PlasmaParticleContainer.cpp | 97 ++++++++---- .../plasma/PlasmaParticleContainerInit.cpp | 78 +--------- 8 files changed, 180 insertions(+), 200 deletions(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index 7b862892f7..9bb7151930 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -439,6 +439,9 @@ When both are specified, the per-species value is used. * ``.can_ionize`` (`bool`) optional (default `0`) Whether this plasma can ionize. Can also be set to 1 by specifying ``.ionization_product``. +* ``.can_laser_ionize`` (`bool`) optional (default `.can_ionize`) + Whether this plasma can be ionized by a laser. + * ``.initial_ion_level`` (`int`) optional (default `-1`) The initial ionization state of the plasma. `0` for neutral gasses. If set, the plasma charge gets multiplied by this number. If the plasma species is not ionizable, diff --git a/src/Hipace.cpp b/src/Hipace.cpp index 5b3f349e1b..964ce7a11b 100644 --- a/src/Hipace.cpp +++ b/src/Hipace.cpp @@ -693,11 +693,14 @@ Hipace::SolveOneSlice (int islice, int step) // copy fields (and laser) to diagnostic array FillFieldDiagnostics(current_N_level, islice); - // plasma ionization + // plasma field ionization for (int lev=0; lev const& slice_arr, - const int psi_comp, - const int ez_comp, - const int bx_comp, - const int by_comp, - const int bz_comp, - const amrex::Real dx_inv, - const amrex::Real dy_inv, - const amrex::Real x_pos_offset, - const amrex::Real y_pos_offset, - const int depos_order_xy) -{ - if (depos_order_xy == 0) { - doGatherShapeN<0>(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr, - psi_comp, ez_comp, bx_comp, by_comp, bz_comp, - dx_inv, dy_inv, x_pos_offset, y_pos_offset); - } else if (depos_order_xy == 1) { - doGatherShapeN<1>(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr, - psi_comp, ez_comp, bx_comp, by_comp, bz_comp, - dx_inv, dy_inv, x_pos_offset, y_pos_offset); - } else if (depos_order_xy == 2) { - doGatherShapeN<2>(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr, - psi_comp, ez_comp, bx_comp, by_comp, bz_comp, - dx_inv, dy_inv, x_pos_offset, y_pos_offset); - } else if (depos_order_xy == 3) { - doGatherShapeN<3>(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr, - psi_comp, ez_comp, bx_comp, by_comp, bz_comp, - dx_inv, dy_inv, x_pos_offset, y_pos_offset); - } -} - - - /** * \brief Field gather for a single particle of just Bx and By * @@ -330,6 +265,80 @@ void doLaserGatherShapeN (const amrex::Real xp, } } +/** + * \brief Laser field gather for a single particle + * + * \tparam depos_order_xy Order of the transverse shape factor for the field gather + * \param[in] xp Particle position x + * \param[in] yp Particle position y + * \param[in] Ap a field at particle position + * \param[in] ADxp d/dx a field at particle position + * \param[in] ADzetap d/dzeta a field at particle position + * \param[in] laser_arr slice array for WhichSlice::This + * \param[in] aabs_comp field component for field aabs + * \param[in] dx_inv inverse cell spacing in x direction + * \param[in] dy_inv inverse cell spacing in y direction + * \param[in] x_pos_offset offset for converting positions to indexes + * \param[in] y_pos_offset offset for converting positions to indexes + */ +template +AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE +void doLaserGatherShapeN (const amrex::Real xp, + const amrex::Real yp, + amrex::GpuComplex& Ap, + amrex::GpuComplex& ADxp, + amrex::GpuComplex& ADzetap, + Array3 const& laser_arr, + const amrex::Real dx_inv, + const amrex::Real dy_inv, + const amrex::Real dzeta_inv, + const amrex::Real x_pos_offset, + const amrex::Real y_pos_offset) +{ + using namespace amrex::literals; + + // x,y direction + const amrex::Real x = (xp-x_pos_offset)*dx_inv; + const amrex::Real y = (yp-y_pos_offset)*dy_inv; + + // --- Compute shape factors + // x direction + // j_cell leftmost cell in x that the particle touches. sx_cell shape factor along x + amrex::Real sx_cell[depos_order_xy + 1]; + const int i_cell = compute_shape_factor(sx_cell, x); + + // y direction + amrex::Real sy_cell[depos_order_xy + 1]; + const int j_cell = compute_shape_factor(sy_cell, y); + + // Gather field Aabssq, AabssqDxp, and AabssqDxp on particle from field on grid slice_arr + // the derivative is calculated on the fly + for (int iy=0; iy<=depos_order_xy; iy++){ + for (int ix=0; ix<=depos_order_xy; ix++){ + using namespace WhichLaserSlice; + const amrex::Real s_cell = sx_cell[ix]*sy_cell[iy]; + const int i = i_cell+ix; + const int j = j_cell+iy; + Ap += amrex::GpuComplex { + s_cell * laser_arr(i, j, n00j00_r), + s_cell * laser_arr(i, j, n00j00_i) + }; + ADxp += amrex::GpuComplex { + s_cell * 0.5_rt * dx_inv * + (laser_arr(i + 1, j, n00j00_r) - laser_arr(i - 1, j, n00j00_r)), + s_cell * 0.5_rt * dx_inv * + (laser_arr(i + 1, j, n00j00_i) - laser_arr(i - 1, j, n00j00_i)) + }; + ADzetap += amrex::GpuComplex { + s_cell * dzeta_inv * + (laser_arr(i, j, n00jp1_r) - laser_arr(i, j, n00j00_r)), + s_cell * dzeta_inv * + (laser_arr(i, j, n00jp1_i) - laser_arr(i, j, n00j00_i)) + }; + } + } +} + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void doGatherEz (const amrex::Real xp, const amrex::Real yp, diff --git a/src/particles/plasma/MultiPlasma.H b/src/particles/plasma/MultiPlasma.H index 04f556c097..5cad24189f 100644 --- a/src/particles/plasma/MultiPlasma.H +++ b/src/particles/plasma/MultiPlasma.H @@ -99,7 +99,15 @@ public: */ void DoFieldIonization (const int lev, const amrex::Geometry& geom, const Fields& fields); - bool IonizationOn () const; + /** Calculates Ionization Probability from laser and makes new Plasma Particles + * + * \param[in] islice zeta slice index + * \param[in] laser_geom Geometry of the laser + * \param[in] laser the laser class + */ + void DoLaserIonization (const int islice, const amrex::Geometry& laser_geom, + const MultiLaser& laser); + /** \brief whether any plasma species uses a neutralizing background, e.g. no ion motion */ bool AnySpeciesNeutralizeBackground () const; diff --git a/src/particles/plasma/MultiPlasma.cpp b/src/particles/plasma/MultiPlasma.cpp index a7ac963da1..c9fd5700cd 100644 --- a/src/particles/plasma/MultiPlasma.cpp +++ b/src/particles/plasma/MultiPlasma.cpp @@ -47,16 +47,16 @@ MultiPlasma::InitData (amrex::Vector slice_ba, plasma.InitData(gm[0]); if(plasma.m_can_ionize) { - PlasmaParticleContainer* plasma_product = nullptr; for (int i=0; i 0) m_all_bins.resize(m_nplasmas); @@ -128,14 +128,13 @@ MultiPlasma::DoFieldIonization ( } } -bool -MultiPlasma::IonizationOn () const +void +MultiPlasma::DoLaserIonization ( + const int islice, const amrex::Geometry& laser_geom, const MultiLaser& laser) { - bool ionization_on = false; for (auto& plasma : m_all_plasmas) { - if (plasma.m_can_ionize) ionization_on = true; + plasma.LaserIonization(islice, laser_geom, laser, Hipace::m_background_density_SI); } - return ionization_on; } bool diff --git a/src/particles/plasma/PlasmaParticleContainer.H b/src/particles/plasma/PlasmaParticleContainer.H index 7623c37bf6..30b177d99f 100644 --- a/src/particles/plasma/PlasmaParticleContainer.H +++ b/src/particles/plasma/PlasmaParticleContainer.H @@ -84,10 +84,9 @@ public: /** Initialize ADK prefactors of ionizable plasmas * * \param[in] geom Geometry of the simulation, to get the cell size - * \param[in] product_pc The electron plasma PC that this Ion Plasma ionizes to * \param[in] background_density_SI background plasma density (only needed for normalized units) */ - void InitIonizationModule (const amrex::Geometry& geom, PlasmaParticleContainer* product_pc, + void InitIonizationModule (const amrex::Geometry& geom, const amrex::Real background_density_SI); /** Calculates Ionization Probability and generates new Plasma Particles @@ -102,25 +101,16 @@ public: const Fields& fields, const amrex::Real background_density_SI); - /** Initialize ADK prefactors of Laser ionizable plasmas - * - * \param[in] geom Geometry of the simulation, to get the cell size - * \param[in] product_pc The electron plasma PC that this Ion Plasma ionizes to - * \param[in] background_density_SI background plasma density (only needed for normalized units) - */ - void InitLaserIonization (const amrex::Geometry& geom, PlasmaParticleContainer* product_pc, - const amrex::Real background_density_SI); - /** Calculates Ionization Probability from a Laser and generates new Plasma Particles * - * \param[in] lev MR level - * \param[in] geom Geometry of the simulation, to get the cell size - * \param[in] fields the general field class + * \param[in] islice zeta slice index + * \param[in] laser_geom Geometry of the laser + * \param[in] laser the laser class * \param[in] background_density_SI background plasma density (only needed for normalized units) */ - void LaserIonization (const int lev, - const amrex::Geometry& geom, - const Fields& fields, + void LaserIonization (const int islice, + const amrex::Geometry& laser_geom, + const MultiLaser& laser, const amrex::Real background_density_SI); /** Reorder particles to speed-up current deposition @@ -208,8 +198,10 @@ public: // ionization: + bool m_can_ionize = false; /**< whether this plasma can ionize from anything */ + bool m_can_field_ionize = false; /**< whether this plasma can ionize from the field */ + bool m_can_laser_ionize = false; /**< whether this plasma can ionize from a laser */ int m_init_ion_lev = -1; /**< initial Ion level of each particle */ - bool m_can_ionize = false; /**< whether this plasma can ionize */ std::string m_product_name = ""; /**< name of Ionization product plasma */ PlasmaParticleContainer* m_product_pc = nullptr; /**< Ionization product plasma */ /** to calculate Ionization probability with ADK formula */ @@ -218,7 +210,6 @@ public: amrex::Gpu::DeviceVector m_adk_exp_prefactor; /** to calculate Ionization probability with ADK formula */ amrex::Gpu::DeviceVector m_adk_power; - /** to calculate laser Ionization probability with ADK formula */ amrex::Gpu::DeviceVector m_laser_adk_prefactor; diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index c829135680..d98672890f 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -65,9 +65,15 @@ PlasmaParticleContainer::ReadParameters () AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_mass != 0, "The plasma particle mass must be specified"); bool ion_lev_specified = queryWithParser(pp, "initial_ion_level", m_init_ion_lev); - m_can_ionize = pp.contains("ionization_product"); + m_can_field_ionize = pp.contains("ionization_product"); + + queryWithParser(pp, "can_ionize", m_can_field_ionize); + bool use_laser = true; // TODO: use actual value (laser not yet initialized at this time) + m_can_laser_ionize = m_can_field_ionize && use_laser; + queryWithParser(pp, "can_laser_ionize", m_can_laser_ionize); + + m_can_ionize = m_can_field_ionize || m_can_laser_ionize; - queryWithParser(pp, "can_ionize", m_can_ionize); if(m_can_ionize) { m_neutralize_background = false; // change default AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_init_ion_lev >= 0, @@ -265,7 +271,7 @@ IonizationModule (const int lev, const Fields& fields, const amrex::Real background_density_SI) { - if (!m_can_ionize) return; + if (!m_can_field_ionize) return; HIPACE_PROFILE("PlasmaParticleContainer::IonizationModule()"); using namespace amrex::literals; @@ -292,8 +298,6 @@ IonizationModule (const int lev, amrex::Real const x_pos_offset = GetPosOffset(0, geom, slice_fab.box()); const amrex::Real y_pos_offset = GetPosOffset(1, geom, slice_fab.box()); - const int depos_order_xy = Hipace::m_depos_order_xy; - auto& plevel_ion = GetParticles(0); auto index = std::make_pair(mfi_ion.index(), mfi_ion.LocalTileIndex()); if(plevel_ion.find(index) == plevel_ion.end()) continue; @@ -331,8 +335,17 @@ IonizationModule (const int lev, long num_ions = ptile_ion.numParticles(); - amrex::ParallelForRNG(num_ions, - [=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine) { + amrex::AnyCTO( + amrex::TypeList< + amrex::CompileTimeOptions<0, 1, 2, 3> + >{}, { + Hipace::m_depos_order_xy + }, + [&] (auto cto_func) { + amrex::ParallelForRNG(num_ions, cto_func); + }, + [=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine, + auto depos_order_xy) { if (amrex::ConstParticleIDWrapper(idcpup[ip]) < 0 || amrex::ConstParticleCPUWrapper(idcpup[ip]) != lev) return; @@ -345,10 +358,10 @@ IonizationModule (const int lev, amrex::ParticleReal ExmByp = 0., EypBxp = 0., Ezp = 0.; amrex::ParticleReal Bxp = 0., Byp = 0., Bzp = 0.; - doGatherShapeN(xp, yp, + doGatherShapeN(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr, psi_comp, ez_comp, bx_comp, by_comp, bz_comp, - dx_inv, dy_inv, x_pos_offset, y_pos_offset, depos_order_xy); + dx_inv, dy_inv, x_pos_offset, y_pos_offset); const amrex::ParticleReal Exp = ExmByp + Byp * phys_const.c; const amrex::ParticleReal Eyp = EypBxp - Bxp * phys_const.c; @@ -378,7 +391,7 @@ IonizationModule (const int lev, if (num_new_electrons.dataValue() == 0) continue; if(Hipace::m_verbose >= 3) { - amrex::Print() << "Number of ionized Plasma Particles: " + amrex::Print() << "Number of ionized Plasma Particles (field): " << num_new_electrons.dataValue() << "\n"; } @@ -441,29 +454,36 @@ IonizationModule (const int lev, void PlasmaParticleContainer:: -LaserIonization (const amrex::Geometry& geom, +LaserIonization (const int islice, + const amrex::Geometry& laser_geom, + const MultiLaser& laser, const amrex::Real background_density_SI) { - if (!m_can_ionize) return; + if (!m_can_laser_ionize || !laser.UseLaser(islice)) return; HIPACE_PROFILE("PlasmaParticleContainer::LaserIonization()"); using namespace amrex::literals; using Complex = amrex::GpuComplex; + constexpr Complex I(0.,1.); const PhysConst phys_const = get_phys_const(); // Loop over particle boxes with both ion and electron Particle Containers at the same time for (amrex::MFIter mfi_ion = MakeMFIter(0, DfltMfi); mfi_ion.isValid(); ++mfi_ion) { + // Extract laser array + Array3 const laser_arr = laser.getSlices().const_array(mfi_ion); + + const CheckDomainBounds laser_bounds {laser_geom}; + // Extract properties associated with physical size of the box - const amrex::Real dx_inv = geom.InvCellSize(0); - const amrex::Real dy_inv = geom.InvCellSize(1); + const amrex::Real dx_inv = laser_geom.InvCellSize(0); + const amrex::Real dy_inv = laser_geom.InvCellSize(1); + const amrex::Real dzeta_inv = laser_geom.InvCellSize(2); // Offset for converting positions to indexes - amrex::Real const x_pos_offset = GetPosOffset(0, geom, slice_fab.box()); - const amrex::Real y_pos_offset = GetPosOffset(1, geom, slice_fab.box()); - - const int depos_order_xy = Hipace::m_depos_order_xy; + amrex::Real const x_pos_offset = GetPosOffset(0, laser_geom, laser_geom.Domain()); + const amrex::Real y_pos_offset = GetPosOffset(1, laser_geom, laser_geom.Domain()); auto& plevel_ion = GetParticles(0); auto index = std::make_pair(mfi_ion.index(), mfi_ion.LocalTileIndex()); @@ -481,7 +501,6 @@ LaserIonization (const amrex::Geometry& geom, (PhysConstSI::ep0 * PhysConstSI::m_e) ); const amrex::Real E0 = Hipace::m_normalized_units ? wp * PhysConstSI::m_e * PhysConstSI::c / PhysConstSI::q_e : 1; - const amrex::Real pi_inv_3 = 3 / MathConst::pi; int * const ion_lev = soa_ion.GetIntData(PlasmaIdx::ion_lev).data(); const amrex::Real * const x_prev = soa_ion.GetRealData(PlasmaIdx::x_prev).data(); @@ -504,24 +523,38 @@ LaserIonization (const amrex::Geometry& geom, long num_ions = ptile_ion.numParticles(); - amrex::ParallelForRNG(num_ions, - [=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine) { - - if (amrex::ConstParticleIDWrapper(idcpup[ip]) < 0 || - amrex::ConstParticleCPUWrapper(idcpup[ip]) != lev) return; + amrex::AnyCTO( + amrex::TypeList< + amrex::CompileTimeOptions<0, 1, 2, 3> + >{}, { + Hipace::m_depos_order_xy + }, + [&] (auto cto_func) { + amrex::ParallelForRNG(num_ions, cto_func); + }, + [=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine, + auto depos_order_xy) { // avoid temp slice const amrex::Real xp = x_prev[ip]; const amrex::Real yp = y_prev[ip]; - const amrex::Real A = 0; - const amrex::Real A_dzeta = 0; - const amrex::Real A_dx = 0; + if (amrex::ConstParticleIDWrapper(idcpup[ip]) < 0 || + !laser_bounds.contains(xp, yp)) return; + + Complex A = 0; + Complex A_dx = 0; + Complex A_dzeta = 0; - const Complex E1 = i * A - A_dzeta; + // TODO convert units of A + // this is likely incorrect + doLaserGatherShapeN(xp, yp, A, A_dx, A_dzeta, laser_arr, + dx_inv, dy_inv, dzeta_inv, x_pos_offset, y_pos_offset); + + const Complex E1 = I * A - A_dzeta; const Complex E2 = - A_dx; - const amrex::Real Ep = std::sqrt( std::abs(E1*E1) + std::abs(E2*E2) )*E0; + const amrex::Real Ep = std::sqrt( amrex::abs(E1*E1) + amrex::abs(E2*E2) )*E0; // Compute probability of ionization p const amrex::Real gammap = (1.0_rt + uxp[ip] * uxp[ip] * clightsq @@ -550,7 +583,7 @@ LaserIonization (const amrex::Geometry& geom, if (num_new_electrons.dataValue() == 0) continue; if(Hipace::m_verbose >= 3) { - amrex::Print() << "Number of ionized Plasma Particles: " + amrex::Print() << "Number of ionized Plasma Particles (laser): " << num_new_electrons.dataValue() << "\n"; } @@ -565,6 +598,7 @@ LaserIonization (const amrex::Geometry& geom, auto arrdata_elec = ptile_elec.GetStructOfArrays().realarray(); auto int_arrdata_elec = ptile_elec.GetStructOfArrays().intarray(); auto idcpu_elec = ptile_elec.GetStructOfArrays().GetIdCPUData().data(); + auto idcpu_ion = ptile_ion.GetStructOfArrays().GetIdCPUData().data(); const int init_ion_lev = m_product_pc->m_init_ion_lev; @@ -580,7 +614,8 @@ LaserIonization (const amrex::Geometry& geom, // Copy ion data to new electron amrex::ParticleIDWrapper{idcpu_elec[pidx]} = 2; // only for valid/invalid - amrex::ParticleCPUWrapper{idcpu_elec[pidx]} = lev; // current level + amrex::ParticleCPUWrapper{idcpu_elec[pidx]} = + amrex::ParticleCPUWrapper{idcpu_ion[pidx]}; // current level arrdata_elec[PlasmaIdx::x ][pidx] = arrdata_ion[PlasmaIdx::x ][ip]; arrdata_elec[PlasmaIdx::y ][pidx] = arrdata_ion[PlasmaIdx::y ][ip]; diff --git a/src/particles/plasma/PlasmaParticleContainerInit.cpp b/src/particles/plasma/PlasmaParticleContainerInit.cpp index 3a918cc670..e7d369cf83 100644 --- a/src/particles/plasma/PlasmaParticleContainerInit.cpp +++ b/src/particles/plasma/PlasmaParticleContainerInit.cpp @@ -379,15 +379,12 @@ InitParticles (const amrex::RealVect& a_u_std, void PlasmaParticleContainer:: -InitIonizationModule (const amrex::Geometry& geom, PlasmaParticleContainer* product_pc, - const amrex::Real background_density_SI) +InitIonizationModule (const amrex::Geometry& geom, const amrex::Real background_density_SI) { HIPACE_PROFILE("PlasmaParticleContainer::InitIonizationModule()"); using namespace amrex::literals; - if (!m_can_ionize) return; - const bool normalized_units = Hipace::m_normalized_units; if (normalized_units) { AMREX_ALWAYS_ASSERT_WITH_MESSAGE(background_density_SI!=0, @@ -395,14 +392,13 @@ InitIonizationModule (const amrex::Geometry& geom, PlasmaParticleContainer* prod "be specified via 'hipace.background_density_SI'"); } - m_product_pc = product_pc; amrex::ParmParse pp(m_name); std::string physical_element; getWithParser(pp, "element", physical_element); AMREX_ALWAYS_ASSERT_WITH_MESSAGE(ion_map_ids.count(physical_element) != 0, "There are no ionization energies available for this element. " "Please update src/utils/IonizationEnergiesTable.H using write_atomic_data_cpp.py"); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE((std::abs(product_pc->m_charge / m_charge +1) < 1e-3), + AMREX_ALWAYS_ASSERT_WITH_MESSAGE((std::abs(m_product_pc->m_charge / m_charge +1) < 1e-3), "Ion and Ionization product charges have to be opposite"); // Get atomic number and ionization energies from file const int ion_element_id = ion_map_ids[physical_element]; @@ -435,10 +431,12 @@ InitIonizationModule (const amrex::Geometry& geom, PlasmaParticleContainer* prod m_adk_power.resize(ion_atomic_number); m_adk_prefactor.resize(ion_atomic_number); m_adk_exp_prefactor.resize(ion_atomic_number); + m_laser_adk_prefactor.resize(ion_atomic_number); amrex::Gpu::PinnedVector h_adk_power(ion_atomic_number); amrex::Gpu::PinnedVector h_adk_prefactor(ion_atomic_number); amrex::Gpu::PinnedVector h_adk_exp_prefactor(ion_atomic_number); + amrex::Gpu::PinnedVector h_laser_adk_prefactor(ion_atomic_number); for (int i=0; im_charge / m_charge +1) < 1e-3), - "Ion and Ionization product charges have to be opposite"); - // Get atomic number and ionization energies from file - const int ion_element_id = ion_map_ids[physical_element]; - const int ion_atomic_number = ion_atomic_numbers[ion_element_id]; - amrex::Vector h_ionization_energies(ion_atomic_number); - const int offset = ion_energy_offsets[ion_element_id]; - for(int i=0; i(background_density_SI) * - PhysConstSI::q_e*PhysConstSI::q_e / - (PhysConstSI::ep0 * PhysConstSI::m_e) ); - const amrex::Real dt = normalized_units ? geom.CellSize(2)/wp : geom.CellSize(2)/phys_const.c; - - m_laser_adk_prefactor.resize(ion_atomic_number); - - amrex::Gpu::PinnedVector h_laser_adk_prefactor(ion_atomic_number); - - for (int i=0; i Date: Wed, 25 Sep 2024 13:26:23 +0200 Subject: [PATCH 04/76] fix doc --- src/particles/particles_utils/FieldGather.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/particles/particles_utils/FieldGather.H b/src/particles/particles_utils/FieldGather.H index c1d356ab8f..2bb413a68d 100644 --- a/src/particles/particles_utils/FieldGather.H +++ b/src/particles/particles_utils/FieldGather.H @@ -275,9 +275,9 @@ void doLaserGatherShapeN (const amrex::Real xp, * \param[in] ADxp d/dx a field at particle position * \param[in] ADzetap d/dzeta a field at particle position * \param[in] laser_arr slice array for WhichSlice::This - * \param[in] aabs_comp field component for field aabs * \param[in] dx_inv inverse cell spacing in x direction * \param[in] dy_inv inverse cell spacing in y direction + * \param[in] dzeta_inv inverse cell spacing in zeta direction * \param[in] x_pos_offset offset for converting positions to indexes * \param[in] y_pos_offset offset for converting positions to indexes */ From 9a8205a0997f6098778c6461c2c9b55cc4bad9e6 Mon Sep 17 00:00:00 2001 From: Eya Dammak Date: Fri, 13 Dec 2024 18:17:25 +0100 Subject: [PATCH 05/76] LaserIonization: calculation of Ep components --- src/particles/plasma/PlasmaParticleContainer.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index d98672890f..c70cd9623d 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -501,7 +501,9 @@ LaserIonization (const int islice, (PhysConstSI::ep0 * PhysConstSI::m_e) ); const amrex::Real E0 = Hipace::m_normalized_units ? wp * PhysConstSI::m_e * PhysConstSI::c / PhysConstSI::q_e : 1; - + const amrex::Real lambda0 = laser.GetLambda0(); + const amrex::Real omega0 = 2.0 * MathConst::pi * phys_const.c / lambda0; + int * const ion_lev = soa_ion.GetIntData(PlasmaIdx::ion_lev).data(); const amrex::Real * const x_prev = soa_ion.GetRealData(PlasmaIdx::x_prev).data(); const amrex::Real * const y_prev = soa_ion.GetRealData(PlasmaIdx::y_prev).data(); @@ -551,10 +553,11 @@ LaserIonization (const int islice, doLaserGatherShapeN(xp, yp, A, A_dx, A_dzeta, laser_arr, dx_inv, dy_inv, dzeta_inv, x_pos_offset, y_pos_offset); - const Complex E1 = I * A - A_dzeta; - const Complex E2 = - A_dx; + const Complex Et = I * A * omega0 + A_dzeta * phys_const.c; //transverse component + const Complex El = - A_dx * phys_const.c; //longitudinal component - const amrex::Real Ep = std::sqrt( amrex::abs(E1*E1) + amrex::abs(E2*E2) )*E0; + amrex::Real Ep = std::sqrt( amrex::abs(Et*Et) + amrex::abs(El*El) ); + Ep = Ep * phys_const.m_e * phys_const.c / phys_const.q_e; // Compute probability of ionization p const amrex::Real gammap = (1.0_rt + uxp[ip] * uxp[ip] * clightsq From 3237c8076b4b8804f51bb9225669870b0abf5284 Mon Sep 17 00:00:00 2001 From: Eya Dammak Date: Wed, 18 Dec 2024 11:34:48 +0100 Subject: [PATCH 06/76] fix the error in the laser adk prefactor --- src/particles/plasma/PlasmaParticleContainer.cpp | 5 +++-- src/particles/plasma/PlasmaParticleContainerInit.cpp | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index c70cd9623d..187b47d91f 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -557,8 +557,9 @@ LaserIonization (const int islice, const Complex El = - A_dx * phys_const.c; //longitudinal component amrex::Real Ep = std::sqrt( amrex::abs(Et*Et) + amrex::abs(El*El) ); - Ep = Ep * phys_const.m_e * phys_const.c / phys_const.q_e; - + Ep *= phys_const.m_e * phys_const.c / phys_const.q_e; + Ep *= E0; + // Compute probability of ionization p const amrex::Real gammap = (1.0_rt + uxp[ip] * uxp[ip] * clightsq + uyp[ip] * uyp[ip] * clightsq diff --git a/src/particles/plasma/PlasmaParticleContainerInit.cpp b/src/particles/plasma/PlasmaParticleContainerInit.cpp index e7d369cf83..b2dbc82523 100644 --- a/src/particles/plasma/PlasmaParticleContainerInit.cpp +++ b/src/particles/plasma/PlasmaParticleContainerInit.cpp @@ -414,11 +414,10 @@ InitIonizationModule (const amrex::Geometry& geom, const amrex::Real background_ // without Gamma function const PhysConst phys_const = make_constants_SI(); const amrex::Real alpha = 0.0072973525693_rt; - const amrex::Real r_e = 2.8179403227e-15_rt; const amrex::Real a3 = alpha * alpha * alpha; const amrex::Real a4 = a3 * alpha; - const amrex::Real wa = a3 * phys_const.c / r_e; - const amrex::Real Ea = phys_const.m_e * phys_const.c * phys_const.c / phys_const.q_e * a4 / r_e; + const amrex::Real wa = a3 * phys_const.c / PhysConstSI::r_e; + const amrex::Real Ea = phys_const.m_e * phys_const.c * phys_const.c / phys_const.q_e * a4 / PhysConstSI::r_e; const amrex::Real UH = table_ionization_energies[0]; const amrex::Real l_eff = std::sqrt(UH/h_ionization_energies[0]) - 1._rt; @@ -448,7 +447,7 @@ InitIonizationModule (const amrex::Geometry& geom, const amrex::Real background_ h_adk_prefactor[i] = dt * wa * C2 * ( Uion/(2*UH) ) * std::pow(2*std::pow((Uion/UH),3./2)*Ea,2*n_eff - 1); h_adk_exp_prefactor[i] = -2./3 * std::pow( Uion/UH,3./2) * Ea; - h_laser_adk_prefactor[i] = (3 / MathConst::pi) * std::pow(Uion/UH, -3./2.); + h_laser_adk_prefactor[i] = (3 / MathConst::pi) * std::pow(Uion/UH, -3./2.) / Ea; } amrex::Gpu::copy(amrex::Gpu::hostToDevice, From ca1fda7da831e82cf84c725794163c74de87e747 Mon Sep 17 00:00:00 2001 From: Eya Dammak Date: Thu, 19 Dec 2024 16:28:06 +0100 Subject: [PATCH 07/76] adding the circular polarization case --- src/laser/MultiLaser.H | 3 +++ src/particles/plasma/PlasmaParticleContainer.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.H b/src/laser/MultiLaser.H index 29f8616be8..781ca128da 100644 --- a/src/laser/MultiLaser.H +++ b/src/laser/MultiLaser.H @@ -171,6 +171,9 @@ public: /** Get the geometry of the Laser Box */ const amrex::Geometry& GetLaserGeom () const { return m_laser_geom_3D; } + /** If the polarization is linear or circular */ + bool LinearPolarization () const { return m_linear_polarization; } + /** If the laser geometry includes this slice * \param[in] islice slice index */ diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 187b47d91f..0cd912f2ec 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -503,6 +503,7 @@ LaserIonization (const int islice, wp * PhysConstSI::m_e * PhysConstSI::c / PhysConstSI::q_e : 1; const amrex::Real lambda0 = laser.GetLambda0(); const amrex::Real omega0 = 2.0 * MathConst::pi * phys_const.c / lambda0; + const bool linear_polarization = laser.LinearPolarization(); int * const ion_lev = soa_ion.GetIntData(PlasmaIdx::ion_lev).data(); const amrex::Real * const x_prev = soa_ion.GetRealData(PlasmaIdx::x_prev).data(); @@ -570,7 +571,12 @@ LaserIonization (const int islice, std::pow(Ep, adk_power[ion_lev_loc]) * std::exp( adk_exp_prefactor[ion_lev_loc]/Ep ); - amrex::Real w_dtau_ac = w_dtau_dc * std::sqrt(Ep * laser_adk_prefactor[ion_lev_loc]); + amrex::Real w_dtau_ac; + if (linear_polarization) { + w_dtau_ac = w_dtau_dc * std::sqrt(Ep * laser_adk_prefactor[ion_lev_loc]); + } else { + w_dtau_ac = w_dtau_dc; + } amrex::Real p = 1._rt - std::exp( - w_dtau_ac ); From c44f3438ef2fe3721057e0af314a2c73d9c92f71 Mon Sep 17 00:00:00 2001 From: Eya Dammak Date: Fri, 20 Dec 2024 11:40:28 +0100 Subject: [PATCH 08/76] new test in linear polarization --- CMakeLists.txt | 6 ++ .../analysis_laser_ionization.py | 46 ++++++++++++++ .../input_laser_ionization_linear | 61 +++++++++++++++++++ .../laser_ionization.1Rank.json | 32 ++++++++++ tests/checksum/reset_all_benchmarks.sh | 12 ++++ tests/laser_ionization.1Rank.sh | 38 ++++++++++++ 6 files changed, 195 insertions(+) create mode 100755 examples/laser_ionization/analysis_laser_ionization.py create mode 100644 examples/laser_ionization/input_laser_ionization_linear create mode 100644 tests/checksum/benchmarks_json/laser_ionization.1Rank.json create mode 100755 tests/laser_ionization.1Rank.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index dc4604f2f3..3cdf08938b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,6 +342,12 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) + add_test(NAME laser_ionization.1Rank + COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_ionization.1Rank.sh + $ ${HiPACE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + ) + if (NOT HiPACE_COMPUTE STREQUAL CUDA) # These tests only run on CPU diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py new file mode 100755 index 0000000000..7fe2a032bc --- /dev/null +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -0,0 +1,46 @@ +#! /usr/bin/env python3 + +# +# This file is part of HiPACE++. +# +# Authors: + +import numpy as np +import math +from openpmd_viewer import OpenPMDTimeSeries +import statistics + +parser = argparse.ArgumentParser(description='Compare with WarpX the fraction of ionization for a specific value of a0 with a linear polarized laser') +parser.add_argument('--output-dir', + dest='output_dir', + default='new', + help='Path to the directory containing output files') +args = parser.parse_args() + +ts = OpenPMDTimeSeries(args.output_dir) + +lambda0 = 800.e-9 +a0 = 0.00885126 +nc = 1.75e27 +n0 = nc / 10000 + +me = 9.1093837015e-31 +c = 299792458 +qe = 1.602176634e-19 +C = me * c * c * 2 * math.pi / (lambda0 * qe) + +E0 = C * a0 + +iteration = 0 +rho_elec, _ = ts.get_field(field='rho_elec', coord='z', iteration=iteration, plot=False) +rho_elec_mean = np.mean(rho_elec, axis=(1, 2)) +rho_average = statistics.mean(rho_elec_mean[0:10]) +fraction = rho_average / (-qe) / (n0) + +fraction_warpx = 0.41014984 #result from WarpX simulation + +relative_diff = np.abs( ( fraction - fraction_warpx ) / fraction_warpx ) +tolerance = 0.1 +print("percentage error for the fraction of ionization = "+ str(relative_diff *100) + '%') + +assert (relative_diff < tolerance), 'Test laser_ionization did not pass' diff --git a/examples/laser_ionization/input_laser_ionization_linear b/examples/laser_ionization/input_laser_ionization_linear new file mode 100644 index 0000000000..8e8cdaa29b --- /dev/null +++ b/examples/laser_ionization/input_laser_ionization_linear @@ -0,0 +1,61 @@ +max_step = 0 +hipace.dt = 0 +hipace.verbose=3 + +amr.n_cell =32 32 50 + +my_constants.kp_inv = 10.e-6 + +my_constants.nc = 1.75e27 +my_constants.n0 = nc/10000 + +my_constants.a0 = 0.00885126 + +my_constants.w0_um = 1.e8 +my_constants.tau_fs = 30/1.17741 +my_constants.lambda0_nm = 800 + +hipace.file_prefix = new +hipace.do_tiling = 0 +hipace.deposit_rho_individual = 1 + +geometry.prob_lo = -10.*kp_inv -10.*kp_inv -15.*kp_inv #box shifted +geometry.prob_hi = 10.*kp_inv 10.*kp_inv 5.*kp_inv + +lasers.names = laser +lasers.lambda0 = lambda0_nm * 1.e-9 + + +laser.a0 = a0 +laser.position_mean = 0. 0. 0 +laser.w0 = w0_um*1.e-6 +laser.tau = tau_fs*1.e-15 +laser.focal_distance = 50.e-6 + +plasmas.names = elec ion + +elec.density(x,y,z) = n0 +elec.ppc = 0 0 +elec.u_mean = 0.0 0.0 0.0 +elec.element = electron +elec.neutralize_background = false + +ion.density(x,y,z) = n0 +ion.ppc = 1 1 +ion.u_mean = 0.0 0.0 0.0 +ion.element = H +ion.mass_Da = 1.008 +ion.initial_ion_level = 0 +ion.can_laser_ionize = 1 +ion.ionization_product = elec + +amr.max_level = 0 + +diagnostic.output_period = 1 + +hipace.depos_order_xy = 0 + +boundary.field = Dirichlet +boundary.particle = Periodic + +diagnostic.diag_type = xyz \ No newline at end of file diff --git a/tests/checksum/benchmarks_json/laser_ionization.1Rank.json b/tests/checksum/benchmarks_json/laser_ionization.1Rank.json new file mode 100644 index 0000000000..533c7d9a6e --- /dev/null +++ b/tests/checksum/benchmarks_json/laser_ionization.1Rank.json @@ -0,0 +1,32 @@ +{ + "lev=0": { + "Bx": 2682248.7057786, + "By": 2693948.2733652, + "Bz": 461542.2571099, + "ExmBy": 1615808685829100.0, + "EypBx": 1618198283855800.0, + "Ez": 661283579146520.0, + "Psi": 10769981642.67, + "Sx": 7.6153143423645e+17, + "Sy": 7.6749662052452e+17, + "chi": 2095164846204800.0, + "jx": 5.1803326176917e+17, + "jx_beam": 231581100098160.0, + "jy": 5.1661888254051e+17, + "jy_beam": 230138001520970.0, + "jz_beam": 1.6907142961472e+17, + "rhomjz": 8996307095.7456 + }, + "beam": { + "charge": 1.127932350336e-16, + "id": 248160, + "mass": 6.413006125856e-28, + "x": 0.00024861156942758, + "y": 0.00024733653871292, + "z": 0.014359549367752, + "ux": 3002.9712584681, + "uy": 3008.1141100408, + "uz": 1386735.4182493, + "w": 825000000.0 + } +} diff --git a/tests/checksum/reset_all_benchmarks.sh b/tests/checksum/reset_all_benchmarks.sh index ac93637fe7..8f945f88c1 100755 --- a/tests/checksum/reset_all_benchmarks.sh +++ b/tests/checksum/reset_all_benchmarks.sh @@ -430,3 +430,15 @@ then --file_name ${build_dir}/bin/transverse_benchmark.1Rank.sh \ --test-name transverse_benchmark.1Rank.sh fi + +# laser_ionization.1Rank.sh +if [[ $all_tests = true ]] || [[ $one_test_name = "laser_ionization.1Rank.sh" ]] +then + cd $build_dir + ctest --output-on-failure -R laser_ionization.1Rank.sh \ + || echo "ctest command failed, maybe just because checksums are different. Keep going" + cd $checksum_dir + ./checksumAPI.py --reset-benchmark \ + --file_name ${build_dir}/bin/laser_ionization.1Rank \ + --test-name laser_ionization.1Rank +fi diff --git a/tests/laser_ionization.1Rank.sh b/tests/laser_ionization.1Rank.sh new file mode 100755 index 0000000000..03d6905bd9 --- /dev/null +++ b/tests/laser_ionization.1Rank.sh @@ -0,0 +1,38 @@ +#! /usr/bin/env bash + +# +# This file is part of HiPACE++. +# +# Authors: EyaDammak + + +# This file is part of the HiPACE++ test suite. +# It runs a Hipace simulation with in neutral hydrogen that gets ionized by the laser + +# abort on first encounted error +set -eu -o pipefail + +# Read input parameters +HIPACE_EXECUTABLE=$1 +HIPACE_SOURCE_DIR=$2 + +HIPACE_EXAMPLE_DIR=${HIPACE_SOURCE_DIR}/examples/laser_ionization +HIPACE_TEST_DIR=${HIPACE_SOURCE_DIR}/tests + +FILE_NAME=`basename "$0"` +TEST_NAME="${FILE_NAME%.*}" + +rm -rf $TEST_NAME + +# Run the simulation +mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/input_laser_ionization_linear + +# Compare the result with theory +$HIPACE_EXAMPLE_DIR/analysis_laser_ionization.py + +# Compare the results with checksum benchmark +$HIPACE_TEST_DIR/checksum/checksumAPI.py \ + --evaluate \ + --file_name $TEST_NAME \ + --test-name $TEST_NAME + From dd4cf72a6b017456c030ac718c857625823491a5 Mon Sep 17 00:00:00 2001 From: Eya Dammak Date: Fri, 3 Jan 2025 17:31:32 +0100 Subject: [PATCH 09/76] fix issues of tab --- CMakeLists.txt | 2 +- .../plasma/PlasmaParticleContainer.cpp | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cdf08938b..227366c8d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,7 +342,7 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) - add_test(NAME laser_ionization.1Rank + add_test(NAME laser_ionization.1Rank COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_ionization.1Rank.sh $ ${HiPACE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 0cd912f2ec..af89c4567d 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -501,10 +501,10 @@ LaserIonization (const int islice, (PhysConstSI::ep0 * PhysConstSI::m_e) ); const amrex::Real E0 = Hipace::m_normalized_units ? wp * PhysConstSI::m_e * PhysConstSI::c / PhysConstSI::q_e : 1; - const amrex::Real lambda0 = laser.GetLambda0(); + const amrex::Real lambda0 = laser.GetLambda0(); const amrex::Real omega0 = 2.0 * MathConst::pi * phys_const.c / lambda0; - const bool linear_polarization = laser.LinearPolarization(); - + const bool linear_polarization = laser.LinearPolarization(); + int * const ion_lev = soa_ion.GetIntData(PlasmaIdx::ion_lev).data(); const amrex::Real * const x_prev = soa_ion.GetRealData(PlasmaIdx::x_prev).data(); const amrex::Real * const y_prev = soa_ion.GetRealData(PlasmaIdx::y_prev).data(); @@ -559,8 +559,8 @@ LaserIonization (const int islice, amrex::Real Ep = std::sqrt( amrex::abs(Et*Et) + amrex::abs(El*El) ); Ep *= phys_const.m_e * phys_const.c / phys_const.q_e; - Ep *= E0; - + Ep *= E0; + // Compute probability of ionization p const amrex::Real gammap = (1.0_rt + uxp[ip] * uxp[ip] * clightsq + uyp[ip] * uyp[ip] * clightsq @@ -571,12 +571,12 @@ LaserIonization (const int islice, std::pow(Ep, adk_power[ion_lev_loc]) * std::exp( adk_exp_prefactor[ion_lev_loc]/Ep ); - amrex::Real w_dtau_ac; - if (linear_polarization) { - w_dtau_ac = w_dtau_dc * std::sqrt(Ep * laser_adk_prefactor[ion_lev_loc]); - } else { - w_dtau_ac = w_dtau_dc; - } + amrex::Real w_dtau_ac; + if (linear_polarization) { + w_dtau_ac = w_dtau_dc * std::sqrt(Ep * laser_adk_prefactor[ion_lev_loc]); + } else { + w_dtau_ac = w_dtau_dc; + } amrex::Real p = 1._rt - std::exp( - w_dtau_ac ); From 39166cfd1963123f5df4051f3aa9063ab5bbaf98 Mon Sep 17 00:00:00 2001 From: EyaDammak Date: Fri, 3 Jan 2025 18:01:40 +0100 Subject: [PATCH 10/76] Fix file modes and remove EOL whitespaces --- examples/laser_ionization/analysis_laser_ionization.py | 2 +- src/particles/plasma/PlasmaParticleContainer.cpp | 4 ++-- tests/checksum/reset_all_benchmarks.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 7fe2a032bc..5382ea71d4 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -36,7 +36,7 @@ rho_elec_mean = np.mean(rho_elec, axis=(1, 2)) rho_average = statistics.mean(rho_elec_mean[0:10]) fraction = rho_average / (-qe) / (n0) - + fraction_warpx = 0.41014984 #result from WarpX simulation relative_diff = np.abs( ( fraction - fraction_warpx ) / fraction_warpx ) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index af89c4567d..912cb71b3d 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -504,7 +504,7 @@ LaserIonization (const int islice, const amrex::Real lambda0 = laser.GetLambda0(); const amrex::Real omega0 = 2.0 * MathConst::pi * phys_const.c / lambda0; const bool linear_polarization = laser.LinearPolarization(); - + int * const ion_lev = soa_ion.GetIntData(PlasmaIdx::ion_lev).data(); const amrex::Real * const x_prev = soa_ion.GetRealData(PlasmaIdx::x_prev).data(); const amrex::Real * const y_prev = soa_ion.GetRealData(PlasmaIdx::y_prev).data(); @@ -560,7 +560,7 @@ LaserIonization (const int islice, amrex::Real Ep = std::sqrt( amrex::abs(Et*Et) + amrex::abs(El*El) ); Ep *= phys_const.m_e * phys_const.c / phys_const.q_e; Ep *= E0; - + // Compute probability of ionization p const amrex::Real gammap = (1.0_rt + uxp[ip] * uxp[ip] * clightsq + uyp[ip] * uyp[ip] * clightsq diff --git a/tests/checksum/reset_all_benchmarks.sh b/tests/checksum/reset_all_benchmarks.sh index 8f945f88c1..4cf5ed1caa 100755 --- a/tests/checksum/reset_all_benchmarks.sh +++ b/tests/checksum/reset_all_benchmarks.sh @@ -431,7 +431,7 @@ then --test-name transverse_benchmark.1Rank.sh fi -# laser_ionization.1Rank.sh +# laser_ionization.1Rank.sh if [[ $all_tests = true ]] || [[ $one_test_name = "laser_ionization.1Rank.sh" ]] then cd $build_dir From c7eeae46e0a62fc26a29d6b2f2d9c3ae741c06d1 Mon Sep 17 00:00:00 2001 From: EyaDammak Date: Fri, 3 Jan 2025 19:16:02 +0100 Subject: [PATCH 11/76] change name of inputs file --- ...t_laser_ionization_linear => inputs_laser_ionization_linear} | 0 tests/laser_ionization.1Rank.sh | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename examples/laser_ionization/{input_laser_ionization_linear => inputs_laser_ionization_linear} (100%) diff --git a/examples/laser_ionization/input_laser_ionization_linear b/examples/laser_ionization/inputs_laser_ionization_linear similarity index 100% rename from examples/laser_ionization/input_laser_ionization_linear rename to examples/laser_ionization/inputs_laser_ionization_linear diff --git a/tests/laser_ionization.1Rank.sh b/tests/laser_ionization.1Rank.sh index 03d6905bd9..6dc14dc808 100755 --- a/tests/laser_ionization.1Rank.sh +++ b/tests/laser_ionization.1Rank.sh @@ -25,7 +25,7 @@ TEST_NAME="${FILE_NAME%.*}" rm -rf $TEST_NAME # Run the simulation -mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/input_laser_ionization_linear +mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_laser_ionization_linear # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_ionization.py From 0dda9dc518e65b38b2b4f3bf5a8121768e576e95 Mon Sep 17 00:00:00 2001 From: EyaDammak Date: Sun, 5 Jan 2025 13:36:11 +0100 Subject: [PATCH 12/76] missing library import --- examples/laser_ionization/analysis_laser_ionization.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 5382ea71d4..506415165a 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -5,6 +5,7 @@ # # Authors: +import argparse import numpy as np import math from openpmd_viewer import OpenPMDTimeSeries From f7dc046d624b55df0a61f43673af1ab02b563e8d Mon Sep 17 00:00:00 2001 From: EyaDammak Date: Mon, 6 Jan 2025 08:32:06 +0100 Subject: [PATCH 13/76] higher tolerance for the test --- examples/laser_ionization/analysis_laser_ionization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 506415165a..a13470bd82 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -41,7 +41,7 @@ fraction_warpx = 0.41014984 #result from WarpX simulation relative_diff = np.abs( ( fraction - fraction_warpx ) / fraction_warpx ) -tolerance = 0.1 +tolerance = 0.15 print("percentage error for the fraction of ionization = "+ str(relative_diff *100) + '%') assert (relative_diff < tolerance), 'Test laser_ionization did not pass' From 19c3b2433235f82f919cb16bc369e79e577b0668 Mon Sep 17 00:00:00 2001 From: EyaDammak Date: Mon, 6 Jan 2025 09:02:41 +0100 Subject: [PATCH 14/76] issue in naming test files --- tests/checksum/reset_all_benchmarks.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/checksum/reset_all_benchmarks.sh b/tests/checksum/reset_all_benchmarks.sh index 4cf5ed1caa..1a9f8178dd 100755 --- a/tests/checksum/reset_all_benchmarks.sh +++ b/tests/checksum/reset_all_benchmarks.sh @@ -439,6 +439,6 @@ then || echo "ctest command failed, maybe just because checksums are different. Keep going" cd $checksum_dir ./checksumAPI.py --reset-benchmark \ - --file_name ${build_dir}/bin/laser_ionization.1Rank \ - --test-name laser_ionization.1Rank + --file_name ${build_dir}/bin/laser_ionization.1Rank.sh \ + --test-name laser_ionization.1Rank.sh fi From 5a822ff5f5bf326babcc48bd126a19021d7c92b9 Mon Sep 17 00:00:00 2001 From: EyaDammak Date: Mon, 6 Jan 2025 13:34:27 +0100 Subject: [PATCH 15/76] fixing chacksum --- tests/checksum/reset_all_benchmarks.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/checksum/reset_all_benchmarks.sh b/tests/checksum/reset_all_benchmarks.sh index 1a9f8178dd..cd1c9a3d3e 100755 --- a/tests/checksum/reset_all_benchmarks.sh +++ b/tests/checksum/reset_all_benchmarks.sh @@ -431,14 +431,14 @@ then --test-name transverse_benchmark.1Rank.sh fi -# laser_ionization.1Rank.sh -if [[ $all_tests = true ]] || [[ $one_test_name = "laser_ionization.1Rank.sh" ]] +# laser_ionization.1Rank +if [[ $all_tests = true ]] || [[ $one_test_name = "laser_ionization.1Rank" ]] then cd $build_dir - ctest --output-on-failure -R laser_ionization.1Rank.sh \ + ctest --output-on-failure -R laser_ionization.1Rank \ || echo "ctest command failed, maybe just because checksums are different. Keep going" cd $checksum_dir ./checksumAPI.py --reset-benchmark \ - --file_name ${build_dir}/bin/laser_ionization.1Rank.sh \ - --test-name laser_ionization.1Rank.sh + --file_name ${build_dir}/bin/laser_ionization.1Rank \ + --test-name laser_ionization.1Rank fi From 34553d852cae9bb3ee830b3d80a9ec42114bec39 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:47:57 +0100 Subject: [PATCH 16/76] Update inputs_laser_ionization_linear --- examples/laser_ionization/inputs_laser_ionization_linear | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser_ionization/inputs_laser_ionization_linear b/examples/laser_ionization/inputs_laser_ionization_linear index 8e8cdaa29b..8be2fde56b 100644 --- a/examples/laser_ionization/inputs_laser_ionization_linear +++ b/examples/laser_ionization/inputs_laser_ionization_linear @@ -15,7 +15,7 @@ my_constants.w0_um = 1.e8 my_constants.tau_fs = 30/1.17741 my_constants.lambda0_nm = 800 -hipace.file_prefix = new +hipace.file_prefix = laser_ionization.1Rank hipace.do_tiling = 0 hipace.deposit_rho_individual = 1 @@ -58,4 +58,4 @@ hipace.depos_order_xy = 0 boundary.field = Dirichlet boundary.particle = Periodic -diagnostic.diag_type = xyz \ No newline at end of file +diagnostic.diag_type = xyz From 8dde446bfba9a7fcb110a8d4d9433537fa6ed1d7 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:56:22 +0100 Subject: [PATCH 17/76] Update laser_ionization.1Rank.sh --- tests/laser_ionization.1Rank.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/laser_ionization.1Rank.sh b/tests/laser_ionization.1Rank.sh index 6dc14dc808..e93c448bf0 100755 --- a/tests/laser_ionization.1Rank.sh +++ b/tests/laser_ionization.1Rank.sh @@ -25,11 +25,13 @@ TEST_NAME="${FILE_NAME%.*}" rm -rf $TEST_NAME # Run the simulation -mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_laser_ionization_linear +mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_laser_ionization_linear \ + hipace.file_prefix=$TEST_NAME # Compare the result with theory $HIPACE_EXAMPLE_DIR/analysis_laser_ionization.py + # Compare the results with checksum benchmark $HIPACE_TEST_DIR/checksum/checksumAPI.py \ --evaluate \ From d69142d41c52c5893fe2ae1c6efc7ea88c0cab01 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Tue, 7 Jan 2025 18:04:46 +0100 Subject: [PATCH 18/76] Update analysis_laser_ionization.py --- examples/laser_ionization/analysis_laser_ionization.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index a13470bd82..21efee4bb6 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -14,7 +14,6 @@ parser = argparse.ArgumentParser(description='Compare with WarpX the fraction of ionization for a specific value of a0 with a linear polarized laser') parser.add_argument('--output-dir', dest='output_dir', - default='new', help='Path to the directory containing output files') args = parser.parse_args() From b6e807d68c0451ecf89222a43a86603916b08e36 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Wed, 8 Jan 2025 14:37:09 +0100 Subject: [PATCH 19/76] Update analysis_laser_ionization.py --- examples/laser_ionization/analysis_laser_ionization.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 21efee4bb6..d3c0ab2677 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -14,6 +14,7 @@ parser = argparse.ArgumentParser(description='Compare with WarpX the fraction of ionization for a specific value of a0 with a linear polarized laser') parser.add_argument('--output-dir', dest='output_dir', + default='diags/hdf5', help='Path to the directory containing output files') args = parser.parse_args() From 3f5a558cc982bd5d9ef50a3201526dee9fdad876 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:40:02 +0100 Subject: [PATCH 20/76] Update laser_ionization.1Rank.sh Co-authored-by: Alexander Sinn <64009254+AlexanderSinn@users.noreply.github.com> --- tests/laser_ionization.1Rank.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/laser_ionization.1Rank.sh b/tests/laser_ionization.1Rank.sh index e93c448bf0..b94f6be3bb 100755 --- a/tests/laser_ionization.1Rank.sh +++ b/tests/laser_ionization.1Rank.sh @@ -29,7 +29,7 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_laser_ionization_line hipace.file_prefix=$TEST_NAME # Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_ionization.py +$HIPACE_EXAMPLE_DIR/analysis_laser_ionization.py --output-dir=$TEST_NAME # Compare the results with checksum benchmark From 3ade106bc1b5f961a378857e4a67357ff1a35504 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:48:40 +0100 Subject: [PATCH 21/76] Update laser_ionization.1Rank.json --- .../laser_ionization.1Rank.json | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/tests/checksum/benchmarks_json/laser_ionization.1Rank.json b/tests/checksum/benchmarks_json/laser_ionization.1Rank.json index 533c7d9a6e..a729567e1d 100644 --- a/tests/checksum/benchmarks_json/laser_ionization.1Rank.json +++ b/tests/checksum/benchmarks_json/laser_ionization.1Rank.json @@ -1,32 +1,24 @@ { "lev=0": { - "Bx": 2682248.7057786, - "By": 2693948.2733652, - "Bz": 461542.2571099, - "ExmBy": 1615808685829100.0, - "EypBx": 1618198283855800.0, - "Ez": 661283579146520.0, - "Psi": 10769981642.67, - "Sx": 7.6153143423645e+17, - "Sy": 7.6749662052452e+17, - "chi": 2095164846204800.0, - "jx": 5.1803326176917e+17, - "jx_beam": 231581100098160.0, - "jy": 5.1661888254051e+17, - "jy_beam": 230138001520970.0, - "jz_beam": 1.6907142961472e+17, - "rhomjz": 8996307095.7456 - }, - "beam": { - "charge": 1.127932350336e-16, - "id": 248160, - "mass": 6.413006125856e-28, - "x": 0.00024861156942758, - "y": 0.00024733653871292, - "z": 0.014359549367752, - "ux": 3002.9712584681, - "uy": 3008.1141100408, - "uz": 1386735.4182493, - "w": 825000000.0 + "BX": 2.4704851632294, + "By": 2.6799368761902, + "Bz": 1.5030719459031, + "ExmBy": 0.0, + "ЕурВ×": 0.0, + "Ez": 2174420265.8172, + "Psi": 0.0, + "SX": 160890445526.53, + "Sy": 152768732376.4, + "aabs": 0.19201022247138, + "chi": 108089752071000.0, + "jx": 331058648252.63, + "jX_beam": 0.0, + "jy": 330458351440.27, + "jy_beam": 0.0, + "iz_beam": 0.0, + "laserEnvelope": 30.678508193173, + "rho_elec": 488784170.47985, + "tho_ion": 488788044.26813, + "rhomjz": 0.0 } } From dc6f54ed48fcc6f91e8cf4874208324ca1455c46 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:01:23 +0100 Subject: [PATCH 22/76] Update laser_ionization.1Rank.json --- .../laser_ionization.1Rank.json | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/checksum/benchmarks_json/laser_ionization.1Rank.json b/tests/checksum/benchmarks_json/laser_ionization.1Rank.json index a729567e1d..e98d25cbe7 100644 --- a/tests/checksum/benchmarks_json/laser_ionization.1Rank.json +++ b/tests/checksum/benchmarks_json/laser_ionization.1Rank.json @@ -1,24 +1,24 @@ { "lev=0": { - "BX": 2.4704851632294, - "By": 2.6799368761902, - "Bz": 1.5030719459031, - "ExmBy": 0.0, - "ЕурВ×": 0.0, - "Ez": 2174420265.8172, - "Psi": 0.0, - "SX": 160890445526.53, - "Sy": 152768732376.4, - "aabs": 0.19201022247138, - "chi": 108089752071000.0, - "jx": 331058648252.63, - "jX_beam": 0.0, - "jy": 330458351440.27, - "jy_beam": 0.0, - "iz_beam": 0.0, - "laserEnvelope": 30.678508193173, - "rho_elec": 488784170.47985, - "tho_ion": 488788044.26813, - "rhomjz": 0.0 + "Bx": 2.4704851632294, + "By": 2.6799368761902, + "Bz": 1.5030719459031, + "ExmBy": 0.0, + "ЕурВx": 0.0, + "Ez": 2174420265.8172, + "Psi": 0.0, + "Sx": 160890445526.53, + "Sy": 152768732376.4, + "aabs": 0.19201022247138, + "chi": 108089752071000.0, + "jx": 331058648252.63, + "jx_beam": 0.0, + "jy": 330458351440.27, + "jy_beam": 0.0, + "jz_beam": 0.0, + "laserEnvelope": 30.678508193173, + "rho_elec": 488784170.47985, + "rho_ion": 488788044.26813, + "rhomjz": 0.0 } } From 52ebcb80d8ce3b59c51443c24ea68bd8a9b29bf8 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:20:20 +0100 Subject: [PATCH 23/76] Update laser_ionization.1Rank.json Co-authored-by: Alexander Sinn <64009254+AlexanderSinn@users.noreply.github.com> --- tests/checksum/benchmarks_json/laser_ionization.1Rank.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/checksum/benchmarks_json/laser_ionization.1Rank.json b/tests/checksum/benchmarks_json/laser_ionization.1Rank.json index e98d25cbe7..cd893bf35f 100644 --- a/tests/checksum/benchmarks_json/laser_ionization.1Rank.json +++ b/tests/checksum/benchmarks_json/laser_ionization.1Rank.json @@ -4,7 +4,7 @@ "By": 2.6799368761902, "Bz": 1.5030719459031, "ExmBy": 0.0, - "ЕурВx": 0.0, + "EypBx": 0.0, "Ez": 2174420265.8172, "Psi": 0.0, "Sx": 160890445526.53, From b3fa4a24dc92c7817cd8c3a061c701603d477043 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Wed, 8 Jan 2025 17:14:27 +0100 Subject: [PATCH 24/76] Update laser_ionization.1Rank.json --- .../laser_ionization.1Rank.json | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/checksum/benchmarks_json/laser_ionization.1Rank.json b/tests/checksum/benchmarks_json/laser_ionization.1Rank.json index cd893bf35f..ac3026c928 100644 --- a/tests/checksum/benchmarks_json/laser_ionization.1Rank.json +++ b/tests/checksum/benchmarks_json/laser_ionization.1Rank.json @@ -1,24 +1,24 @@ { "lev=0": { - "Bx": 2.4704851632294, - "By": 2.6799368761902, - "Bz": 1.5030719459031, + "Bx": 2.6828383569303, + "By": 2.7679232216354, + "Bz": 1.8909285687383, "ExmBy": 0.0, "EypBx": 0.0, - "Ez": 2174420265.8172, + "Ez": 2448530507.7321, "Psi": 0.0, - "Sx": 160890445526.53, - "Sy": 152768732376.4, + "Sx": 174799612003.59, + "Sy": 165714923911.0, "aabs": 0.19201022247138, - "chi": 108089752071000.0, - "jx": 331058648252.63, + "chi": 105640532321080.0, + "jx": 340889782577.97, "jx_beam": 0.0, - "jy": 330458351440.27, + "jy": 344102223375.08, "jy_beam": 0.0, "jz_beam": 0.0, "laserEnvelope": 30.678508193173, - "rho_elec": 488784170.47985, - "rho_ion": 488788044.26813, + "rho_elec": 477708750.68105, + "rho_ion": 477712998.48921, "rhomjz": 0.0 } } From 50f984075381c79a922ff2f04b8e2b1c4fde5921 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Wed, 8 Jan 2025 17:24:58 +0100 Subject: [PATCH 25/76] Update CMakeLists.txt --- CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 227366c8d4..edb479a9b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,12 +342,6 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) - add_test(NAME laser_ionization.1Rank - COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_ionization.1Rank.sh - $ ${HiPACE_SOURCE_DIR} - WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - ) - if (NOT HiPACE_COMPUTE STREQUAL CUDA) # These tests only run on CPU @@ -436,6 +430,12 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) + add_test(NAME laser_ionization.1Rank + COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_ionization.1Rank.sh + $ ${HiPACE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + ) + else() add_test(NAME transverse_benchmark.1Rank From 88b9b32c75dab5aa284d7fd5a8a64bdb384eb2eb Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:05:18 +0100 Subject: [PATCH 26/76] Update analysis_laser_ionization.py --- .../analysis_laser_ionization.py | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index d3c0ab2677..637074e794 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -3,7 +3,7 @@ # # This file is part of HiPACE++. # -# Authors: +# Authors: EyaDammak import argparse import numpy as np @@ -11,17 +11,24 @@ from openpmd_viewer import OpenPMDTimeSeries import statistics -parser = argparse.ArgumentParser(description='Compare with WarpX the fraction of ionization for a specific value of a0 with a linear polarized laser') -parser.add_argument('--output-dir', - dest='output_dir', - default='diags/hdf5', +parser = argparse.ArgumentParser( + description='Script to analyze the equality of two simulations') +parser.add_argument('--first', + dest='first', + required=True, help='Path to the directory containing output files') +parser.add_argument('--second', + dest='second', + required=True, + help='Path to the directory containing output files')) args = parser.parse_args() -ts = OpenPMDTimeSeries(args.output_dir) +ts_linear = OpenPMDTimeSeries(args.first) +ts_circular = OpenPMDTimeSeries(args.second) lambda0 = 800.e-9 -a0 = 0.00885126 +a0_linear = 0.00885126 +a0_circular = 0.00787934 nc = 1.75e27 n0 = nc / 10000 @@ -30,18 +37,29 @@ qe = 1.602176634e-19 C = me * c * c * 2 * math.pi / (lambda0 * qe) -E0 = C * a0 +E0_linear = C * a0_linear +E0_circular = C * a0_circular iteration = 0 -rho_elec, _ = ts.get_field(field='rho_elec', coord='z', iteration=iteration, plot=False) -rho_elec_mean = np.mean(rho_elec, axis=(1, 2)) -rho_average = statistics.mean(rho_elec_mean[0:10]) -fraction = rho_average / (-qe) / (n0) -fraction_warpx = 0.41014984 #result from WarpX simulation +rho_elec_linear, _ = ts_linear.get_field(field='rho_elec', coord='z', iteration=iteration, plot=False) +rho_elec_mean_linear = np.mean(rho_elec_linear, axis=(1, 2)) +rho_average_linear = statistics.mean(rho_elec_mean_linear[0:10]) +fraction_linear = rho_average_linear / (-qe) / (n0) + +rho_elec_circular, _ = ts_circular.get_field(field='rho_elec', coord='z', iteration=iteration, plot=False) +rho_elec_mean_circular = np.mean(rho_elec_circular, axis=(1, 2)) +rho_average_circular = statistics.mean(rho_elec_mean_circular[0:10]) #average over a thickness in the ionized region +fraction_circular = rho_average_circular / (-qe) / (n0) + +fraction_warpx_linear = 0.41014984 #result from WarpX simulation +fraction_warpx_circular = 0.502250841 #result from WarpX simulation + +relative_diff_linear = np.abs( ( fraction_linear - fraction_warpx_linear ) / fraction_warpx_linear ) +relative_diff_circular = np.abs( ( fraction_circular - fraction_warpx_circular ) / fraction_warpx_circular ) -relative_diff = np.abs( ( fraction - fraction_warpx ) / fraction_warpx ) tolerance = 0.15 -print("percentage error for the fraction of ionization = "+ str(relative_diff *100) + '%') +print("percentage error for the fraction of ionization in linear polarization = "+ str(relative_diff_linear *100) + '%') +print("percentage error for the fraction of ionization in circular polarization = "+ str(relative_diff_linear *100) + '%') -assert (relative_diff < tolerance), 'Test laser_ionization did not pass' +assert ( (relative_diff_linear < tolerance) && (relative_diff_circular < tolerance) ), 'Test laser_ionization did not pass' From 7d25b673d2ec817a2b423b4a18bd846b33d91824 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:15:10 +0100 Subject: [PATCH 27/76] Update laser_ionization.1Rank.sh --- tests/laser_ionization.1Rank.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/laser_ionization.1Rank.sh b/tests/laser_ionization.1Rank.sh index b94f6be3bb..07c4edd399 100755 --- a/tests/laser_ionization.1Rank.sh +++ b/tests/laser_ionization.1Rank.sh @@ -25,16 +25,19 @@ TEST_NAME="${FILE_NAME%.*}" rm -rf $TEST_NAME # Run the simulation -mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_laser_ionization_linear \ - hipace.file_prefix=$TEST_NAME +mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_laser_ionization \ + hipace.file_prefix=$TEST_NAME/linear + +mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_laser_ionization \ + lasers.polarization = circular \ + hipace.file_prefix=$TEST_NAME/circular # Compare the result with theory -$HIPACE_EXAMPLE_DIR/analysis_laser_ionization.py --output-dir=$TEST_NAME +$HIPACE_EXAMPLE_DIR/analysis_laser_ionization.py --first=$TEST_NAME/linear --second=$TEST_NAME/circular # Compare the results with checksum benchmark $HIPACE_TEST_DIR/checksum/checksumAPI.py \ --evaluate \ - --file_name $TEST_NAME \ + --file_name $TEST_NAME/linear \ --test-name $TEST_NAME - From f20d8bfc7f2083841a5c8ed91e3cb2a7911e36a4 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:16:16 +0100 Subject: [PATCH 28/76] Update and rename inputs_laser_ionization_linear to inputs_laser_ionization --- .../{inputs_laser_ionization_linear => inputs_laser_ionization} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/laser_ionization/{inputs_laser_ionization_linear => inputs_laser_ionization} (100%) diff --git a/examples/laser_ionization/inputs_laser_ionization_linear b/examples/laser_ionization/inputs_laser_ionization similarity index 100% rename from examples/laser_ionization/inputs_laser_ionization_linear rename to examples/laser_ionization/inputs_laser_ionization From 75595941b7f5b51692716f3c6c8ee0b792d15c21 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:21:38 +0100 Subject: [PATCH 29/76] Update analysis_laser_ionization.py --- examples/laser_ionization/analysis_laser_ionization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 637074e794..acc0869bf3 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -20,7 +20,7 @@ parser.add_argument('--second', dest='second', required=True, - help='Path to the directory containing output files')) + help='Path to the directory containing output files') args = parser.parse_args() ts_linear = OpenPMDTimeSeries(args.first) From e764a8764d784490992ff98ddeabe2b576612460 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 9 Jan 2025 13:06:45 +0100 Subject: [PATCH 30/76] Update analysis_laser_ionization.py --- examples/laser_ionization/analysis_laser_ionization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index acc0869bf3..18e2ff4e9a 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -62,4 +62,4 @@ print("percentage error for the fraction of ionization in linear polarization = "+ str(relative_diff_linear *100) + '%') print("percentage error for the fraction of ionization in circular polarization = "+ str(relative_diff_linear *100) + '%') -assert ( (relative_diff_linear < tolerance) && (relative_diff_circular < tolerance) ), 'Test laser_ionization did not pass' +assert ( (relative_diff_linear < tolerance) and (relative_diff_circular < tolerance) ), 'Test laser_ionization did not pass' From 9c3c57155f8101fcbd3dc33a06c7679fbe19bdc3 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 9 Jan 2025 13:22:42 +0100 Subject: [PATCH 31/76] Update analysis_laser_ionization.py --- examples/laser_ionization/analysis_laser_ionization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 18e2ff4e9a..4fbde4b3cb 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -60,6 +60,6 @@ tolerance = 0.15 print("percentage error for the fraction of ionization in linear polarization = "+ str(relative_diff_linear *100) + '%') -print("percentage error for the fraction of ionization in circular polarization = "+ str(relative_diff_linear *100) + '%') +print("percentage error for the fraction of ionization in circular polarization = "+ str(relative_diff_circular *100) + '%') assert ( (relative_diff_linear < tolerance) and (relative_diff_circular < tolerance) ), 'Test laser_ionization did not pass' From 90c85ed6a33df7b2e73dc85290185c51442f3957 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:26:38 +0100 Subject: [PATCH 32/76] Update analysis_laser_ionization.py --- examples/laser_ionization/analysis_laser_ionization.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 4fbde4b3cb..79ab20979a 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -26,19 +26,13 @@ ts_linear = OpenPMDTimeSeries(args.first) ts_circular = OpenPMDTimeSeries(args.second) -lambda0 = 800.e-9 a0_linear = 0.00885126 a0_circular = 0.00787934 + nc = 1.75e27 n0 = nc / 10000 -me = 9.1093837015e-31 -c = 299792458 qe = 1.602176634e-19 -C = me * c * c * 2 * math.pi / (lambda0 * qe) - -E0_linear = C * a0_linear -E0_circular = C * a0_circular iteration = 0 From d1730d43c665dd957a638b0a1b78073fe64401c9 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:29:33 +0100 Subject: [PATCH 33/76] Update laser_ionization.1Rank.sh --- tests/laser_ionization.1Rank.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/laser_ionization.1Rank.sh b/tests/laser_ionization.1Rank.sh index 07c4edd399..5a22401027 100755 --- a/tests/laser_ionization.1Rank.sh +++ b/tests/laser_ionization.1Rank.sh @@ -26,9 +26,11 @@ rm -rf $TEST_NAME # Run the simulation mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_laser_ionization \ + my_constants.a0 = 0.00885126 \ hipace.file_prefix=$TEST_NAME/linear mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_laser_ionization \ + my_constants.a0 = 0.00787934 \ lasers.polarization = circular \ hipace.file_prefix=$TEST_NAME/circular From b4b494cfe7304bfa43af9790f714ccd73808b102 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:36:11 +0100 Subject: [PATCH 34/76] Update analysis_laser_ionization.py --- examples/laser_ionization/analysis_laser_ionization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 79ab20979a..e4fef2fb5b 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -52,7 +52,7 @@ relative_diff_linear = np.abs( ( fraction_linear - fraction_warpx_linear ) / fraction_warpx_linear ) relative_diff_circular = np.abs( ( fraction_circular - fraction_warpx_circular ) / fraction_warpx_circular ) -tolerance = 0.15 +tolerance = 0.25 print("percentage error for the fraction of ionization in linear polarization = "+ str(relative_diff_linear *100) + '%') print("percentage error for the fraction of ionization in circular polarization = "+ str(relative_diff_circular *100) + '%') From 925002fe646a1f0d968153560c1abc20433dfa5d Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:57:40 +0100 Subject: [PATCH 35/76] Update reset_all_benchmarks.sh --- tests/checksum/reset_all_benchmarks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/checksum/reset_all_benchmarks.sh b/tests/checksum/reset_all_benchmarks.sh index cd1c9a3d3e..8b71b650ce 100755 --- a/tests/checksum/reset_all_benchmarks.sh +++ b/tests/checksum/reset_all_benchmarks.sh @@ -439,6 +439,6 @@ then || echo "ctest command failed, maybe just because checksums are different. Keep going" cd $checksum_dir ./checksumAPI.py --reset-benchmark \ - --file_name ${build_dir}/bin/laser_ionization.1Rank \ + --file_name ${build_dir}/bin/laser_ionization.1Rank/linear \ --test-name laser_ionization.1Rank fi From 9cb30f321d6a661c6a41c9b517e6e37eb99746c7 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:32:43 +0100 Subject: [PATCH 36/76] Update CMakeLists.txt Adding the option of choosing if it runs on CPU or GPU --- CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index edb479a9b3..33d4932452 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,6 +342,12 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) + add_test(NAME laser_ionization.1Rank + COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_ionization.1Rank.sh + $ ${HiPACE_SOURCE_DIR} ${HiPACE_COMPUTE} + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + ) + if (NOT HiPACE_COMPUTE STREQUAL CUDA) # These tests only run on CPU @@ -430,12 +436,6 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) - add_test(NAME laser_ionization.1Rank - COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_ionization.1Rank.sh - $ ${HiPACE_SOURCE_DIR} - WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - ) - else() add_test(NAME transverse_benchmark.1Rank From 1054b336bd66db92aacb8e63671d64b05d0717d9 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:34:57 +0100 Subject: [PATCH 37/76] Update laser_ionization.1Rank.sh --- tests/laser_ionization.1Rank.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/laser_ionization.1Rank.sh b/tests/laser_ionization.1Rank.sh index 5a22401027..8062dd9157 100755 --- a/tests/laser_ionization.1Rank.sh +++ b/tests/laser_ionization.1Rank.sh @@ -15,6 +15,7 @@ set -eu -o pipefail # Read input parameters HIPACE_EXECUTABLE=$1 HIPACE_SOURCE_DIR=$2 +HIPACE_COMPUTE=$3 HIPACE_EXAMPLE_DIR=${HIPACE_SOURCE_DIR}/examples/laser_ionization HIPACE_TEST_DIR=${HIPACE_SOURCE_DIR}/tests @@ -38,8 +39,10 @@ mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_laser_ionization \ $HIPACE_EXAMPLE_DIR/analysis_laser_ionization.py --first=$TEST_NAME/linear --second=$TEST_NAME/circular -# Compare the results with checksum benchmark -$HIPACE_TEST_DIR/checksum/checksumAPI.py \ - --evaluate \ - --file_name $TEST_NAME/linear \ - --test-name $TEST_NAME +# Compare the results with checksum benchmark if it runs on CPU only +if [[ "$HIPACE_COMPUTE" != "CUDA" ]]; then + $HIPACE_TEST_DIR/checksum/checksumAPI.py \ + --evaluate \ + --file_name $TEST_NAME/linear \ + --test-name $TEST_NAME + fi From d6656fee9ea93313d7f6ff45857f447466c299b7 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Mon, 13 Jan 2025 16:44:19 +0100 Subject: [PATCH 38/76] Update PlasmaParticleContainer.cpp little clean up --- .../plasma/PlasmaParticleContainer.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 912cb71b3d..7e9249bd79 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -501,9 +501,9 @@ LaserIonization (const int islice, (PhysConstSI::ep0 * PhysConstSI::m_e) ); const amrex::Real E0 = Hipace::m_normalized_units ? wp * PhysConstSI::m_e * PhysConstSI::c / PhysConstSI::q_e : 1; - const amrex::Real lambda0 = laser.GetLambda0(); + const amrex::Real lambda0 = laser.GetLambda0(); const amrex::Real omega0 = 2.0 * MathConst::pi * phys_const.c / lambda0; - const bool linear_polarization = laser.LinearPolarization(); + const bool linear_polarization = laser.LinearPolarization(); int * const ion_lev = soa_ion.GetIntData(PlasmaIdx::ion_lev).data(); const amrex::Real * const x_prev = soa_ion.GetRealData(PlasmaIdx::x_prev).data(); @@ -559,7 +559,7 @@ LaserIonization (const int islice, amrex::Real Ep = std::sqrt( amrex::abs(Et*Et) + amrex::abs(El*El) ); Ep *= phys_const.m_e * phys_const.c / phys_const.q_e; - Ep *= E0; + Ep *= E0; // Compute probability of ionization p const amrex::Real gammap = (1.0_rt + uxp[ip] * uxp[ip] * clightsq @@ -571,12 +571,12 @@ LaserIonization (const int islice, std::pow(Ep, adk_power[ion_lev_loc]) * std::exp( adk_exp_prefactor[ion_lev_loc]/Ep ); - amrex::Real w_dtau_ac; - if (linear_polarization) { - w_dtau_ac = w_dtau_dc * std::sqrt(Ep * laser_adk_prefactor[ion_lev_loc]); - } else { - w_dtau_ac = w_dtau_dc; - } + amrex::Real w_dtau_ac; + if (linear_polarization) { + w_dtau_ac = w_dtau_dc * std::sqrt(Ep * laser_adk_prefactor[ion_lev_loc]); + } else { + w_dtau_ac = w_dtau_dc; + } amrex::Real p = 1._rt - std::exp( - w_dtau_ac ); From 8400bfec8df5653970d2b6c34b184bacbe8cc5fe Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Wed, 15 Jan 2025 18:36:57 +0100 Subject: [PATCH 39/76] Update analysis_laser_ionization.py --- examples/laser_ionization/analysis_laser_ionization.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index e4fef2fb5b..5042fafc7e 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -53,7 +53,9 @@ relative_diff_circular = np.abs( ( fraction_circular - fraction_warpx_circular ) / fraction_warpx_circular ) tolerance = 0.25 -print("percentage error for the fraction of ionization in linear polarization = "+ str(relative_diff_linear *100) + '%') -print("percentage error for the fraction of ionization in circular polarization = "+ str(relative_diff_circular *100) + '%') +print(f"fraction_warpx_linear = {fraction_warpx_linear}") +print(f"fraction_hipace_linear = {fraction_linear}") +print(f"fraction_warpx_circular = {fraction_warpx_circular}") +print(f"fraction_hipace_circular = {fraction_circular}") assert ( (relative_diff_linear < tolerance) and (relative_diff_circular < tolerance) ), 'Test laser_ionization did not pass' From 9a4096f15d0e607084b3cd6cd06ac5b0356cad40 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 15:52:33 +0100 Subject: [PATCH 40/76] Update CMakeLists.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33d4932452..aa02e26781 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -343,9 +343,9 @@ if(BUILD_TESTING) ) add_test(NAME laser_ionization.1Rank - COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_ionization.1Rank.sh - $ ${HiPACE_SOURCE_DIR} ${HiPACE_COMPUTE} - WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_ionization.1Rank.sh + $ ${HiPACE_SOURCE_DIR} ${HiPACE_COMPUTE} + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) if (NOT HiPACE_COMPUTE STREQUAL CUDA) From 6835952fa8a94294cab12d7deb2a830971843008 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 15:53:23 +0100 Subject: [PATCH 41/76] Update examples/laser_ionization/inputs_laser_ionization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser_ionization/inputs_laser_ionization | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/laser_ionization/inputs_laser_ionization b/examples/laser_ionization/inputs_laser_ionization index 8be2fde56b..624215945d 100644 --- a/examples/laser_ionization/inputs_laser_ionization +++ b/examples/laser_ionization/inputs_laser_ionization @@ -2,7 +2,8 @@ max_step = 0 hipace.dt = 0 hipace.verbose=3 -amr.n_cell =32 32 50 +amr.n_cell = 32 32 50 + my_constants.kp_inv = 10.e-6 From cde03a73c0dc8c9ecccec450c8ce216cc8904b7c Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 15:54:45 +0100 Subject: [PATCH 42/76] Update src/particles/plasma/PlasmaParticleContainer.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/particles/plasma/PlasmaParticleContainer.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 7e9249bd79..ca398fadeb 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -549,17 +549,16 @@ LaserIonization (const int islice, Complex A_dx = 0; Complex A_dzeta = 0; - // TODO convert units of A - // this is likely incorrect doLaserGatherShapeN(xp, yp, A, A_dx, A_dzeta, laser_arr, dx_inv, dy_inv, dzeta_inv, x_pos_offset, y_pos_offset); + // Convert from vector potential to electric field. Units are fixed later. const Complex Et = I * A * omega0 + A_dzeta * phys_const.c; //transverse component const Complex El = - A_dx * phys_const.c; //longitudinal component + // Get amplitude of the electric field envelope and normalize to correct SI unit. amrex::Real Ep = std::sqrt( amrex::abs(Et*Et) + amrex::abs(El*El) ); - Ep *= phys_const.m_e * phys_const.c / phys_const.q_e; - Ep *= E0; + Ep *= phys_const.m_e * phys_const.c / phys_const.q_e * E0; // Compute probability of ionization p const amrex::Real gammap = (1.0_rt + uxp[ip] * uxp[ip] * clightsq From a8edd47a9080bfd2e31780ef7e2492945c49057e Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 15:55:26 +0100 Subject: [PATCH 43/76] Update src/laser/MultiLaser.H MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/laser/MultiLaser.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.H b/src/laser/MultiLaser.H index 781ca128da..d0c9352f29 100644 --- a/src/laser/MultiLaser.H +++ b/src/laser/MultiLaser.H @@ -171,7 +171,7 @@ public: /** Get the geometry of the Laser Box */ const amrex::Geometry& GetLaserGeom () const { return m_laser_geom_3D; } - /** If the polarization is linear or circular */ + /** Whether the polarization is linear. If not, circular polarization is assumed */ bool LinearPolarization () const { return m_linear_polarization; } /** If the laser geometry includes this slice From 63815337ae975cae76ab0a91557859a3a6300f6f Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:35:31 +0100 Subject: [PATCH 44/76] Update src/particles/plasma/PlasmaParticleContainer.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/particles/plasma/PlasmaParticleContainer.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index ca398fadeb..141e4f24e8 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -570,12 +570,8 @@ LaserIonization (const int islice, std::pow(Ep, adk_power[ion_lev_loc]) * std::exp( adk_exp_prefactor[ion_lev_loc]/Ep ); - amrex::Real w_dtau_ac; - if (linear_polarization) { - w_dtau_ac = w_dtau_dc * std::sqrt(Ep * laser_adk_prefactor[ion_lev_loc]); - } else { - w_dtau_ac = w_dtau_dc; - } + amrex::Real const w_dtau_ac = w_dtau_dc * + (linear_polarization ? std::sqrt(Ep * laser_adk_prefactor[ion_lev_loc]) : 1._rt); amrex::Real p = 1._rt - std::exp( - w_dtau_ac ); From 353beea589dec2a3c25b498be4f9fcf4b88f0793 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:35:41 +0100 Subject: [PATCH 45/76] Update src/particles/plasma/PlasmaParticleContainer.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/particles/plasma/PlasmaParticleContainer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 141e4f24e8..d68b0da7dc 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -627,7 +627,6 @@ LaserIonization (const int islice, arrdata_elec[PlasmaIdx::w ][pidx] = arrdata_ion[PlasmaIdx::w ][ip]; arrdata_elec[PlasmaIdx::ux ][pidx] = 0._rt; arrdata_elec[PlasmaIdx::uy ][pidx] = 0._rt; - // later we could consider adding a finite temperature to the ionized electrons arrdata_elec[PlasmaIdx::psi ][pidx] = 1._rt; arrdata_elec[PlasmaIdx::x_prev ][pidx] = arrdata_ion[PlasmaIdx::x_prev][ip]; arrdata_elec[PlasmaIdx::y_prev ][pidx] = arrdata_ion[PlasmaIdx::y_prev][ip]; From 3f45ca92b5a9f6eea894a27e4d4d187d4e0e3506 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:35:52 +0100 Subject: [PATCH 46/76] Update src/particles/plasma/PlasmaParticleContainerInit.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/particles/plasma/PlasmaParticleContainerInit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/particles/plasma/PlasmaParticleContainerInit.cpp b/src/particles/plasma/PlasmaParticleContainerInit.cpp index b2dbc82523..c876e2fbee 100644 --- a/src/particles/plasma/PlasmaParticleContainerInit.cpp +++ b/src/particles/plasma/PlasmaParticleContainerInit.cpp @@ -447,7 +447,7 @@ InitIonizationModule (const amrex::Geometry& geom, const amrex::Real background_ h_adk_prefactor[i] = dt * wa * C2 * ( Uion/(2*UH) ) * std::pow(2*std::pow((Uion/UH),3./2)*Ea,2*n_eff - 1); h_adk_exp_prefactor[i] = -2./3 * std::pow( Uion/UH,3./2) * Ea; - h_laser_adk_prefactor[i] = (3 / MathConst::pi) * std::pow(Uion/UH, -3./2.) / Ea; + h_laser_adk_prefactor[i] = (3. / MathConst::pi) * std::pow(Uion/UH, -3./2.) / Ea; } amrex::Gpu::copy(amrex::Gpu::hostToDevice, From cedd4621cc894aecadd16adac2eeb2cd2ba7a561 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:44:03 +0100 Subject: [PATCH 47/76] Update PlasmaParticleContainerInit.cpp --- src/particles/plasma/PlasmaParticleContainerInit.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainerInit.cpp b/src/particles/plasma/PlasmaParticleContainerInit.cpp index c876e2fbee..eac29b18a1 100644 --- a/src/particles/plasma/PlasmaParticleContainerInit.cpp +++ b/src/particles/plasma/PlasmaParticleContainerInit.cpp @@ -442,12 +442,12 @@ InitIonizationModule (const amrex::Geometry& geom, const amrex::Real background_ const amrex::Real n_eff = (i+1) * std::sqrt(UH/h_ionization_energies[i]); const amrex::Real C2 = std::pow(2,2*n_eff)/(n_eff*std::tgamma(n_eff+l_eff+1) * std::tgamma(n_eff-l_eff)); - h_adk_power[i] = -(2*n_eff - 1); + h_adk_power[i] = -(2 * n_eff - 1.); const amrex::Real Uion = h_ionization_energies[i]; - h_adk_prefactor[i] = dt * wa * C2 * ( Uion/(2*UH) ) - * std::pow(2*std::pow((Uion/UH),3./2)*Ea,2*n_eff - 1); - h_adk_exp_prefactor[i] = -2./3 * std::pow( Uion/UH,3./2) * Ea; - h_laser_adk_prefactor[i] = (3. / MathConst::pi) * std::pow(Uion/UH, -3./2.) / Ea; + h_adk_prefactor[i] = dt * wa * C2 * ( Uion / (2. * UH) ) + * std::pow(2*std::pow((Uion/UH),3./2.)*Ea,2*n_eff - 1); + h_adk_exp_prefactor[i] = -2./3. * std::pow( Uion/UH,3./2) * Ea; + h_laser_adk_prefactor[i] = (3./MathConst::pi) * std::pow(Uion/UH, -3./2.) / Ea; } amrex::Gpu::copy(amrex::Gpu::hostToDevice, From c66bf7583f16bf90ca504f476cad378734b23124 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:45:11 +0100 Subject: [PATCH 48/76] Update PlasmaParticleContainerInit.cpp --- src/particles/plasma/PlasmaParticleContainerInit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainerInit.cpp b/src/particles/plasma/PlasmaParticleContainerInit.cpp index eac29b18a1..fb459d656f 100644 --- a/src/particles/plasma/PlasmaParticleContainerInit.cpp +++ b/src/particles/plasma/PlasmaParticleContainerInit.cpp @@ -444,9 +444,9 @@ InitIonizationModule (const amrex::Geometry& geom, const amrex::Real background_ * std::tgamma(n_eff-l_eff)); h_adk_power[i] = -(2 * n_eff - 1.); const amrex::Real Uion = h_ionization_energies[i]; - h_adk_prefactor[i] = dt * wa * C2 * ( Uion / (2. * UH) ) + h_adk_prefactor[i] = dt * wa * C2 * ( Uion / (2.*UH) ) * std::pow(2*std::pow((Uion/UH),3./2.)*Ea,2*n_eff - 1); - h_adk_exp_prefactor[i] = -2./3. * std::pow( Uion/UH,3./2) * Ea; + h_adk_exp_prefactor[i] = -2./3. * std::pow( Uion/UH,3./2.) * Ea; h_laser_adk_prefactor[i] = (3./MathConst::pi) * std::pow(Uion/UH, -3./2.) / Ea; } From c7a666bd415936ce6c5d0e9802697357c707b2fb Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:55:19 +0100 Subject: [PATCH 49/76] Update src/particles/plasma/PlasmaParticleContainer.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/particles/plasma/PlasmaParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index d68b0da7dc..390bce0db0 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -483,7 +483,7 @@ LaserIonization (const int islice, // Offset for converting positions to indexes amrex::Real const x_pos_offset = GetPosOffset(0, laser_geom, laser_geom.Domain()); - const amrex::Real y_pos_offset = GetPosOffset(1, laser_geom, laser_geom.Domain()); + amrex::Real const y_pos_offset = GetPosOffset(1, laser_geom, laser_geom.Domain()); auto& plevel_ion = GetParticles(0); auto index = std::make_pair(mfi_ion.index(), mfi_ion.LocalTileIndex()); From d0d0fa4d4d3b03cd14be0eaf23f385bae32a2a49 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 17:36:43 +0100 Subject: [PATCH 50/76] Update PlasmaParticleContainer.cpp --- .../plasma/PlasmaParticleContainer.cpp | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 390bce0db0..434b6c60e9 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -335,6 +335,9 @@ IonizationModule (const int lev, long num_ions = ptile_ion.numParticles(); +// This kernel extends AMReX's parallel kernels to support multiple deposition orders +// (0, 1, 2, 3) at compile time, as it relies on `doLaserGatherShapeN` for computations +// specific to the selected deposition order. amrex::AnyCTO( amrex::TypeList< amrex::CompileTimeOptions<0, 1, 2, 3> @@ -342,7 +345,9 @@ IonizationModule (const int lev, Hipace::m_depos_order_xy }, [&] (auto cto_func) { + // This choice of AMReX's parallel kernel enables the use of `amrex::Random` within the loop. amrex::ParallelForRNG(num_ions, cto_func); + }, [=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine, auto depos_order_xy) { @@ -383,7 +388,7 @@ IonizationModule (const int lev, { ion_lev[ip] += 1; p_ion_mask[ip] = 1; - amrex::Gpu::Atomic::Add( p_num_new_electrons, 1u ); + amrex::Gpu::Atomic::Add( p_num_new_electrons, 1u ); // Ensures thread-safe access when incrementing `p_ip_elec` } }); amrex::Gpu::streamSynchronize(); @@ -416,7 +421,7 @@ IonizationModule (const int lev, [=] AMREX_GPU_DEVICE (long ip) { if(p_ion_mask[ip] != 0) { - const long pid = amrex::Gpu::Atomic::Add( p_ip_elec, 1u ); + const long pid = amrex::Gpu::Atomic::Add( p_ip_elec, 1u ); // Ensures thread-safe access when incrementing `p_ip_elec` const long pidx = pid + old_size; // Copy ion data to new electron @@ -525,7 +530,10 @@ LaserIonization (const int islice, amrex::Real* AMREX_RESTRICT laser_adk_prefactor = m_laser_adk_prefactor.data(); long num_ions = ptile_ion.numParticles(); - + +// This kernel extends AMReX's parallel kernels to support multiple deposition orders +// (0, 1, 2, 3) at compile time, as it relies on `doLaserGatherShapeN` for computations +// specific to the selected deposition order. amrex::AnyCTO( amrex::TypeList< amrex::CompileTimeOptions<0, 1, 2, 3> @@ -533,7 +541,9 @@ LaserIonization (const int islice, Hipace::m_depos_order_xy }, [&] (auto cto_func) { + // This choice of AMReX's parallel kernel enables the use of `amrex::Random` within the loop. amrex::ParallelForRNG(num_ions, cto_func); + }, [=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine, auto depos_order_xy) { @@ -580,7 +590,7 @@ LaserIonization (const int islice, { ion_lev[ip] += 1; p_ion_mask[ip] = 1; - amrex::Gpu::Atomic::Add( p_num_new_electrons, 1u ); + amrex::Gpu::Atomic::Add( p_num_new_electrons, 1u ); // Ensures thread-safe access when incrementing `p_ip_elec` } }); amrex::Gpu::streamSynchronize(); @@ -614,7 +624,7 @@ LaserIonization (const int islice, [=] AMREX_GPU_DEVICE (long ip) { if(p_ion_mask[ip] != 0) { - const long pid = amrex::Gpu::Atomic::Add( p_ip_elec, 1u ); + const long pid = amrex::Gpu::Atomic::Add( p_ip_elec, 1u ); // Ensures thread-safe access when incrementing `p_ip_elec` const long pidx = pid + old_size; // Copy ion data to new electron From f31d947325cd3d3c8b112bbd58eba56030e667ea Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 18:17:15 +0100 Subject: [PATCH 51/76] Update PlasmaParticleContainer.cpp --- .../plasma/PlasmaParticleContainer.cpp | 93 ++++++++++--------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 434b6c60e9..0fbbf06cdc 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -308,7 +308,7 @@ IonizationModule (const int lev, auto& soa_ion = ptile_ion.GetStructOfArrays(); // For momenta and weights const amrex::Real clightsq = 1.0_rt / ( phys_const.c * phys_const.c ); - // calcuation of E0 in SI units for denormalization + // Calcuation of E0 in SI units for denormalization const amrex::Real wp = std::sqrt(static_cast(background_density_SI) * PhysConstSI::q_e*PhysConstSI::q_e / (PhysConstSI::ep0 * PhysConstSI::m_e) ); @@ -335,9 +335,10 @@ IonizationModule (const int lev, long num_ions = ptile_ion.numParticles(); -// This kernel extends AMReX's parallel kernels to support multiple deposition orders -// (0, 1, 2, 3) at compile time, as it relies on `doLaserGatherShapeN` for computations -// specific to the selected deposition order. + + // This kernel supports multiple deposition orders (0, 1, 2, 3) at compile time + // and calculates ionization probability. If ionization occurs, it increments + // `p_num_new_electrons` to calculate the number of ionized electrons. amrex::AnyCTO( amrex::TypeList< amrex::CompileTimeOptions<0, 1, 2, 3> @@ -345,8 +346,7 @@ IonizationModule (const int lev, Hipace::m_depos_order_xy }, [&] (auto cto_func) { - // This choice of AMReX's parallel kernel enables the use of `amrex::Random` within the loop. - amrex::ParallelForRNG(num_ions, cto_func); + amrex::ParallelForRNG(num_ions, cto_func); // enables the use of `amrex::Random` within the loop }, [=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine, @@ -355,11 +355,11 @@ IonizationModule (const int lev, if (amrex::ConstParticleIDWrapper(idcpup[ip]) < 0 || amrex::ConstParticleCPUWrapper(idcpup[ip]) != lev) return; - // avoid temp slice + // Avoid temp slice const amrex::Real xp = x_prev[ip]; const amrex::Real yp = y_prev[ip]; - // define field at particle position reals + // Define field at particle position reals amrex::ParticleReal ExmByp = 0., EypBxp = 0., Ezp = 0.; amrex::ParticleReal Bxp = 0., Byp = 0., Bzp = 0.; @@ -388,7 +388,7 @@ IonizationModule (const int lev, { ion_lev[ip] += 1; p_ion_mask[ip] = 1; - amrex::Gpu::Atomic::Add( p_num_new_electrons, 1u ); // Ensures thread-safe access when incrementing `p_ip_elec` + amrex::Gpu::Atomic::Add( p_num_new_electrons, 1u ); // ensures thread-safe access when incrementing `p_ip_elec` } }); amrex::Gpu::streamSynchronize(); @@ -400,8 +400,8 @@ IonizationModule (const int lev, << num_new_electrons.dataValue() << "\n"; } - - // resize electron particle tile + + // Resize electron particle tile const auto old_size = ptile_elec.numParticles(); const auto new_size = old_size + num_new_electrons.dataValue(); ptile_elec.resize(new_size); @@ -417,15 +417,16 @@ IonizationModule (const int lev, amrex::Gpu::DeviceScalar ip_elec(0); uint32_t * AMREX_RESTRICT p_ip_elec = ip_elec.dataPtr(); + // This kernel adds the new ionized electrons to the Plasma Particle Container amrex::ParallelFor(num_ions, [=] AMREX_GPU_DEVICE (long ip) { if(p_ion_mask[ip] != 0) { - const long pid = amrex::Gpu::Atomic::Add( p_ip_elec, 1u ); // Ensures thread-safe access when incrementing `p_ip_elec` + const long pid = amrex::Gpu::Atomic::Add( p_ip_elec, 1u ); // ensures thread-safe access when incrementing `p_ip_elec` const long pidx = pid + old_size; // Copy ion data to new electron - amrex::ParticleIDWrapper{idcpu_elec[pidx]} = 2; // only for valid/invalid + amrex::ParticleIDWrapper{idcpu_elec[pidx]} = 2; // sets the ionized electron ID to 2 (valid/invalid) for the new electron amrex::ParticleCPUWrapper{idcpu_elec[pidx]} = lev; // current level arrdata_elec[PlasmaIdx::x ][pidx] = arrdata_ion[PlasmaIdx::x ][ip]; arrdata_elec[PlasmaIdx::y ][pidx] = arrdata_ion[PlasmaIdx::y ][ip]; @@ -433,7 +434,7 @@ IonizationModule (const int lev, arrdata_elec[PlasmaIdx::w ][pidx] = arrdata_ion[PlasmaIdx::w ][ip]; arrdata_elec[PlasmaIdx::ux ][pidx] = 0._rt; arrdata_elec[PlasmaIdx::uy ][pidx] = 0._rt; - // later we could consider adding a finite temperature to the ionized electrons + // Later we could consider adding a finite temperature to the ionized electrons arrdata_elec[PlasmaIdx::psi ][pidx] = 1._rt; arrdata_elec[PlasmaIdx::x_prev ][pidx] = arrdata_ion[PlasmaIdx::x_prev][ip]; arrdata_elec[PlasmaIdx::y_prev ][pidx] = arrdata_ion[PlasmaIdx::y_prev][ip]; @@ -452,7 +453,7 @@ IonizationModule (const int lev, } }); - // synchronize before ion_mask and ip_elec go out of scope + // Synchronize before ion_mask and ip_elec go out of scope amrex::Gpu::streamSynchronize(); } } @@ -497,10 +498,10 @@ LaserIonization (const int islice, mfi_ion.index(), mfi_ion.LocalTileIndex()); auto& ptile_ion = plevel_ion.at(index); - auto& soa_ion = ptile_ion.GetStructOfArrays(); // For momenta and weights + auto& soa_ion = ptile_ion.GetStructOfArrays(); // for momenta and weights const amrex::Real clightsq = 1.0_rt / ( phys_const.c * phys_const.c ); - // calcuation of E0 in SI units for denormalization + // Calcuation of E0 in SI units for denormalization const amrex::Real wp = std::sqrt(static_cast(background_density_SI) * PhysConstSI::q_e*PhysConstSI::q_e / (PhysConstSI::ep0 * PhysConstSI::m_e) ); @@ -531,9 +532,9 @@ LaserIonization (const int islice, long num_ions = ptile_ion.numParticles(); -// This kernel extends AMReX's parallel kernels to support multiple deposition orders -// (0, 1, 2, 3) at compile time, as it relies on `doLaserGatherShapeN` for computations -// specific to the selected deposition order. + // This kernel supports multiple deposition orders (0, 1, 2, 3) at compile time + // and calculates ionization probability. If ionization occurs, it increments + // `p_num_new_electrons` to calculate the number of ionized electrons. amrex::AnyCTO( amrex::TypeList< amrex::CompileTimeOptions<0, 1, 2, 3> @@ -541,14 +542,13 @@ LaserIonization (const int islice, Hipace::m_depos_order_xy }, [&] (auto cto_func) { - // This choice of AMReX's parallel kernel enables the use of `amrex::Random` within the loop. - amrex::ParallelForRNG(num_ions, cto_func); + amrex::ParallelForRNG(num_ions, cto_func); // enables the use of `amrex::Random` within the loop }, [=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine, auto depos_order_xy) { - // avoid temp slice + // Avoid temp slice const amrex::Real xp = x_prev[ip]; const amrex::Real yp = y_prev[ip]; @@ -563,8 +563,8 @@ LaserIonization (const int islice, dx_inv, dy_inv, dzeta_inv, x_pos_offset, y_pos_offset); // Convert from vector potential to electric field. Units are fixed later. - const Complex Et = I * A * omega0 + A_dzeta * phys_const.c; //transverse component - const Complex El = - A_dx * phys_const.c; //longitudinal component + const Complex Et = I * A * omega0 + A_dzeta * phys_const.c; // transverse component + const Complex El = - A_dx * phys_const.c; // longitudinal component // Get amplitude of the electric field envelope and normalize to correct SI unit. amrex::Real Ep = std::sqrt( amrex::abs(Et*Et) + amrex::abs(El*El) ); @@ -590,7 +590,7 @@ LaserIonization (const int islice, { ion_lev[ip] += 1; p_ion_mask[ip] = 1; - amrex::Gpu::Atomic::Add( p_num_new_electrons, 1u ); // Ensures thread-safe access when incrementing `p_ip_elec` + amrex::Gpu::Atomic::Add( p_num_new_electrons, 1u ); // ensures thread-safe access when incrementing `p_ip_elec` } }); amrex::Gpu::streamSynchronize(); @@ -602,8 +602,8 @@ LaserIonization (const int islice, << num_new_electrons.dataValue() << "\n"; } - - // resize electron particle tile + + // Resize electron particle tile const auto old_size = ptile_elec.numParticles(); const auto new_size = old_size + num_new_electrons.dataValue(); ptile_elec.resize(new_size); @@ -620,15 +620,16 @@ LaserIonization (const int islice, amrex::Gpu::DeviceScalar ip_elec(0); uint32_t * AMREX_RESTRICT p_ip_elec = ip_elec.dataPtr(); + // This kernel adds the new ionized electrons to the Plasma Particle Container amrex::ParallelFor(num_ions, [=] AMREX_GPU_DEVICE (long ip) { if(p_ion_mask[ip] != 0) { - const long pid = amrex::Gpu::Atomic::Add( p_ip_elec, 1u ); // Ensures thread-safe access when incrementing `p_ip_elec` + const long pid = amrex::Gpu::Atomic::Add( p_ip_elec, 1u ); // ensures thread-safe access when incrementing `p_ip_elec` const long pidx = pid + old_size; // Copy ion data to new electron - amrex::ParticleIDWrapper{idcpu_elec[pidx]} = 2; // only for valid/invalid + amrex::ParticleIDWrapper{idcpu_elec[pidx]} = 2; // sets the ionized electron ID to 2 (valid/invalid) for the new electron amrex::ParticleCPUWrapper{idcpu_elec[pidx]} = amrex::ParticleCPUWrapper{idcpu_ion[pidx]}; // current level arrdata_elec[PlasmaIdx::x ][pidx] = arrdata_ion[PlasmaIdx::x ][ip]; @@ -655,7 +656,7 @@ LaserIonization (const int islice, } }); - // synchronize before ion_mask and ip_elec go out of scope + // Synchronize before ion_mask and ip_elec go out of scope amrex::Gpu::streamSynchronize(); } } @@ -677,7 +678,7 @@ PlasmaParticleContainer::InSituComputeDiags (int islice) // Loop over particle boxes for (PlasmaParticleIterator pti(*this); pti.isValid(); ++pti) { - // loading the data + // Loading the data const auto ptd = pti.GetParticleTile().getParticleTileData(); amrex::Long const num_particles = pti.numParticles(); @@ -698,13 +699,13 @@ PlasmaParticleContainer::InSituComputeDiags (int islice) if (!ptd.id(ip).is_valid() || x*x + y*y > insitu_radius_sq) { return amrex::IdentityTuple(ReduceTuple{}, reduce_op); } - // particle's Lorentz factor + // Particle's Lorentz factor const amrex::Real gamma = (1.0_rt + ux*ux + uy*uy + psi*psi)/(2.0_rt*psi); - // the *c from uz cancels with the /c from the proper velocity conversion + // The *c from uz cancels with the /c from the proper velocity conversion const amrex::Real uz = (gamma - psi); - // weight with quasi-static weighting factor + // Weight with quasi-static weighting factor const amrex::Real w = ptd.rdata(PlasmaIdx::w)[ip] * gamma/psi; - // no quasi-static weighting factor to calculate quasi-static energy + // No quasi-static weighting factor to calculate quasi-static energy const amrex::Real energy = ptd.rdata(PlasmaIdx::w)[ip] * (gamma - 1._rt); return { // Tuple contains: w, // 0 sum(w) @@ -753,16 +754,16 @@ PlasmaParticleContainer::InSituWriteToFile (int step, amrex::Real time, const am HIPACE_PROFILE("PlasmaParticleContainer::InSituWriteToFile()"); #ifdef HIPACE_USE_OPENPMD - // create subdirectory + // Create subdirectory openPMD::auxiliary::create_directories(m_insitu_file_prefix); #endif - // zero pad the rank number; + // Zero pad the rank number; std::string::size_type n_zeros = 4; std::string rank_num = std::to_string(amrex::ParallelDescriptor::MyProc()); std::string pad_rank_num = std::string(n_zeros-std::min(rank_num.size(), n_zeros),'0')+rank_num; - // open file + // Open file std::ofstream ofs{m_insitu_file_prefix + "/reduced_" + m_name + "." + pad_rank_num + ".txt", std::ofstream::out | std::ofstream::app | std::ofstream::binary}; @@ -772,8 +773,8 @@ PlasmaParticleContainer::InSituWriteToFile (int step, amrex::Real time, const am geom.CellSizeArray().product() : 1; // dx * dy * dz in normalized units, 1 otherwise const int is_normalized_units = Hipace::m_normalized_units; - // specify the structure of the data later available in python - // avoid pointers to temporary objects as second argument, stack variables are ok + // Specify the structure of the data later available in python + // Avoid pointers to temporary objects as second argument, stack variables are ok const amrex::Vector all_data{ {"time" , &time}, {"step" , &step}, @@ -821,16 +822,16 @@ PlasmaParticleContainer::InSituWriteToFile (int step, amrex::Real time, const am }; if (ofs.tellp() == 0) { - // write JSON header containing a NumPy structured datatype + // Write JSON header containing a NumPy structured datatype insitu_utils::write_header(all_data, ofs); } - // write binary data according to datatype in header + // Write binary data according to datatype in header insitu_utils::write_data(all_data, ofs); - // close file + // Close file ofs.close(); - // assert no file errors + // Assert no file errors #ifdef HIPACE_USE_OPENPMD AMREX_ALWAYS_ASSERT_WITH_MESSAGE(ofs, "Error while writing insitu plasma diagnostics"); #else @@ -838,7 +839,7 @@ PlasmaParticleContainer::InSituWriteToFile (int step, amrex::Real time, const am "Maybe the specified subdirectory does not exist"); #endif - // reset arrays for insitu data + // Reset arrays for insitu data for (auto& x : m_insitu_rdata) x = 0.; for (auto& x : m_insitu_idata) x = 0; for (auto& x : m_insitu_sum_rdata) x = 0.; From 4c69a1586c82b77061d68e1df2b01f601acccda6 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 18:19:11 +0100 Subject: [PATCH 52/76] Update PlasmaParticleContainer.cpp --- src/particles/plasma/PlasmaParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 0fbbf06cdc..c187f6abe7 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -308,7 +308,7 @@ IonizationModule (const int lev, auto& soa_ion = ptile_ion.GetStructOfArrays(); // For momenta and weights const amrex::Real clightsq = 1.0_rt / ( phys_const.c * phys_const.c ); - // Calcuation of E0 in SI units for denormalization + // Calculation of E0 in SI units for denormalization const amrex::Real wp = std::sqrt(static_cast(background_density_SI) * PhysConstSI::q_e*PhysConstSI::q_e / (PhysConstSI::ep0 * PhysConstSI::m_e) ); From 971e002f1f8dd313abf9784727bddcb3c6012c95 Mon Sep 17 00:00:00 2001 From: Eya Dammak Date: Thu, 16 Jan 2025 22:57:56 +0100 Subject: [PATCH 53/76] issue with the style resolved --- .../plasma/PlasmaParticleContainer.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index c187f6abe7..f887e39845 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -336,8 +336,8 @@ IonizationModule (const int lev, long num_ions = ptile_ion.numParticles(); - // This kernel supports multiple deposition orders (0, 1, 2, 3) at compile time - // and calculates ionization probability. If ionization occurs, it increments + // This kernel supports multiple deposition orders (0, 1, 2, 3) at compile time + // and calculates ionization probability. If ionization occurs, it increments // `p_num_new_electrons` to calculate the number of ionized electrons. amrex::AnyCTO( amrex::TypeList< @@ -347,7 +347,7 @@ IonizationModule (const int lev, }, [&] (auto cto_func) { amrex::ParallelForRNG(num_ions, cto_func); // enables the use of `amrex::Random` within the loop - + }, [=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine, auto depos_order_xy) { @@ -400,7 +400,7 @@ IonizationModule (const int lev, << num_new_electrons.dataValue() << "\n"; } - + // Resize electron particle tile const auto old_size = ptile_elec.numParticles(); const auto new_size = old_size + num_new_electrons.dataValue(); @@ -417,7 +417,7 @@ IonizationModule (const int lev, amrex::Gpu::DeviceScalar ip_elec(0); uint32_t * AMREX_RESTRICT p_ip_elec = ip_elec.dataPtr(); - // This kernel adds the new ionized electrons to the Plasma Particle Container + // This kernel adds the new ionized electrons to the Plasma Particle Container amrex::ParallelFor(num_ions, [=] AMREX_GPU_DEVICE (long ip) { @@ -531,9 +531,9 @@ LaserIonization (const int islice, amrex::Real* AMREX_RESTRICT laser_adk_prefactor = m_laser_adk_prefactor.data(); long num_ions = ptile_ion.numParticles(); - - // This kernel supports multiple deposition orders (0, 1, 2, 3) at compile time - // and calculates ionization probability. If ionization occurs, it increments + + // This kernel supports multiple deposition orders (0, 1, 2, 3) at compile time + // and calculates ionization probability. If ionization occurs, it increments // `p_num_new_electrons` to calculate the number of ionized electrons. amrex::AnyCTO( amrex::TypeList< @@ -543,7 +543,7 @@ LaserIonization (const int islice, }, [&] (auto cto_func) { amrex::ParallelForRNG(num_ions, cto_func); // enables the use of `amrex::Random` within the loop - + }, [=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine, auto depos_order_xy) { @@ -602,7 +602,7 @@ LaserIonization (const int islice, << num_new_electrons.dataValue() << "\n"; } - + // Resize electron particle tile const auto old_size = ptile_elec.numParticles(); const auto new_size = old_size + num_new_electrons.dataValue(); From 1d27cc087cc65907a5930dff9963f6ae6f4bf52d Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:33:42 +0100 Subject: [PATCH 54/76] Update PlasmaParticleContainer.cpp --- src/particles/plasma/PlasmaParticleContainer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index f887e39845..540582d791 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -3,7 +3,7 @@ * This file is part of HiPACE++. * * Authors: AlexanderSinn, Andrew Myers, MaxThevenet, Severin Diederichs - * Weiqun Zhang, Angel Ferran Pousa + * Weiqun Zhang, Angel Ferran Pousa, EyaDammak * License: BSD-3-Clause-LBNL */ #include "Hipace.H" @@ -14,7 +14,7 @@ #include "utils/GPUUtil.H" #include "utils/InsituUtil.H" #ifdef HIPACE_USE_OPENPMD -# include +#include #endif #include "particles/pusher/PlasmaParticleAdvance.H" #include "particles/pusher/BeamParticleAdvance.H" From 24f20bb72a142a53256e2906ac90574506973dd2 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:52:42 +0100 Subject: [PATCH 55/76] Update PlasmaParticleContainer.cpp --- src/particles/plasma/PlasmaParticleContainer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 540582d791..47a39974ad 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -68,7 +68,7 @@ PlasmaParticleContainer::ReadParameters () m_can_field_ionize = pp.contains("ionization_product"); queryWithParser(pp, "can_ionize", m_can_field_ionize); - bool use_laser = true; // TODO: use actual value (laser not yet initialized at this time) + bool use_laser = true; m_can_laser_ionize = m_can_field_ionize && use_laser; queryWithParser(pp, "can_laser_ionize", m_can_laser_ionize); @@ -466,6 +466,8 @@ LaserIonization (const int islice, const amrex::Real background_density_SI) { if (!m_can_laser_ionize || !laser.UseLaser(islice)) return; + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(laser.UseLaser(islice) != true, + "Error: LaserIonization requires the laser to be enabled in the current slice."); HIPACE_PROFILE("PlasmaParticleContainer::LaserIonization()"); using namespace amrex::literals; From c5d1544aad49152b216957d6007f5c56c98c2a8e Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:56:28 +0100 Subject: [PATCH 56/76] Update PlasmaParticleContainerInit.cpp --- src/particles/plasma/PlasmaParticleContainerInit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainerInit.cpp b/src/particles/plasma/PlasmaParticleContainerInit.cpp index fb459d656f..189247bb5e 100644 --- a/src/particles/plasma/PlasmaParticleContainerInit.cpp +++ b/src/particles/plasma/PlasmaParticleContainerInit.cpp @@ -228,7 +228,7 @@ InitParticles (const amrex::RealVect& a_u_std, unsigned int uiy = amrex::min(ny-1,amrex::max(0,iy)); unsigned int uiz = amrex::min(nz-1,amrex::max(0,iz)); - // ordering of axes from fastest to slowest: + // Ordering of axes from fastest to slowest: // x // y // z (not used) @@ -421,7 +421,7 @@ InitIonizationModule (const amrex::Geometry& geom, const amrex::Real background_ const amrex::Real UH = table_ionization_energies[0]; const amrex::Real l_eff = std::sqrt(UH/h_ionization_energies[0]) - 1._rt; - // plasma frequency in SI units to denormalize ionization + // Plasma frequency in SI units to denormalize ionization const amrex::Real wp = std::sqrt(static_cast(background_density_SI) * PhysConstSI::q_e*PhysConstSI::q_e / (PhysConstSI::ep0 * PhysConstSI::m_e) ); From 06f63f90cc65ce79f1427a1090ea18f007628d43 Mon Sep 17 00:00:00 2001 From: Eya Dammak Date: Thu, 16 Jan 2025 23:59:55 +0100 Subject: [PATCH 57/76] style fixed --- src/particles/plasma/PlasmaParticleContainer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 47a39974ad..89231b529f 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -68,7 +68,7 @@ PlasmaParticleContainer::ReadParameters () m_can_field_ionize = pp.contains("ionization_product"); queryWithParser(pp, "can_ionize", m_can_field_ionize); - bool use_laser = true; + bool use_laser = true; m_can_laser_ionize = m_can_field_ionize && use_laser; queryWithParser(pp, "can_laser_ionize", m_can_laser_ionize); @@ -466,7 +466,7 @@ LaserIonization (const int islice, const amrex::Real background_density_SI) { if (!m_can_laser_ionize || !laser.UseLaser(islice)) return; - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(laser.UseLaser(islice) != true, + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(laser.UseLaser(islice) != true, "Error: LaserIonization requires the laser to be enabled in the current slice."); HIPACE_PROFILE("PlasmaParticleContainer::LaserIonization()"); From d52d78398dabb9910ce9f8433eb44c2bab180539 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 00:29:26 +0100 Subject: [PATCH 58/76] Update PlasmaParticleContainer.cpp --- src/particles/plasma/PlasmaParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 89231b529f..43cf0dc06c 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -466,7 +466,7 @@ LaserIonization (const int islice, const amrex::Real background_density_SI) { if (!m_can_laser_ionize || !laser.UseLaser(islice)) return; - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(laser.UseLaser(islice) != true, + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( !m_can_laser_ionize || laser.UseLaser(), "Error: LaserIonization requires the laser to be enabled in the current slice."); HIPACE_PROFILE("PlasmaParticleContainer::LaserIonization()"); From 0bd60b7d3300478c4a411844448756108c85f9df Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 00:34:08 +0100 Subject: [PATCH 59/76] Update PlasmaParticleContainer.cpp --- src/particles/plasma/PlasmaParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 43cf0dc06c..5bf77751a0 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -465,9 +465,9 @@ LaserIonization (const int islice, const MultiLaser& laser, const amrex::Real background_density_SI) { - if (!m_can_laser_ionize || !laser.UseLaser(islice)) return; AMREX_ALWAYS_ASSERT_WITH_MESSAGE( !m_can_laser_ionize || laser.UseLaser(), "Error: LaserIonization requires the laser to be enabled in the current slice."); + if (!m_can_laser_ionize || !laser.UseLaser(islice)) return; HIPACE_PROFILE("PlasmaParticleContainer::LaserIonization()"); using namespace amrex::literals; From 79102e7c864cf2198ba15f71a9e25702add32827 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 00:55:49 +0100 Subject: [PATCH 60/76] Update PlasmaParticleContainer.cpp --- src/particles/plasma/PlasmaParticleContainer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 5bf77751a0..80908d97d4 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -68,8 +68,7 @@ PlasmaParticleContainer::ReadParameters () m_can_field_ionize = pp.contains("ionization_product"); queryWithParser(pp, "can_ionize", m_can_field_ionize); - bool use_laser = true; - m_can_laser_ionize = m_can_field_ionize && use_laser; + m_can_laser_ionize = false; queryWithParser(pp, "can_laser_ionize", m_can_laser_ionize); m_can_ionize = m_can_field_ionize || m_can_laser_ionize; From 486f7fac4377091a881b3e5b809c1474aa415784 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:03:56 +0100 Subject: [PATCH 61/76] Update analysis_laser_ionization.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser_ionization/analysis_laser_ionization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 5042fafc7e..5642c7d40d 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -10,7 +10,7 @@ import math from openpmd_viewer import OpenPMDTimeSeries import statistics - +from scipy.constants import e as qe parser = argparse.ArgumentParser( description='Script to analyze the equality of two simulations') parser.add_argument('--first', From c9b433faec33b060a5f242d8672035721ad91deb Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:04:02 +0100 Subject: [PATCH 62/76] Update analysis_laser_ionization.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser_ionization/analysis_laser_ionization.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 5642c7d40d..7ddd823f7f 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -32,8 +32,6 @@ nc = 1.75e27 n0 = nc / 10000 -qe = 1.602176634e-19 - iteration = 0 rho_elec_linear, _ = ts_linear.get_field(field='rho_elec', coord='z', iteration=iteration, plot=False) From 8cead44ff69f4546f83002f4aae5a87564a45f37 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:04:17 +0100 Subject: [PATCH 63/76] Update analysis_laser_ionization.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser_ionization/analysis_laser_ionization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 7ddd823f7f..d5a6363817 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -34,7 +34,7 @@ iteration = 0 -rho_elec_linear, _ = ts_linear.get_field(field='rho_elec', coord='z', iteration=iteration, plot=False) +rho_elec_linear, _ = ts_linear.get_field(field='rho_elec', coord='z', iteration=iteration) rho_elec_mean_linear = np.mean(rho_elec_linear, axis=(1, 2)) rho_average_linear = statistics.mean(rho_elec_mean_linear[0:10]) fraction_linear = rho_average_linear / (-qe) / (n0) From 4d60a5da8f835f517b44d213f7d0c74305cd834a Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:04:59 +0100 Subject: [PATCH 64/76] Update analysis_laser_ionization.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser_ionization/analysis_laser_ionization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index d5a6363817..139d707415 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -37,7 +37,7 @@ rho_elec_linear, _ = ts_linear.get_field(field='rho_elec', coord='z', iteration=iteration) rho_elec_mean_linear = np.mean(rho_elec_linear, axis=(1, 2)) rho_average_linear = statistics.mean(rho_elec_mean_linear[0:10]) -fraction_linear = rho_average_linear / (-qe) / (n0) +fraction_linear = -rho_average_linear / qe / n0 rho_elec_circular, _ = ts_circular.get_field(field='rho_elec', coord='z', iteration=iteration, plot=False) rho_elec_mean_circular = np.mean(rho_elec_circular, axis=(1, 2)) From 1b6b4505cc510a34b2a9340bfa8d13315d0748be Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:05:06 +0100 Subject: [PATCH 65/76] Update analysis_laser_ionization.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser_ionization/analysis_laser_ionization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 139d707415..4565df6083 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -42,7 +42,7 @@ rho_elec_circular, _ = ts_circular.get_field(field='rho_elec', coord='z', iteration=iteration, plot=False) rho_elec_mean_circular = np.mean(rho_elec_circular, axis=(1, 2)) rho_average_circular = statistics.mean(rho_elec_mean_circular[0:10]) #average over a thickness in the ionized region -fraction_circular = rho_average_circular / (-qe) / (n0) +fraction_circular = -rho_average_circular / qe / n0 fraction_warpx_linear = 0.41014984 #result from WarpX simulation fraction_warpx_circular = 0.502250841 #result from WarpX simulation From 28f5fa8271eb1f58c98de68945dc794bb4f23554 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:05:14 +0100 Subject: [PATCH 66/76] Update analysis_laser_ionization.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser_ionization/analysis_laser_ionization.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 4565df6083..2c04c00233 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -44,8 +44,8 @@ rho_average_circular = statistics.mean(rho_elec_mean_circular[0:10]) #average over a thickness in the ionized region fraction_circular = -rho_average_circular / qe / n0 -fraction_warpx_linear = 0.41014984 #result from WarpX simulation -fraction_warpx_circular = 0.502250841 #result from WarpX simulation +fraction_warpx_linear = 0.41014984 # result from WarpX simulation +fraction_warpx_circular = 0.502250841 # result from WarpX simulation relative_diff_linear = np.abs( ( fraction_linear - fraction_warpx_linear ) / fraction_warpx_linear ) relative_diff_circular = np.abs( ( fraction_circular - fraction_warpx_circular ) / fraction_warpx_circular ) From 7b73bcd9896ff27d7c76b2fdce9d5f0150de4e04 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:05:22 +0100 Subject: [PATCH 67/76] Update inputs_laser_ionization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser_ionization/inputs_laser_ionization | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser_ionization/inputs_laser_ionization b/examples/laser_ionization/inputs_laser_ionization index 624215945d..74a49ed066 100644 --- a/examples/laser_ionization/inputs_laser_ionization +++ b/examples/laser_ionization/inputs_laser_ionization @@ -1,6 +1,6 @@ max_step = 0 hipace.dt = 0 -hipace.verbose=3 +hipace.verbose = 3 amr.n_cell = 32 32 50 From 019631087a8cc257d8c3c7554078e08d7a7efdd9 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:05:46 +0100 Subject: [PATCH 68/76] Update PlasmaParticleContainer.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/particles/plasma/PlasmaParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 80908d97d4..4e462edc56 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -14,7 +14,7 @@ #include "utils/GPUUtil.H" #include "utils/InsituUtil.H" #ifdef HIPACE_USE_OPENPMD -#include +# include #endif #include "particles/pusher/PlasmaParticleAdvance.H" #include "particles/pusher/BeamParticleAdvance.H" From 66677fee4ae6c4b52b97b1d759bfe114d02d467b Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:06:04 +0100 Subject: [PATCH 69/76] Update PlasmaParticleContainer.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/particles/plasma/PlasmaParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 4e462edc56..91f068d36b 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -345,7 +345,7 @@ IonizationModule (const int lev, Hipace::m_depos_order_xy }, [&] (auto cto_func) { - amrex::ParallelForRNG(num_ions, cto_func); // enables the use of `amrex::Random` within the loop + amrex::ParallelForRNG(num_ions, cto_func); // enables the use of amrex::Random within the loop }, [=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine, From f38e5819db1868e7d629a3e677695450da051d03 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:06:21 +0100 Subject: [PATCH 70/76] Update PlasmaParticleContainer.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/particles/plasma/PlasmaParticleContainer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 91f068d36b..5daae6fcbb 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -338,6 +338,7 @@ IonizationModule (const int lev, // This kernel supports multiple deposition orders (0, 1, 2, 3) at compile time // and calculates ionization probability. If ionization occurs, it increments // `p_num_new_electrons` to calculate the number of ionized electrons. + // It also constructs a mask with 1 boolean per macro-ion: 1 if ionized, 0 otherwise. amrex::AnyCTO( amrex::TypeList< amrex::CompileTimeOptions<0, 1, 2, 3> From 557e9ce91abd8a56c16be474c7fcc8da9ee14bf5 Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:06:35 +0100 Subject: [PATCH 71/76] Update PlasmaParticleContainer.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- src/particles/plasma/PlasmaParticleContainer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 5daae6fcbb..7aa15fbef5 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -537,6 +537,7 @@ LaserIonization (const int islice, // This kernel supports multiple deposition orders (0, 1, 2, 3) at compile time // and calculates ionization probability. If ionization occurs, it increments // `p_num_new_electrons` to calculate the number of ionized electrons. + // It also constructs a mask with 1 boolean per macro-ion: 1 if ionized, 0 otherwise. amrex::AnyCTO( amrex::TypeList< amrex::CompileTimeOptions<0, 1, 2, 3> From bac079353dc320f6df0ab8ccd7ebcb089b39604f Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:06:58 +0100 Subject: [PATCH 72/76] Update analysis_laser_ionization.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maxence Thévenet --- examples/laser_ionization/analysis_laser_ionization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/laser_ionization/analysis_laser_ionization.py b/examples/laser_ionization/analysis_laser_ionization.py index 2c04c00233..46b562a946 100755 --- a/examples/laser_ionization/analysis_laser_ionization.py +++ b/examples/laser_ionization/analysis_laser_ionization.py @@ -39,7 +39,7 @@ rho_average_linear = statistics.mean(rho_elec_mean_linear[0:10]) fraction_linear = -rho_average_linear / qe / n0 -rho_elec_circular, _ = ts_circular.get_field(field='rho_elec', coord='z', iteration=iteration, plot=False) +rho_elec_circular, _ = ts_circular.get_field(field='rho_elec', coord='z', iteration=iteration) rho_elec_mean_circular = np.mean(rho_elec_circular, axis=(1, 2)) rho_average_circular = statistics.mean(rho_elec_mean_circular[0:10]) #average over a thickness in the ionized region fraction_circular = -rho_average_circular / qe / n0 From 81f4648913a477334b197f9496770ea110d07218 Mon Sep 17 00:00:00 2001 From: Eya Dammak Date: Fri, 17 Jan 2025 11:50:57 +0100 Subject: [PATCH 73/76] style --- src/particles/plasma/PlasmaParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 7aa15fbef5..31fa883973 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -338,7 +338,7 @@ IonizationModule (const int lev, // This kernel supports multiple deposition orders (0, 1, 2, 3) at compile time // and calculates ionization probability. If ionization occurs, it increments // `p_num_new_electrons` to calculate the number of ionized electrons. - // It also constructs a mask with 1 boolean per macro-ion: 1 if ionized, 0 otherwise. + // It also constructs a mask with 1 boolean per macro-ion: 1 if ionized, 0 otherwise. amrex::AnyCTO( amrex::TypeList< amrex::CompileTimeOptions<0, 1, 2, 3> From e637c0b254e11a9076a8ccf00fb436108c9cc60e Mon Sep 17 00:00:00 2001 From: "Eya D." <81635404+EyaDammak@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:54:12 +0100 Subject: [PATCH 74/76] Update PlasmaParticleContainer.cpp From 279cac408563560270c2f804b96f2beeaaa869cb Mon Sep 17 00:00:00 2001 From: Maxence Thevenet Date: Fri, 17 Jan 2025 12:30:19 +0100 Subject: [PATCH 75/76] tmp modification to check whether tests execute as expected --- .github/workflows/cudaLocal.yml | 2 +- .github/workflows/linux.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cudaLocal.yml b/.github/workflows/cudaLocal.yml index 3dde28fa2d..b75491d668 100644 --- a/.github/workflows/cudaLocal.yml +++ b/.github/workflows/cudaLocal.yml @@ -46,4 +46,4 @@ jobs: run: | source $HOME/profile.hipace conda activate openpmd - ctest --test-dir build --output-on-failure + ctest --test-dir build --verbose diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a22a311558..1be8ab91b9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -45,7 +45,7 @@ jobs: -DCMAKE_VERBOSE_MAKEFILE=ON cmake --build build -j 2 - name: Run Tests - run: ctest --test-dir build --output-on-failure + run: ctest --test-dir build --verbose linux_gcc_cxx17: name: GNU@7.5 C++17 Serial @@ -75,7 +75,7 @@ jobs: -DHiPACE_PUSHER=AB5 cmake --build build -j 2 - name: Run Tests - run: ctest --test-dir build --output-on-failure + run: ctest --test-dir build --verbose # enable again when we open-source (free core-hours for GH Actions) # From e352df3cc9d4d6b5b156cc3570a2c2fbfd154f3e Mon Sep 17 00:00:00 2001 From: Maxence Thevenet Date: Fri, 17 Jan 2025 12:39:58 +0100 Subject: [PATCH 76/76] revert changes --- .github/workflows/cudaLocal.yml | 2 +- .github/workflows/linux.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cudaLocal.yml b/.github/workflows/cudaLocal.yml index b75491d668..3dde28fa2d 100644 --- a/.github/workflows/cudaLocal.yml +++ b/.github/workflows/cudaLocal.yml @@ -46,4 +46,4 @@ jobs: run: | source $HOME/profile.hipace conda activate openpmd - ctest --test-dir build --verbose + ctest --test-dir build --output-on-failure diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 1be8ab91b9..a22a311558 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -45,7 +45,7 @@ jobs: -DCMAKE_VERBOSE_MAKEFILE=ON cmake --build build -j 2 - name: Run Tests - run: ctest --test-dir build --verbose + run: ctest --test-dir build --output-on-failure linux_gcc_cxx17: name: GNU@7.5 C++17 Serial @@ -75,7 +75,7 @@ jobs: -DHiPACE_PUSHER=AB5 cmake --build build -j 2 - name: Run Tests - run: ctest --test-dir build --verbose + run: ctest --test-dir build --output-on-failure # enable again when we open-source (free core-hours for GH Actions) #