Using LightGraphs to study ODEproblems

Hi everyone,

I’m studying an ODEProblem where the function have a laplacian operator.

#Domain and grid 
Nx = 40
Ny = 40
lx = 12
ly = 12

# the Laplacian operator
function Laplacian2D(Nx, Ny, lx, ly)
	hx = lx/Nx
	hy = ly/Ny
	D2x = CenteredDifference(2, 2, hx, Nx)
	D2y = CenteredDifference(2, 2, hy, Ny)
	Qx = PeriodicBC(hx |> typeof)
	Qy = PeriodicBC(hy |> typeof)
	
	A = kron(sparse(I, Ny, Ny), sparse(D2x * Qx)[1]) + kron(sparse(D2y * Qy)[1], sparse(I, Nx, Nx))
	return A
end

Now I want to think my problem as a diffusion process on a lattice defined using LightGraphs package where the periodic boundary condition are additive links between the nodes on the lattice border.

What I expect is to find the same solutions from these two different approaches, because I use the same solvers and the only thing changed, the Laplacian (in the lattice it is expressed as laplacian_matrix(h)), would be the same respect the first approach.

But the solutions are different, so what I’m doing wrong? Do you have some hints for this problem?

Thank you so much for the help

Are your constants different?

I saw that the two operators differ only for a constant that multiplies each values. I think that this is due because the lattice has not a dx. Could that be the problem?

It could be. It’s impossible to tell from the code given here.