BAGS - btrettel's air gun simulation

Threads about how water guns work and other miscellaneous water gun technology threads.
User avatar
SSCBen
Posts: 6449
Joined: Sat Mar 22, 2003 1:00 pm

BAGS - btrettel's air gun simulation

Post by SSCBen » Fri Jan 02, 2009 4:48 am

The forum's slow so I'll post something somewhat related that I've been working on lately.

I've developed a simulation of a pneumatic gun I call BAGS. This simulation will help me optimize pneumatic guns to use less energy, less air, or both. So far I've configured it to run loops until it finds some states that get a certain muzzle velocity. Others might find it helpful for that because you can't do that with GGDT.

If you just want to get an idea of how your pneumatic gun might perform, I'd suggest skipping my model and using GGDT. GGDT is more accurate because it takes more variables into account and doesn't use some approximations I'm using at the moment.

If you do want to run the simulation you'll need Python, which is available for the vast majority of systems. You'll also need to edit the file to change the inputs because I never bothered to add a series of questions at the beginning.

This simulation isn't completely related to water guns, but I intend to use it to optimize a water balloon launcher. And I have started a similar simulation of water guns that is significantly simpler. Eventually I'll spice these up with some sort of GUI, but for now the terminal is adequate.

There's a bunch of things on my to-do list, but I'm going to wait until after I build the basic shell of the water balloon launcher I want to make and start some tests before going much deeper. Most things I intend to change at this point involve things I'm not too familiar with anyway.

User avatar
Silence
Posts: 3825
Joined: Sun Apr 09, 2006 9:01 pm

Re: BAGS - btrettel's air gun simulation

Post by Silence » Fri Jan 02, 2009 5:10 am

Looks good. I can't run it right now since I'd need some reasonable initial measurements to calculate anything of value.

A few notes:
  • You should consider parsing command line arguments (values listed after python modulename.py) and options (keywords and their values listed between python and modulename.py) . This page has a good solution for defining the options that you'll accept. The parse_args() returns a tuple of the options and the args. options is an object whose member variables' names are the names of each option that you defined. args is an array of args; I think args[0] probably gives you modulename.py since that's an arg being given to the python interpreter.
  • Have you experimented with different values of h (the time interval you iterate by)?
Last edited by Silence on Fri Jan 02, 2009 5:18 am, edited 1 time in total.

User avatar
SSCBen
Posts: 6449
Joined: Sat Mar 22, 2003 1:00 pm

Re: BAGS - btrettel's air gun simulation

Post by SSCBen » Fri Jan 02, 2009 1:43 pm

Parsing command line arguments sounds like something to try in the future. I'll keep it in mind.

The step size h was chosen because it's small enough to not introduce much error and large enough to be reasonably fast. The method I'm using to approximate the solutions to the differential equations is called the forward Euler method. It is the most simple method but also the one that introduces the most error. I'm using it because parts of the simulation change so often, any higher order approximation would become a pain to change parts with. Later once things have solidified I'll switch to the basic 4th order Runge-Kutta method.

One thing to note is that how I calculate the new barrel temperature is probably wrong in some way. To be honest I had no idea how to do this, so I treated each time interval as a closed system and then used an energy balance on the barrel to figure out its equilibrium temperature. Of course, in reality the barrel wouldn't have just one temperature or will you be able to treat part of a non-closed system as a closed system, but this is reasonably close to GGDT.

I emailed my thermodynamics TA about this but he hasn't commented directly on the code yet. I'm hoping he'll have some more specific suggestions. If anyone here is particularly well versed in thermodynamics I'd appreciate if you could take a look at that function.

I checked out some old GGDT source code to see how D_Hall did this, but as far as I can tell, his method wouldn't return the correct units, so I'm no better off.

Edit: I just realized by dynamic pressure terms in the force equation was incomplete... I am fixing it right now.
Last edited by SSCBen on Fri Jan 02, 2009 1:54 pm, edited 1 time in total.

User avatar
SSCBen
Posts: 6449
Joined: Sat Mar 22, 2003 1:00 pm

Re: BAGS - btrettel's air gun simulation

Post by SSCBen » Sun Jan 18, 2009 7:05 pm

I've made a few minor changes to BAGS that should increase its accuracy a good bit. Originally I did not use the critical flow equation (see the trettel.org page) because CALM (a simpler pneumatic gun model) did not, but for the sake of experimentation I added it. My model now agrees even closer with GGDT. At muzzle velocities of less than 1000 fps, BAGS is within about 2% of GGDT.

