Warning

 

Close

Confirm Action

Are you sure you wish to do this?

Confirm Cancel
BCM
User Panel

Site Notices
Posted: 11/14/2017 10:01:16 PM EDT
Background:

I have a new air rifle that has three "power" (muzzle energy) settings.  The way it works is it changes the size of the transfer port.  What I want is to find an equation that will allow me to estimate the size needed to change the muzzle energy to a desired level.

The way it is now an approximately .078" diameter port produces about 12 ft-lbs of muzzle energy, a .096" diameter port results in 25 ft-lbs, and .209 gives 45 ft-lbs.  My first thought was that the area of the port and energy would be linear, but that proved not to be the case.  The diameter with respect to energy is closer to being linear, but is not.  Upon plotting the points it appears that the equation will have the following form:

Y = A X B + C

where A, B, and C are the unknowns.  Y is the port size, and X is the muzzle energy.

So, how do you solve for the A, B, and C when the equations have this form:

Y1 = A X1B + C

Y2 = A X2B + C

Y3 = A X3B + C


I'm mostly quite fuzzy about how to handle the exponent B, especially since it may not be an integer.  (If it turns out to be about 1.4, things are showing that adiabatic expansion is definitely occurring.)
Link Posted: 11/14/2017 10:08:09 PM EDT
[#1]
Quoted:
Background:

I have a new air rifle that has three "power" (muzzle energy) settings.  The way it works is it changes the size of the transfer port.  What I want is to find an equation that will allow me to estimate the size needed to change the muzzle energy to a desired level.

The way it is now an approximately .078" diameter port produces about 12 ft-lbs of muzzle energy, a .096" diameter port results in 25 ft-lbs, and .209 gives 45 ft-lbs.  My first thought was that the area of the port and energy would be linear, but that proved not to be the case.  The diameter with respect to energy is closer to being linear, but is not.  Upon plotting the points it appears that the equation will have the following form:

Y = A X B + C

where A, B, and C are the unknowns.  Y is the port size, and X is the muzzle energy.

So, how do you solve for the A, B, and C when the equations have this form:

Y1 = A X1B + C

Y2 = A X2B + C

Y3 = A X3B + C

I'm mostly quite fuzzy about how to handle the exponent B, especially since it may not be an integer.  (If it turns out to be about 1.4, things are showing that adiabatic expansion is definitely occurring.)
View Quote



The way those are set up, A, B, and C are constants.   You have 3 equations and 3 unknowns.  Start by solving the other equations for a different unknown and then substitute into the others, and repeat.  I would solve for b last, since  you are going to have "Root B" = (Y-C)/AX
Link Posted: 11/18/2017 1:06:11 AM EDT
[#2]
With only three points, your fit sensitivity to small measurement errors is going to be horrendous.  I understand that's how your rifle is set up, just don't expect great predictions out of this data.

You can convert you problem to a linear least-squares regression by doing a couple of transformations.  First, physical principles would imply that C=0.  Set up your data as vectors: Y=[y1;y2;y3] and X=[x1;x2;x3].  You can now formulate the problem as Y=A*X^B.  Taking the logarithm of both sides yields ln(Y)=ln(A)+B*ln(X).  Let Z=ln(Y), R=ln(X), and F=ln(A).  Then you have Z=F+B*R.  Let Q=[ones(3,1),R] and T:=[F;B].  Then you can solve for T in the least-squares sense as T=pinv(Q)*Z.  Then you can back things out again by letting A=exp(T(1)) and B=T(2).

Results of applying the regression are shown below.  In this case T=[ 5.7124 ; 1.1806].  This is the best fit achievable using the power law I described above on your data.  Like I said, it looks pretty crappy.  You really want more points in your dataset to do these kind of things.  I also didn't really get anything better by looking at port area instead of diameter.  It may be that a power law isn't the best model for your data.  More sophisticated stuff will likely require you to switch over to nonlinear least squares, which is a whole other ball of wax.

Link Posted: 11/18/2017 12:13:30 PM EDT
[#3]
I took a look at the nonlinear least-squares version of this, which is not great either.  In this case, I can allow a nonzero C, but we lose the ability to guarantee an optimal solution.  The solution appears to be nonunique, i.e. there are an infinite number of combinations of A,B,C that produce approximately the same fit.

For a given starting guess, I was able to compute a solution [A,B,C]=[1.18e+04;0.00264;-1.17e+04].  The plots shown below compare that fit to your table data, as well as to interpolated/extrapolated table data.

Link Posted: 11/18/2017 1:36:30 PM EDT
[#4]
Though you might think that C would be zero, this is most likely not the real case.  There are significant energy absorbing things going on with the rifle.  Not the least of which are friction of the pellet in the barrel, a minimum volume of air to get the pellet all the way out the barrel, minimum energy just to get the pellet moving, and heat loss upon the gas expanding through all the various parts of the valve, and ports.

The primary idea behind this exercise is to get some approximations on port sizes for energy levels I desire, and then make a power adjustment wheel accordingly.  I could take the trial and error approach, and I expect that there will be a bit of that in the end.  But, that would mean a lot more machining time and material. (I would get a lot more data points doing this, however.)  I just want to have some better starting points than a linear approximation.

The other purpose of this exercise is to refresh some of my disused math skills.

Where I got with the substitutions and am stuck (assuming I did the algebra correctly) is as follows:

I got C and A in terms of Y where and got the Y terms on the left side and the XnB terms on the right.

Letting Y be solved terms of Yn I have:

Y = ( X3B-X1B ) / ( X2B-X1B )

Now I know there is a way to use the Logarithm function, but I cannot seem to recall the rules for a fraction of this type.
Link Posted: 11/19/2017 12:18:36 AM EDT
[#5]
I am not aware of any explicit solution to your system of equations when C is a free parameter.  3 equations and 3 unknowns does not guarantee that an explicit solution exists.  It can be "solved" numerically with something like a Levenberg-Marquardt algorithm, which is essentially what I showed above.
Link Posted: 11/19/2017 3:11:33 PM EDT
[#6]
Well, I think I have found a satisfactory solution.  I had some semi-log paper.  I made to plots using the data points I have.  One plot has the energy on the logarithmic axis while the other has the diameter on that axis.  Going very old school, I dug out my french curves and drew smooth curves.  Both of these curves give very similar numbers---close enough to get started anyway.  One other thing about this method, is that the curves make sense with the physical situation.  That is, there is a diameter in which a peak energy will occur, and this is about the bore diameter.  Beyond that point, there will be an energy decrease.  Based on experience with other airguns and port sizes, this is what actually happens.  Also, at the other end, there is a diameter in which no muzzle energy will occur.  Very small changed in diameters at this end make a marked difference in energy.  This, too, is consistent with experience.
Link Posted: 11/21/2017 3:39:15 PM EDT
[#7]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Well, I think I have found a satisfactory solution.  I had some semi-log paper.  I made to plots using the data points I have.  One plot has the energy on the logarithmic axis while the other has the diameter on that axis.  Going very old school, I dug out my french curves and drew smooth curves.  Both of these curves give very similar numbers---close enough to get started anyway.  One other thing about this method, is that the curves make sense with the physical situation.  That is, there is a diameter in which a peak energy will occur, and this is about the bore diameter.  Beyond that point, there will be an energy decrease.  Based on experience with other airguns and port sizes, this is what actually happens.  Also, at the other end, there is a diameter in which no muzzle energy will occur.  Very small changed in diameters at this end make a marked difference in energy.  This, too, is consistent with experience.
View Quote
It takes a bunch of degrees of freedom and terms to approximate a curve like that.

Driving the curve fit software to do it takes a LOT of practice.
Link Posted: 11/25/2017 9:13:00 AM EDT
[#8]
Have you tried logging the equations?

Natural log (i.e. ln) has many useful properties such as:
xy = log(x) + log(y)
x^y = y*log(x)
<a href="http://www.rapidtables.com/math/algebra/Ln.htm">etc

</a>obligatory wikipedia page that probably has more detail than you need

use ln on the equations to remove the powers from X and they should become linear equations in log space. This makes it relatively easy to solve for the constants and then use E to remove the log influence.
Link Posted: 11/25/2017 9:14:48 PM EDT
[#9]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Have you tried logging the equations?

Natural log (i.e. ln) has many useful properties such as:
xy = log(x) + log(y)
x^y = y*log(x)
<a href="http://www.rapidtables.com/math/algebra/Ln.htm">etc

</a>obligatory wikipedia page that probably has more detail than you need

use ln on the equations to remove the powers from X and they should become linear equations in log space. This makes it relatively easy to solve for the constants and then use E to remove the log influence.
View Quote
That was done above.  But if he wants the affine constant C to be nonzero, then that method won't work anymore.
Link Posted: 12/5/2017 12:03:48 AM EDT
[#10]
We have 3 equations and 3 unknowns:

12 == a*0.078^b + c

25 == a*0.096^b + c

45 == a*0.209^b + c

Put c on the other side of the equalities:

12 - c == a*0.078^b

25 - c == a*0.096^b

45 - c == a*0.209^b

Divide the first equation by the second, and then divide the first equation by the third:

(12 - c)/(25 - c) == (0.078/0.096)^b

(12 - c)/(45 - c) == (0.078/0.209)^b

The a's cancel and now we have two equations and two unknowns. Take the Log of these:

Log[(12 - c)/(25 - c)] == b*Log[ 0.078/0.096]

Log[(12 - c)/(45 - c)] == b*Log[ 0.078/0.209]

The b's come down, and now we divide these equations and the b's cancel:

Log[(12 - c)/(25 - c)]/Log[(12 - c)/(45 - c)] == Log[ 0.078/0.096]/Log[ 0.078/0.209]

We are down to one equation and one unknown. An nonlinear equation like this could have one solution, many solutions, or no solutions. It happens that this equation has a single solution:

c = 50.3975

You can plot the equation above to see this, or use a root finder with a decent initial guess. I did both. Now we can substitute c into one of the above equations to get b:

b = Log[(12 - c)/(25 - c)]/Log[ 0.078/0.096] == -1.99067

Then substitute c and b into one of the first equations to get a:

a = (12 - c)/0.078^b = -0.239237

Putting it together:

y == -0.239237*x^-1.99067+50.3975

This curve matches the data points very accurately. Notice that a and b both came out to be negative. Positive b would let y increase without bound; that can't be correct for large enough x. If b were greater than 1, the curve would be concave upwards, and the data doesn't look that way. With this equation, the parameter c is the max energy as the port diameter goes to infinity. b happens to be very close to -2, maybe this equation is capturing some real physics.
Link Posted: 12/7/2017 11:36:07 PM EDT
[#11]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
We have 3 equations and 3 unknowns:

12 == a*0.078^b + c

25 == a*0.096^b + c

45 == a*0.209^b + c

Put c on the other side of the equalities:

12 - c == a*0.078^b

25 - c == a*0.096^b

45 - c == a*0.209^b

Divide the first equation by the second, and then divide the first equation by the third:

(12 - c)/(25 - c) == (0.078/0.096)^b

(12 - c)/(45 - c) == (0.078/0.209)^b

The a's cancel and now we have two equations and two unknowns. Take the Log of these:

Log[(12 - c)/(25 - c)] == b*Log[ 0.078/0.096]

Log[(12 - c)/(45 - c)] == b*Log[ 0.078/0.209]

The b's come down, and now we divide these equations and the b's cancel:

Log[(12 - c)/(25 - c)]/Log[(12 - c)/(45 - c)] == Log[ 0.078/0.096]/Log[ 0.078/0.209]

We are down to one equation and one unknown. An nonlinear equation like this could have one solution, many solutions, or no solutions. It happens that this equation has a single solution:

c = 50.3975

You can plot the equation above to see this, or use a root finder with a decent initial guess. I did both. Now we can substitute c into one of the above equations to get b:

b = Log[(12 - c)/(25 - c)]/Log[ 0.078/0.096] == -1.99067

Then substitute c and b into one of the first equations to get a:

a = (12 - c)/0.078^b = -0.239237

Putting it together:

y == -0.239237*x^-1.99067+50.3975

This curve matches the data points very accurately. Notice that a and b both came out to be negative. Positive b would let y increase without bound; that can't be correct for large enough x. If b were greater than 1, the curve would be concave upwards, and the data doesn't look that way. With this equation, the parameter c is the max energy as the port diameter goes to infinity. b happens to be very close to -2, maybe this equation is capturing some real physics.
View Quote
Huh, look at that!  Plugging something close to your answer into Levenburg-Marquardt ends up converging to the same result, although it looks like the initial guess has to be pretty close in order to converge.  Looks like that's why it missed the first time around.
Link Posted: 12/19/2017 3:39:45 PM EDT
[#12]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Huh, look at that!  Plugging something close to your answer into Levenburg-Marquardt ends up converging to the same result, although it looks like the initial guess has to be pretty close in order to converge.  Looks like that's why it missed the first time around.
View Quote View All Quotes
View All Quotes
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Quoted:
We have 3 equations and 3 unknowns:

12 == a*0.078^b + c

25 == a*0.096^b + c

45 == a*0.209^b + c

Put c on the other side of the equalities:

12 - c == a*0.078^b

25 - c == a*0.096^b

45 - c == a*0.209^b

Divide the first equation by the second, and then divide the first equation by the third:

(12 - c)/(25 - c) == (0.078/0.096)^b

(12 - c)/(45 - c) == (0.078/0.209)^b

The a's cancel and now we have two equations and two unknowns. Take the Log of these:

Log[(12 - c)/(25 - c)] == b*Log[ 0.078/0.096]

Log[(12 - c)/(45 - c)] == b*Log[ 0.078/0.209]

The b's come down, and now we divide these equations and the b's cancel:

Log[(12 - c)/(25 - c)]/Log[(12 - c)/(45 - c)] == Log[ 0.078/0.096]/Log[ 0.078/0.209]

We are down to one equation and one unknown. An nonlinear equation like this could have one solution, many solutions, or no solutions. It happens that this equation has a single solution:

c = 50.3975

You can plot the equation above to see this, or use a root finder with a decent initial guess. I did both. Now we can substitute c into one of the above equations to get b:

b = Log[(12 - c)/(25 - c)]/Log[ 0.078/0.096] == -1.99067

Then substitute c and b into one of the first equations to get a:

a = (12 - c)/0.078^b = -0.239237

Putting it together:

y == -0.239237*x^-1.99067+50.3975

This curve matches the data points very accurately. Notice that a and b both came out to be negative. Positive b would let y increase without bound; that can't be correct for large enough x. If b were greater than 1, the curve would be concave upwards, and the data doesn't look that way. With this equation, the parameter c is the max energy as the port diameter goes to infinity. b happens to be very close to -2, maybe this equation is capturing some real physics.
Huh, look at that!  Plugging something close to your answer into Levenburg-Marquardt ends up converging to the same result, although it looks like the initial guess has to be pretty close in order to converge.  Looks like that's why it missed the first time around.
Remember that almost all differential equations are actually solved by assuming a form for the solution and then adding terms to make it work in the defined equation.

Transformation of the set of equations using Laplace transform often reduces the solution to simple algebra in the Laplace domain.

You can even handle singularities in Laplace as long as convergence of series occurs.
Close Join Our Mail List to Stay Up To Date! Win a FREE Membership!

Sign up for the ARFCOM weekly newsletter and be entered to win a free ARFCOM membership. One new winner* is announced every week!

You will receive an email every Friday morning featuring the latest chatter from the hottest topics, breaking news surrounding legislation, as well as exclusive deals only available to ARFCOM email subscribers.


By signing up you agree to our User Agreement. *Must have a registered ARFCOM account to win.
Top Top