Skip to content

Commit

Permalink
Avoid taking a time step that will bring too close to a breakpoint.
Browse files Browse the repository at this point in the history
In case the selected step will bring too close to a breakpoint, reduce
this step so that the next step will be larger. This avoids numerical
errors when needing a very small time steps when approaching a breakpoint.
  • Loading branch information
in3otd committed Jan 26, 2016
1 parent 1940742 commit 3b952c7
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions qucs-core/src/trsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,18 +643,32 @@ void trsolver::adjustDelta (nr_double_t t)
}
else
{
if (delta > (t - current) && t > current)
// check whether this step will bring too close to a breakpoint
// is ok if the step will go past the breakpoint, this is handled by
// the next branch
if ((t - (current + delta) < deltaMin) && ((current + delta) < t))
{
// save last valid delta and set exact step
stepDelta = deltaOld;
delta = t - current;
good = 1;
}
// if we take this delta we will end up too close to the breakpoint
// and next step will be very tiny, possibly causing numerical issues
// so reduce it so that next step will likely not end up too close
// to the breakpoint
delta /= 2.0;
}
else
{
stepDelta = -1.0;
{
if (delta > (t - current) && t > current)
{
// save last valid delta and set exact step
stepDelta = deltaOld;
delta = t - current;
good = 1;
}
else
{
stepDelta = -1.0;
}
}
}
}
if (delta > deltaMax) delta = deltaMax;
if (delta < deltaMin) delta = deltaMin;
}
Expand Down

0 comments on commit 3b952c7

Please sign in to comment.