The other change I made was a quick bit of code to allow non-constant flow coefficients.

Many more items are on the todo list, but for now I'm very satisfied with my work.
Last edited by SSCBen on Sun Jan 18, 2009 11:38 pm, edited 1 time in total.

User avatar
Silence
Posts: 3825
Joined: Sun Apr 09, 2006 9:01 pm

Re: BAGS - btrettel's air gun simulation

Post by Silence » Tue Jan 20, 2009 7:44 pm

I've been trying to do write a web interface for BAGS using Python, but I've run into trouble with a function call.

First I had to modify your current version, which doesn't include a main function that another program can call. The call is:

Code: Select all

calculate(6, 1.590, 18, 300, 2, 530, 40, 10, 0.1, 0.0749571691, 5e-3, 0)
But that produces a traceback:

Code: Select all

Traceback (most recent call last):
  ...
  File "/home/pyglobe/webapps/nerfbox_cherrypy/bags.py", line 97, in calculate
    mb = (Pb * Vb(x))/(R * Tb)
  File "/home/pyglobe/webapps/nerfbox_cherrypy/bags.py", line 37, in Vb
    return (pi/4) * pow(d,2) * xi + Vd
TypeError: a float is required
I don't think I gave it the wrong type of variables, but then again, maybe I did. Vd is the "10" in the function call; I tried giving it a non-integer value, but that didn't help. I split up the line with the offending return statement and it doesn't seem to like pi/4. Is it supposed to be Pi/4, which I see elsewhere?

Edit: Switching to capital Pi didn't help.
Attachments

[The extension py has been deactivated and can no longer be displayed.]

Last edited by Silence on Tue Jan 20, 2009 7:50 pm, edited 1 time in total.

User avatar
SSCBen
Posts: 6449
Joined: Sat Mar 22, 2003 1:00 pm

Re: BAGS - btrettel's air gun simulation

Post by SSCBen » Tue Jan 20, 2009 11:42 pm

Pi is different than pi. Pi is whatever the function called and pi is 3.14159. This is definitely a confusing point! Feel free to change those. As I said earlier, there was no logical reason for those variable names other than to not cause problems. And I'll admit I am not the best programmer--I tend to do what works and not learn anything more elegant.

That line calculates the current barrel volume from the projectile position (Vb means barrel volume and x is the current projectile position). Specifically the barrel volume is the "dead volume" added to the volume from the projectile's starting position to its current position. Mathematically that is the volume of a cylinder, which is what the first part of statement contains.

While I'm not completely sure what the problem here is, it likely has something to do with global variables. Add this line after you defined calculate: global Pb, Pc, Tb, Tc, mb, mc, h, x_dot, x, work, t, accel

That should fix it and make some extra variables global.

It's definitely worth explaining exactly how the program works so I'll try to do that right now. I'll make a new post.

User avatar
SSCBen
Posts: 6449
Joined: Sat Mar 22, 2003 1:00 pm

Re: BAGS - btrettel's air gun simulation

Post by SSCBen » Wed Jan 21, 2009 1:17 am

I've attached the results of two hours of writing about the current version of BAGS. What I've written is a little rough in terms of the actual writing and the formatting, but it'll suffice. I've uploaded a slightly changed version of BAGS to trettel.org, but it doesn't change the results of the simulation so you won't have to update your online script.

Sorry for using PDF, but I wrote it in a word processor and don't have time to convert it to HTML at the moment.

Edit: I've updated the PDF a bit and uploaded it here: http://trettel.org/bags.pdf
Last edited by SSCBen on Wed Jan 21, 2009 3:40 am, edited 1 time in total.

User avatar
Silence
Posts: 3825
Joined: Sun Apr 09, 2006 9:01 pm

Re: BAGS - btrettel's air gun simulation

Post by Silence » Wed Jan 21, 2009 2:39 am

Standard units haven't bothered me too much, but that's because I didn't do the math. I'm definitely waiting for the conversion to SI, though. Thankfully, you'll only need to change the constants and little else.

I've never heard of the Runge-Kutta approximation, but we'll probably get to it soon.

Python has an exponentiation operator, a**b, which is a shortcut for math.pow(a, b). Or for squaring, you could just use a*a. They're not necessarily better, but if you know what the operators do, it's probably easier to scan.

Finally, for some of the larger equations, you could split everything up into statements and store them into local variables. That would make them easier for readers to parse.

