April 2019
Intermediate to advanced
426 pages
11h 13m
English
The Python implementation of the implicit scheme is given in the following FDImplicitEu class. We can inherit the implementation of the explicit method from the FDExplicitEu class we discussed earlier and override the necessary methods of interest, namely, the setup_coefficients and traverse_grid methods:
In [ ]: import numpy as np import scipy.linalg as linalg """ Explicit method of Finite Differences """ class FDImplicitEu(FDExplicitEu): def setup_coefficients(self): self.a = 0.5*(self.r*self.dt*self.i_values - (self.sigma**2)*self.dt*\ (self.i_values**2)) self.b = 1 + \ (self.sigma**2)*self.dt*\ (self.i_values**2) + \ self.r*self.dt self.c = -0.5*(self.r*self.dt*self.i_values ...
Read now
Unlock full access