# How to discretize and solve a 3D Poisson Equation with Dirichlet boundary conditions owing to DifEqOperators

**URL:** <https://discourse.julialang.org/t/how-to-discretize-and-solve-a-3d-poisson-equation-with-dirichlet-boundary-conditions-owing-to-difeqoperators/40681>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [June 3, 2020, 3:24pm UTC](https://discourse.julialang.org/t/how-to-discretize-and-solve-a-3d-poisson-equation-with-dirichlet-boundary-conditions-owing-to-difeqoperators/40681 "2020-06-03T15:24:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RenaudV](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@RenaudV](https://discourse.julialang.org/u/RenaudV)\
**Post date:** [June 3, 2020, 3:24pm UTC](https://discourse.julialang.org/t/how-to-discretize-and-solve-a-3d-poisson-equation-with-dirichlet-boundary-conditions-owing-to-difeqoperators/40681/1 "2020-06-03T15:24:02Z")

</div>

I love the following example of solving a 1D Poisson equation with DiffEqOperators.  
However , I struggle to do the analog 3D example. Can somebody indicate me the right steps?

using DiffEqOperators, Plots  
#Poisson Eq in 1D  
#`Δu = f` with boundary conditions `u(0) = 0` and `u(1) = 0`

Δx = 0.1  
x = Δx:Δx:1-Δx # Solve only for the interior: the endpoints are known to be zero!  
N = length(x)  
f = sin.(2π\*x)

Δ = CenteredDifference(2, 2, Δx, N)  
bc = Dirichlet0BC(Float64)  
u = (Δ\*bc) \ f

u\_analytic(x) = -sin(2π\*x)/4(π^2)

plot(x, u)  
plot!(x, u\_analytic.(x))

In 3D, I could define Δ as:

Δxx = CenteredDifference{1}(2,2,Δx,N)  
Δyy = CenteredDifference{2}(2,2,Δx,N)  
Δzz = CenteredDifference{3}(2,2,Δx,N)  
Δ = Δxx + Δyy + Δzz

But then, what to do ?  
Thanks in advance for any kind of answer …
