Python Simulation

This area is for ADVANCED theory and discussions only. If you just joined fusor.net, chances are this is NOT the area for you to be posting.
Wyatt Sheffield
Posts: 1
Joined: Fri Aug 30, 2019 3:27 am
Real name: Wyatt Sheffield
Contact:

Re: Python Simulation

Post by Wyatt Sheffield » Sun Sep 22, 2019 4:21 pm

This simulation, while no doubt quite accurate takes a loooong time to compute. If we are wanting to simulate individual particles, I think it might be more effective to calculate the field and forces at the position of each particle only. Of course, if there are n charged particles in the simulation it will run in O(n^2) time - that is, if it takes 1 second to calculate the forces and fields on 1000 particles, it would take 4 seconds for 2000, 9 seconds for 3000, etc. However, given the length of time it took for the given python script to halt I still think this may be a viable alternative.

User avatar
Nicolas Krause
Posts: 169
Joined: Fri Sep 30, 2016 11:36 pm
Real name: Nicolas Krause
Location: Canada
Contact:

Re: Python Simulation

Post by Nicolas Krause » Tue Oct 15, 2019 3:39 pm

Hi Wyatt,

The current simulation is incomplete, the plan is to calculate a very precise voltage field using a finite difference approximation (which takes a long time) and then use that voltage field as a reference for the rest of the simulation. That way you can do one large chunk of computation and not have to repeat the computation over and over, which I was hoping would help when scaling to large numbers of particles. I've done a bit more work on this over the summer, but while the code compiles I have to tweak some parameters to get it running properly. If you want to speed up the simulation I'd suggest the following.
  • Dial down the sensitivity
  • Use the existing code in a Jupyter notebook:
    This way a single computation could be completed to produce an accurate field, and then you could compute particle paths and collisions on their own, without having to redo the field approximation each and every time.

DR_DANIEL_GOODMAN
Posts: 7
Joined: Thu Dec 28, 2017 4:43 am
Real name: Daniel Goodman

Re: Python Simulation

Post by DR_DANIEL_GOODMAN » Sat Jan 25, 2020 12:14 am

To all on the simulation thread here:

Purely out of curiosity, I did a search for fuso simulation software, and got this:

https://www.bing.com/search?pc=SUWI&for ... n+software

That then had two apparently relevant SourceForge links:

https://sourceforge.net/projects/fusortools/

And:

https://sourceforge.net/p/fusortools/me ... f/default/

I'll try to see if I can find more; also, anyone here increasing this ever done such simulation in MATLAB at all, I'd just wondered, I'd done a good deal of numerical methods before my disability at various points, and had given thought to trying to do such simukations, I had to do a good deal of such software searching, both freeware/open-source, as well as commercial, at various points, I'll try to send more if I can find it at all, if germane, seemingly, hope the above was of some interest, at least, if nothing ekse, of course.

Many thanks,

Dr. Daniel Goodman.

P.S. I'm also interested in any hobbyist group efforts for chairs on Long Island, as I have an interest in possibly integrating fusors into volunteer STEM tutoring I'm seeking to be allowed to do, if at all possibke, as well, if anyone might know if such groups and/or projects near my wife and myself, many thanks once again, I'd be interested in thoughts about the sites I'd sent in above, and the search also, whenever convenient, no rush, of course, please pardon any typos, I'm on an Android tablet at the moment with not the greatest keyboard and spell checker, I'm afraid.

User avatar
Nicolas Krause
Posts: 169
Joined: Fri Sep 30, 2016 11:36 pm
Real name: Nicolas Krause
Location: Canada
Contact:

Re: Python Simulation

Post by Nicolas Krause » Sun Nov 29, 2020 7:35 pm

I figured it was time for an update on this little project. Over the summer I monkeyed around a bit more with the code, it correctly simulates a 2d electrical field from a grid, and I can place a particle in the field and watch it move (if you'd like the completed code I can post it here). However, calculating the field takes a decent amount of time, and one of the core reasons for making this simulation is to be able to test different grid shapes. Already I can get a calculation that takes a few days to complete if I put in a decent level of resolution, if I extend the simulation to 3d I'm quite concerned it'll take too long to be of real use as a tool for testing. However, if I were to build a small computational cluster I'd be able to achieve a significant speedup. So that's what I plan on doing! To start I'm going to port my initial code over to a new language called Julia. It's used extensively in scientific computation and has good support for parallelization. Since I have zero clue at the moment how to program for parallelization I've constructed a small low cost cluster from 4 Raspberry Pi's and a used network switch. I still have to configure the devices and get them setup. I may start a new thread once I actually get around to that!
IMG_1395[1].JPG

User avatar
Nathan Marshall
Posts: 47
Joined: Thu May 09, 2019 12:13 am
Real name: Nathan Marshall

Re: Python Simulation

Post by Nathan Marshall » Sun Dec 06, 2020 4:18 pm

I wrote a numerical solver in Python for the 3D Laplace equation with the relaxation method. Here I set up a two ring grid with a ring in the X-plane and a ring in the Z-plane. The two images are slices of the potential on the X and Y planes so we can see one complete ring in one image and the other just has four points from the two rings. I tried to visualize the E-field by taking the gradient and plotting vector fields/streamplots but it was a real mess... Visualization for the 3D case is much more difficult. I did 10,000 iterations to get these images. I used the numba just-in-time compiler which tremendously speeds up the triple nested for loop needed for 3D. The simulation took about a minute on my laptop.
x_plane.png
y_plane.png

User avatar
Nicolas Krause
Posts: 169
Joined: Fri Sep 30, 2016 11:36 pm
Real name: Nicolas Krause
Location: Canada
Contact:

Re: Python Simulation

Post by Nicolas Krause » Tue Dec 08, 2020 5:02 pm

Very cool Nathan, as an aside my dad did his undergrad at Kansas State! Yes with 3d I think visualisation is quite difficult, I'm not 100% sure on the tack I'll take yet. From my research the easiest way to do it seems to be to take "slices" of the field at different heights, so you calculate the field say a cm away from the wire, then 2cm, then 3cm etc... and you can view them discretely. Later on I might move to a more complicated method of visualisation once I understand what I'm doing.

User avatar
Nathan Marshall
Posts: 47
Joined: Thu May 09, 2019 12:13 am
Real name: Nathan Marshall

Re: Python Simulation

Post by Nathan Marshall » Mon Feb 15, 2021 1:28 am

It has been a while since the last post on this thread. Tonight I had some inspiration to continue playing around with fusor simulations and I think I'm getting some interesting results now. I wrote a program that I have jokingly named "SIMION Lite". It takes the 3D potentials I calculated before and converts them to an electric field by taking the gradient. Then I create a deuteron with some initial position and zero velocity. By determining which grid box of my electric field its current position falls within, I can find the force on the deuteron and consequently its acceleration. I then increment its velocity and position with this information. This continues until the particle runs into a boundary like the grid or I reach a predetermined max number of iterations. Here is a plot of 20 different ion tracks using this program:
Two_Ring_Grid_Ion_Paths.png
It seems that the cross of ion jets observed in two ring fusors is clearly showing!

Nicolas, that is really neat that your dad did an undergrad at K-State too! It is a small world.

User avatar
Richard Hull
Moderator
Posts: 13213
Joined: Fri Jun 15, 2001 1:44 pm
Real name: Richard Hull

Re: Python Simulation

Post by Richard Hull » Mon Feb 15, 2021 5:07 am

Nice bit of work there. One assumes an infinite mean free path within the field in an ideal vacuum with zero collisions transferring energy to other particles and thereby, having our deuteron becoming a fast neutral. What you show is the absolute ideal, which we in our untrained wisdom back in 1997 believed of the Farnsworth device.... Virtual infinitely looping deuterons.
Now, after many hard won lessons, wakeup calls and being slapped around in the real world...........

Richard Hull
Progress may have been a good thing once, but it just went on too long. - Yogi Berra
Fusion is the energy of the future....and it always will be
Retired now...Doing only what I want and not what I should...every day is a saturday.

User avatar
Nathan Marshall
Posts: 47
Joined: Thu May 09, 2019 12:13 am
Real name: Nathan Marshall

Re: Python Simulation

Post by Nathan Marshall » Mon Feb 15, 2021 1:00 pm

Thanks Richard! And yes, this is of course an extremely idealized model of a fusor that ignores many factors known to be present in real fusors. Reality is always a rude awakening for the daydreaming theorist.

User avatar
Richard Hull
Moderator
Posts: 13213
Joined: Fri Jun 15, 2001 1:44 pm
Real name: Richard Hull

Re: Python Simulation

Post by Richard Hull » Mon Feb 15, 2021 6:21 pm

I remain very impressed with the work of others to present to us mathematical simulations in graphical form. I long held, in my mind, the above simplistic example of ion (deuteron) paths from my first learning about the fusor until I actually did fusion in the late 90's. We have long discussed, in many postings, the multitude of flies in the ointment within the fusor environment in which fusion is miraculously taking place in spite of the flies and the many adverse goings-on to doing fusion in the purest sense of the physics involved.

Richard Hull
Progress may have been a good thing once, but it just went on too long. - Yogi Berra
Fusion is the energy of the future....and it always will be
Retired now...Doing only what I want and not what I should...every day is a saturday.

Post Reply

Return to “Advanced Technical Discussion Area”