btrettel's Nerf blog

random thoughts about the ballistics of foam darts

Archive for the ‘Math’ Category

Notes about valves and flow rates

Posted by btrettel on March 20, 2013

Comparing valves for compressed gases can be difficult for several reasons. Even if you are familiar with how valve performance is specified, you can easily make mistakes. Valve performance is specified in several different sloppy and confusing ways, almost always in non-metric units. The worst part is that valve performance can be specified in obvious ways, but people working in the industry don’t do that.

Flow rates

The confusion starts immediately with the definition of the flow rate. Rather than specifying a mass flow rate (i.e., something like g/s), most valve manufacturers instead specify a volumetric flow rate (i.e., something like m3/s). Why? I’m not entirely sure. It’s probably a combination of tradition (e.g., “that’s all I was taught”), familiarity, laziness (e.g., the flow meter gives volumetric, and they don’t want to convert), or ignorance (e.g., they don’t realize it matters). I suspect the practice was held over from liquid valve flow, where the fluid density doesn’t vary much and the volumetric flow rate is just proportional to the mass flow rate.

This is problematic because volume can vary considerably over a range of temperatures/densities for the same mass flow rate. To use a volumetric flow rate (by converting it to a mass flow rate to use in a mass conservation equation) requires an engineer to know the temperature and pressure at which it applies.

With this in mind, some engineers developed the unit called “standard cubic feet per minute” or SCFM for short where the temperature and pressure are supposed to be standard, i.e., known. Unfortunately, there is no standard, though usually the reference pressure is 1 atm and the reference temperature is 70F.

Unfortunately, some companies simply treat SCFM as if it were the actual measured flow rate! It’s as if they don’t understand what the point of the standardization was or even that the S stands for standard. Clippard is one of these companies (I asked by email. Their reference pressure is the pressure they did the test at and their reference temperature is 70F.). If you are using a company’s valve, I suggest asking what their reference conditions are. If they don’t know, then don’t assume anything about their products. I’ve found that some companies are completely ignorant about the performance of their products. Some companies have no idea where the numbers they print on their spec sheets come from. They sometimes don’t even know the units to the numbers. This is extremely sloppy and it’s rather scary that a large number of engineers work this way.

The relationship between volumetric flow rate and mass flow rate is \dot{m} = \rho Q where \dot{m} is the mass flow rate, \rho is the mass density, and Q is the volumetric flow rate.

We can find \rho with the ideal gas law (\displaystyle P = \rho \frac{\overline{R}}{M} T) and convert between volumetric and mass flow rates. P is the pressure (in absolute units), T is the temperature (again, absolute temperature), \overline{R} is the universal gas constant, and M is the molecular mass of the gas (for us this is air). So, rearranging the equation above yields \displaystyle \rho = \frac{P M}{\overline{R} T}.

The standard uses the standard temperature and pressure. So, for example, for convert from a volumetric flow rate of 20 SCFM to a mass flow rate in g/s, we can do the following:

\displaystyle \dot{m} = \rho Q = \frac{P_\text{s} M Q}{\overline{R} T_\text{s}}
\displaystyle = \frac{101325~\text{Pa} \cdot 28.97~\text{g/mol} \cdot 20~\text{ft}^3\text{/min}}{8.3145~\text{J/(mol K)} \cdot 293.15~\text{K}} \left(\frac{3.28~\text{ft}}{\text{m}}\right)^3 \frac{1~\text{min}}{60~\text{s}} = 11.4~\text{g/s}

Valve flow coefficients and flow models

Often valve performance is specified with a valve flow coefficient. In the US, this usually is called C_\text{v} where v refers to valve. (This is not the heat capacity at constant volume. Again, this is another confusing point.)

Like the valve flow rate, C_\text{v} is defined in terms of liquid, not gas flows. C_\text{v} is defined as the volumetric flow rate in gallons per minute (GPM) for a pressure drop of 1 psi. There are some mainly empirical equations (scroll down to the section “Flow Coefficient – Cv – for Air and other Gases”) that can be used to calculate the volumetric flow rate (and mass flow rate from there). The “derivation” of this model is available in this book.

For more information on this subject, I suggest reading my notes about Nerf engineering, which contain many references to other materials. In particular, I detail a more accurate empirical valve model that can be used in computer simulations.

