diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index ddd21708a3..0af15caf08 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -924,7 +924,7 @@ In-situ diagnostics compute slice quantities (1 number per quantity per longitud For particle beams, they can be used to calculate the main characterizing beam parameters (width, energy spread, emittance, etc.), from which most common beam parameters (e.g. slice and projected emittance, etc.) can be computed. Additionally, the plasma particle properties (e.g, the temperature) can be calculated. For particle beams, the following quantities are calculated per slice and stored: -``sum(w), [x], [x^2], [y], [y^2], [z], [z^2], [ux], [ux^2], [uy], [uy^2], [uz], [uz^2], [x*ux], [y*uy], [z*uz], [ga], [ga^2], np``. +``sum(w), [x], [x^2], [y], [y^2], [z], [z^2], [ux], [ux^2], [uy], [uy^2], [uz], [uz^2], [x*ux], [y*uy], [z*uz], [x*uy], [y*ux], [ux/uz], [uy/uz], [ga], [ga^2], np``. For plasma particles, the following quantities are calculated per slice and stored: ``sum(w), [x], [x^2], [y], [y^2], [ux], [ux^2], [uy], [uy^2], [uz], [uz^2], [ga], [ga^2], np``. Thereby, "[]" stands for averaging over all particles in the current slice, @@ -933,7 +933,7 @@ Averages and totals over all slices are also provided for convenience under the respective ``average`` and ``total`` subcategories. For the field in-situ diagnostics, the following quantities are calculated per slice and stored: -``[Ex^2], [Ey^2], [Ez^2], [Bx^2], [By^2], [Bz^2], [ExmBy^2], [EypBx^2], [Ez*jz_beam]``. +``[Ex^2], [Ey^2], [Ez^2], [Bx^2], [By^2], [Bz^2], [ExmBy^2], [EypBx^2], [jz_beam], [Ez*jz_beam]``. Thereby, "[]" stands for averaging over all cells in the current slice. These quantities can be used to calculate the energy stored in the fields. diff --git a/src/fields/Fields.H b/src/fields/Fields.H index 7a18b5be44..8c0d270336 100644 --- a/src/fields/Fields.H +++ b/src/fields/Fields.H @@ -522,7 +522,7 @@ private: /** If any plasma species has a neutralizing background */ bool m_any_neutral_background = false; /** Number of real field properties for in-situ per-slice reduced diagnostics. */ - static constexpr int m_insitu_nrp = 9; + static constexpr int m_insitu_nrp = 10; /** How often the insitu field diagnostics should be computed and written * Default is 0, meaning no output */ int m_insitu_period {0}; diff --git a/src/fields/Fields.cpp b/src/fields/Fields.cpp index 9851858e3b..25b8dcc9fe 100644 --- a/src/fields/Fields.cpp +++ b/src/fields/Fields.cpp @@ -1303,7 +1303,8 @@ Fields::InSituComputeDiags (int step, amrex::Real time, int islice, const amrex: pow<2>(arr(i,j,Bz)), // 5 [Bz^2] pow<2>(arr(i,j,ExmBy)), // 6 [ExmBy^2] pow<2>(arr(i,j,EypBx)), // 7 [EypBx^2] - arr(i,j,Ez)*arr(i,j,jz_beam) // 8 [Ez*jz_beam] + arr(i,j,jz_beam), // 8 [jz_beam] + arr(i,j,Ez)*arr(i,j,jz_beam) // 9 [Ez*jz_beam] }; }); } @@ -1360,7 +1361,8 @@ Fields::InSituWriteToFile (int step, amrex::Real time, const amrex::Geometry& ge {"[Bz^2]" , &m_insitu_rdata[5*nslices], nslices}, {"[ExmBy^2]", &m_insitu_rdata[6*nslices], nslices}, {"[EypBx^2]", &m_insitu_rdata[7*nslices], nslices}, - {"[Ez*jz_beam]", &m_insitu_rdata[8*nslices], nslices}, + {"[jz_beam]", &m_insitu_rdata[8*nslices], nslices}, + {"[Ez*jz_beam]", &m_insitu_rdata[9*nslices], nslices}, {"integrated", { {"[Ex^2]" , &m_insitu_sum_rdata[0]}, {"[Ey^2]" , &m_insitu_sum_rdata[1]}, @@ -1370,7 +1372,8 @@ Fields::InSituWriteToFile (int step, amrex::Real time, const amrex::Geometry& ge {"[Bz^2]" , &m_insitu_sum_rdata[5]}, {"[ExmBy^2]", &m_insitu_sum_rdata[6]}, {"[EypBx^2]", &m_insitu_sum_rdata[7]}, - {"[Ez*jz_beam]", &m_insitu_sum_rdata[8]} + {"[jz_beam]", &m_insitu_sum_rdata[8]}, + {"[Ez*jz_beam]", &m_insitu_sum_rdata[9]} }} }; diff --git a/src/particles/beam/BeamParticleContainer.H b/src/particles/beam/BeamParticleContainer.H index 4daa81a5cb..e97f7d420f 100644 --- a/src/particles/beam/BeamParticleContainer.H +++ b/src/particles/beam/BeamParticleContainer.H @@ -301,7 +301,7 @@ private: int m_nslices; /**< number of z slices of the domain */ /** Number of real beam properties for in-situ per-slice reduced diagnostics. */ - static constexpr int m_insitu_nrp = 18; + static constexpr int m_insitu_nrp = 22; /** Number of int beam properties for in-situ per-slice reduced diagnostics. */ static constexpr int m_insitu_nip = 1; /** Per-slice real beam properties */ diff --git a/src/particles/beam/BeamParticleContainer.cpp b/src/particles/beam/BeamParticleContainer.cpp index 750a23b024..b51c0b0348 100644 --- a/src/particles/beam/BeamParticleContainer.cpp +++ b/src/particles/beam/BeamParticleContainer.cpp @@ -471,6 +471,8 @@ BeamParticleContainer::InSituComputeDiags (int islice) const amrex::Real uz = ptd.rdata(BeamIdx::uz)[ip] * clight_inv; const amrex::Real w = ptd.rdata(BeamIdx::w)[ip]; + const amrex::Real uz_inv = uz == 0._rt ? 0._rt : 1._rt / uz; + if (ptd.id(ip) < 0 || x*x + y*y > insitu_radius_sq) { return MakeZeroTuple(ReduceTuple{}); } @@ -492,9 +494,13 @@ BeamParticleContainer::InSituComputeDiags (int islice) w*x*ux, // 13 [x*ux] w*y*uy, // 14 [y*uy] w*z*uz, // 15 [z*uz] - w*gamma, // 16 [ga] - w*gamma*gamma, // 17 [ga^2] - 1 // 18 Np + w*x*uy, // 16 [x*uy] + w*y*ux, // 17 [y*ux] + w*ux*uz_inv, // 18 [ux/uz] + w*uy*uz_inv, // 19 [uy/uz] + w*gamma, // 20 [ga] + w*gamma*gamma, // 21 [ga^2] + 1 // 22 Np }; }); @@ -570,8 +576,12 @@ BeamParticleContainer::InSituWriteToFile (int step, amrex::Real time, const amre {"[x*ux]" , &m_insitu_rdata[13*nslices], nslices}, {"[y*uy]" , &m_insitu_rdata[14*nslices], nslices}, {"[z*uz]" , &m_insitu_rdata[15*nslices], nslices}, - {"[ga]" , &m_insitu_rdata[16*nslices], nslices}, - {"[ga^2]" , &m_insitu_rdata[17*nslices], nslices}, + {"[x*uy]" , &m_insitu_rdata[16*nslices], nslices}, + {"[y*ux]" , &m_insitu_rdata[17*nslices], nslices}, + {"[ux/uz]" , &m_insitu_rdata[18*nslices], nslices}, + {"[uy/uz]" , &m_insitu_rdata[19*nslices], nslices}, + {"[ga]" , &m_insitu_rdata[20*nslices], nslices}, + {"[ga^2]" , &m_insitu_rdata[21*nslices], nslices}, {"sum(w)" , &m_insitu_rdata[0], nslices}, {"Np" , &m_insitu_idata[0], nslices}, {"average" , { @@ -590,8 +600,12 @@ BeamParticleContainer::InSituWriteToFile (int step, amrex::Real time, const amre {"[x*ux]", &(m_insitu_sum_rdata[13] /= sum_w0)}, {"[y*uy]", &(m_insitu_sum_rdata[14] /= sum_w0)}, {"[z*uz]", &(m_insitu_sum_rdata[15] /= sum_w0)}, - {"[ga]" , &(m_insitu_sum_rdata[16] /= sum_w0)}, - {"[ga^2]", &(m_insitu_sum_rdata[17] /= sum_w0)} + {"[x*uy]", &(m_insitu_sum_rdata[16] /= sum_w0)}, + {"[y*ux]", &(m_insitu_sum_rdata[17] /= sum_w0)}, + {"[ux/uz]",&(m_insitu_sum_rdata[18] /= sum_w0)}, + {"[uy/uz]",&(m_insitu_sum_rdata[19] /= sum_w0)}, + {"[ga]" , &(m_insitu_sum_rdata[20] /= sum_w0)}, + {"[ga^2]", &(m_insitu_sum_rdata[21] /= sum_w0)} }}, {"total" , { {"sum(w)", &m_insitu_sum_rdata[0]},