I remember an argument by the_halls (the creator of GGDT) for not revealing how his model works: because those who can understand it don't need an explanation, and those who can't understand it wouldn't understand the explanation, either. But that's just not true, so I really appreciate your walkthrough. :cool:

Earlier, I was confused by the efficiency calculations, since I didn't see any optimization or analysis or anything. But from the PDF, it makes a lot of sense now, and valve configurations are a practical fine idea. Adjusting all the parameters to see how to improve muzzle velocity would take a tremendous amount of computation.

User avatar
SSCBen
Posts: 6449
Joined: Sat Mar 22, 2003 1:00 pm

Re: BAGS - btrettel's air gun simulation

Post by SSCBen » Wed Jan 21, 2009 2:58 am

I understand exactly why D_Halls doesn't want to release any code. But I don't share the same opinion. To be honest, I found CALM, an open source model that is much simpler than mine, to be extremely helpful in developing my own. And I don't really need to know how it works as much as I need verification, and D_Halls was actually very willing to verify some of my thoughts. BAGS and my explanations hopefully will allow others to develop their own models for their own purposes. Or they could just use BAGS, which should be adequate for most circumstances.

I'll explain a bit about optimization...

The released version of BAGS has none of my optimization code in it. My optimization code is nothing more than an exhaustive search tacked on to the released code. I take the table of results, examine them, try different variables, make some 3D graphs with gnuplot, make some regressions with Grace, try different inputs, repeat, etc. It's complicated. I'm hoping to learn some more about search methods in the coming months so this process is simplified. Luckily for me my father has a 30 year old book called "Design of Thermal Systems" which contains a great deal about search methods.

To be more specific, my current optimization code basically loops through different gas chamber volumes, finding the minimum pressure that gets the desired muzzle velocity at the optimal barrel length (the barrel length where efficiency is maximized) for each gas chamber volume. As I use an exhaustive search, getting any useful information can take hours. But it's well worth the time. I can get 60% energy efficiency without too much difficulty. Some guns I've seen promoted as "highly efficient" on Spudfiles had efficiencies of less than 20% for comparison. ;)

With Nerf guns pilot actuated valves really hurt your efficiency. At the optimal setups, the pilot volume can be comparable or even larger than the theoretical optimal pressure chamber volume. So I'm investigating and designing my own non-pilot actuated valves, based a bit on clide's HEAR valve. My version is simpler and a little more robust.

Also, my model does seem to be somewhat inaccurate at high pressure, but it's latest incarnation has only been conservative by at most 15% compared against GGDT, which is good. I am willing to accept better performance than my model predicts!

Edit: Here's an example of the output from BAGS modified to optimize efficiency of a theoretical Nerf gun:

Code: Select all

