Before starting, make sure you've installed the bmi-live package in developer mode. Execute this statement at the command line (not in this notebook!):
$ python setup.py develop
Include one import that we'll use later:
In [1]:
    
import numpy as np
    
Start by importing the Diffusion class from the bmi-live package:
In [2]:
    
from bmi_live import Diffusion
    
Create an instance of the model:
In [3]:
    
m = Diffusion()
    
This instance uses default parameter values set up in the class. View them:
In [4]:
    
print('Number of columns:', m.nx)
print('Number of rows:', m.ny)
print('Spacing between columns:', m.dx)
print('Spacing between rows:', m.dy)
print('Diffusivity coefficient:', m.alpha)
    
    
What does the initial temperature array look like?
In [5]:
    
print(m.temperature)
    
    
Add an impulse to the initial temperature field:
In [6]:
    
m.temperature[3, 3] = 100.0
    
Check that the temperature field has been updated:
In [7]:
    
print(m.temperature)
    
    
Now advance the model by a single time step:
In [8]:
    
m.advance()
    
View the new state of the temperature field:
In [9]:
    
print(m.temperature)
    
    
There's diffusion!
Advance the model to some distant time:
In [10]:
    
distant_time = 10
for _ in range(distant_time):
    m.advance()
    
View the new state of the temperature field (with help from np.set_printoptions):
In [11]:
    
np.set_printoptions(formatter={'float': '{: 6.2f}'.format})
print(m.temperature)
    
    
Note that temperature is set to zero at the boundaries.