# Codes for integrating and plotting ODEs using python
#
# Paul J. Atzberger, http://atzberger.org/
#
from scipy.integrate import odeint
import numpy as np; import matplotlib; import matplotlib.pyplot as plt;

# Adjust plotting parameters
fontsize = 14;
font = {'family' : 'DejaVu Sans',
        'weight' : 'normal',
        'size'   : fontsize};

matplotlib.rc('font', **font);

# Setup the function f(y,t) for RHS dy/dt = f(y,t).
def f1(y, t, a):    
    f = -a*y;
    return f;

# Setup for the initial value problem
a = 2.0; 
y0 = 3.0; 

# Construct numerical approximation to the solution of the ODE
t = np.linspace(0, 10, 101);
sol = odeint(f1, y0, t, args=(a,));

# Plot the solution
plt.figure(1,figsize=(8,6),facecolor='white');
plt.plot(t,sol[:,0],'b',label=r'$y(t)$');
plt.legend(loc='best');
plt.xlabel('t')
plt.ylabel(r'$y$')
plt.title(r'Solution $y(t)$');
#plt.grid();
#plt.draw();
plt.show();

