Using Python DAE solver for coupled equations in time and space

223 Views Asked by At

I would like to solve two coupled equations in time and space, using the scikits.odes.dae solver.

My equations are as follows:

dy1/dt = dy1/dz + y2

y1 = 5 * y2

The code I have written is the following

import matplotlib.pyplot as plt
import numpy as np
from scikits.odes import dae

N  = 51 #number os spacesteps
L  = 1.0 #[m] length of sorbent bed, also a guess 
dz = L/(N-1) #[m] length of space step

time = np.arange(0, 1.5, 0.1)
dydz = 1

y0 = [1, 0.2] #initial values y0[0] = y1 and y0[1] = y2
yp0 = [1, 1] #initial guess for \dot{y1} and \dot{y2}

def trial_space(t, y, ydot, result):
    result[0] = ydot[0] - 6 * dydz + y[1]
    result[1] = y[0] - 5 * y[1]

solver = dae('ida', trial_space)
solution = = solver.solve(time, y0, yp0)

Currently, I am feeding the solver a constant value of dydz, but actually I would like to use a central differencing scheme to obtain dy/dz[i] = (y[i+1] - y[i-1])/(2*dz)

How do I integrate this into the solver?

0

There are 0 best solutions below