mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Merge pull request #1890 from ojschumann/rational_dist
Rational univariate distribution
This commit is contained in:
commit
c2fe6327e2
9 changed files with 234 additions and 8 deletions
|
|
@ -80,6 +80,32 @@ private:
|
|||
double b_; //!< Upper bound of distribution
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
//! PowerLaw distribution over the interval [a,b] with exponent n : p(x)=c x^n
|
||||
//==============================================================================
|
||||
|
||||
class PowerLaw : public Distribution {
|
||||
public:
|
||||
explicit PowerLaw(pugi::xml_node node);
|
||||
PowerLaw(double a, double b, double n)
|
||||
: offset_ {std::pow(a, n + 1)}, span_ {std::pow(b, n + 1) - offset_},
|
||||
ninv_ {1 / (n + 1)} {};
|
||||
|
||||
//! Sample a value from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
//! \return Sampled value
|
||||
double sample(uint64_t* seed) const;
|
||||
|
||||
double a() const { return std::pow(offset_, ninv_); }
|
||||
double b() const { return std::pow(offset_ + span_, ninv_); }
|
||||
double n() const { return 1 / ninv_ - 1; }
|
||||
private:
|
||||
//! Store processed values in object to allow for faster sampling
|
||||
double offset_; //!< a^(n+1)
|
||||
double span_; //!< b^(n+1) - a^(n+1)
|
||||
double ninv_; //!< 1/(n+1)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
//! Maxwellian distribution of form c*sqrt(E)*exp(-E/theta)
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue