Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3bf9f09

Browse files
committed
Move comments into docstring.
1 parent e6e977a commit 3bf9f09

1 file changed

Lines changed: 22 additions & 19 deletions

File tree

lib/matplotlib/streamplot.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -357,27 +357,30 @@ def rk4_integrate(x0, y0):
357357

358358
return rk4_integrate
359359

360-
## I have added this RK12 integrator, which I think supercedes both
361-
## other integrators. The rationale is two-fold:
362-
##
363-
## 1. To get decent looking trajectories and to sample every mask cell
364-
## on the trajectory we need a small timestep, so a lower order
365-
## solver doesn't hurt us unless the data is *very* high resolution.
366-
## In fact, for cases where the user inputs
367-
## data smaller or of similar grid size to the mask grid, the higher
368-
## order corrections are negligable because of the v fast linear
369-
## interpolation used in interpgrid.
370-
##
371-
## 2. For high resolution input data (i.e. beyond the mask
372-
## resolution), we must reduce the timestep. Therefore, an adaptive
373-
## timestep is more suited to the problem as this would be very hard
374-
## to judge automatically otherwise.
375-
##
376-
## This integrator is about 1.5 - 2x as fast as both the RK4 and RK45
377-
## solvers in most setups on my machine. I would recommend removing the
378-
## other two to keep things simple.
379360

380361
def _rk12(x0, y0, dmap, f):
362+
"""2nd-order Runge-Kutta algorithm with adaptive step size.
363+
364+
This method is also referred to as the improved Euler's method, or Heun's
365+
method. This method is favored over higher-order methods because:
366+
367+
1. To get decent looking trajectories and to sample every mask cell
368+
on the trajectory we need a small timestep, so a lower order
369+
solver doesn't hurt us unless the data is *very* high resolution.
370+
In fact, for cases where the user inputs
371+
data smaller or of similar grid size to the mask grid, the higher
372+
order corrections are negligible because of the very fast linear
373+
interpolation used in `interpgrid`.
374+
375+
2. For high resolution input data (i.e. beyond the mask
376+
resolution), we must reduce the timestep. Therefore, an adaptive
377+
timestep is more suited to the problem as this would be very hard
378+
to judge automatically otherwise.
379+
380+
This integrator is about 1.5 - 2x as fast as both the RK4 and RK45
381+
solvers in most setups on my machine. I would recommend removing the
382+
other two to keep things simple.
383+
"""
381384
## This error is below that needed to match the RK4 integrator. It
382385
## is set for visual reasons -- too low and corners start
383386
## appearing ugly and jagged. Can be tuned.

0 commit comments

Comments
 (0)