Vd	P	Vc	L	v	n	nnp	m	mnp
0.01	403.9	0.05	3.58604394291	181.806300818	0.182575949854	0.547727849561	8.10029605298	2.70009868433
0.01	232.6	0.1	4.39247561719	181.804214949	0.257871993161	0.515743986321	6.2197866202	3.1098933101
0.01	135.55	0.2	5.38302241413	181.836504341	0.322900170257	0.484350255386	5.43696523883	3.62464349255
0.01	96.7	0.3	5.83778261073	181.81921688	0.360712052867	0.480949403823	5.17156806684	3.87867605013
0.01	78.85	0.4	6.46654228503	181.842370864	0.367725723884	0.459657154855	5.27117556967	4.21694045574
0.01	67.5	0.5	7.0061134858	181.887842706	0.368852112583	0.4426225351	5.41490451672	4.5124204306
0.01	59.55	0.6	7.48298685673	181.897968701	0.367089450497	0.428271025579	5.57334061184	4.77714909587
0.01	53.6	0.7	7.90464691102	181.801494343	0.363745016849	0.415708590685	5.73311372042	5.01647450537
0.01	49.05	0.8	8.29988858216	181.893819766	0.359746358994	0.404714653868	5.90224592323	5.24644082065
0.01	45.35	0.9	8.65733936268	181.816013404	0.355179768089	0.394644186766	6.06335604527	5.45702044074
0.01	42.35	1.0	9.00040269452	181.867179661	0.35050708758	0.385557796338	6.22847720769	5.66225200699
0.01	39.85	1.1	9.32603416326	181.961505114	0.34578712737	0.377222320768	6.39359837012	5.86079850594
0.01	37.7	1.2	9.6288737786	181.968198955	0.340978386326	0.369393251854	6.55270297197	6.0486488972
0.01	35.85	1.3	9.92129920996	181.992295709	0.336223652859	0.362087010771	6.71047056035	6.23115123462
0.01	34.2	1.4	10.1892381043	181.861713651	0.331392467285	0.355063357805	6.85887905452	6.40162045088
0.01	32.8	1.5	10.4631870496	181.970191885	0.326867222007	0.348658370141	7.01664664291	6.57810622772
0.01	31.5	1.6	10.7070976501	181.812514905	0.322190721824	0.342327641938	7.15970708322	6.73854784303
0.01	30.4	1.7	10.9668628544	181.965463648	0.317912294717	0.336613017936	7.31613765815	6.90968556603
0.01	29.35	1.8	11.1971403972	181.814384999	0.313454323459	0.33086845254	7.45585556482	7.06344211404
0.01	28.45	1.9	11.4388064732	181.934578482	0.309363518619	0.325645809072	7.60760659263	7.227226263
0.01	27.6	2.0	11.6617321315	181.886480944	0.305223386412	0.320484555733	7.74933001949	7.38031430428
0.01	26.85	2.1	11.8936626818	181.993737631	0.301338704359	0.315688166472	7.89773851365	7.53875039939
0.01	26.15	2.2	12.1121925039	182.035539829	0.297499391958	0.311022091593	8.0414674607	7.69183844067
0.01	25.5	2.3	12.3237650561	182.049392788	0.29373610403	0.306507238988	8.18252238083	7.84158394829
0.01	24.9	2.4	12.5324979135	182.07328599	0.290085178494	0.302172060931	8.32290879422	7.98999244245
0.01	24.3	2.5	12.7132576453	181.825374095	0.286272325937	0.297723218974	8.44725104609	8.12235677509
0.01	23.8	2.6	12.9241781346	181.963848816	0.28292550548	0.293807255691	8.59164849987	8.27343929617
0.01	23.3	2.7	13.109785392	181.879971719	0.27945840125	0.289808712407	8.72267581904	8.41115168264
0.01	22.85	2.8	13.3040752158	181.921435649	0.276200740664	0.286065052831	8.85971969878	8.55421212296
0.01	22.45	2.9	13.509331243	182.11856374	0.273178440327	0.282598386545	9.00478565929	8.70462613732
0.01	22.05	3.0	13.6940594813	182.142985743	0.270073917429	0.279076381344	9.13915551212	8.84434404398
0.05	397.8	0.05	3.48163786807	181.811925988	0.185774248587	0.557322745762	7.97795932131	2.65931977377
0.05	223.9	0.1	4.1357573399	181.811891806	0.269532773394	0.539065546787	5.987146278	2.993573139
0.05	127.45	0.2	4.91940822965	181.82397622	0.34712884273	0.520693264094	5.11207096783	3.40804731188
0.05	94.4	0.3	5.63074362792	181.834979256	0.371212355617	0.494949807489	5.04856282843	3.78642212132
0.05	76.95	0.4	6.24095003412	181.807527336	0.378398172905	0.472997716132	5.14415929089	4.11532743271
0.05	65.95	0.5	6.77617919217	181.81716857	0.37890186603	0.454682239237	5.29056226486	4.40880188738
0.05	58.3	0.6	7.25682545058	181.873179921	0.376383926781	0.439114581244	5.45635193401	4.6768730863
0.05	52.6	0.7	7.69100820329	181.881763366	0.372329749244	0.425519713422	5.62615264355	4.92288356311
0.05	48.15	0.8	8.08427265043	181.817138919	0.367462880272	0.413395740305	5.79394783289	5.15017585146
0.05	44.6	0.9	8.45207656863	181.813089627	0.362293555509	0.40254839501	5.9630800357	5.36677203213
0.05	41.7	1.0	8.80165622914	181.871986249	0.35703958139	0.39274353953	6.13288074524	5.57534613203
0.05	39.25	1.1	9.12559589367	181.862205122	0.351700513413	0.383673287359	6.29733340093	5.77255561752
0.05	37.15	1.2	9.43213161691	181.803212845	0.346359056775	0.375222311507	6.45710650951	5.96040600878
0.05	35.35	1.3	9.72505511268	181.800536553	0.341160236117	0.367403331203	6.61687961809	6.14424535966
0.05	33.8	1.4	10.0147660447	181.890774633	0.336159954028	0.360171379315	6.77865824686	6.32674769707
0.05	32.4	1.5	10.2809336902	181.827225344	0.331137644482	0.353213487447	6.93107778141	6.49788542007
0.05	31.2	1.6	10.5536221038	181.97582887	0.326450774327	0.346853947722	7.09151939672	6.67437119691
0.05	30.1	1.7	10.8071417508	181.995740383	0.321774480314	0.34070239092	7.24393893126	6.84149787952
0.05	29.1	1.8	11.0498943052	181.970647273	0.317187192589	0.334808703289	7.39234742542	7.0032765083
0.05	28.2	1.9	11.2881052047	181.98103931	0.312767840204	0.329229305478	7.54075591959	7.16371812361
0.05	27.35	2.0	11.5073279641	181.825310481	0.308313973269	0.323729671933	7.67913681279	7.31346363123
0.05	26.6	2.1	11.7335508413	181.833098734	0.304146436362	0.318629599998	7.8242027733	7.4685571927
0.05	25.95	2.2	11.971313096	182.07381194	0.300331567199	0.313983002071	7.9799648415	7.63300984839
0.05	25.3	2.3	12.1801178773	182.004484131	0.296328132629	0.309211964483	8.1183457347	7.78008132909
0.05	24.7	2.4	12.3860530585	181.949100173	0.292453726886	0.30463929884	8.25605812118	7.92581579633
0.05	24.15	2.5	12.5914293742	181.94238483	0.288736948112	0.300286426037	8.39510752111	8.0722187703
0.05	23.65	2.6	12.7983921138	182.018604193	0.285208254642	0.296177802898	8.5374994547	8.22129577119
0.05	23.15	2.7	12.9819949257	181.871799802	0.2815619229	0.291990142266	8.66652125368	8.35700263748
0.05	22.7	2.8	13.1743985396	181.855049255	0.27814190616	0.288075545666	8.80155961323	8.4980575576
0.05	22.3	2.9	13.3759334053	181.997789631	0.274970885825	0.284452640508	8.94462005355	8.64646605177
0.05	21.9	3.0	13.5588061955	181.968353912	0.271722677895	0.280780100492	9.07698438618	8.78417843824
0.1	417.1	0.05	3.7167363389	181.802913855	0.176018671987	0.528056015961	8.36502471824	2.78834157275
0.1	228.95	0.1	4.24600969395	181.815821369	0.262670280773	0.525340561546	6.12218463755	3.06109231878
0.1	129.7	0.2	5.01683969493	181.845197848	0.340130595585	0.510195893377	5.20231937644	3.46821291763
0.1	95.1	0.3	5.66353496189	181.861214749	0.368082939747	0.490777252996	5.08599920534	3.814499404
0.1	77.1	0.4	6.23072132827	181.879709234	0.377822972553	0.472278715691	5.15418689184	4.12334951348
0.1	65.85	0.5	6.73984231648	181.847259051	0.379712764418	0.455655317302	5.28254018409	4.40211682008
0.1	58.1	0.6	7.19872704374	181.877414979	0.377945863173	0.440936840368	5.43763374556	4.66082892477
0.1	52.35	0.7	7.6189208576	181.831460885	0.374242622746	0.427705854567	5.59941237433	4.89948582754
0.1	47.95	0.8	8.01281743113	181.917670455	0.369698307324	0.41591059574	5.7698815906	5.12878363609
0.1	44.4	0.9	8.37649105446	181.896996893	0.364574317993	0.405082575548	5.93633976648	5.34270578983
0.1	41.5	1.0	8.7207616077	181.917782661	0.359269539613	0.395196493574	6.1034664491	5.54860586282
0.1	39.05	1.1	9.04238329012	181.855718261	0.353818972706	0.385984333861	6.26524507787	5.74314132138
0.1	37.0	1.2	9.35732547422	181.933458539	0.34852757906	0.377571543982	6.43103474702	5.93633976648
0.1	35.2	1.3	9.64938346364	181.877431725	0.343177749001	0.369576037386	6.58880233541	6.11817359717
0.1	33.65	1.4	9.93310395764	181.914589815	0.338027535323	0.362172359275	6.74857544399	6.29867041439
0.1	32.3	1.5	10.2139787754	182.02355975	0.333071787461	0.355276573292	6.90968556603	6.47783021815
0.1	31.05	1.6	10.4675111893	181.887788091	0.328002513324	0.348502670407	7.05742555346	6.64228287385
0.1	29.95	1.7	10.7202612133	181.852334209	0.323173270324	0.342183462696	7.20783956782	6.80740403627
0.1	29.0	1.8	10.9793626571	182.033185332	0.318700312638	0.336405885562	7.36694416967	6.979210266
0.1	28.1	1.9	11.2151552563	181.999401054	0.314147183357	0.330681245639	7.51401565037	7.13831486785
0.1	27.3	2.0	11.4550574538	182.079224222	0.309844513979	0.325336739678	7.66509817145	7.30009349662
0.1	26.55	2.1	11.6813271211	182.055771679	0.305569477169	0.320120404654	7.80949562523	7.45451855136
0.1	25.85	2.2	11.8940733295	181.969638383	0.301356849485	0.315054888098	7.9492135319	7.60359555225
0.1	25.2	2.3	12.1016567369	181.861405533	0.297246198745	0.310169946517	8.08625741164	7.74933001949
0.1	24.65	2.4	12.3315643835	182.084126623	0.293587544156	0.305820358496	8.23934545292	7.9097716348
0.1	24.1	2.5	12.5365180447	182.050401094	0.289785624587	0.30137704957	8.37772634612	8.05550610204
0.1	23.6	2.6	12.7432103623	182.10108971	0.286177996904	0.297184842939	8.51944977298	8.2039145962
0.1	23.1	2.7	12.9262238145	181.927429783	0.282450753359	0.292911892373	8.64780306523	8.33895295575
0.1	22.65	2.8	13.1181274061	181.886272395	0.278958654541	0.288921463632	8.78217291805	8.47933936915
0.1	22.25	2.9	13.319182484	182.007732018	0.275726126012	0.28523392346	8.92456485164	8.62707935658
0.1	21.85	3.0	13.5035007254	181.956118739	0.272415230352	0.28149573803	9.05626067754	8.76412323633
0.2	465.55	0.05	4.32345283568	181.809186038	0.155412843897	0.46623853169	9.33669925097	3.11223308366
0.2	249.3	0.1	4.74659869215	181.815929033	0.238040036578	0.476080073155	6.66634911615	3.33317455807
0.2	137.7	0.2	5.40067629522	181.813246316	0.316901657243	0.475352485865	5.52320260706	3.68213507137
0.2	99.3	0.3	5.95662620161	181.855334961	0.349693464781	0.466257953042	5.31061746677	3.98296310008
0.2	79.55	0.4	6.45159841833	181.807589988	0.363744339299	0.454680424124	5.31797104081	4.25437683265
0.2	67.45	0.5	6.90571580781	181.850654351	0.369026702502	0.442832043002	5.41089347634	4.50907789695
0.2	59.2	0.6	7.32911110335	181.914155713	0.369742536354	0.431366292413	5.54058378205	4.74907181319
0.2	53.15	0.7	7.72153075402	181.916170404	0.367881827494	0.420436374279	5.68498123583	4.97435858135
0.2	48.5	0.8	8.08683382194	181.879247751	0.364554318089	0.410123607851	5.83606375691	5.18761222837
0.2	44.8	0.9	8.43032682749	181.816269636	0.360380622113	0.400422913459	5.98982030492	5.39083827443
0.2	41.8	1.0	8.76009626656	181.817472553	0.355809654727	0.391390620199	6.14758789331	5.58871626664
0.2	39.3	1.1	9.07350907132	181.8169421	0.350993518217	0.382902019873	6.3053554817	5.77990919155
0.2	37.2	1.2	9.37986357102	181.893285661	0.346148486192	0.374994193375	6.46579709701	5.96842808954
0.2	35.4	1.3	9.67533602353	181.99198058	0.34130565505	0.367559936208	6.62623871232	6.15293594715
0.2	33.8	1.4	9.95011770846	181.938259156	0.336335493208	0.360359457008	6.77865824686	6.32674769707
0.2	32.4	1.5	10.2172255094	181.917796623	0.331467617395	0.353565458555	6.93107778141	6.49788542007
0.2	31.15	1.6	10.4720918058	181.858171395	0.32664892403	0.347064481782	7.0801547823	6.66367508922
0.2	30.05	1.7	10.7259217784	181.888919829	0.322030066297	0.340973011374	7.23190581011	6.83013326511
0.2	29.05	1.8	10.9700984798	181.866065539	0.317467855832	0.335104958934	7.37964579755	6.99124338715
0.2	28.15	1.9	11.2093174107	181.873497399	0.313054232084	0.329530770615	7.52738578498	7.15101649573
0.2	27.35	2.0	11.4480789289	181.990729108	0.308875216074	0.324318976878	7.67913681279	7.31346363123
0.2	26.6	2.1	11.6748474009	181.998535675	0.304700130339	0.319209660355	7.8242027733	7.4685571927
0.2	25.9	2.2	11.8920941178	181.939397452	0.300571076214	0.31423339786	7.9645891867	7.61830270032
0.2	25.25	2.3	12.1016670806	181.854815819	0.296531344192	0.309424011331	8.10230157317	7.76470567429
0.2	24.7	2.4	12.3313930051	182.10413746	0.292952333914	0.30515868116	8.25605812118	7.92581579633
0.2	24.15	2.5	12.5381867805	182.090171893	0.289206205631	0.300774453856	8.39510752111	8.0722187703
0.2	23.6	2.6	12.7189210439	181.82334372	0.28530568829	0.296278983993	8.51944977298	8.2039145962
0.2	23.15	2.7	12.9324719887	182.002873094	0.281967907188	0.29241116301	8.66652125368	8.35700263748
0.2	22.7	2.8	13.1253714272	181.977888971	0.278517792475	0.288464856492	8.80155961323	8.4980575576
0.2	22.3	2.9	13.3297339151	182.116377936	0.275329340231	0.284823455411	8.94462005355	8.64646605177
0.2	21.9	3.0	13.5127401397	182.078487983	0.272051690935	0.281120080633	9.07698438618	8.78417843824
What does all that mean? Each line describes how an optimal situation for a certain volume gas chamber and dead volume would perform. You can see that efficiency has its peaks and gas mass has minimums. That's what I'm looking for.

