# Boundary conditions (?) in MethodOfLines.jl PDE

**URL:** <https://discourse.julialang.org/t/boundary-conditions-in-methodoflines-jl-pde/91725>\
**Category:** Modelling & Simulations\
**Tags:** package\
**Created:** [December 16, 2022, 4:40am UTC](https://discourse.julialang.org/t/boundary-conditions-in-methodoflines-jl-pde/91725 "2022-12-16T04:40:03Z")\
**Posts on this page:** 4\
**Page:** 2

<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:** [July 6, 2023, 11:34am UTC](https://discourse.julialang.org/t/boundary-conditions-in-methodoflines-jl-pde/91725/21 "2023-07-06T11:34:44Z")

</div>

> [@mkretzschmar](#):
>
> and strangely, I get exactly the same plot.

That is because the vectors for `t` and `a` are the same length in your particular example (they also have the same entries). If you change one of them, for example choose `dt = tmax/1000.0` you will see the problem.

Yes, in `heatmap` you should first give the values for the x-axis and then the y-axis, but which is which has to match the actual data. In this case, `sol_pde[S(t, a)]` has the time points along the first dimension (which is “down”, so it corresponds to the _y-axis_ when you would plot a matrix) and the space points along the second dimension (which is “sideways”, so it corresponds to the _x-axis_ ).

So another solution to fix the plot would be to just transpose the matrix, i.e. plot `transpose(soln)` to flip the order of the axes without having to change anything else.

(I find it’s a little bit like USB-A plugs … I usually need at least two tries to figure out the right order of the axes when plotting heatmaps – choosing differently-sized ranges for the x- and y- directions can help to spot the difference 😃 )

---

<div class="post-metadata">

**Author:** ![mkretzschmar](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@mkretzschmar](https://discourse.julialang.org/u/mkretzschmar)\
**Post date:** [July 6, 2023, 11:43am UTC](https://discourse.julialang.org/t/boundary-conditions-in-methodoflines-jl-pde/91725/22 "2023-07-06T11:43:13Z")

</div>

Great! thanks a lot, that clarifies everything!

---

<div class="post-metadata">

**Author:** ![Michiel\_van\_Boven](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michiel_van_boven/32/203668_2.png) [@Michiel\_van\_Boven](https://discourse.julialang.org/u/Michiel_van_Boven)\
**Post date:** [November 7, 2023, 3:17pm UTC](https://discourse.julialang.org/t/boundary-conditions-in-methodoflines-jl-pde/91725/23 "2023-11-07T15:17:46Z")

</div>

Dear Sevi,

Thanks for the hepl so far. With @mkretzschmar and @chvandorp I am now trying to extend the model to add a contact function c(a,b) to the model, specifying the rate at which individuals of age a make contact with individuals of age b. For this to work we would need to replace the integral over a in the above model (Ia(I(t,a))) with the integral (over the whole domain) over b of c(a,b)\*I(b,t). So far we have been unsuccessful getting this to work.

Building on [https://github.com/SciML/MethodOfLines.jl/blob/master/docs/src/tutorials/PIDE.md](https://github.com/SciML/MethodOfLines.jl/blob/master/docs/src/tutorials/PIDE.md) we have gone through various attempts using intermediate variables along the lines

Y(t, a, b) ~ c\_rate(a, b) \* I(t, b),  
X(t, a) ~ Ia(Y(t, a, b)),

where b is an additional parameter and X and Y are new intermediate variables. Also included are (I believe) proper boundary conditions for Y, i.e

Y(tmin, a) ~ c\_rate(a, a) \* I(tmin, a),  
Y(t, amin) ~ c\_rate(amin, amin) \* I(t, amin)

Any suggestions how we could proceed with this?

---

<div class="post-metadata">

**Author:** ![sdwfrost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdwfrost/32/2831_2.png) [@sdwfrost](https://discourse.julialang.org/u/sdwfrost)\
**Post date:** [November 8, 2023, 4:36pm UTC](https://discourse.julialang.org/t/boundary-conditions-in-methodoflines-jl-pde/91725/24 "2023-11-08T16:36:14Z")

</div>

It’s been a while since I looked at this; as I never really got my head around this, in the meantime, you could try a simple discretization approach, so this isn’t a blocker. See [Help with speeding up large ODE system from ModelingToolkit - Specific Domains / Modelling & Simulations - Julia Programming Language (julialang.org)](https://discourse.julialang.org/t/help-with-speeding-up-large-ode-system-from-modelingtoolkit/98903/1), although the simplification takes quite a while.

[Previous page](https://discourse.julialang.org/t/boundary-conditions-in-methodoflines-jl-pde/91725.md?page=1)