Accuracy of manufacturer data

You should always question the accuracy of valve manufacturer data (assuming that you understand what it means, which, as I’ve explained, isn’t always clear). In my experience, the flow rates given seem to be optimistic. It’s not easy to quantify how optimistic they are, but you should keep this in mind.

An aside

I could insert a long rant about how some engineers don’t understand what they are doing and treat some equations like magic black boxes which give them “the answer”. They don’t understand the assumptions or development of the equation. They don’t try to improve the equation to be more general, more useful, or less confusing, e.g., by eliminating confusing “standard” volumetric flow rates and moving to obvious mass flow rates. This practice creates a lot of confusion for people who do know what they are doing. If you are in engineering, please, don’t be one of these folks.

Posted in Interior ballistics, Math, Misconceptions, Pneumatics | Comments Off on Notes about valves and flow rates

Nerf Engineering notes

Posted by btrettel on July 8, 2012

I’ve started organizing my writings and thoughts on Nerf ballistics into a set of notes (link corrected). Readers of my blog might be interested.

For the moment my notes are very rough and incomplete. I’ll update the PDF as I make changes. I’d appreciate any feedback, especially corrections and ideas.

Edit (2012-10-02): I’ve removed the notes because they need a lot of work before I’m comfortable distributing them.

Edit (2013-01-19): I’ve readded the notes as I’ve revised them somewhat. They are still a work in progress.

Posted in Design, Exterior ballistics, Interior ballistics, Math, Pneumatics, Safety, Springers, Terminal ballistics | 2 Comments »

Solving the point mass model of a dart’s trajectory, part two

Posted by btrettel on June 12, 2011

I wrote a technical paper about solving these equations and made some conclusions for design. I have fully solved the flat-fire case given that the x velocity stays above a certain number (and it generally will).

(Original link broken: My newer notes contain that paper and more.)

The take-home message is pretty simple: Keep kinetic energy constant. If you reduce the drag coefficient multiplied by the cross-sectional area, you’ll increase range. If you reduce the muzzle velocity divided by the dart mass, you’ll increase range.

The latter conclusion is not too surprising to me as I already knew dart mass had an effect like that, but to quantify the effect is very nice.

I’d happily accept corrections, comments, questions, suggestions, and whatever else.

Posted in Exterior ballistics, Math | 2 Comments »

boltsniper’s optimal barrel length formula

Posted by btrettel on June 11, 2011

Whenever there is a thread about one of the holy grails of Nerf ballistics, an equation for the barrel length that maximizes performance, someone is bound to mention the results of some tests boltsniper did in 2005 when he was designing the FAR. boltsniper, for the uninitiated, is one of the few engineers in the Nerf hobby, so his words have some authority behind them. People generally misrepresent what he said and overstate this formula’s abilities. What boltsniper actually said is written below. The emphasis is mine.

I did some experimentation to determine what would be the optimal barrel length for a given plunger size.  The goal was to find the barrel length for which the dart would exit the barrel as the plunger reaches the end of the plunger tube.  I started off by matching the volume of the plunger to the volume of the barrel.  I knew that this was going to produce too long a barrel but it was a good place to start.  This would assume that the air inside the plunger and barrel is incompressible and that there are no leaks.  In the real world this is not the case.  I reduced the barrel length until I had found the length at which the dart was leaving the barrel as the plunger was reaching its stop, coinciding with the maximum attainable range.  Experimentally the plunger volume seems to be about 4 times that of the barrel.  The relation for barrel to plunger size can be summed up in the following equation,

4 \pi r_b^2 l_b = \pi r_p^2 l_p

where r_b is the barrel radius, r_p is the plunger radius, l_b is the barrel length, and l_p is the plunger length.  For Nerf applications the barrel is almost always 1/2″ PVC or CPVC.  r_b can then be set as a constant at 0.25″ and removed from the equation.  Since we are trying to solve for the barrel length with a given plunger size, the equation can be rearranged and simplified to:

l_b = D_p^2 l_p

This simple equation makes it easy to roughly but quickly size a barrel to a given plunger.  The equation could also be used to size a plunger for a given length barrel.  This equation is based on experimental data and is not perfect.  Four is not the golden number.  This produces the optimal barrel length for the situation I was testing.  The type of dart, dart-barrel friction, and total system volume will likely effect the optimal ratio.  Nevertheless, the above equation can be used as a starting point.

