- #1
Jonny6001
- 20
- 0
Hi, I have a pseudocode I would like to try and implement and understand the programming of it in python. The physics and maths of the case is no problem, but the implementation of the code in Python is something I'm not familiar with.
The problem is a simple 1D linear convection using finite differences.
I have Python 2.6, Numpy and matplotlib.
I have attached the pseudocode as an image file. I can more or less input this in a form that Python understands but I'm not quite sure how to start off the loops with a value of 'i' and maybe I need to add and increment to 'i' once it has done the loop once?
I mean for a start, I should be able to run the first for loop which says for values of i between 0.5 and 1, the value of 'ui' will be 2, everywhere else ui=1.
Then plot the results in matplotlib.
I have tried this and I get a blank ploot with x-axis around the 20 and y-axis around 1, so the axes are not far off but the increment of the loop is something I'm not getting. By the way, this is my own interest, not a homework or assignment, so there isn't anyone I can ask the most basic quiestions to.
Thanks a lot for your time, I'm sure if I can be shown how to make a start then it will slowly click into place.
The problem is a simple 1D linear convection using finite differences.
I have Python 2.6, Numpy and matplotlib.
I have attached the pseudocode as an image file. I can more or less input this in a form that Python understands but I'm not quite sure how to start off the loops with a value of 'i' and maybe I need to add and increment to 'i' once it has done the loop once?
I mean for a start, I should be able to run the first for loop which says for values of i between 0.5 and 1, the value of 'ui' will be 2, everywhere else ui=1.
Then plot the results in matplotlib.
I have tried this and I get a blank ploot with x-axis around the 20 and y-axis around 1, so the axes are not far off but the increment of the loop is something I'm not getting. By the way, this is my own interest, not a homework or assignment, so there isn't anyone I can ask the most basic quiestions to.
Thanks a lot for your time, I'm sure if I can be shown how to make a start then it will slowly click into place.