I need to solve the following hyperbolic equation in x and phi co-ordinates

$$\frac{\partial \left ( -s/f \right )}{\partial \varphi }+\frac{\partial \left ( 1/f \right )}{\partial x}=0$$

$$\varphi >0\rightarrow f=\left ( 1+\frac{\left ( 1-s \right )\left ( 1+0.4\varphi e^{-x} \right )}{10s} \right )^{-1} $$

$$\varphi <0\rightarrow f=\left ( 1+\frac{1-s}{10s} \right )^{-1}$$

$$\varphi =-0.1x\rightarrow s=0.1,f=0.526$$ $$x=0,\varphi >0\rightarrow s=1,f=1$$

in domain $$0<x<1$$ $$-0.1x<\varphi <1 $$

I am searching for the hyperbolic package that can solve this equation like clawpack, but I don't know how to define my equation there thanks

  • $\begingroup$ yes David , you are right, in the problem I want to solve at initial condition f=0 and 1/f tends to infinity but lets here assume at t=0 s=0.1 and f=0.5 $\endgroup$ Oct 22 '14 at 6:26
  • $\begingroup$ David I edit the equation a little bit, this is exactly the one that I need to solve as you can see its in x and phi coordinate instead of x and time, and I need to deal with different f when phi is negative $\endgroup$ Oct 22 '14 at 8:48
  • $\begingroup$ David,the initial condition is at phi=-0.1x, s=0.1 and the boundary condition is at x=0 $\endgroup$ Oct 22 '14 at 10:31
  • $\begingroup$ It is much clearer now! Are you interested in solutions after characteristics cross? Do you have some basis for determining a meaningful weak solution after characteristics cross? $\endgroup$ Oct 23 '14 at 7:31
  • $\begingroup$ I am familiar with the analytical solution (self similar and method of characteristics) of first order hyperbolic equations and shock condition, but I never solved them numerically.do you think I can solve this equation by method of characteristics? $\endgroup$ Oct 23 '14 at 12:13

Since you have a scalar problem in one space dimension, it shouldn't be too difficult to come up with a semi-analytic solution using the method of characteristics. Here's something to get you started.

The problem can be written in a nicer form if you define $g=1/f$. Then you can solve for $s$ to find

$$s(g,x,\phi) = \frac{\alpha(x,\phi)}{\alpha(x,\phi) + g - 1}$$


$$\alpha(x,\phi) = \begin{cases} \frac{1+\frac{4}{10}\phi e^{-x}}{10} & \phi>0 \\ \frac{1}{10} & \phi \le 0.\end{cases}$$

Then your conservation law is simply

$$g_x - \left( s(g,x,\phi) g \right)_\phi = 0,$$

which looks like a traditional scalar hyperbolic PDE. The method of characteristics will allow you to find solutions up to the "time" when characteristics cross. You will probably need a Newton solver and an ODE solver to implement the method.

In case you want to compute an approximate solution by numerical discretization, I recommend the following:

  • If you know your solutions do not contain shocks, then I would just code up a simple finite difference discretization of the equation above (for instance, using Python or MATLAB and centered differences).
  • If you need to compute solutions with shocks, then more sophisticated methods are called for. You might consider using PyClaw (disclaimer: I'm a PyClaw developer).
  • $\begingroup$ I am working on the semi analytic solution but do you know any package that can solve this numerically, to compare the result $\endgroup$ Oct 27 '14 at 22:54

This is just a small addition to David Ketcheson's comments about solving numerically.

If you want to obtain a numerical solution using MATLAB, Lawrence Shampine has written a MATLAB solver for hyperbolic PDEs that is designed to be (relatively) easy to use. If you look about half-way down this page:


you will see a section titled "Hyperbolic PDEs" that has links to his paper and MATLAB code for this capability. Because it is written entirely in MATLAB code, the "installation" is trivial.

  • $\begingroup$ +1. But the difficulty with using this (or most other) software is that the problem has "initial values" given along a line that does not align with either of the coordinate axes. The easiest approach would probably be to rotate coordinates before using something like this. $\endgroup$ Nov 2 '14 at 4:57
  • $\begingroup$ yes David, you are right, I need to rotate the initial condition line $\endgroup$ Nov 3 '14 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.