Also note that the optimal barrel lengths can be incredibly short, which isn't desired. This situation is constrained to what is practical. Edit: Actually, I'm not certain that a short barrel is a bad thing. The only thing I think it might affect is the accuracy, and I'm not even sure it will affect that because all of these situations have essentially the same muzzle velocity.

Edit again: After a little research I can see that barrel length alone doesn't have a serious impact in accuracy. What matters is the distance between iron sights. More precision is possible with a larger distance. Also, longer barrels can sag, which can introduce problems. Moving the sight closest to the person farther back can help with precision. Basic beam theory can help with the second problem. Short barrels are the way to go.
Last edited by SSCBen on Wed Jan 21, 2009 10:32 pm, edited 1 time in total.

User avatar
Silence
Posts: 3825
Joined: Sun Apr 09, 2006 9:01 pm

Re: BAGS - btrettel's air gun simulation

Post by Silence » Wed Jan 21, 2009 5:07 am

Woah, I guess I totally underestimated your goals after all. And it seems like your solution is more refined than brute-forcing every combination of dimensions.

It looks like you've already got some pretty groundbreaking results. I'm glad I've been procrastinating on that piston-valve Nerf gun I've been thinking about. :cool:

Have you thought about creating charts with all that information? The massive screendump works, but I think it's fairly easy to use something like matplotlib. In fact, I'm guessing you use that already at UMD.

