MercuryDPM
Trunk
|
Namespace for some extra maths function that are often needed. More...
Functions | |
Mdouble | gamma (Mdouble gamma_in) |
This is the gamma function returns the true value for the half integer value. More... | |
Mdouble | beta (Mdouble z, Mdouble w) |
This is the beta function, returns the approximation based on cmath's implementation of ln(gamma) More... | |
Mdouble | chi_squared (Mdouble x, unsigned int k) |
This is a chi_squared function return the value x and degrees of freedom k. More... | |
Mdouble | chi_squared_prob (Mdouble x, unsigned int k) |
This is the function which actually gives the probability back using a chi squared test. More... | |
Mdouble | goldenSectionSearch (Mdouble(*function)(const Mdouble), Mdouble min, Mdouble cur, Mdouble max, Mdouble endCondition, Mdouble curVal=std::numeric_limits< Mdouble >::quiet_NaN()) |
This function performs a golden section search to find the location of the minimum of a function. More... | |
template<typename T > | |
int | sign (T val) |
This is a sign function, it returns -1 for negative numbers, 1 for positive numbers and 0 for 0. More... | |
template<typename T > | |
T | square (const T val) |
squares a number More... | |
template<typename T > | |
T | cubic (const T val) |
calculates the cube of a number More... | |
bool | isEqual (Mdouble v1, Mdouble v2, Mdouble absError) |
Compares the difference of two Mdouble with an absolute error, useful in UnitTests. More... | |
bool | isEqual (Vec3D v1, Vec3D v2, Mdouble absError) |
Compares the difference of two Vec3D with an absolute error, useful in UnitTests. More... | |
bool | isEqual (Matrix3D m1, Matrix3D m2, Mdouble absError) |
Compares the difference of two Vec3D with an absolute error, useful in UnitTests. More... | |
bool | isEqual (MatrixSymmetric3D m1, MatrixSymmetric3D m2, Mdouble absError) |
bool | isEqual (Quaternion v1, Quaternion v2, double absError) |
template<typename T > | |
constexpr T | factorial (const T t) |
factorial function More... | |
Mdouble | sin (Mdouble x) |
Mdouble | cos (Mdouble x) |
Mdouble | exp (Mdouble Exponent) |
Mdouble | log (Mdouble Power) |
template<typename T > | |
T | tan (T x) |
Mdouble | chebyshev (Mdouble x, const Mdouble coef[], int N) |
Namespace for evaluating the zeroth modified Bessel function of the first kind, I0(x), required in StatisticsPoint.hcc. More... | |
Mdouble | I0_exp (Mdouble x) |
Mdouble | I0 (Mdouble x) |
Namespace for some extra maths function that are often needed.
This is the beta function, returns the approximation based on cmath's implementation of ln(gamma)
Computes the beta function for real numbers, based on cmath's approximation of the ln of the gamma function. See https://en.wikipedia.org/wiki/Beta_function for more details
z | first Mdouble argument to compute the beta function of |
w | second Mdouble argument to compute the beta function of |
Definition at line 164 of file ExtendedMath.cc.
References exp().
Referenced by SuperQuadricParticle::computeMass(), Multipole::convertMultipoleToLocal(), InfiniteWall::getFurthestPointSuperQuadric(), SuperQuadricParticle::getVolume(), ParhamiMcMeekingSinterSpecies::set(), SuperQuadricParticle::setBoundingRadius(), SuperQuadricParticle::setInertia(), LocalExpansion::translateLocalExpansion(), and Multipole::TranslateMultipoleExpansionTo().
Namespace for evaluating the zeroth modified Bessel function of the first kind, I0(x), required in StatisticsPoint.hcc.
Definition at line 293 of file ExtendedMath.cc.
References constants::i, and logger.
Referenced by I0_exp().
This is a chi_squared function return the value x and degrees of freedom k.
Definition at line 172 of file ExtendedMath.cc.
References exp(), and gamma().
Referenced by chi_squared_prob().
This is the function which actually gives the probability back using a chi squared test.
This calculates the probability based on a chi squared test First we calculated the cumulative chi_squared function.
This is the function which actually gives the probability back It is calculated by calling the normal chi_squared function and using the trapezoidal rule. The final results is 1-the cumulative chi_squared function
Definition at line 188 of file ExtendedMath.cc.
References chi_squared(), and constants::i.
Referenced by RNG::test().
Definition at line 64 of file ExtendedMath.cc.
References constants::i, and constants::pi.
Referenced by ChuteWithHopper::addHopper(), LiquidBridgeWilletInteraction::computeAdhesionForce(), LiquidMigrationWilletInteraction::computeAdhesionForce(), BaseCluster::computeInternalStructure(), SinterLinInteraction::computeNormalForce(), CircularPeriodicBoundary::createPeriodicParticle(), LevelSetWall::createVTKSphere(), VChute::getDistanceAndNormal(), SineWall::getDistanceAndNormal(), HorizontalScrew::getDistanceAndNormal(), HorizontalBaseScrew::getDistanceAndNormal(), Coil::getDistanceAndNormal(), InfiniteWallWithHole::getDistanceAndNormal(), Screw::getDistanceAndNormalLabCoordinates(), Vec3D::getFromCylindricalCoordinates(), RNG::getNormalVariate(), helpers::objectivenessTest(), BaseCluster::particleInsertionSuccessful(), HopperInsertionBoundary::placeParticle(), CircularPeriodicBoundary::rotateParticle(), Quaternion::setAngleZ(), CurvyChute::setChuteAngleAndMagnitudeOfGravity(), Chute::setChuteAngleAndMagnitudeOfGravity(), Quaternion::setEuler(), sphericalHarmonics::sphericalHarmonics(), tan(), HorizontalBaseScrew::writeVTK(), HorizontalScrew::writeVTK(), Screw::writeVTK(), AxisymmetricIntersectionOfWalls::writeVTK(), and ScrewsymmetricIntersectionOfWalls::writeVTK().
T mathsFunc::cubic | ( | const T | val | ) |
calculates the cube of a number
Definition at line 115 of file ExtendedMath.h.
Referenced by Chute::addFlowParticlesCompactly(), CGCoordinates::XYZ::getGaussPrefactor(), PSD::getVolumetricMeanRadius(), CGCoordinates::XYZ::normalisePolynomialCoefficients(), and ChuteBottom::setupInitialConditions().
Definition at line 84 of file ExtendedMath.cc.
References X.
Referenced by beta(), chi_squared(), HeatFluidCoupledParticle::f1(), HeatFluidCoupledParticle::f2(), CGCoordinates::Base_X_Y_Z::getGaussIntegralPrefactor(), CGCoordinates::Base_XY_XZ_YZ::getGaussIntegralPrefactor(), CGCoordinates::XYZ::getGaussIntegralPrefactor(), CGCoordinates::Base_XY_XZ_YZ::getGaussPrefactor(), CGCoordinates::XYZ::getGaussPrefactor(), helpers::getMaximumVelocity(), RNG::getPoissonVariate(), LinearPlasticViscoelasticNormalSpecies::getRestitutionCoefficient(), LinearViscoelasticNormalSpecies::getRestitutionCoefficient(), SinterLinNormalSpecies::getRestitutionCoefficient(), HGridOptimiser::histNumberParticlesPerCell(), I0(), log(), ParhamiMcMeekingSinterSpecies::set(), SinterNormalSpecies::setParhamiMcKeeping(), and sphericalHarmonics::sphericalHarmonics().
constexpr T mathsFunc::factorial | ( | const T | t | ) |
factorial function
Definition at line 155 of file ExtendedMath.h.
Referenced by sphericalHarmonics::computeSquaredFactorialValues(), HGridOptimiser::histNumberParticlesPerCell(), and sphericalHarmonics::sphericalHarmonics().
This is the gamma function returns the true value for the half integer value.
This is the gamma function, gives 'exact' answers for the half integer values This is done using the recussion relation and the known values for 1 and 0.5 Note, return NaN for non-half integer values.
Definition at line 137 of file ExtendedMath.cc.
References constants::sqrt_pi.
Referenced by chi_squared(), InfiniteWall::getFurthestPointSuperQuadric(), HopperInsertionBoundary::placeParticle(), and SuperQuadricParticle::setBoundingRadius().
Mdouble mathsFunc::goldenSectionSearch | ( | Mdouble(*)(const Mdouble) | function, |
Mdouble | min, | ||
Mdouble | cur, | ||
Mdouble | max, | ||
Mdouble | endCondition, | ||
Mdouble | curVal = std::numeric_limits<Mdouble>::quiet_NaN() |
||
) |
This function performs a golden section search to find the location of the minimum of a function.
[in] | function | A function pointer to the function of which you want to calculate the location of its minimum. |
[in] | min | The minimum location |
[in] | cur | The current location |
[in] | max | The maximum location |
[in] | endCondition | The algorithm terminates when abs(max - min) < endCondition |
[in] | curVal | The value of the function at the current location (on default this value is calculated internally) |
Definition at line 206 of file ExtendedMath.cc.
Definition at line 311 of file ExtendedMath.cc.
References A, and chebyshev().
Referenced by I0().
Compares the difference of two Mdouble with an absolute error, useful in UnitTests.
[in] | v1 | The first Mdouble |
[in] | v2 | The second Mdouble |
[in] | absError | The allowed maximum absolute error |
Definition at line 251 of file ExtendedMath.cc.
Referenced by checkTemplate(), isEqual(), SuperQuadricParticle::setBoundingRadius(), and MercuryBase::setHGridCellOverSizeRatio().
Compares the difference of two Vec3D with an absolute error, useful in UnitTests.
[in] | v1 | The first Vec3D |
[in] | v2 | The second Vec3D |
[in] | absError | The allowed maximum absolute error |
Definition at line 257 of file ExtendedMath.cc.
Compares the difference of two Vec3D with an absolute error, useful in UnitTests.
[in] | m1 | The first Vec3D |
[in] | m2 | The second Vec3D |
[in] | absError | The allowed maximum absolute error |
Definition at line 262 of file ExtendedMath.cc.
References isEqual(), Matrix3D::XX, Matrix3D::XY, Matrix3D::XZ, Matrix3D::YX, Matrix3D::YY, Matrix3D::YZ, Matrix3D::ZX, Matrix3D::ZY, and Matrix3D::ZZ.
bool mathsFunc::isEqual | ( | MatrixSymmetric3D | m1, |
MatrixSymmetric3D | m2, | ||
Mdouble | absError | ||
) |
Definition at line 275 of file ExtendedMath.cc.
References isEqual(), MatrixSymmetric3D::XX, MatrixSymmetric3D::XY, MatrixSymmetric3D::XZ, MatrixSymmetric3D::YY, MatrixSymmetric3D::YZ, and MatrixSymmetric3D::ZZ.
bool mathsFunc::isEqual | ( | Quaternion | v1, |
Quaternion | v2, | ||
double | absError | ||
) |
Definition at line 285 of file ExtendedMath.cc.
References Quaternion::getComponent(), and isEqual().
Definition at line 104 of file ExtendedMath.cc.
Referenced by CircularPeriodicBoundary::checkBoundaryAfterParticleMoved(), helpers::computeDisptFromCollisionTimeAndRestitutionCoefficientAndTangentialRestitutionCoefficientAndEffectiveMass(), CircularPeriodicBoundary::createPeriodicParticle(), HeatFluidCoupledParticle::f1(), HeatFluidCoupledParticle::f2(), RNG::getNormalVariate(), SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficient(), LinearPlasticViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), LinearViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), SinterLinNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), HertzianViscoelasticNormalSpecies::setEffectiveElasticModulusAndRestitutionCoefficient(), LinearViscoelasticNormalSpecies::setRestitutionCoefficient(), LinearPlasticViscoelasticNormalSpecies::setRestitutionCoefficient(), SinterLinNormalSpecies::setRestitutionCoefficient(), SinterNormalSpecies::setStiffnessAndRestitutionCoefficient(), and SinterLinNormalSpecies::setStiffnessAndRestitutionCoefficient().
int mathsFunc::sign | ( | T | val | ) |
This is a sign function, it returns -1 for negative numbers, 1 for positive numbers and 0 for 0.
Definition at line 97 of file ExtendedMath.h.
Referenced by PeriodicBoundaryHandler::checkIsReal(), SuperQuadricParticle::computeHessianLabFixed(), SuperQuadricParticle::computeShapeGradientLabFixed(), HorizontalScrew::getDistanceAndNormal(), Screw::getDistanceAndNormalLabCoordinates(), InfiniteWall::getFurthestPointSuperQuadric(), and PeriodicBoundaryHandler::updateParticles().
Definition at line 44 of file ExtendedMath.cc.
References constants::i, and constants::pi.
Referenced by ChuteWithHopper::addHopper(), BaseCluster::computeInternalStructure(), SinterLinInteraction::computeNormalForce(), LevelSetWall::createVTKSphere(), VChute::getDistanceAndNormal(), SineWall::getDistanceAndNormal(), HorizontalScrew::getDistanceAndNormal(), HorizontalBaseScrew::getDistanceAndNormal(), Coil::getDistanceAndNormal(), InfiniteWallWithHole::getDistanceAndNormal(), Screw::getDistanceAndNormalLabCoordinates(), Vec3D::getFromCylindricalCoordinates(), ChuteWithHopper::getMaximumVelocityInducedByGravity(), RNG::getNormalVariate(), helpers::objectivenessTest(), BaseCluster::particleInsertionSuccessful(), HopperInsertionBoundary::placeParticle(), CircularPeriodicBoundary::rotateParticle(), Quaternion::setAngleZ(), CurvyChute::setChuteAngleAndMagnitudeOfGravity(), Chute::setChuteAngleAndMagnitudeOfGravity(), Quaternion::setEuler(), tan(), HorizontalBaseScrew::writeVTK(), HorizontalScrew::writeVTK(), Screw::writeVTK(), AxisymmetricIntersectionOfWalls::writeVTK(), and ScrewsymmetricIntersectionOfWalls::writeVTK().
T mathsFunc::square | ( | const T | val | ) |
squares a number
Definition at line 106 of file ExtendedMath.h.
Referenced by DPMBase::checkParticleForInteractionLocal(), helpers::computeDisptFromCollisionTimeAndRestitutionCoefficientAndTangentialRestitutionCoefficientAndEffectiveMass(), SlidingFrictionInteraction::computeFrictionForce(), MindlinRollingTorsionInteraction::computeFrictionForce(), FrictionInteraction::computeFrictionForce(), BaseParticle::computeMass(), SinterInteraction::computeNormalForce(), HertzianSinterInteraction::computeSinterForce(), LinearPlasticViscoelasticNormalSpecies::computeTimeStep(), SinterLinNormalSpecies::computeTimeStep(), SinterNormalSpecies::computeTimeStep(), PSD::convertProbabilityDensityNumberDistributionToProbabilityDensityVolumeDistribution(), PSD::convertProbabilityDensityToProbabilityDensityNumberDistribution(), Matrix3D::deviator(), HertzianViscoelasticNormalSpecies::getCollisionTime(), LinearPlasticViscoelasticNormalSpecies::getCollisionTime(), SinterNormalSpecies::getCollisionTime(), LinearViscoelasticNormalSpecies::getCollisionTime(), SinterLinNormalSpecies::getCollisionTime(), StatisticsVector< T >::getCutoff2(), ParabolaChute::getDistanceAndNormal(), SineWall::getDistanceAndNormal(), HorizontalScrew::getDistanceAndNormal(), Coil::getDistanceAndNormal(), Screw::getDistanceAndNormalLabCoordinates(), CGCoordinates::XY::getDistanceSquared(), CGCoordinates::Y::getDistanceSquared(), CGCoordinates::RZ::getDistanceSquared(), CGCoordinates::Z::getDistanceSquared(), CGCoordinates::X::getDistanceSquared(), CGCoordinates::XZ::getDistanceSquared(), CGCoordinates::YZ::getDistanceSquared(), CGCoordinates::R::getDistanceSquared(), ChargedBondedInteraction::getElasticEnergy(), LinearViscoelasticInteraction::getElasticEnergy(), SinterInteraction::getElasticEnergy(), HertzianSinterInteraction::getElasticEnergy(), SinterLinInteraction::getElasticEnergy(), LinearPlasticViscoelasticInteraction::getElasticEnergy(), IrreversibleAdhesiveInteraction::getElasticEnergy(), HertzianViscoelasticInteraction::getElasticEnergy(), HertzianViscoelasticInteraction::getElasticEnergyAtEquilibrium(), CGCoordinates::Base_X_Y_Z::getGaussIntegralPrefactor(), CGCoordinates::Base_XY_XZ_YZ::getGaussIntegralPrefactor(), CGCoordinates::XYZ::getGaussIntegralPrefactor(), CGCoordinates::Base_XY_XZ_YZ::getGaussPrefactor(), CGCoordinates::XYZ::getGaussPrefactor(), helpers::getMaximumVelocity(), CGFields::GradVelocityField::getSquared(), CGFields::LiquidMigrationFields::getSquared(), CGFields::StandardFields::getSquared(), CGCoordinates::YZ::getTangentialSquared(), CGCoordinates::RZ::getTangentialSquared(), CGCoordinates::XY::getTangentialSquared(), CGCoordinates::XZ::getTangentialSquared(), CGCoordinates::XYZ::getTangentialSquared(), Mercury3D::hGridFindContactsWithTargetCell(), MercuryBase::hGridUpdateMove(), BaseParticle::isInContactWith(), CGCoordinates::Base_XY_XZ_YZ::normalisePolynomialCoefficients(), SuperQuadricParticle::setBoundingRadius(), StatisticsVector< T >::setCGWidth(), SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficient(), SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficientNoDispt(), LinearPlasticViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), LinearViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), SinterLinNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), LinearViscoelasticNormalSpecies::setRestitutionCoefficient(), LinearPlasticViscoelasticNormalSpecies::setRestitutionCoefficient(), SinterLinNormalSpecies::setRestitutionCoefficient(), SinterNormalSpecies::setStiffnessAndRestitutionCoefficient(), SinterLinNormalSpecies::setStiffnessAndRestitutionCoefficient(), MatrixSymmetric3D::square(), and Matrix3D::square().
T mathsFunc::tan | ( | T | x | ) |
Definition at line 178 of file ExtendedMath.h.
Referenced by ChuteWithHopper::addHopper(), SinterLinInteraction::computeNormalForce(), VChute::getDistanceAndNormal(), and ChuteWithHopper::setHopper().