Skip to content

Commit

Permalink
use for loop instead of while
Browse files Browse the repository at this point in the history
  • Loading branch information
Piyush Sharda authored and Piyush Sharda committed Aug 27, 2024
1 parent 8f168a0 commit 3638ae8
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions networks/metal_chem/actual_rhs.H
Original file line number Diff line number Diff line change
Expand Up @@ -4148,19 +4148,17 @@ std::pair<Real, Real> compute_Semenov_Tdust(Real Tgas, const Array1D<Real, 0, Nu
Real phys_Tcmb = 2.73 * (1.0 + z);
Real C = -1.0 * (intJRad + A * amrex::Math::powi<4>(phys_Tcmb) + std::pow(Tgas, 1.5) * amrex::Math::powi<2>(nH) * alpha_gd * user_dust2gas_ratio);

int iterr = 0;
Real Tdold = krome_Semenov_Tdust;
Real Tdnew = 0.0;

while (true) {
for (int iterr = 0; iterr <= 1001; ++iterr) {
Real fx = A * amrex::Math::powi<4>(Tdold) + B * Tdold + C;
Real fdash_x = 4.0 * A * amrex::Math::powi<3>(Tdold) + B;

Tdnew = Tdold - fx / fdash_x;
Real rel_t = std::abs((Tdnew - Tdold) / Tdold);
Real abs_t = std::abs(Tdnew - Tdold);
Tdold = Tdnew;
++iterr;

if (abs_t < 1e-8 || rel_t < 1e-5) {
break;
Expand Down

0 comments on commit 3638ae8

Please sign in to comment.