User avatar
SSCBen
Posts: 6449
Joined: Sat Mar 22, 2003 1:00 pm

Re: BAGS - btrettel's air gun simulation

Post by SSCBen » Wed Jan 21, 2009 1:57 pm

This isn't extremely refined but it's reasonable. I do use some logic to reduce the number of calculations done substantially, but I still need to apply some faster search methods. Using a lattice search wouldn't be too difficult and should be very substantially faster than generating what I've posted.

I have created charts with it too. I haven't used matplotlib (yet) but I'm hoping to include some graphs later. At the moment I clean up the output to make a 3D plot with gnuplot if I want to visualize anything.

The reason that I'm getting such groundbreaking improvements is simply because barely anyone has taken this approach before. I say barely anyone rather than no one because I assume some sort of analysis has been done by some people who didn't discuss it much. I have found very little about pneumatic efficiency on the internet, and what I have found typically wasn't very helpful and sometimes was incorrect.

Some people in the spud gun world use the word efficiency, but I don't think they mean efficiency in the literal sense that I do. They seemed to use "efficiency" as a reason to nitpick things that might help performance.

I'm hoping to eventually modify BAGS to look at spring guns efficiency, where energy efficiency perhaps would matter more. The logic there would be to look at situations where the piston simultaneously runs into the end and then the dart leaves when efficiency is maximized. Loop this for different spring lengths and spring constants and keep the muzzle velocity constant and a clearer picture of what's going on should appear. Then you can start looking at things like dead volume, plunger mass, dart mass, etc.

