Skip to content

Commit

Permalink
Handling division by zero errors with in-land particles
Browse files Browse the repository at this point in the history
  • Loading branch information
bastorer committed May 24, 2024
1 parent f0e3639 commit 8a08b9d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Functions/Particles/particles_evolve_trajectories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ void RKF45_update( // Fehlbers's RK 4(5)

// If the error was too large, then we'll need to redo the step with a smaller dt.
// If the error was smaller than our tolerance, than the step is adaptively increased
dt_tmp = std::fmax( std::fmin( 0.9 * dt * pow( eps / TE, 1./5 ), dt_max ), dt_min );
if ( TE == 0 ) {
dt_tmp = dt_max;
} else {
dt_tmp = std::fmax( std::fmin( 0.9 * dt * pow( eps / TE, 1./5 ), dt_max ), dt_min );
}

if (dt_tmp <= dt_min) { break; } // if we're at the smallest dt, just stop
}
Expand Down Expand Up @@ -377,7 +381,11 @@ void DOPRI5_update( // Dormand-Prince 5(4)

// If the error was too large, then we'll need to redo the step with a smaller dt.
// If the error was smaller than our tolerance, than the step is adaptively increased
dt_tmp = std::fmax( std::fmin( 0.9 * dt * pow( eps / TE, 1./5 ), dt_max ), dt_min );
if ( TE == 0 ) {
dt_tmp = dt_max;
} else {
dt_tmp = std::fmax( std::fmin( 0.9 * dt * pow( eps / TE, 1./5 ), dt_max ), dt_min );
}

if (dt_tmp <= dt_min) { break; } // if we're at the smallest dt, just stop
}
Expand Down

0 comments on commit 8a08b9d

Please sign in to comment.