Skip to content

Custom particle Update#190

Merged
LudwigBoess merged 21 commits into1.4.0rcfrom
dev/custom_particle_bcs
Apr 7, 2026
Merged

Custom particle Update#190
LudwigBoess merged 21 commits into1.4.0rcfrom
dev/custom_particle_bcs

Conversation

@LudwigBoess
Copy link
Copy Markdown
Collaborator

@LudwigBoess LudwigBoess commented Mar 21, 2026

This PR adds the option to define a custom particle update in the problem generator. This update is called in the pusher, before the boundary conditions, and allows the application of a custom position update before the current deposit.
It can be used to add reflection in specific parts of the domain, or to resample velocities.

@LudwigBoess LudwigBoess requested a review from haykh March 21, 2026 01:01
@LudwigBoess LudwigBoess changed the base branch from master to 1.4.0rc March 21, 2026 01:02
@LudwigBoess
Copy link
Copy Markdown
Collaborator Author

LudwigBoess commented Mar 21, 2026

[OUTDATED|

As an example, this is how you would implement a reflecting BC that resamples the particle velocity on reflection in the pgen:

    struct CustomPrtlBC {
      random_number_pool_t pool;
      real_t temp_cold, temp_hot;

      template <class PusherKernel>
      Inline void operator()(index_t p, int dim, bool is_min, const PusherKernel& pusher) const {
        vec_t<Dim::_3D> v {ZERO};

        // Reflecting boundary that resamples velocity
        if (dim == 1) {
          if (is_min) {
            arch::JuttnerSinge(v, temp_cold, pool);

            pusher.i1(p)  = 0;
            pusher.dx1(p) = ONE - pusher.dx1(p);
            pusher.ux1(p) = v[0];
            pusher.ux2(p) = v[1];
            pusher.ux3(p) = v[2];
          } else {
            arch::JuttnerSinge(v, temp_hot, pool);

            pusher.i1(p)  = pusher.ni1 - 1;
            pusher.dx1(p) = ONE - pusher.dx1(p);
            pusher.ux1(p) = v[0];
            pusher.ux2(p) = v[1];
            pusher.ux3(p) = v[2];
          }
          
        }
      }
    };

    template <class D>
    auto CustomParticleBoundary(simtime_t /*time*/, spidx_t sp, D& domain) const {
      return CustomPrtlBC{
        domain.random_pool(),
        temperature / domain.species[sp].mass(), 
        temperature_gradient * temperature / domain.species[sp].mass()
      };
    }

@LudwigBoess LudwigBoess changed the title Custom particle BCs Custom particle Update Mar 31, 2026
@LudwigBoess LudwigBoess mentioned this pull request Apr 3, 2026
@LudwigBoess LudwigBoess marked this pull request as ready for review April 7, 2026 23:17
@LudwigBoess LudwigBoess merged commit b11f24f into 1.4.0rc Apr 7, 2026
26 checks passed
@LudwigBoess LudwigBoess deleted the dev/custom_particle_bcs branch April 7, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants