# How to start Partial Differential Equation (PDE) Solving in Julia for modified Wave Equation

**URL:** <https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555>\
**Category:** Numerics\
**Created:** [September 13, 2020, 5:03pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555 "2020-09-13T17:03:02Z")\
**Posts on this page:** 20\
**Page:** 2

<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 14, 2020, 11:56pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/21 "2020-09-14T23:56:23Z")

</div>

I completely forgot, but here’s a whole article and a JuliaCon workshop that goes through how to do this stuff “by hand” with loops, ApproxFun, DiffEqOperators, etc. It does a lot on heat equations, but it should be clear that what you get out of the spatial discretizations is second order ODEs which you can either do implicitly like the spatial parts or just solve the second order ODE:

> **[Solving PDEs in Julia](https://nextjournal.com/sosiris-de/pde-2018)**
>
> How are finite elements, multigrid methods, ODE solvers, etc. all the same topic?

[![](https://global.discourse-cdn.com/julialang/original/3X/3/4/34c6d6d79a98fdaa07cab08eced8b33d76b08735.jpeg "JuliaCon 2018 | Solving Partial Differential Equations with Julia | Chris Rackauckas") ](https://www.youtube.com/watch?v=okGybBmihOE)

You can then grab something like [Allen–Cahn equation - Wikipedia](https://en.wikipedia.org/wiki/Allen%E2%80%93Cahn_equation) and make sense of it as a discretization in a way like [https://benchmarks.sciml.ai/html/MOLPDE/allen\_cahn\_fdm\_wpd.html](https://benchmarks.sciml.ai/html/MOLPDE/allen_cahn_fdm_wpd.html)

---

<div class="post-metadata">

**Author:** ![CosmoProf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cosmoprof/32/15516_2.png) [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Post date:** [September 15, 2020, 12:01am UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/22 "2020-09-15T00:01:19Z")

</div>

Ok thanks, the pull/250 article is interesting, though I didn’t see anything with double time derivatives, Dtt, that looks like a wave equation.

All I can do now is read through all these package descriptions, if there’s any further info or developments, please let me know; code sample suggestions always welcome.

---

<div class="post-metadata">

**Author:** ![CosmoProf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cosmoprof/32/15516_2.png) [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Post date:** [September 15, 2020, 12:03am UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/23 "2020-09-15T00:03:20Z")

</div>

The article & video look interesting, I’ll check them out.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 15, 2020, 12:21am UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/24 "2020-09-15T00:21:45Z")

</div>

Sorry, bad handwriting. That actually is F\_X. eta is the test function, which is one of the basis functions of the expansion F( X) = \sum\_i N\_i(X) F\_i.  
Once that expansion is plugged into the integrals, the formulation resolves into a system of coupled ordinary differential equations.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 15, 2020, 12:22am UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/25 "2020-09-15T00:22:25Z")

</div>

So, what about it? What does the PDE problem look like?

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [September 15, 2020, 7:02am UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/26 "2020-09-15T07:02:53Z")

</div>

What are the boundary conditions? I feel your PDE has an analytical solution

---

<div class="post-metadata">

**Author:** ![CosmoProf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cosmoprof/32/15516_2.png) [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Post date:** [September 15, 2020, 5:55pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/27 "2020-09-15T17:55:00Z")

</div>

Rveltz, I would dearly love for there to be an analytical solution, but the function G(t,x) is non-separable in t & z, so how is that possible?

In addition to terms dependent upon t alone, G(t,x) it has terms like Exp[Sin(t-x)], which cannot be separated. So how can one derive an analytical solution?

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [September 15, 2020, 6:02pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/28 "2020-09-15T18:02:20Z")

</div>

> [@CosmoProf](#):
>
> G(t,x) \* F(t,x)

I am guessing this is a convolution in x?

---

<div class="post-metadata">

**Author:** ![CosmoProf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cosmoprof/32/15516_2.png) [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Post date:** [September 15, 2020, 6:04pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/29 "2020-09-15T18:04:23Z")

</div>

No. It is a function G times a function F.  
G(t,x) is known, F(t,x) is the function to be solved for in the differential equation.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 15, 2020, 6:21pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/30 "2020-09-15T18:21:42Z")

</div>

What about the BCs? And ICs?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 15, 2020, 7:30pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/31 "2020-09-15T19:30:43Z")

</div>

> [@CosmoProf](#):
>
> I’m not looking for a quick-and-dirty solution. I need an absolutely unimpeachable solution to this equation, a “bet my reputation on it” solution. […] I am new to Julia (and to numerical work on PDE’s), and I didn’t want to kludge something together that might produce nonsense results.

I think you have no choice here but to really learn something about numerical methods for PDEs. Method of Lines would probably be a good starting point since your equations are likely to be quite stiff (since your coefficient G varies by 10 orders of magnitude), you are in 1+1 dimensions, and it lets you exploit an ODE solver in time so you only need to understand spatial discretization. The fundamental thing to realize here is that solving PDEs is **not just a small step up from solving ODEs.**

For ODEs, there are “cookie-cutter” methods that handle 99% of problems well — you write a function for your right-hand-solver, throw it blindly at an generic adaptive-stepsize routine using one of the [common algorithm choices](https://diffeq.sciml.ai/stable/tutorials/ode_example/#Choosing-a-Solver-Algorithm), maybe try a couple of different algorithm choices to see which is faster, and you’re done. Most people don’t really need to know how the methods work internally, because they are so robust.

For PDEs, there are a lot more choices, a lot less automation, and much less robustness, so you really need to know something about how the methods work in order to use them effectively. We can give you a few pointers (e.g. try ApproxFun, try finite differences in x with MOL in t, …), but you will need to go and read something about how those methods work. You can also try the literature in your field — mimic how other people solve the same equations.

---

<div class="post-metadata">

**Author:** ![CosmoProf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cosmoprof/32/15516_2.png) [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Post date:** [September 15, 2020, 7:46pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/32 "2020-09-15T19:46:07Z")

</div>

Stevengi, those are good points, and I’m doing all of those things, while simultaneously asking for help on this discussion board. Learning the mathematical methods doesn’t provide concrete examples for how to code them in Julia.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 15, 2020, 8:04pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/33 "2020-09-15T20:04:55Z")

</div>

How about you give us the info I asked for? Then we might be able to help you…

---

<div class="post-metadata">

**Author:** ![CosmoProf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cosmoprof/32/15516_2.png) [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Post date:** [September 15, 2020, 8:14pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/34 "2020-09-15T20:14:58Z")

</div>

PetrKrys, the Initial and Boundary Conditions are whatever you want them to be. You don’t need them to either find analytical solutions or to construct numerical solution algorithms. Those are applied at the end. That’s how differential equations work.

As for the equation itself, you have that in my very first post, with all the information needed to address my questions. I am not yet publishing the full form of G(t,x), that is not needed to answer my questions.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 15, 2020, 8:19pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/35 "2020-09-15T20:19:26Z")

</div>

The boundary conditions are absolutely critical. For instance, is your domain bounded? One-sided or extending to infinity on both sides? If the domain is infinite, what is the boundary condition at infinity? F=0?

The form of G is obviously of crucial importance. If it is rapidly varying, that will determine the method that can be applied to solve the ODEs. The method may have to be adaptive in order to capture rapid transitions in the behavior.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 15, 2020, 8:20pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/36 "2020-09-15T20:20:25Z")

</div>

I have to say I don’t get it: you want help, but you won’t answer questions, and you’re pretty sparing with information.

---

<div class="post-metadata">

**Author:** ![CosmoProf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cosmoprof/32/15516_2.png) [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Post date:** [September 15, 2020, 8:26pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/37 "2020-09-15T20:26:31Z")

</div>

PetrKrysUCSD,

t \> 0 .  
-Infinity \< x \< +Infinity.  
As explained above, I will only be modelling a small range in both.

I do not know the boundary conditions because I haven’t figured out yet what makes sense. I still do not know how that is relevant to constructing analytical or numerical solutions in general. They are applied at the end.

I have given tons of information about G(t,x), more than enough to address the problem, I am not publishing the full function yet.

PetrKrysUCSD, every single time you have responded to a post of mine on this discussion board, you have sent me on a wild goose chase. Please do not feel the need to respond to my future posts.

I remain grateful to everyone else for their suggestions.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [September 15, 2020, 8:34pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/38 "2020-09-15T20:34:24Z")

</div>

I may be wrong, but I would say that ApproxFun is your first best bet in x=1d, the least technical on the numerical side. You can write you pde very closely to the mathematical formulation. It will be slow but the result will be super precise.

Then if you want speed, finite elements would be good or the MOL as many suggested before.

---

<div class="post-metadata">

**Author:** ![CosmoProf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cosmoprof/32/15516_2.png) [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Post date:** [September 15, 2020, 8:40pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/39 "2020-09-15T20:40:32Z")

</div>

Rveltz, thanks, I’m reading whatever documentation I can find on ApproxFun. (I’m reading about ten different things simultaneously after all the suggestions, plus still doing calculations on paper to figure out the initial conditions, so it’s taking me time to catch up to the discussion and have more precise questions to ask.)

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 15, 2020, 8:44pm UTC](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555/40 "2020-09-15T20:44:05Z")

</div>

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

[Previous page](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555.md?page=1)

[Next page](https://discourse.julialang.org/t/how-to-start-partial-differential-equation-pde-solving-in-julia-for-modified-wave-equation/46555.md?page=3)
