Ballistics

Started by Logi, February 22, 2011, 09:40:58 PM

Previous topic - Next topic

Logi

If I could get some input and help as to the formula etc. for naval gunnery (with regard to range etc.) such as that in Nobody's Ballistic program, I can finish this part of this thing I'm writing.

I'm lacking a "solid" imagery of what happens between muzzle and impact point.

Also, I might come back and ask for other things in this thread. Any help would be greatly appreciated.

Desertfox

Funny, just today in class we where writing a computer program to calculate precisely that. You need muzzle velocity, gun angle, and drag coefficient. The equation used will be a 2nd Order Differential Equation. I don't have it with me atm but I can get it to you by Thursday. What program are you using?
"We don't run from the end of the world. We CHARGE!" Schlock

http://www.schlockmercenary.com/d/20090102.html

Nobody

I don't know a fixed formula, I use a approximated step by step calculation.

You have air drag:
   Fw := 1/2 * roh * v² * A * cw
with
   Fw   -   the force which decelerates your shell
   roh   -   the air density, pressure or altitude dependent
   v   -   speed
   A   -   cross section area of the shell (A := Pi * r²)
   cw   -   air drag coefficient, shape and speed dependent

and don't forget the gravity which ultimately gets the shell back to earth.

So besides muzzle velocity, gun angle and a speed dependent drag coefficient you also need the diameter and the mass of the shell. Not to mention that the surface of the earth is a curve, which makes everything more complicated - at least if you want to be precise.
Nothing of this is is really complicated though, it's just a bit of physics.

What programming language are you using?
What do you need it for?

Logi

I'm writing my own program in Java, as a part that might be useful for an integrated simulation program.

I've been using muzzle energy (as by P3D's approximation) to approximate muzzle velocity, and it seems to be in the right ballpark.

I would like to be generally precise, it doesn't have to be precise to the digits, but precise in the process and concept.

Nobody

I don't like P3D's formula, but I have to admit that it works - somehow.

Java... haven't used that for ages. If someone could tell me how to read from files with it I might be able rewrite my "algorithms", but not this week.

Logi

The air drag is a parallel force to the direction of movement, correct?

Logi

#6
Can any of you spot the error in calculation? It's giving me weird numbers if the fire angle isn't 45 degrees.

public void Ballistic(double dia, double cal, double m, double a, double h){
      //initializes values, xCord and yCord are on grid. Assumes direction flow is in xCord. yCord is for deviation such as wind. Wind deviation not yet implemented.
      diameter = dia;
      caliber = cal;
      mass = m;
      angle = a;
      
      muzzleEnergy = caliber * Math.pow(getDia(), 3) * 0.04;
      muzzleVelocity = Math.sqrt(getME() * 2000000.0 / getMass());
      currentVelocity = muzzleVelocity;
      
      xVelocity = Math.cos(angle) * getMV();
      yVelocity = Math.sin(angle) * getMV();
      
      xCord = 0;
      yCord = 0;
      
      distance = 0;
      height = 3.28 * h;
   }
   
   public void deceleration(){
      //Fw = 0.5 * roh * v^2 * A * cw
      // Fw - the force which decelerates your shell
      // roh - air density, pressure, or altitude dependent --> 1.21 * Math.exp(height/ 8000)  -> 1.29 at STP
      // v - speed
      // A - cross-section area of the shell (A = Pi * r^2)

      // cw - air drag coefficient, shape, and speed dependent. Set to approximate constant 0.28 (USN 14" and 16" SuperHeavy varies from 0.26 to 0.3) -- Using 0.3 for USN 16" 2700lb for now.

      
      dragForce = 1.29 * Math.pow(currentVelocity, 2) * Pi * Math.pow(getDia() / 2, 2) * 0.30 * 0.000025;
      
      deceleration = 3.28 * dragForce / getMass();
      
      xtemp = xVelocity;
      ytemp = yVelocity;
      
      if (height > 0){
         
         xVelocity -= Math.cos(angle) * deceleration;
         yVelocity -= 32.174 + (Math.sin(angle) * deceleration);
         
         currentVelocity = Math.sqrt( Math.pow(xVelocity, 2) + Math.pow(yVelocity, 2));
         
         angle = Math.asin(yVelocity / currentVelocity);
         
         time++;
         
         distance += Math.abs((xVelocity + xtemp) / 2);
         height += (yVelocity + ytemp) / 2;
         
         xCord = distance;
      }
   }