The last paragraph seems to be completely ignored by most people who use this formula. At best it’s a starting point for further testing. The equation only applies to the FAR as that was all that he tested.

boltsniper later expanded on the restrictions on the use of this formula at NerfHaven. (Again, the emphasis is my own.)

I derived that empirically and more importantly it was derived for the specific situation I intended on using it for: a plunger weapon. It will not work for a compressed air system. One of the big factors I used to come up with that was the lack of compressibility. I later factored that in with a constant that was derived empirically. My tests were with a setup exactly like I was going to use on a the finished product. If you scale the system down that magic constant may not hold true.

There are too many variables to analytically design the optimal barrel length. If you are going to build or mod a spring gun the equation I provided may be a good starting point. That equation gives a barrel length that is slightly too long, so to obtain the optimal length you are going to have to go shorter.

The only real way to do it is experimentally.

The short message is that this equation only applies for the situation he was testing for.

But does it even apply for that situation? I’d argue no. boltsniper wasn’t testing for optimal barrel length. In his own words (which I emphasized above), boltsniper’s “goal was to find the barrel length for which the dart would exit the barrel as the plunger reaches the end of the plunger tube.” This does not coincide with when performance peaks based on my understanding of the interior ballistic processes.

Performance is maximized when acceleration slows to zero. If the plunger is at the end of the plunger tube, the pressure is approximately maximized. This corresponds to maximum acceleration because the force is maximized, not maximum velocity. The ideal barrel length is definitely longer in this case.

(I’ll mostly ignore the question of how he knew the plunger struck the end of the tube when the dart left. I seriously question how he determined that. The entire process occurs in a fraction of a second. He’d need a high speed camera with a clear plunger tube and barrel, some other optimal system, some acoustic system, some similar combination, or something I’m not considering to actually determine this with accuracy.)

In summary, this formula should not be used for general purpose design to approximate ideal barrel length. I suggest using a chronometer, ballistic pendulum, or some other device or procedure to measure the muzzle velocity or where it stops increasing as the barrel length is changed. Alternatively, range can be measured, but please note that drag can cause range to not increase from increases in muzzle velocity, the performance parameter that we’re examining.

If more general-purpose approximations are wanted, I have developed approximate equations for ideal barrel length of pneumatics and springers based on adiabatic process relationships. These equations apply when the pressure in the barrel approximately equals the pressure in the gas chamber or plunger tube. For pneumatics, this is valid for very fast and high speed valves and very heavy projectiles. For springers, this is valid for very heavy projectiles. How heavy “very heavy” is depends on the situation, and I have not fully developed a criteria to determine this. The link contains an approximation I developed a year ago.

Posted in Design, Interior ballistics, Math, Misconceptions | Comments Off on boltsniper’s optimal barrel length formula

Solving the point mass model of a dart’s trajectory, part one

Posted by btrettel on June 7, 2011

This blog post is relatively math heavy and it serves mostly as notes for my own use. I will assume some familiarity with differential calculus and ordinary differential equations. I also will assume some familiarity with the basic equations that govern the motion of Nerf darts after they leave the barrel.

Yesterday I had an epiphany while in the shower about a potential approach to solve the equations for the trajectory of a point mass with quadratic drag. This is a simplification to the standard equations of motion for the trajectory of a point mass in 2D with quadratic drag. These equations are presented below without derivation (or an explanation of what k is).

EOM in x: \ddot{x} = -k \dot{x} \sqrt{\dot{x}^2 + \dot{y}^2}

EOM in y: \ddot{y} = -k \dot{y} \sqrt{\dot{x}^2 + \dot{y}^2} - g

These are two coupled non-linear ODEs. To the best of my knowledge, there is no known solution in terms of elementary functions. You either have to define new functions to solve these equations or solve them numerically, as I have done in the past.

But we can do a few tricks to get an okay approximation. Note that the vast majority of shots from Nerf guns are level. Basically, this means that the y component of velocity is far smaller than the x component. If we ignore drag and solve \ddot{y} = -g directly, we can find that the maximum velocity of a Nerf dart in the y direction is less than 10 m/s. But Nerf darts almost always will be traveling faster than 30 m/s. If we assume that \sqrt{\dot{x}^2 + \dot{y}^2} \approx \dot{x} we commit at worst a 5% error if the x velocity stays above 30 m/s. This is the assumption I will make.

