# Using LightGraphs to study ODEproblems

**URL:** https://discourse.julialang.org/t/using-lightgraphs-to-study-odeproblems/69545
**Category:** Graphs
**Tags:** lightgraphs, ode, lattices
**Created:** [October 11, 2021, 8:38am UTC](https://discourse.julialang.org/t/using-lightgraphs-to-study-odeproblems/69545 "2021-10-11T08:38:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Frazze](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frazze/32/25142_2.png) [@Frazze](https://discourse.julialang.org/u/Frazze)
#### Post date: [October 11, 2021, 8:38am UTC](https://discourse.julialang.org/t/using-lightgraphs-to-study-odeproblems/69545/1 "2021-10-11T08:38:35Z")

</div>

Hi everyone,

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

```julia
#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](https://github.com/sbromberger/LightGraphs.jl) 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

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [October 11, 2021, 4:19pm UTC](https://discourse.julialang.org/t/using-lightgraphs-to-study-odeproblems/69545/2 "2021-10-11T16:19:02Z")

</div>

Are your constants different?

---

<div class="post-metadata">

### Author: ![Frazze](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frazze/32/25142_2.png) [@Frazze](https://discourse.julialang.org/u/Frazze)
#### Post date: [October 14, 2021, 9:20am UTC](https://discourse.julialang.org/t/using-lightgraphs-to-study-odeproblems/69545/3 "2021-10-14T09:20:50Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [October 14, 2021, 10:41am UTC](https://discourse.julialang.org/t/using-lightgraphs-to-study-odeproblems/69545/4 "2021-10-14T10:41:33Z")

</div>

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