Skip to content

Commit 2767b9c

Browse files
fixed easy exponents
1 parent b19c7ca commit 2767b9c

File tree

5 files changed

+7
-245
lines changed

5 files changed

+7
-245
lines changed

src/HG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ double HG::CalculateRadialExtentConvectiveEnvelope() const {
517517
BaseStar clone = *this; // clone this star so can manipulate without changes persisiting
518518
clone.ResolveEnvelopeLoss(true); // update clone's attributes after envelope is lost
519519

520-
return PPOW(m_Tau, 1.0 / 2.0) * (m_Radius - clone.Radius());
520+
return sqrt(m_Tau) * (m_Radius - clone.Radius());
521521
}
522522

523523

src/MainSequence.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ double MainSequence::CalculateDeltaR(const double p_Mass) const {
348348
double deltaR;
349349

350350
if (utils::Compare(p_Mass, massCutoffs(MHook)) <= 0) deltaR = 0.0; // this really is supposed to be 0
351-
else if (utils::Compare(p_Mass, a[42]) <= 0) deltaR = a[43] * PPOW(((p_Mass - massCutoffs(MHook)) / (a[42] - massCutoffs(MHook))), 0.5);
351+
else if (utils::Compare(p_Mass, a[42]) <= 0) deltaR = a[43] * sqrt((p_Mass - massCutoffs(MHook)) / (a[42] - massCutoffs(MHook)));
352352
else if (utils::Compare(p_Mass, 2.0) < 0) deltaR = a[43] + ((m_RConstants[static_cast<int>(R_CONSTANTS::B_DELTA_R)] - a[43]) * PPOW(((p_Mass - a[42]) / (2.0 - a[42])), a[44]));
353353
else {
354354
// pow() is slow - use multiplication (sqrt() is faster than pow())
@@ -483,7 +483,7 @@ double MainSequence::CalculateRadiusOnPhase(const double p_Mass, const double p_
483483
* @return Radial extent of the star's convective envelope in Rsol
484484
*/
485485
double MainSequence::CalculateRadialExtentConvectiveEnvelope() const {
486-
return utils::Compare(m_Mass, 0.35) <= 0 ? m_Radius * PPOW(1.0 - m_Tau, 1.0 / 4.0) : 0.0;
486+
return utils::Compare(m_Mass, 0.35) <= 0 ? m_Radius * sqrt(sqrt(1.0 - m_Tau)) : 0.0;
487487
}
488488

489489

src/WhiteDwarfs.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ double WhiteDwarfs::CalculateLuminosityOnPhase_Static(const double p_Mass, const
3131
* @return Radius of a White Dwarf in Rsol (since WD is ~ Earth sized, expect answer around 0.009)
3232
*/
3333
double WhiteDwarfs::CalculateRadiusOnPhase_Static(const double p_Mass) {
34-
return std::max(NEUTRON_STAR_RADIUS, 0.0115 * sqrt(PPOW(MCH / p_Mass, 2.0 / 3.0) - PPOW(p_Mass / MCH, 2.0 / 3.0)));
34+
double MCH_Mass_one_third = std::cbrt(MCH / p_Mass);
35+
double MCH_Mass_two_thirds = MCH_Mass_one_third* MCH_Mass_one_third
36+
return std::max(NEUTRON_STAR_RADIUS, 0.0115 * sqrt((MCH_Mass_two_thirds - 1.0/MCH_Mass_two_thirds )));
3537
}

src/ppowtest

Lines changed: 0 additions & 240 deletions
This file was deleted.

src/utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ namespace utils {
172172
double a_cubed_SI_top = G * ((p_Mass1 * MSOL_TO_KG) + (p_Mass2 * MSOL_TO_KG)) * p_Period * p_Period * SECONDS_IN_DAY * SECONDS_IN_DAY;
173173
double a_cubed_SI_bottom = 4.0 * M_PI * M_PI;
174174
double a_cubed_SI = a_cubed_SI_top / a_cubed_SI_bottom;
175-
double a_SI = PPOW(a_cubed_SI, 1.0 / 3.0);
175+
double a_SI = std::cbrt(a_cubed_SI);
176176

177177
return a_SI / AU;
178178
}

0 commit comments

Comments
 (0)