I have solved 1d shock tube problem. (Euler's equations). Using following steps:
1) Define Riemann problem over the domain
2) Carry out local linearisation
3) Based on linearisation, write eigen values and eigenvectors
4) Use upwinding, i.e. find out numerical flux and use update equation

When I implemented above strategy in Matlab, it worked fine. But 'same' problem was when coded in python, it showed problem for some values of the left and right states. When the left and right states were altered to some new parameters, it worked fine and got the expected results.

Why should this happen?

Is this a problem with python, or the 'thinking' strategy of python and matlab are different?

I used numpy for defining arrays and matrices. I used numpy.linalg.solve() function for finding the vector of characteristic variables and hence the vector of flux differences. I used pylab.plot(X,Y) for plotting.

(I cross checked the program several times. I guess there is no problem with it. And it runs well... its just that the graphs given are not correct for some values of the left and right states)

  • 1
    $\begingroup$ Statements like this always need details: "it showed problem for some values of the left and right states". Explain what is different, show input and output. Can you narrow the source of error down by running different parts of the code separately? $\endgroup$
    – Jed Brown
    Jun 4 '12 at 11:51

I guess the problem is with the pressure conditions I gave.
1) condition 1
Domain divided equally in 101 number of points. Two halves are defined as


velocity=0 everywhere: resultsenter image description here

2) Condition 2:

density and velocity same as above

enter image description here

Whereas on matlab, I checked only on 2nd case (but with the same code). which on python is also working fine. So i guess my question was not mature, and I should have done this work before asking it.Here is high resolution picture taking 501 equally spaced points on domain:

enter image description here

I think the nature of graph in first case is because the method can not handle this big jump in pressure.

(surprisingly when pressure and density both were set to [10:1], it worked well!) (any inputs on this are welcome)


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