Skip to content

Commit

Permalink
Changed how the t_start value is ensured to be equal to the last end
Browse files Browse the repository at this point in the history
point (if given) using a tolerance of 1e-15. This fixes an
issue where the t_start value and the end point are the same
but "==" operator returns false due to machine precision error and the
simulation fails to run.
  • Loading branch information
ASinanSaglam committed Dec 20, 2018
1 parent 10523e7 commit cf9a69c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bng2/Perl2/BNGAction.pm
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,14 @@ sub simulate

# Set start time for trajectory
my $t_start;
my $tol=1e-15;
if ( defined $params->{t_start} )
{
$t_start = $params->{t_start};
# if this is a continuation, check that model time equals t_start
if ($continue)
{
unless ( defined($model->Time) and ($model->Time == $t_start) )
unless ( defined($model->Time) and (abs($model->Time - $t_start) < $tol) )
{ return "t_start must equal current model time for continuation."; }
}
}
Expand Down

0 comments on commit cf9a69c

Please sign in to comment.