Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logic on CalcTempAtFalseVacFraction() #149

Merged
merged 6 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion include/BSMPT/bounce_solution/bounce_solution.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,19 @@ class BounceSolution
*/
const double RelErr = 1e-6;

/**
* @brief Maximum relative difference in temperature on the fraction of false
* vacuum to be accepted.
*
*/
const double RelativeTemperatureInCalcTempAtFalseVacFraction = 1e-8;

/**
* @brief Maximum relative error on the fraction of vacuum tunneled to be
* accepted.
*/
const double RelativeErrorInCalcTempAtFalseVacFraction = 1e-3;

/**
* @brief pair of coexisiting phases
*/
Expand Down Expand Up @@ -547,4 +560,4 @@ struct resultErrorPair Nintegrate_Outer(BounceSolution &obj);
*/
struct resultErrorPair Nderive_BounceRatio(BounceSolution &obj);

} // namespace BSMPT
} // namespace BSMPT
26 changes: 15 additions & 11 deletions src/bounce_solution/bounce_solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,9 +754,12 @@ double BounceSolution::CalcTempAtFalseVacFraction(const double &false_vac_frac)
this->SetStoredTemp(T_middle); // update temp storage for inner integral
double IatT = prefac * Nintegrate_Outer(*this).result;

bool numerically_unstable = false;

while (std::abs(T_up / T_down - 1) > 1e-8)
while (
(std::abs(T_up / T_down - 1) >
RelativeTemperatureInCalcTempAtFalseVacFraction * 1e-4) or
(not almost_the_same(int_at_false_vac_frac,
IatT,
RelativeErrorInCalcTempAtFalseVacFraction * 1e-4)))
{
T_middle = (T_up + T_down) / 2.;
this->SetStoredTemp(T_middle); // update temp storage for inner integral
Expand All @@ -775,18 +778,19 @@ double BounceSolution::CalcTempAtFalseVacFraction(const double &false_vac_frac)
T_down = T_middle;
}

if (std::abs(T_up / T_down - 1) < 1e-8 and
not almost_the_same(int_at_false_vac_frac, IatT))
// Condition for success
if (std::abs(T_up / T_down - 1) <
RelativeTemperatureInCalcTempAtFalseVacFraction and
almost_the_same(int_at_false_vac_frac,
IatT,
RelativeErrorInCalcTempAtFalseVacFraction))
{
numerically_unstable = true;
res_Temp = T_middle;
break;
}
}
if (not numerically_unstable)
{
res_Temp = T_middle;
}
}
// Not numerically stable
return res_Temp;
}

Expand Down Expand Up @@ -1092,4 +1096,4 @@ double BounceSolution::GetInvTimeScale()
return this->betaH;
}

} // namespace BSMPT
} // namespace BSMPT