Skip to content

Commit

Permalink
[mini] Add radius to fixed weight beams (#1006)
Browse files Browse the repository at this point in the history
* add option to add a radius

* typo

* set default radius to inf

* move propagation after cut and fix doc

* make ballistic propagation depend on single particle momentum
  • Loading branch information
SeverinDiederichs authored Aug 9, 2023
1 parent fb3f621 commit b587430
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
8 changes: 4 additions & 4 deletions docs/source/run/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ which are valid only for certain beam types, are introduced further below under
* ``<beam name>.zmax`` (`float`) (default `infinity`)
Maximum in `z` at which particles are injected.

* ``<beam name>.radius`` (`float`)
Maximum radius ``<beam name>.radius`` :math:`= \sqrt{x^2 + y^2}` within that particles are
injected.

* ``<beam name>.element`` (`string`) optional (default `electron`)
The Physical Element of the plasma. Sets charge, mass and, if available,
the specific Ionization Energy of each state.
Expand Down Expand Up @@ -520,10 +524,6 @@ Option: ``fixed_ppc``
* ``<beam name>.ppc`` (3 `int`) (default `1 1 1`)
Number of particles per cell in `x`-, `y`-, and `z`-direction to generate the beam.

* ``<beam name>.radius`` (`float`)
Maximum radius ``<beam name>.radius`` :math:`= \sqrt{x^2 + y^2}` within that particles are
injected.

* ``<beam name>.density`` (`float`)
Peak density of the beam.
The absolute value of this parameter is used when initializing the beam.
Expand Down
5 changes: 3 additions & 2 deletions src/particles/beam/BeamParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public:
const amrex::Real total_charge,
const amrex::Real z_foc,
const bool do_symmetrize,
const bool can, const amrex::Real zmin, const amrex::Real zmax);
const bool can, const amrex::Real zmin, const amrex::Real zmax,
const amrex::Real radius);

#ifdef HIPACE_USE_OPENPMD
/** Checks the input file first to determine its Datatype
Expand Down Expand Up @@ -218,7 +219,7 @@ private:
amrex::IntVect m_ppc {1, 1, 1}; /**< Number of particles per cell in each direction */
amrex::Real m_zmin; /**< Min longitudinal particle position of the beam */
amrex::Real m_zmax; /**< Max longitudinal particle position of the beam */
amrex::Real m_radius; /**< Radius of the can beam */
amrex::Real m_radius {std::numeric_limits<amrex::Real>::infinity()}; /**< Radius of the beam */
amrex::RealVect m_position_mean {0., 0., 0.}; /**< mean position of the beam */
amrex::Real m_min_density {0.}; /**< minimum density at which beam particles are generated */
amrex::IntVect m_random_ppc {0, 0, 0}; /**< if the cell position is random in each direction */
Expand Down
3 changes: 2 additions & 1 deletion src/particles/beam/BeamParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ BeamParticleContainer::InitData (const amrex::Geometry& geom)
amrex::Real zmax = std::numeric_limits<amrex::Real>::infinity();
std::string profile = "gaussian";
queryWithParser(pp, "profile", profile);
queryWithParser(pp, "radius", m_radius);
if (profile == "can") {
can = true;
getWithParser(pp, "zmin", zmin);
Expand Down Expand Up @@ -162,7 +163,7 @@ BeamParticleContainer::InitData (const amrex::Geometry& geom)

const GetInitialMomentum get_momentum(m_name);
InitBeamFixedWeight(m_num_particles, get_momentum, pos_mean_x, pos_mean_y, pos_mean_z,
m_position_std, m_total_charge, m_z_foc, m_do_symmetrize, can, zmin, zmax);
m_position_std, m_total_charge, m_z_foc, m_do_symmetrize, can, zmin, zmax, m_radius);
m_total_num_particles = getBeamInitSlice().size();

} else if (m_injection_type == "from_file") {
Expand Down
14 changes: 8 additions & 6 deletions src/particles/beam/BeamParticleContainerInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ InitBeamFixedWeight (int num_to_add,
const amrex::Real total_charge,
const amrex::Real z_foc,
const bool do_symmetrize,
const bool can, const amrex::Real zmin, const amrex::Real zmax)
const bool can, const amrex::Real zmin, const amrex::Real zmax,
const amrex::Real radius)
{
HIPACE_PROFILE("BeamParticleContainer::InitParticles()");
using namespace amrex::literals;
Expand Down Expand Up @@ -355,13 +356,14 @@ InitBeamFixedWeight (int num_to_add,
amrex::Real u[3] = {0.,0.,0.};
get_momentum(u[0],u[1],u[2], engine, z, duz_per_uz0_dzeta);

// Propagate each electron ballistically for z_foc
x -= z_foc*u[0]/get_momentum.m_u_mean[2];
y -= z_foc*u[1]/get_momentum.m_u_mean[2];

const amrex::Real z_central = z + z_mean;
int valid_id = pid;
if (z_central < zmin || z_central > zmax) valid_id = -1;
if (z_central < zmin || z_central > zmax ||
x*x + y*y > radius*radius) valid_id = -1;

// Propagate each electron ballistically for z_foc
x -= z_foc*u[0]/u[2];
y -= z_foc*u[1]/u[2];

const amrex::Real cental_x_pos = pos_mean_x(z_central);
const amrex::Real cental_y_pos = pos_mean_y(z_central);
Expand Down

0 comments on commit b587430

Please sign in to comment.