Skip to content

Commit

Permalink
Merge pull request #41 from husseinaluie/Particle_dev
Browse files Browse the repository at this point in the history
Handling division by zero errors with in-land particles
  • Loading branch information
bastorer authored May 24, 2024
2 parents bb2e59b + 8a08b9d commit c418d7f
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 c418d7f

Please sign in to comment.