This commit is contained in:
GuySten 2026-03-16 15:12:57 +02:00
parent 2343d27bd2
commit c19ba54698
2 changed files with 19 additions and 5 deletions

View file

@ -51,14 +51,26 @@ private:
class ParticleRay : public Ray, public Particle {
public:
ParticleRay(
Position r, Direction u, ParticleType type_, double time_, double E_)
: Ray(r, u)
{
type() = type_;
time() = time_;
E() = E_;
}
void on_intersection() override;
// Sets the dist_ variable
void update_distance() override;
const double& traversal_distance() const { return traversal_distance_; }
const double& traversal_mfp() const { return traversal_mfp_; }
protected:
// Records how much time passed during travel
double time_distance_ {0.0};
// Records how much mean free paths the ray traveled
double mfp_distance_ {0.0};
double traversal_mfp_ {0.0};
};
} // namespace openmc

View file

@ -173,11 +173,13 @@ void Ray::update_distance()
traversal_distance_ += boundary().distance();
}
void ParticleRay::on_intersection() {}
void ParticleRay::update_distance()
{
Ray::update_distance();
time_distance_ += speed() * boundary().distance();
time() += boundary().distance() / speed();
// Calculate microscopic and macroscopic cross sections
if (material() != MATERIAL_VOID) {
@ -205,7 +207,7 @@ void ParticleRay::update_distance()
macro_xs().nu_fission = 0.0;
}
mfp_distance_ += macro_xs().total * boundary().distance();
traversal_mfp_ += macro_xs().total * boundary().distance();
}
} // namespace openmc