2018-07-05 07:01:19 -05:00
|
|
|
#ifndef DISTRIBUTION_MULTI_H
|
|
|
|
|
#define DISTRIBUTION_MULTI_H
|
|
|
|
|
|
2021-04-22 16:46:23 -04:00
|
|
|
#include "openmc/memory.h"
|
2018-07-05 07:01:19 -05:00
|
|
|
|
2018-07-16 10:50:23 -05:00
|
|
|
#include "pugixml.hpp"
|
|
|
|
|
|
2018-08-20 14:40:32 -05:00
|
|
|
#include "openmc/distribution.h"
|
|
|
|
|
#include "openmc/position.h"
|
2018-07-05 07:01:19 -05:00
|
|
|
|
|
|
|
|
namespace openmc {
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
//! Probability density function for points on the unit sphere. Extensions of
|
|
|
|
|
//! this type are used to sample angular distributions for starting sources
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
|
|
class UnitSphereDistribution {
|
|
|
|
|
public:
|
|
|
|
|
UnitSphereDistribution() {};
|
2018-07-16 10:50:23 -05:00
|
|
|
explicit UnitSphereDistribution(Direction u) : u_ref_ {u} {};
|
|
|
|
|
explicit UnitSphereDistribution(pugi::xml_node node);
|
2018-07-05 07:01:19 -05:00
|
|
|
virtual ~UnitSphereDistribution() = default;
|
|
|
|
|
|
2023-12-02 11:35:23 -06:00
|
|
|
static unique_ptr<UnitSphereDistribution> create(pugi::xml_node node);
|
|
|
|
|
|
2018-07-05 07:01:19 -05:00
|
|
|
//! Sample a direction from the distribution
|
2019-12-05 19:50:31 +00:00
|
|
|
//! \param seed Pseudorandom number seed pointer
|
2018-07-05 07:01:19 -05:00
|
|
|
//! \return Direction sampled
|
2019-12-05 19:50:31 +00:00
|
|
|
virtual Direction sample(uint64_t* seed) const = 0;
|
2018-07-05 07:01:19 -05:00
|
|
|
|
2018-07-16 10:50:23 -05:00
|
|
|
Direction u_ref_ {0.0, 0.0, 1.0}; //!< reference direction
|
2018-07-05 07:01:19 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
//! Explicit distribution of polar and azimuthal angles
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
|
|
class PolarAzimuthal : public UnitSphereDistribution {
|
|
|
|
|
public:
|
|
|
|
|
PolarAzimuthal(Direction u, UPtrDist mu, UPtrDist phi);
|
2018-07-16 10:50:23 -05:00
|
|
|
explicit PolarAzimuthal(pugi::xml_node node);
|
2018-07-05 07:01:19 -05:00
|
|
|
|
|
|
|
|
//! Sample a direction from the distribution
|
2019-12-05 19:50:31 +00:00
|
|
|
//! \param seed Pseudorandom number seed pointer
|
2018-07-05 07:01:19 -05:00
|
|
|
//! \return Direction sampled
|
2023-02-16 14:06:59 -06:00
|
|
|
Direction sample(uint64_t* seed) const override;
|
2020-03-19 15:43:39 -04:00
|
|
|
|
|
|
|
|
// Observing pointers
|
2020-03-20 12:04:22 -04:00
|
|
|
Distribution* mu() const { return mu_.get(); }
|
|
|
|
|
Distribution* phi() const { return phi_.get(); }
|
2020-03-19 15:43:39 -04:00
|
|
|
|
2018-07-05 07:01:19 -05:00
|
|
|
private:
|
|
|
|
|
UPtrDist mu_; //!< Distribution of polar angle
|
|
|
|
|
UPtrDist phi_; //!< Distribution of azimuthal angle
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
//! Uniform distribution on the unit sphere
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
2021-03-24 08:11:40 -05:00
|
|
|
Direction isotropic_direction(uint64_t* seed);
|
|
|
|
|
|
2018-07-05 07:01:19 -05:00
|
|
|
class Isotropic : public UnitSphereDistribution {
|
|
|
|
|
public:
|
|
|
|
|
Isotropic() {};
|
|
|
|
|
|
|
|
|
|
//! Sample a direction from the distribution
|
2019-12-05 19:50:31 +00:00
|
|
|
//! \param seed Pseudorandom number seed pointer
|
2018-07-05 07:01:19 -05:00
|
|
|
//! \return Sampled direction
|
2023-02-16 14:06:59 -06:00
|
|
|
Direction sample(uint64_t* seed) const override;
|
2018-07-05 07:01:19 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
//! Monodirectional distribution
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
|
|
class Monodirectional : public UnitSphereDistribution {
|
|
|
|
|
public:
|
|
|
|
|
Monodirectional(Direction u) : UnitSphereDistribution {u} {};
|
2018-07-16 10:50:23 -05:00
|
|
|
explicit Monodirectional(pugi::xml_node node)
|
|
|
|
|
: UnitSphereDistribution {node} {};
|
2018-07-05 07:01:19 -05:00
|
|
|
|
|
|
|
|
//! Sample a direction from the distribution
|
2019-12-05 19:50:31 +00:00
|
|
|
//! \param seed Pseudorandom number seed pointer
|
2018-07-05 07:01:19 -05:00
|
|
|
//! \return Sampled direction
|
2023-02-16 14:06:59 -06:00
|
|
|
Direction sample(uint64_t* seed) const override;
|
2018-07-05 07:01:19 -05:00
|
|
|
};
|
|
|
|
|
|
2021-04-22 16:46:23 -04:00
|
|
|
using UPtrAngle = unique_ptr<UnitSphereDistribution>;
|
2018-07-17 06:43:35 -05:00
|
|
|
|
2018-07-05 07:01:19 -05:00
|
|
|
} // namespace openmc
|
|
|
|
|
|
|
|
|
|
#endif // DISTRIBUTION_MULTI_H
|