User avatar
Silence
Posts: 3825
Joined: Sun Apr 09, 2006 9:01 pm

Re: BAGS - btrettel's air gun simulation

Post by Silence » Thu Jan 22, 2009 4:44 am

I'm surprised by both the fact that you've bothered to do all this and the errors in popular belief when it comes to "efficiency." All those rules of thumb about volumes, lengths, valve configurations, and that sort of thing look like complete nonsense now.

User avatar
cantab
Posts: 1492
Joined: Fri Oct 19, 2007 1:35 pm

Re: BAGS - btrettel's air gun simulation

Post by cantab » Thu Jan 22, 2009 1:15 pm

Alternatively, once Ben starts building guns, it may turn out that all that theory is nonsense and there's complications that make the 'rules of thumb' right after all.

Not saying it's likely, but until you build a real, physical thing you just can't know.
I work on Windows. My toolbox is Linux.
Arsenal:
Super Soaker: XP215, 2xXP220, Liquidator, Aquashock Secret Strike M(odded), Arctic Blast M, CPS1200, CPS2100, SC Power Pak, 3l aquapack, 1.5l aquapack
Water Warriors: Jet, Sting Ray M, Shark, Argon M, Tiger Shark, PulseMaster
Others: Waterbolt, The Blaster, Storm 500, Shield Blaster 2000, generic PR gun, generic backpack piston pumper (broken), 3l garden sprayer M, 10l water carrier:

