Feeds:
Posts

## Simulating PDE on graphs in R

In R schematically we start with absolute value for undirected graphs and then we can modify this for metric directed graphs if need be easily.  The main issue is to keep functions as n*n matrices with vertex values along the diagonal.  Then the adjacency matrix can be used for gradient calculation.

Since we’re interested first in evolution equations, all we have to do is just evolve in the obvious way in discrete time steps.

d/dt u(x,t0) = (all the terms that required at time t_0)

So then

u(x,t_{k+1}) = u(x,t_k) + (all the terms of the PDE besides d/dt u)

So the only problem is to calculate the terms not involving d/dt and just plugging in.  This can be done right away and then tomorrow I can start playing with simulations of Navier-Stokes-like PDE.

n<-length(vertices(graph))

for (i in 1:n){
for (j in 1:j){
if (A[i,j]>0){
}
}
}

}
graph.dot<-function(F0,F1,graph){
n<-length(vertices(graph)
s<-0
for (i in 1:n){
for (j in 1:j) {
if (A[i,j]>0){
s<-s+ F0[i,j]*F1[i,j]
}
}
}
s
}
flow.ns<-function(u0, graph,timesteps,epsilon){
H<-graph.laplacian(graph)
diffusion<- H%*%u0
flow<-matrix(0,nrow=n*n,ncol=timesteps)
u[0,:]<-flatten(u0)
uk<-u0
for (t in 1:timestep){