From deefa525f90282b19f762c6116e76bdf7567555d Mon Sep 17 00:00:00 2001 From: Alexander Sinn Date: Fri, 9 Jan 2026 12:33:54 +0100 Subject: [PATCH 1/4] Prevent plasma ionization past the atomic number --- src/particles/plasma/PlasmaParticleContainer.H | 1 + src/particles/plasma/PlasmaParticleContainer.cpp | 8 ++++++++ src/particles/plasma/PlasmaParticleContainerInit.cpp | 1 + 3 files changed, 10 insertions(+) diff --git a/src/particles/plasma/PlasmaParticleContainer.H b/src/particles/plasma/PlasmaParticleContainer.H index 6762648aac..d3559c5bfd 100644 --- a/src/particles/plasma/PlasmaParticleContainer.H +++ b/src/particles/plasma/PlasmaParticleContainer.H @@ -279,6 +279,7 @@ public: 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 */ + int m_max_ion_lev = 0; /**< maximum ionization level */ 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 */ diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index b7dbd3501b..ae1084b77e 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -418,6 +418,7 @@ IonizationModule (const int lev, 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(); + const int max_ion_lev = m_max_ion_lev; long num_ions = ptile_ion.numParticles(); @@ -466,6 +467,9 @@ IonizationModule (const int lev, const amrex::Real gamma_psi = plasma_gamma_psi(ux, uy, 1._rt / psi, /* Assumes Aabssq == 0 */ 0._rt); const int ion_lev_loc = ptd_ion.idata(PlasmaIdx::ion_lev)[ip]; + if (ion_lev_loc >= max_ion_lev) { + return; + } // gamma / (psi + 1) to complete dt for QSA amrex::Real w_dtau = gamma_psi * adk_prefactor[ion_lev_loc] * std::pow(Ep, adk_power[ion_lev_loc]) * @@ -611,6 +615,7 @@ LaserIonization (const int islice, amrex::Real* AMREX_RESTRICT laser_adk_prefactor = m_laser_adk_prefactor.data(); amrex::Real* AMREX_RESTRICT laser_dp_prefactor = m_laser_dp_prefactor.data(); amrex::Real* AMREX_RESTRICT laser_dp_second_prefactor = m_laser_dp_second_prefactor.data(); + const int max_ion_lev = m_max_ion_lev; long num_ions = ptile_ion.numParticles(); @@ -660,6 +665,9 @@ LaserIonization (const int islice, const amrex::Real gamma_psi = plasma_gamma_psi(ux, uy, 1._rt / psi, /* Assumes Aabssq == 0 */ 0._rt); const int ion_lev_loc = ptd_ion.idata(PlasmaIdx::ion_lev)[ip]; + if (ion_lev_loc >= max_ion_lev) { + return; + } // gamma / (psi + 1) to complete dt for QSA amrex::Real w_dtau_dc = gamma_psi * adk_prefactor[ion_lev_loc] * std::pow(Ep, adk_power[ion_lev_loc]) * diff --git a/src/particles/plasma/PlasmaParticleContainerInit.cpp b/src/particles/plasma/PlasmaParticleContainerInit.cpp index 46e38a0fc4..4f6d955d0a 100644 --- a/src/particles/plasma/PlasmaParticleContainerInit.cpp +++ b/src/particles/plasma/PlasmaParticleContainerInit.cpp @@ -426,6 +426,7 @@ InitIonizationModule (const amrex::Geometry& geom, const amrex::Real background_ // 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]; + m_max_ion_lev = ion_atomic_number; amrex::Vector h_ionization_energies(ion_atomic_number); const int offset = ion_energy_offsets[ion_element_id]; for(int i=0; i Date: Fri, 9 Jan 2026 12:55:18 +0100 Subject: [PATCH 2/4] add print for testing --- src/particles/plasma/PlasmaParticleContainer.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index ae1084b77e..18e4fe25dc 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -467,8 +467,9 @@ IonizationModule (const int lev, const amrex::Real gamma_psi = plasma_gamma_psi(ux, uy, 1._rt / psi, /* Assumes Aabssq == 0 */ 0._rt); const int ion_lev_loc = ptd_ion.idata(PlasmaIdx::ion_lev)[ip]; - if (ion_lev_loc >= max_ion_lev) { - return; + if (ion_lev_loc > max_ion_lev) { + std::cout << "max_ion_lev " << max_ion_lev << " ion_lev_loc " << ion_lev_loc << '\n'; + // return; } // gamma / (psi + 1) to complete dt for QSA amrex::Real w_dtau = gamma_psi * adk_prefactor[ion_lev_loc] * @@ -665,8 +666,9 @@ LaserIonization (const int islice, const amrex::Real gamma_psi = plasma_gamma_psi(ux, uy, 1._rt / psi, /* Assumes Aabssq == 0 */ 0._rt); const int ion_lev_loc = ptd_ion.idata(PlasmaIdx::ion_lev)[ip]; - if (ion_lev_loc >= max_ion_lev) { - return; + if (ion_lev_loc > max_ion_lev) { + std::cout << "max_ion_lev " << max_ion_lev << " ion_lev_loc " << ion_lev_loc << '\n'; + // return; } // gamma / (psi + 1) to complete dt for QSA amrex::Real w_dtau_dc = gamma_psi * adk_prefactor[ion_lev_loc] * From 95ee5911470ff0a955c3ec1cf690514c89369d50 Mon Sep 17 00:00:00 2001 From: Alexander Sinn Date: Fri, 9 Jan 2026 12:57:53 +0100 Subject: [PATCH 3/4] break CI --- tests/ionization.2Rank.sh | 4 +++- tests/laser_ionization.1Rank.sh | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/ionization.2Rank.sh b/tests/ionization.2Rank.sh index 1cc21ce1e7..4fd8ed07ff 100755 --- a/tests/ionization.2Rank.sh +++ b/tests/ionization.2Rank.sh @@ -40,4 +40,6 @@ $HIPACE_TEST_DIR/checksum/checksumAPI.py \ --evaluate \ --file_name $TEST_NAME \ --test-name $TEST_NAME \ - --skip "{'beam': 'id'}" + --skip "{'beam': 'id'}"^ + +exit 1; diff --git a/tests/laser_ionization.1Rank.sh b/tests/laser_ionization.1Rank.sh index eab7146909..50a3f69842 100755 --- a/tests/laser_ionization.1Rank.sh +++ b/tests/laser_ionization.1Rank.sh @@ -51,3 +51,5 @@ if [[ "$HIPACE_COMPUTE" != "CUDA" ]]; then --file_name $TEST_NAME/linear \ --test-name $TEST_NAME fi + +exit 1; From c15eab79517ffbab3c690b28a1d4aa53ccba6981 Mon Sep 17 00:00:00 2001 From: Alexander Sinn Date: Fri, 9 Jan 2026 13:12:04 +0100 Subject: [PATCH 4/4] revert test and reset CI --- .../plasma/PlasmaParticleContainer.cpp | 10 ++-- .../benchmarks_json/ionization.2Rank.json | 48 +++++++++---------- .../laser_ionization.1Rank.json | 40 ++++++++-------- tests/ionization.2Rank.sh | 4 +- tests/laser_ionization.1Rank.sh | 2 - 5 files changed, 49 insertions(+), 55 deletions(-) diff --git a/src/particles/plasma/PlasmaParticleContainer.cpp b/src/particles/plasma/PlasmaParticleContainer.cpp index 18e4fe25dc..ae1084b77e 100644 --- a/src/particles/plasma/PlasmaParticleContainer.cpp +++ b/src/particles/plasma/PlasmaParticleContainer.cpp @@ -467,9 +467,8 @@ IonizationModule (const int lev, const amrex::Real gamma_psi = plasma_gamma_psi(ux, uy, 1._rt / psi, /* Assumes Aabssq == 0 */ 0._rt); const int ion_lev_loc = ptd_ion.idata(PlasmaIdx::ion_lev)[ip]; - if (ion_lev_loc > max_ion_lev) { - std::cout << "max_ion_lev " << max_ion_lev << " ion_lev_loc " << ion_lev_loc << '\n'; - // return; + if (ion_lev_loc >= max_ion_lev) { + return; } // gamma / (psi + 1) to complete dt for QSA amrex::Real w_dtau = gamma_psi * adk_prefactor[ion_lev_loc] * @@ -666,9 +665,8 @@ LaserIonization (const int islice, const amrex::Real gamma_psi = plasma_gamma_psi(ux, uy, 1._rt / psi, /* Assumes Aabssq == 0 */ 0._rt); const int ion_lev_loc = ptd_ion.idata(PlasmaIdx::ion_lev)[ip]; - if (ion_lev_loc > max_ion_lev) { - std::cout << "max_ion_lev " << max_ion_lev << " ion_lev_loc " << ion_lev_loc << '\n'; - // return; + if (ion_lev_loc >= max_ion_lev) { + return; } // gamma / (psi + 1) to complete dt for QSA amrex::Real w_dtau_dc = gamma_psi * adk_prefactor[ion_lev_loc] * diff --git a/tests/checksum/benchmarks_json/ionization.2Rank.json b/tests/checksum/benchmarks_json/ionization.2Rank.json index 1a28eafc14..db8cb33249 100644 --- a/tests/checksum/benchmarks_json/ionization.2Rank.json +++ b/tests/checksum/benchmarks_json/ionization.2Rank.json @@ -1,34 +1,34 @@ { "lev=0": { - "Bx": 2682248.7024631, - "By": 2693948.2701062, - "Bz": 461542.25627809, - "Ex": 2027829034919000.0, - "ExmBy": 1615808683503300.0, - "Ey": 2028075445665300.0, - "EypBx": 1618198281458700.0, - "Ez": 661283577718300.0, - "Psi": 10769981625.527, - "Sx": 7.6153143258378e+17, - "Sy": 7.6749661894861e+17, - "chi": 2095164842379900.0, - "jx": 5.1803326128365e+17, - "jx_beam": 231581099135240.0, - "jy": 5.166188820914e+17, - "jy_beam": 230138000597450.0, - "jz_beam": 1.6907142961473e+17, - "rhomjz": 8996307093.0909 + "Bx": 2620311.1374515, + "By": 2635709.7531506, + "Bz": 414833.05353295, + "Ex": 2012939150389200.0, + "ExmBy": 1596237863501100.0, + "Ey": 1985459967332800.0, + "EypBx": 1577025752807400.0, + "Ez": 679659182354100.0, + "Psi": 10548202179.363, + "Sx": 7.6385240482099e+17, + "Sy": 7.6031507997545e+17, + "chi": 2108090067779600.0, + "jx": 5.1771260837627e+17, + "jx_beam": 229049530186220.0, + "jy": 5.1922551204841e+17, + "jy_beam": 224659467158600.0, + "jz_beam": 1.6907142196764e+17, + "rhomjz": 9012917997.7387 }, "beam": { "charge": 1.127932350336e-16, "id": 248160, "mass": 6.4130061345856e-28, - "x": 0.00024861156909874, - "y": 0.00024733653838739, - "z": 0.014359549367759, - "ux": 3002.9712551376, - "uy": 3008.114106705, - "uz": 1386735.4183111, + "x": 0.00024635902135382, + "y": 0.00024286960511978, + "z": 0.014359553378628, + "ux": 3013.9898183181, + "uy": 3014.5223974211, + "uz": 1386709.9483869, "w": 825000000.0 } } diff --git a/tests/checksum/benchmarks_json/laser_ionization.1Rank.json b/tests/checksum/benchmarks_json/laser_ionization.1Rank.json index e3e1465cb0..a28fe521a2 100644 --- a/tests/checksum/benchmarks_json/laser_ionization.1Rank.json +++ b/tests/checksum/benchmarks_json/laser_ionization.1Rank.json @@ -1,41 +1,41 @@ { "lev=0": { - "Bx": 3.5819859018319, - "By": 3.7269958544827, - "Bz": 2204.1195988099, - "Ex": 1117325248.1712, + "Bx": 3.7149515661811, + "By": 3.7865224175932, + "Bz": 2314.4198911339, + "Ex": 1135170862.8424, "ExmBy": 0.0, - "Ey": 1073852358.0315, + "Ey": 1113714461.3764, "EypBx": 0.0, - "Ez": 775468649901.41, + "Ez": 707934921502.67, "Psi": 0.0, - "Sx": 308477798484.84, - "Sy": 326849048142.86, + "Sx": 316753118383.02, + "Sy": 324030818911.92, "aabs": 0.46877495720552, - "chi": 265988685160760.0, - "jx": 700828092230540.0, + "chi": 267414764966510.0, + "jx": 702652162565720.0, "jx_beam": 0.0, "jy": 0.0, "jy_beam": 0.0, "jz_beam": 0.0, - "laserChi": 907831282357500.0, + "laserChi": 909177572466960.0, "laserEnvelope": 74.898701643489, - "rho_elec": 1202810276.6959, - "rho_ion": 1202806069.8845, + "rho_elec": 1209259053.802, + "rho_ion": 1209254830.8364, "rhomjz": 0.0, - "ux^2_elec": 0.26699411903602, + "ux^2_elec": 0.26780158956573, "ux^2_ion": 0.0, - "ux_elec": 83.376249717662, + "ux_elec": 83.593256064089, "ux_ion": 0.0, "uy^2_elec": 0.0, "uy^2_ion": 0.0, "uy_elec": 0.0, "uy_ion": 0.0, - "uz^2_elec": 1.6555627362415e-06, - "uz^2_ion": 1.4839081226415e-20, - "uz_elec": 0.14984820708954, - "uz_ion": 4.8429931176486e-09, - "w_elec": 480470478299.92, + "uz^2_elec": 1.6568753834647e-06, + "uz^2_ion": 1.5025085926483e-20, + "uz_elec": 0.15044101093153, + "uz_ion": 4.8989912126984e-09, + "w_elec": 483046484939.32, "w_ion": 1400000000000.1, "|a^2|": 0.46877495720552 } diff --git a/tests/ionization.2Rank.sh b/tests/ionization.2Rank.sh index 4fd8ed07ff..1cc21ce1e7 100755 --- a/tests/ionization.2Rank.sh +++ b/tests/ionization.2Rank.sh @@ -40,6 +40,4 @@ $HIPACE_TEST_DIR/checksum/checksumAPI.py \ --evaluate \ --file_name $TEST_NAME \ --test-name $TEST_NAME \ - --skip "{'beam': 'id'}"^ - -exit 1; + --skip "{'beam': 'id'}" diff --git a/tests/laser_ionization.1Rank.sh b/tests/laser_ionization.1Rank.sh index 50a3f69842..eab7146909 100755 --- a/tests/laser_ionization.1Rank.sh +++ b/tests/laser_ionization.1Rank.sh @@ -51,5 +51,3 @@ if [[ "$HIPACE_COMPUTE" != "CUDA" ]]; then --file_name $TEST_NAME/linear \ --test-name $TEST_NAME fi - -exit 1;