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.(adsbygoogle = window.adsbygoogle || []).push({});

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 in to place.

**Physics Forums - The Fusion of Science and Community**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# 1D Linear Convection Python

Loading...

Similar Threads - Linear Convection Python | Date |
---|---|

Linear Regression, etc : Standard vs ML Techniques | Dec 27, 2017 |

C/++/# Rounding error making my graphics barely off? | Feb 23, 2017 |

Fortran How to change data from linear scale to log scale | Nov 30, 2016 |

Eigenword embeddings and spectral learning; I'm a beginner... | Jun 12, 2015 |

1D linear convection with C++ | Mar 21, 2011 |

**Physics Forums - The Fusion of Science and Community**