Simple Euler integration step that extends streamline to boundary.
(xyf_traj, dmap, f)
| 663 | |
| 664 | |
| 665 | def _euler_step(xyf_traj, dmap, f): |
| 666 | """Simple Euler integration step that extends streamline to boundary.""" |
| 667 | ny, nx = dmap.grid.shape |
| 668 | xi, yi = xyf_traj[-1] |
| 669 | cx, cy = f(xi, yi) |
| 670 | if cx == 0: |
| 671 | dsx = np.inf |
| 672 | elif cx < 0: |
| 673 | dsx = xi / -cx |
| 674 | else: |
| 675 | dsx = (nx - 1 - xi) / cx |
| 676 | if cy == 0: |
| 677 | dsy = np.inf |
| 678 | elif cy < 0: |
| 679 | dsy = yi / -cy |
| 680 | else: |
| 681 | dsy = (ny - 1 - yi) / cy |
| 682 | ds = min(dsx, dsy) |
| 683 | xyf_traj.append((xi + cx * ds, yi + cy * ds)) |
| 684 | return ds, xyf_traj |
| 685 | |
| 686 | |
| 687 | # Utility functions |
no test coverage detected
searching dependent graphs…