For an even better approximation, there are a few things that could be done. A perturbation method could be used. A guess for \dot{y} could be made; \dot{y} = -g t, the y velocity neglecting drag, might be good for a conservative approximation. We could assume that \dot{y} is a function of \dot{x} or another variable (like the height, or range), perhaps even a multiple of it. The multiple case reduces to an extra factor the drag coefficient (already a fudge factor for our purposes) can absorb. I will not take any of these approaches as I am only exploring potentially valid solutions now.

With my assumption in mind, I’ll rewrite the EOM.

EOM in x: \ddot{x} = -k \dot{x}^2

EOM in y: \ddot{y} = -k \dot{x} \dot{y} - g

These equations are now uncoupled and only the first one is non-linear. I can solve for \dot{x} directly and substitute that into the second EOM.

\dot{x} can be solved for by doing the following change of variables:

z \equiv \dot{x}^2 \longrightarrow \dot{z} = 2 \dot{x} \ddot{x} \longrightarrow \ddot{x} = \displaystyle \frac{\dot{z}}{2 \sqrt{z}} \longrightarrow \dot{z} = -2 k z^{\tfrac{3}{2}} \longrightarrow z^{-\tfrac{1}{2}} = k t + c

I can substitute back in my definition for z to get \dot{x}. I’ll use the initial condition \dot{x}(t = 0) = V_0 to get the complete solution.

\dot{x} = \displaystyle \frac{1}{k t +c} \longrightarrow \dot{x}(t) = \displaystyle \frac{V_0}{V_0 k t + 1}

Now we must solve the EOM in y. The equation is written below with \dot{x} substituted in. I defined A \equiv k V_0.

\ddot{y} = -\displaystyle \frac{A \dot{y}}{A t + 1} - g

I will use a change of variables and omit most of the details. \xi = \text{ln}(A t + 1)

The ODE with these changes becomes y_{\xi \xi} = - \displaystyle \frac{g e^{2 \xi}}{A^2} where the subscript represents differentiation with respect to that variable. The general solution for this ODE is y = B \xi + C - \displaystyle \frac{g e^{2 \xi}}{4 A^2}.

Substituting back in for y and t and using the ICs \dot{y}(0) = 0 (the dart does not start with any vertical velocity as it is fired flat) and y(0) = h where h is the height of the barrel I arrive at the following equation for the dart’s y position as a function of time.

y(t) = h + \displaystyle \frac{g}{2 (k V_0)^2} \text{ln}(k V_0 t + 1) - \displaystyle \frac{g t}{2 k V_0} - \displaystyle \frac{g t^2}{4}

This is correct. You can solve for \dot{y} and \ddot{y} and substitute back into the ODE to check. You can also check the ICs; they are satisfied. Additionally, the solution approaches the solution without drag. At first I thought it did not, but it can be shown to approach this solution exactly with Taylor series expansion.

To get the range, we must find time  the dart hits the ground. Yet the equation above can not be solved for t explicitly.

So I can find an approximate solution that is undesirable because I can’t proceed to get the range equation. I can think of a few options from here. One is to approximate the equation for y to find an approximate time. Another is to modify the original ODEs in a way that allows for the time to be found. Yet another is to use the identity \ddot{x} dx =\dot{x} d \dot{x} (and the equivalent for y) to avoid time all together, but this approach has another problem: what \dot{x} and \dot{y} correspond to when the dart strikes the ground?

In my next post I will prove that this solution is correct and converges to the solution without drag as k \rightarrow \infty and develop some approximations for different scenarios.

(I had some incorrect ramblings here before. They have been removed.)

Edit: In the next post I will show how the form of the solution for x(t) probably will save us and allow an explicit equation for the range to be formed. x(t) = \displaystyle \frac{\text{ln}(V_0 k t + 1)}{k}. Note that this allows us to replace the ln term in the y equation with a multiple of x. x = R (the range) when the dart hits the ground… this may allow us to find the time the dart hits the ground as a function of R, which we can substitute back into the x equation to solve (hopefully) for R. That is the outline of what I will attempt now.

