# I wanted to generate a contour plot for 2D heat conduction by neural PDE but this code generates blank plot without any contour

**URL:** https://discourse.julialang.org/t/i-wanted-to-generate-a-contour-plot-for-2d-heat-conduction-by-neural-pde-but-this-code-generates-blank-plot-without-any-contour/103960
**Category:** Visualization
**Tags:** question, plotting
**Created:** [September 18, 2023, 12:59am UTC](https://discourse.julialang.org/t/i-wanted-to-generate-a-contour-plot-for-2d-heat-conduction-by-neural-pde-but-this-code-generates-blank-plot-without-any-contour/103960 "2023-09-18T00:59:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ShadmanSakief](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shadmansakief/32/51586_2.png) [@ShadmanSakief](https://discourse.julialang.org/u/ShadmanSakief)
#### Post date: [September 18, 2023, 12:59am UTC](https://discourse.julialang.org/t/i-wanted-to-generate-a-contour-plot-for-2d-heat-conduction-by-neural-pde-but-this-code-generates-blank-plot-without-any-contour/103960/1 "2023-09-18T00:59:28Z")

</div>

using NeuralPDE, Lux, Optimization, OptimizationOptimJL  
import ModelingToolkit: Interval

@parameters x y  
@variables u(..)  
Dxx = Differential(x)^2  
Dyy = Differential(y)^2  
Dx = Differential(x)  
Dy = Differential(y)

# 2D PDE

eq = Dxx(u(x, y)) + Dyy(u(x, y)) ~ -(1e-6/0.238)

# Boundary conditions

bcs = [Dx(u(0, y)) ~ 0.0, Dx(u(2, y)) ~ 0.0,  
Dy(u(x, 0)) ~ 0.0, Dy(u(x, 1)) ~ (5e-5/0.238)\*(298-u(x, 1))]

# Space and time domains

**domains = [x ∈ Interval(0.0, 2.0), y ∈ Interval(0.0, 1.0)]**

# Neural network

dim = 2 # number of dimensions  
chain = Lux.Chain(Dense(dim, 16, Lux.σ), Dense(16, 16, Lux.σ), Dense(16, 1))

# Discretization

dx = 0.05  
discretization = PhysicsInformedNN(chain, GridTraining(dx))

@named pde\_system = PDESystem(eq, bcs, domains, [x, y], [u(x, y)])  
prob = discretize(pde\_system, discretization)

#Optimizer  
opt = OptimizationOptimJL.BFGS()

#Callback function  
callback = function (p, l)  
println(“Current loss is: $l”)  
return false  
end

res = Optimization.solve(prob, opt, callback = callback, maxiters = 1000)  
phi = discretization.phi

using Plots

xs, ys = [infimum(d.domain):(dx / 10):supremum(d.domain) for d in domains]

u\_predict = reshape([first(phi([x, y], res.u)) for x in xs for y in ys],  
(length(xs), length(ys)))

p1 = plot(xs, ys, u\_predict, linetype = :contourf, title = “predict”);  
plot(p1)`

`> Preformatted text`

`

---

<div class="post-metadata">

### Author: ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)
#### Post date: [September 18, 2023, 7:18am UTC](https://discourse.julialang.org/t/i-wanted-to-generate-a-contour-plot-for-2d-heat-conduction-by-neural-pde-but-this-code-generates-blank-plot-without-any-contour/103960/2 "2023-09-18T07:18:27Z")

</div>

Please put your code in triple backticks, as described here

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

otherwise it’s very tedious to copy and run the code.

What are the package/Julia versions you are using here?

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [September 18, 2023, 8:44am UTC](https://discourse.julialang.org/t/i-wanted-to-generate-a-contour-plot-for-2d-heat-conduction-by-neural-pde-but-this-code-generates-blank-plot-without-any-contour/103960/3 "2023-09-18T08:44:42Z")

</div>

What is the output of

```julia
versioninfo()

```

What is the output of

```julia
using Pkg
Pkg.status()

```

?

---

<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: [September 25, 2023, 12:03pm UTC](https://discourse.julialang.org/t/i-wanted-to-generate-a-contour-plot-for-2d-heat-conduction-by-neural-pde-but-this-code-generates-blank-plot-without-any-contour/103960/4 "2023-09-25T12:03:54Z")

</div>

I think I answered this question on Slack and it was just older packages held back by having some random un-updated thing in the global environment.