User avatar
SSCBen
Posts: 6449
Joined: Sat Mar 22, 2003 1:00 pm

Re: BAGS - btrettel's air gun simulation

Post by SSCBen » Thu Jan 22, 2009 2:01 pm

@Silence: I bothered out of a combination of boredom and interest in optimizing Nerf guns. And once I started researching efficiency I noticed that the "experts" on efficiency are really just nitpickers. Barely anyone has a decent idea of what helps. No one other than myself (as far as I can tell at least) knows how much things help or which exact configurations are ideal. So I have a desire to show what is correct too.

Have you fixed the online version of BAGS yet?

@cantab: I don't doubt that the model will need adjustment, but my model matches another very robust model very closely. The other model is very accurate, reporting to be within 5% of the measured muzzle velocity most of the time. BAGS is typically within 2% of that model.

Extensive testing will be done before building any gun to make sure all of the inputs are accurate. That'd be the largest source of error. If your inputs are bad everything else is meaningless. My testing will include a lot of things most people don't do too, like using coils to track the position and velocity of the projectile in the barrel and tracking the pressure with respect to time. Given these measurements are accurate I should have a much better idea how close my model is to reality. I'll of course test the tests' feasibility before using them to gather data.

Edit: Perhaps it would be best if I wrote a page describing how I intend to go further with BAGS...
Last edited by SSCBen on Thu Jan 22, 2009 8:49 pm, edited 1 time in total.

User avatar
Silence
Posts: 3825
Joined: Sun Apr 09, 2006 9:01 pm

Re: BAGS - btrettel's air gun simulation

Post by Silence » Thu Jan 22, 2009 10:19 pm

For me, the biggest turnoff from GGDT was the vast amount of information you have to enter. Naturally it's not specific to that model: GGDT, BAGS, CALM, and any other self-respecting model require all that. But getting a default list of common inputs would be helpful for things like the coefficient of friction, which most people won't bother to measure. I think GGDT had some default valve configurations, but that was about it, and the default inputs certainly wouldn't work for any Nerf gun.

cantab, I agree that building a Nerf gun using the new rules of thumb is necessary to validate what BAGS suggests. But Ben does have experience with Nerf guns already.

I haven't fixed the online BAGS interface yet - school started yesterday (Wednesday, for cantab and others outside this time zone :cool :) , plus we had the district quiz bowl tournament and got back late. I'll add the line declaring the global variables this weekend and see if it works. Hopefully it won't take too long: trying to integrate BAGS forced me to handle tracebacks properly, which has made things easier to work with. Anyway, I'll try to get a link up soon.

Seeing the scope of your optimization efforts has changed my perspective on how the web interface (if you want one and don't mind me using it) should work. At the moment, the current version should at least help people who don't have Python or are uncomfortable with the command line (not that the web page is particularly pretty, at this point).

Locked