-
Notifications
You must be signed in to change notification settings - Fork 25
Option to coarsen the calling of elastic collision operator #1403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from all commits
167f7e3
4c07e75
2fba767
0d8facb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,8 @@ CoulombCollision::ReadParameters( | |
|
|
||
| // default Coulomb log is -1, if < 0 (e.g. not specified), will be computed automatically | ||
| pp.query("CoulombLog", m_CoulombLog); | ||
| // how often the collision operator should be applied - every m_collide_every'th slice | ||
| pp.query("collide_every", m_collide_every); | ||
|
|
||
| for (int i=0; i<(int) beam_species_names.size(); i++) { | ||
| if (beam_species_names[i] == collision_species[0]) m_nbeams += 1; | ||
|
|
@@ -58,11 +60,13 @@ CoulombCollision::ReadParameters( | |
| } | ||
|
|
||
| void | ||
| CoulombCollision::doPlasmaPlasmaCoulombCollision ( | ||
| CoulombCollision::doPlasmaPlasmaCoulombCollision ( int islice, int collide_every, | ||
| int lev, const amrex::Box& bx, const amrex::Geometry& geom, PlasmaParticleContainer& species1, | ||
| PlasmaParticleContainer& species2, bool is_same_species, amrex::Real CoulombLog, | ||
| amrex::Real background_density_SI) | ||
| { | ||
| if (islice%collide_every != 0) {return;} | ||
|
|
||
| HIPACE_PROFILE("CoulombCollision::doCoulombCollision()"); | ||
| AMREX_ALWAYS_ASSERT(lev == 0); | ||
|
|
||
|
|
@@ -104,10 +108,11 @@ CoulombCollision::doPlasmaPlasmaCoulombCollision ( | |
| const amrex::Real inv_dV = geom.InvCellSize(0)*geom.InvCellSize(1)*geom.InvCellSize(2); | ||
| // static_cast<double> to avoid precision problems in FP32 | ||
| const amrex::Real wp = std::sqrt(static_cast<double>(background_density_SI) * | ||
| PhysConstSI::q_e*PhysConstSI::q_e / | ||
| (PhysConstSI::ep0*PhysConstSI::m_e)); | ||
| const amrex::Real dt = normalized_units ? geom.CellSize(2)/wp | ||
| PhysConstSI::q_e*PhysConstSI::q_e / | ||
| (PhysConstSI::ep0*PhysConstSI::m_e)); | ||
| amrex::Real dt = normalized_units ? geom.CellSize(2)/wp | ||
| : geom.CellSize(2)/PhysConstSI::c; | ||
| dt = dt * collide_every; | ||
|
|
||
| amrex::ParallelForRNG( | ||
| n_cells, | ||
|
|
@@ -183,10 +188,11 @@ CoulombCollision::doPlasmaPlasmaCoulombCollision ( | |
| const amrex::Real inv_dV = geom.InvCellSize(0)*geom.InvCellSize(1)*geom.InvCellSize(2); | ||
| // static_cast<double> to avoid precision problems in FP32 | ||
| const amrex::Real wp = std::sqrt(static_cast<double>(background_density_SI) * | ||
| PhysConstSI::q_e*PhysConstSI::q_e / | ||
| (PhysConstSI::ep0*PhysConstSI::m_e)); | ||
| const amrex::Real dt = normalized_units ? geom.CellSize(2)/wp | ||
| PhysConstSI::q_e*PhysConstSI::q_e / | ||
| (PhysConstSI::ep0*PhysConstSI::m_e)); | ||
| amrex::Real dt = normalized_units ? geom.CellSize(2)/wp | ||
| : geom.CellSize(2)/PhysConstSI::c; | ||
| dt = dt * collide_every; | ||
| // Extract particles in the tile that `mfi` points to | ||
| // ParticleTileType& ptile_1 = species_1->ParticlesAt(lev, mfi); | ||
| // ParticleTileType& ptile_2 = species_2->ParticlesAt(lev, mfi); | ||
|
|
@@ -211,7 +217,7 @@ CoulombCollision::doPlasmaPlasmaCoulombCollision ( | |
|
|
||
| // Do not collide if one species is missing in the cell | ||
| if ( cell_stop1 - cell_start1 < 1 || | ||
| cell_stop2 - cell_start2 < 1 ) return; | ||
| cell_stop2 - cell_start2 < 1 ) return; | ||
| // shuffle | ||
| ShuffleFisherYates(indices1, cell_start1, cell_stop1, engine); | ||
| ShuffleFisherYates(indices2, cell_start2, cell_stop2, engine); | ||
|
|
@@ -234,11 +240,13 @@ CoulombCollision::doPlasmaPlasmaCoulombCollision ( | |
| } | ||
|
|
||
| void | ||
| CoulombCollision::doBeamPlasmaCoulombCollision ( | ||
| CoulombCollision::doBeamPlasmaCoulombCollision ( int islice, int collide_every, | ||
| int lev, const amrex::Box& bx, const amrex::Geometry& geom, | ||
| BeamParticleContainer& species1, PlasmaParticleContainer& species2, amrex::Real CoulombLog, | ||
| amrex::Real background_density_SI) | ||
| { | ||
| if (islice%collide_every != 0) {return;} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For Beam Plasma collisions this is a bit tricky. Beam particles usually stay on the same slice between time steps, so with this some won't get any collisions while others would get them every time step. Maybe we should just not allow the use of the parameter for this case. Or do something like |
||
|
|
||
| HIPACE_PROFILE("CoulombCollision::doBeamPlasmaCoulombCollision()"); | ||
| AMREX_ALWAYS_ASSERT(lev == 0); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the name to "collision_period" to make it consistent with the output_period parameter name we use in the diagnostics? Additionally, can you add an entry in the documentation for it here https://github.com/Hi-PACE/hipace/blob/92d3da222f62481e9eacf3207b98aa22fea47b62/docs/source/run/parameters.rst?plain=1#L1457
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I would be good to add an assert that it is >= 1.