Edit again: I believe this is an adequate approximate equation for the range of a flat fired Nerf gun:

R = \displaystyle \frac{1}{C} \text{ln} \left(\frac{h (C V_0)^2}{g} + 1 + \text{ln} \left(\frac{h (C V_0)^2}{g} + 1 \right) \right), where C \equiv \displaystyle \frac{\rho_{atm} C_d A}{m} .

An okay simpler approximation follows.

R = \displaystyle \frac{1}{C} \text{ln} \left(\frac{h (C  V_0)^2}{g} + \frac{27}{25} \right)

Posted in Exterior ballistics, Math | Leave a Comment »

Approximate expansion diameter of latex tubing

Posted by btrettel on June 5, 2011

I previously wrote about how to estimate the expansion diameter of latex tubing, but I made no measurements to verify that the formula I suggested, 8.5 D_i + 2 t where D_i is the unexpanded inner diameter of the tube and t is the unexpanded tube wall thickness, was accurate.

Back in 2010, I made some measurements for tests that were aborted as the tubes continually burst. I was testing higher pressure tubes. These tubes have a tendency to burst and they are extremely loud when they burst if you fill them with air. I do not suggest testing latex tubes with air for this reason.

So, I have three data points and a reasonable understanding of the geometry of these tubes. I’ll make a better estimate for expansion diameter.

I’ll start with a few assumptions. When the tube expands, it is assumed to stop expanding when its expanded inner diameter equals a certain multiple of the unexpanded diameter. This is justifiable based on the observed behavior of the rubber. The Gent hyperelastic model makes the same assumption. My second assumption is that when the tube is fully expanded the cross sectional area of the expanded tube is a multiple of the cross sectional area of the unexpanded tube. I originally anticipated these areas would be equal as I know for small deformations, rubber is approximately incompressible (i.e. the volume is preserved). But that’s only applicable for volume, not area; the tube is expanding in length too. Also, it is only applicable for small deformations. I do not know how the rubber will act for large deformations.

D_o is the outer diameter of the tube. D_i is the inner diameter of the tube. t is the tube wall thickness. The superscript e refers to the expanded state. A variable or constant without e is in the unexpanded state or it does not refer to any state (like the constants).

A = \tfrac{\pi}{4} (D_o^2-D_i^2) is the equation for the cross sectional area of the unexpanded tube.

A^e = \tfrac{\pi}{4} [(D_o^e)^2-(D_i^e)^2] is the equation for the cross sectional area of the expanded tube.

D_i^e = C_1 D_i is my assumption about when the tubes stop expanding.

A^e = C_2 A, where C_2 is my assumption about the cross sectional areas of the tubes when they stop expanding.

Plugging all these equations together and solving for D_o^e, I find that D_o^e = \sqrt{C_1^2 D_i^2 + 4 t C_2 (D_i + t_i)}.

The data points I have available:

  • Unexpanded ID: 3/8″, wall thickness: 3/16″, expanded OD: a bit more than 3″ (from memory)
  • Unexpanded ID: 1/8″, wall thickness: 3/16″, expanded OD: 1.25″
  • Unexpanded ID: 1/8″, wall thickness: 7/32″, expanded OD: 1.375″

A linear regression leads toC_1 = 7.35 andC_2 = 3.33 (R^2 = 0.9999, which would definitely be lower if there were more data points). These constants seem reasonable given my understanding of the phenomena, so it is reasonable to accept that the tubes’ inner diameters expand to about 7.35 times their original inner diameter and the cross sectional area increases by 3.33 times.

The equation above with these constants can be used to find the expanded outer diameter. The equation with C_1 can find the expanded inner diameter. The definition D_o^e = D_i^e + 2 t^e can find the expanded wall thickness.

Further tests are necessary, but this formula is the best I can do with the data I have on hand.

An equation for the inner diameter of a tube if the outer diameter is restricted (i.e. does not fully expand) follows. This is based on the assumption that the area ratio scales linearly with the inner diameter ratio.

D_i^e = (C_1 D_i)^{-1} [\sqrt{4(t C_2)^2 (D_i + t)^2 + (C_1 D_i)^2 (D_o^e)^2} - 2 t C_2 (D_i + t)]

Posted in Design, Math, Pneumatics, Uncategorized | Leave a Comment »