Electric field only used at the position at the beginning of the timestep,

the magnetic field is not changed since its value does not depend on the
particles;
Added a reflector for both ends of the cylinder
This commit is contained in:
2026-01-27 14:19:44 +01:00
parent 32521298d4
commit 0a843f0a4c
8 changed files with 88 additions and 3 deletions
+24
View File
@@ -19,6 +19,30 @@ void ReflectorDPS::reflectBackToDomain(particle::Particle* particle) const {
particle->velocity(CartesianVector(old_velocity));
}
LongitudinalReflector::LongitudinalReflector(double height) : height_(height) {}
bool LongitudinalReflector::needsReflectionBackToDomain(const particle::Particle* particle) const {
blitz::TinyVector<double, 3> position = particle->cartesianPosition().cartesianEntries();
if(position(2) < 0 || position(2) > height_) {
return true;
}
return false;
}
void LongitudinalReflector::reflectBackToDomain(particle::Particle* particle) const {
blitz::TinyVector<double, 3> old_position = particle->cartesianPosition().cartesianEntries();
blitz::TinyVector<double, 3> old_velocity = particle->velocity().cartesianEntries();
if(old_position(2) < 0) {
old_position(2) *= -1;
} else if(old_position(2) > height_) {
old_position(2) = 2*height_ - old_position(2);
}
old_velocity(2) *= -1.;
particle->position(CartesianCoordinate(old_position));
particle->velocity(CartesianVector(old_velocity));
}
bool NoReflector::needsReflectionBackToDomain(
const particle::Particle* particle) const {
return false;