Reputation: 2442
I am new to Theano, and I try to implement a numerical integrator of a reaction-diffusion system - FitzHugh–Nagumo model of this version:
For now my expressions are:
import theano as th
import theano.tensor as T
u = T.dmatrix('u')
v = T.dmatrix('v')
e = T.dscalar('e')
a0 = T.dscalar('a0')
a1 = T.dscalar('a1')
dudt = u - u**3 -v
dvdt = e*(u - a1*v - a0)
So I haven't implemented the finite-differences laplacian operator yet. My question is whether there is a smart way of doing it in Theano?
Upvotes: 8
Views: 1268
Reputation: 865
An interesting example of a similar, but simpler problem, solved using convolutional networks on Google's tensorflow can be found here:
https://www.tensorflow.org/versions/r0.7/tutorials/pdes/index.html
In particular they use the following definition of the diffusion kernel:
laplace_k = make_kernel([[0.5, 1.0, 0.5],
[1.0, -6., 1.0],
[0.5, 1.0, 0.5]])
Upvotes: 2
Reputation: 1183
Is there any reason for using Theano? There are other ways in Python to solve a system of coupled non-linear ODEs.
The reaction-diffusion system definition from Google seems to suggest that u(x,y,t), v(x,y,t).
I am not a user of Theano, but it looks like casting the problem in the form of an equation like b = Ax is the way to go.
Some resources that I came across on Google for using Theano and generally solving PDEs are below.
Expressing the Laplacian using Theano
Solving a reaction-diffusion problem using numpy
Github project using Theano to solve the shallow water PDE
Upvotes: 4
Reputation: 308908
I see two coupled, first order, non-linear, ordinary differential equations here.
Update: Now your equations are clear - Laplacians are there; two coupled nonlinear PDEs. Much better.
You need a finite difference or finite element approach for your spatial discretization. Your choice, of course, but I'd prefer a finite element approach over finite differences.
You also need some kind of numerical integration in time. An implicit error correcting scheme would be best.
I looked quickly at the Theano docs. I didn't see anything to help you with your spatial discretization problem. Once you accomplish that you'll have matrix equations that you can solve, but I don't believe Theano will help you formulate the problem.
I'll admit that I'm not a Theano maven.
Upvotes: 1