Even trivial operations, when placed in a loop, become dead slow. The reason is that in interpreted languages (like MATLAB or Python), each operation you do adds a lot of overhead behind the scenes. Several years ago, it used to be true that same code would also run very slow in MATLAB. If np.sum(np.sum(temp-tempInit)) <= 1e-6: My computer is a Sager Laptop (4 physical cores) I cannot simply wait 6 minutes to this Python code to converge.Īs a curiosity, If you were to ran this code in you computer, what is the elapsed time ? If I leave this to converge it Matlab it took 14218 iterations in almost 3 seconds. Is there any setting intrinsic to Conda or P圜harm to get this code to run in a reasonable amount of time? Specially because I've set a fixed 1000 iterations. And just for good measure I ran the same code with Spyder: 20 seconds! I also ran it with Jupyter and it took also 20 seconds. I tried to translate the same code to Python and ran it with P圜harm using the Conda environment at a staggering 24 seconds. My original code in Matlab follows below and it ran 1000 iterations in around 0.20 seconds. So to start I went to do some fluid dynamics and heat transfer exercises, starting with the basic 2D heat conduction. I have a programming interview test next week and I have to program in Python and I was practicing a little because this term I was using Matlab primarily for classes, but luckily the prior term our team decided to use Python.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |