Virtual Polywell

Discuss how polywell fusion works; share theoretical questions and answers.

Moderators: tonybarry, MSimon

scareduck
Posts: 552
Joined: Wed Oct 17, 2007 5:03 am

Post by scareduck »

First pass is pretty "wow". This version of electron_fluid.c never went NAN or +/- INF on me, so that was one reason I decided to start there. The qd results were off by two orders of magnitude from the original electron_fluid.c results, but then I realized something else: I hadn't added the Intel rounding hack required! So that probably explains part of it. I also found one constant that should really have been configured as a quad double because it was fractional. Both of those together mean I need to move the constant builds to some point after I call fpu_fix_start().

I ran the previous incarnation of qd_ef with "time" for the following results on my 3-year-old i386 desktop machine:

real 380m21.669s
user 294m57.375s
sys 0m18.993s

So it took about 6:20. I'm going to re-run the new version with the above corrections and see if the results agree better. Here's the first few lines from the original electron_fluid.c:

Code: Select all

[rlm@raggy polywell]$ od -tf8 electron_potential.dat | head
0000000   3.037067275614889e-03   3.041723288346559e-03
0000020   3.039437224761356e-03   3.034855679587922e-03
0000040   3.039717384031051e-03   3.036388814775890e-03
0000060   3.039710553814500e-03   3.040881227276960e-03
0000100   3.040283756730124e-03   3.031332840266569e-03
0000120   3.036415630776763e-03   3.032671008829012e-03
0000140   3.036380469575148e-03   3.037567651028073e-03
0000160   3.036418739236356e-03   3.036362889227576e-03
0000200   3.037552683132963e-03   3.040826718653914e-03
0000220   3.041749778376273e-03   3.026560110447962e-03
And here's the results from the qd attempt:

Code: Select all

[rlm@raggy polywell]$ head -20 qd_electron_potential.dat 
2.519036334985061298397113205282948911190032958984375000e-01
2.522898172080299428188254751148633658885955810546875000e-01
2.521002041723427122832390523399226367473602294921875000e-01
2.517201971587248898742927849525585770606994628906250000e-01
2.521234415486853119858778882189653813838958740234375000e-01
2.518473554973596151285164523869752883911132812500000000e-01
2.521228750308683874692405879613943397998809814453125000e-01
2.522199741638976533408822433557361364364624023437500000e-01
2.521704180487013058353795713628642261028289794921875000e-01
2.514280024040125738338251615289209439652040600776672363e-01
2.518495843272564815862324394402094185352325439453125000e-01
2.515389940726627582279206762905232608318328857421875000e-01
2.518466679560640741897259431425482034683227539062500000e-01
2.519451363124093568046646396396681666374206542968750000e-01
2.518498420278124427795773954130709171295166015625000000e-01
2.518452097914717580096066740225069224834442138671875000e-01
2.519438948321060411927874156390316784381866455078125000e-01
2.522154530612717326931715433602221310138702392578125000e-01
2.522920142420904010549520535278134047985076904296875000e-01
2.510321380118170075945727148791775107383728027343750000e-01

MSimon
Posts: 14335
Joined: Mon Jul 16, 2007 7:37 pm
Location: Rockford, Illinois
Contact:

Post by MSimon »

Brent wrote:Kind of a newbie here. I wrote a few thoughts about the Polywell concept on my newly created weblog. I spoke some about modeling. In reality, this part is basically a summary of what I have been learning in an advanced thermodynamics course.
Thanks for the comment at IEC Fusion Tech.
Engineering is the art of making what you want from what you can get at a profit.

scareduck
Posts: 552
Joined: Wed Oct 17, 2007 5:03 am

Post by scareduck »

Just for giggles, I changed the output to write in straight ASCII in case I was missing something in the electron_fluid.c version. Still writes the same values.

scareduck
Posts: 552
Joined: Wed Oct 17, 2007 5:03 am

Post by scareduck »

Having re-run it again, it looks like there are a few significant changes, but they're all past digit 10 or so. The overall message is that the whole calculation took a jump to the left, and then a step to the right, and, well, you can forget about the Time Warp, but it sure did a results warp. I haven't looked too closely at the underlying numbers, but I have a bad feeling that all those divisions make this code very unstable. After reading those PDFs that MSimon linked to (IIRC in this thread) I have no idea where the problem really lies, and if it's necessary to have a PhD in math to figure it out, I'm hopelessly outclassed.

In any event -- I would like to take a crack at drmike's code that was causing underflows. I don't think you ever published it, did you, drmike? Shoot me a copy someplace and I'll see what I can do with it.

drmike
Posts: 825
Joined: Sat Jul 14, 2007 11:54 pm
Contact:

Post by drmike »

OK, I put up two versions. I moved the one you started with to electron_fluid_1.c and put up the last version of electron_fluid.c in its place. I also put up the version that died horribly as electron_fluid_magnetic.c.

Finding ways to make particle codes stable is definitly PhD thesis work, if not life long carrer stuff. There are lots of good reasons controlled fusion hasn't been done yet. It's hard!!

scareduck
Posts: 552
Joined: Wed Oct 17, 2007 5:03 am

Post by scareduck »

Incidentally, I tried running the qd library on J-M Muller's recurrence from the "Mindless" paper MSimon pointed out above. Eventually, it, too, came up with the wrong convergence (100), albeit it took longer to get there than conventional double precision (started to blow up around step 45 rather than step 12 for regular double precision). But without a detailed analysis, it's not clear what we're calculating, or how deep the error noise goes, etc.

scareduck
Posts: 552
Joined: Wed Oct 17, 2007 5:03 am

Post by scareduck »

And, thanks drmike. I'm going to head out to the gym presently and see what I can do when I get back.

scareduck
Posts: 552
Joined: Wed Oct 17, 2007 5:03 am

Post by scareduck »

Well, after about an hour's worth of banging away on it, I clipped the wings of the electron_fluid_magnetic.c code so that the test section at the bottom is removed. I figure if we don't get NaN's by the end of the first section I can move on to run that, and if I do, we're hosed anyway. I also took the liberty of moving certain constants that were being recalculated multiple times in the integration process (pi/4 in particular, but I should probably have also included cos(pi/4)) as global quasi-constants. Anyway, I'm going to leave it run overnight and see what turns up in the morning. It may not be done even by then! That's a lot more kerchunking going on there than in the original version of electron_fluid.c.

scareduck
Posts: 552
Joined: Wed Oct 17, 2007 5:03 am

Post by scareduck »

Actually, I think I see a couple things I may have missed in the qd version of electron_fluid.c that may have caused some weirdness, a couple constants I needed to convert to qd_real's that are involved in divisions. I'll worry about that in the morning.

drmike
Posts: 825
Joined: Sat Jul 14, 2007 11:54 pm
Contact:

Post by drmike »

It's certainly a great experiment. I'm starting to write up the description of the brute force phase space math, it will be interesting to see if we need the quad precision for that as well.

the complexity of plasma is really mind boggling. following electrons in a vacuum is almost doable, and it should be interesting. but once you add ionization and scattering - yuck. "Challenging" becomes an understatement.

Should be fun to try though.
:D

scareduck
Posts: 552
Joined: Wed Oct 17, 2007 5:03 am

Post by scareduck »

Well, good news -- the code finished in a reasonable amount of time, and no NaN's!

Code: Select all

real    375m26.445s
user    310m16.031s
sys     0m15.472s
HOWEVER, I should add that I also clipped out the initialization files for magnetic and electric potential (which I did not have), so those values were all set to zero.

drmike
Posts: 825
Joined: Sat Jul 14, 2007 11:54 pm
Contact:

Post by drmike »

The potentials are computed in separate files. You'll probably have to make those quad precision too. That will change the loading from double size to quad size, but otherwise should be the same.

Electric potential is here.

Magnetic potential is here.

It's the magnetic potential that causes nan or underflow.

scareduck
Posts: 552
Joined: Wed Oct 17, 2007 5:03 am

Post by scareduck »

Well, huh. Looks like this may take a while longer as the potential function uses the GSL quadrature package (I'm starting to pick up all this lingo -- fun stuff!). I may have to retool the GSL package to use C++ and the qd libs.

scareduck
Posts: 552
Joined: Wed Oct 17, 2007 5:03 am

Post by scareduck »

drmike -- do you think you could just make available the double precision initialization files? It would help things get started faster. Thanks.

scareduck
Posts: 552
Joined: Wed Oct 17, 2007 5:03 am

Post by scareduck »

Wait -- are you saying the magnetic_potential.c itself underflows?

I noticed there's a couple constants called "TOOSMALL" or something like that. Are those there to prevent underflow? 'Cause I'm wondering if I should just yank those and let the qd_real variables manage it themselves.

Post Reply