Skip to content

Custom particle BCs#190

Draft
LudwigBoess wants to merge 2 commits into1.4.0rcfrom
dev/custom_particle_bcs
Draft

Custom particle BCs#190
LudwigBoess wants to merge 2 commits into1.4.0rcfrom
dev/custom_particle_bcs

Conversation

@LudwigBoess
Copy link
Collaborator

This PR adds the option to define custom particle BCs in the problem generator

@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
Collaborator Author

LudwigBoess commented Mar 21, 2026

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()
      };
    }

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.

1 participant