Skip to content

Commit

Permalink
Fix dostring example output fails
Browse files Browse the repository at this point in the history
  • Loading branch information
mdpiper committed Aug 12, 2023
1 parent b922c3e commit 7b671eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 2 additions & 4 deletions lessons/python/ivy_diffusion/diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ class Diffusion:
>>> m.concentration = np.zeros(m.shape)
>>> m.concentration[int(m.shape/2)] = 5
>>> m.concentration
array([ 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0,
0.0, 0.0])
array([0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0])
>>> m.time
0.0
>>> m.update()
>>> m.time
1.0
>>> m.concentration
array([ 0.0, 0.0, 0.0, 0.0, 1.2, 2.5, 1.2, 0.0,
0.0, 0.0])
array([0.0, 0.0, 0.0, 0.0, 1.2, 2.5, 1.2, 0.0, 0.0, 0.0])
"""

def __init__(self, shape=10, spacing=1.0, diffusivity=1.0):
Expand Down
5 changes: 4 additions & 1 deletion lessons/python/ivy_diffusion/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ def solve1d(concentration, grid_spacing=1.0, time_step=1.0, diffusivity=1.0):
>>> from solver import solve1d
>>> z = np.zeros(5)
>>> z[2] = 5
>>> z
array([0.0, 0.0, 5.0, 0.0, 0.0])
>>> solve1d(z, diffusivity=0.25)
array([ 0.0, 1.2, 2.5, 1.2, 0.0])
>>> z
array([0.0, 1.2, 2.5, 1.2, 0.0])
"""
flux = -diffusivity * np.diff(concentration) / grid_spacing
concentration[1:-1] -= time_step * np.diff(flux) / grid_spacing
Expand Down

0 comments on commit 7b671eb

Please sign in to comment.