-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Li Lin's final project #19
base: master
Are you sure you want to change the base?
Conversation
Your code looks like C code (or worse, fortran) forcefully made to work in Python. Global variables are a terrible idea! They are dangerous and go against the idea of modularization—the reason for writing functions. If you need a variable inside a function, you should pass it as an argument. If you want to change a variable in the function, you need to Anytime you have a double (or worse, triple) loop, you should ask yourself if there is another way to write that code. This is the Python way! Nesting loops is slow, ugly and most of the time, not necessary. Things for you to think about in the future, as you progress in your Python skills. :-) |
Thanks for your suggestion. You are right, my program runs very slow. Since it is so complicated, I got a very hard time to make it done. When I was trying to use local variables instead of global ones, I was afraid to make it more complex and make mistakes. I think I need more practice in the future. Sent from my iPad
|
Since you are a member of Prof. Michael Keidar's research group, I'm sure that the work you did here is useful to you in that role. For that reason, I hope you will be motivated to do some work to improve it. Here is a detailed review of your work to help you out. The title of the notebook is long! Some of the details could be moved to an introductory paragraph, allowing for a less cumbersome title. How about: "Such a "leapfrog" is called Particle in Cell (PIC) method." This sentence ends a confusing paragraph, overall, and it does not really make sense. I wonder if your have some concepts mixed up. In the course, you learned about the leapfrog method in Module 1/Lesson 4 Equation (3)—>the continuous equation that relates E with phi has not appeared previously, yet we have a discretized form here. And are you sure there should be a 2 in the denominator? If what you have on the r.h.s. is the gradient of phi, and on the numerator you have phi at points i+1 and i ... or is there a typo in the numerator? Embedded figures: the illustrations you include in this notebook are from un-cited sources. This should be avoided: if these figures come from a copyrighted work, you could claim fair use and include them with a credit line; if they are from a licensed source, you should still include the image credit! You are defining a constant You also define other float constants using factors like For the dependent variables, you have defined separate NumPy arrays for each component, e.g., E_x, E_r, E_theta. A better idea is to combine these into an array of arrays. You have too many variables in this code, which makes it unwieldy! I already mentioned in my previous comment that global variables are a terrible idea. That is another issue with your code. Did you base this code on an existing code in Keidar's group? In sum, this is a valiant effort, but I think you went about it the wrong way. I'm guessing you had an existing code that you attempted to adapt. Like we have demonstrated in this course, a better way to manage the development of a new code is to start simple, build modularly, test along the way, and think about optimizations after you've proven correctness. Typos and Style a little bit more complicate—>complicated commonly choose Xe as the fuel, since its low ionization energy—>Xe is commonly chosen as the fuel, due to its low ionization energy effected by the magnets—>affected by the magnets definations—>definition |
Thank you for your comments. My project is not based on any exists codes before. We did a programming homework in Prof. Keidar's class but it was a very simple program to show some spiral trajectory of charged particles in B and E fields. This project is my first time to try a complete simulation. I am very appreciate to have a chance to do that in your class. I checked my Wakari notebook again. It seems that I damaged my code when I was editing text. If you want, I can show you a backup copy of my code which is complete and can run well but with a incomplete teaching text. It was a backup save in my half way. I am sure I will keep working on that code for my future research of plasma in Keidar's team. I learned a lot in your class, and I will keep following the future numerical methods class online. Thanks again for your comments, it is a great help for me to improve my code. Happy New Year! |
No description provided.