It gives me 41.5 kyd as the range for the 16"/50 2700lb at 45 degrees but spits out 75.6 kyd (it's -75.6 kyd without the abs for distance) for the 16"/50 2700lb at 40 degrees.

If I do it on paper using the same equations, I get a correct number, that is 40 degrees gets less range in the positive direction than 45 degrees.

Nobody

#7
Actually no, because none of the formulae makes sense to me. Probably because you are trying not to use SI-units. So all I see are strange constants between bits that might have be physics once.


EDIT
Maybe you should check the sign (direction) of the the gravity and/or the sinus.

Logi

#8
You are correct on the trying to not use SI-units portion. It's all in imperial units as whilst I can use SI in a physics setting, I have no feel of what the numbers mean (I can't tell how big something approximately is if you said 100 meters, 328 feet on the other hand I can tell).

I think I've got it. It's because Math.asin, etc returns in radians. I was expecting it to return in degrees.

Edit: Yes, it works reasonably now. The deceleration is probably mess up but at least 45 degrees is indeed the most range now.

Problem is 45 and 40 degrees only differ by 200 yards and 40 and 30 by 1200 yards.


Problem fixed but the values are still slightly off. 30 degrees gives 33 kyd, 40 degrees gives 41 kyd, 45 degrees gives 43 kyd.

Edit2: I actually think it's good enough considering your Ballistic program gives very similar numbers.

Nobody

Quote from: Logi on February 25, 2011, 09:58:53 AM
You are correct on the trying to not use SI-units portion. It's all in imperial units as whilst I can use SI in a physics setting, I have no feel of what the numbers mean (I can't tell how big something approximately is if you said 100 meters, 328 feet on the other hand I can tell).
... *nothing to say* *silently shaking the head*

QuoteProblem fixed but the values are still slightly off. 30 degrees gives 33 kyd, 40 degrees gives 41 kyd, 45 degrees gives 43 kyd.

Edit2: I actually think it's good enough considering your Ballistic program gives very similar numbers.
Ah well that's probably because approximating the US 16" shells with constant air drag gives very poor results. You could try the German shells, at least with my program the results were usually much closer to the data tables one can find.

Logi

QuoteAh well that's probably because approximating the US 16" shells with constant air drag gives very poor results. You could try the German shells, at least with my program the results were usually much closer to the data tables one can find.

Yes that's quite true. I also find it strange how the air drag coefficients of German shells seem to all be at 0.01 and the USN shells are all at 0.026 to 0.029.

Nobody

Quote from: Logi on February 25, 2011, 12:57:43 PM
QuoteAh well that's probably because approximating the US 16" shells with constant air drag gives very poor results. You could try the German shells, at least with my program the results were usually much closer to the data tables one can find.

Yes that's quite true. I also find it strange how the air drag coefficients of German shells seem to all be at 0.01 and the USN shells are all at 0.026 to 0.029.
That sounds like a major error to me (or you have unit depending constants in your drag coefficient). In my program the German shells were around 0.31 and the US ones varied between 0.2 and 0.35, if I remember correctly, depending on range. However this calculation already included the falling air pressure. I don't think you have that already, have you?

Logi

#12
I added it back it, I think it was something like 1.21 * Math.exp(- height / 8000).

QuoteThat sounds like a major error to me (or you have unit depending constants in your drag coefficient). In my program the German shells were around 0.31 and the US ones varied between 0.2 and 0.35, if I remember correctly, depending on range.

I checked and it's another unit conversion error. I calculated the German shells with the SI system whilst I used Imperial fro the USN shells.

Now it's much more accurate for the USN shells, although still a bit off.

Nobody

Quote from: Logi on February 25, 2011, 01:53:15 PM
I added it back it, I think it was something like 1.21 * Math.exp(- height / 8000).
Just to make sure thats metric again, isn't it?

Quote
QuoteThat sounds like a major error to me (or you have unit depending constants in your drag coefficient). In my program the German shells were around 0.31 and the US ones varied between 0.2 and 0.35, if I remember correctly, depending on range.

I checked and it's another unit conversion error. I calculated the German shells with the SI system whilst I used Imperial fro the USN shells.
Just another proof you would do better calculating in SI  ;D

Logi

QuoteJust to make sure thats metric again, isn't it?
Yes, now I have to convert something again :-\

QuoteJust another proof you would do better calculating in SI  Grin
I could but then I would have no clue what the numbers mean, and I really don't want to convert everything back.