I am working on building a little game program like this one for a sky diving sim and I have got a lot of the equations down but my terminal velocity is way too high for the given alt for any of this. I have been looking at this and gone over it the only thing I can think of is that I have one of the measurements wrong or something. Any help will be appreciated with this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GasLaws
{
class Program
{
static void Main(string[] args)
{
double temperature;
double airPressure;
double airDensity;
double tV;
double alt;
//constants
const double gasCont = 287.05;
const double startTemp = 15; //this is C ground level
const double aidRate = 0.0065; //adiobatic rate for temperature by elevation
//Human Constannts
const double drag = 0.7; //in meters
const double area = 7.5; //ft^2
const double wieght = 175;
Console.WriteLine("Enter the alt in feet");
int tempint = Int32.Parse(Console.ReadLine());
alt = (double)tempint * 0.3048; //convert feet to meters
Console.WriteLine("Alt = " + alt + " m");
//calculate air pressur
airPressure = AirPressure(alt);
temperature = CalTemp(startTemp, alt, aidRate);
airDensity = AirDensity(airPressure, gasCont, temperature);
tV = TerminalVelocity(wieght, drag, airDensity, area);
//pasue screen for a second
Console.ReadLine();
}
//p = 101325(1-2.25577 * 10^-5 * alt) ^5
//this calculates correctly
private static double AirPressure(double al)
{
double tempAlt = 1 - 2.25577 * 0.00001 * al;
Console.WriteLine("Inside eq = " + tempAlt);
tempAlt = Math.Pow(tempAlt, 5 );
Console.WriteLine("Power of 5 = " + tempAlt);
tempAlt = 101325 * tempAlt;
Console.WriteLine("Pressure is = " + tempAlt + " Pascal");
return tempAlt;
}
//temperature calculation
// use adiobatic rate to calculate this
//this is right
private static double CalTemp(double t, double al, double rate) //start temperature and altitude
{
double nTemp = t;
for (int i = 0; i < al; i++)
{
nTemp -= rate;
}
Console.WriteLine("Temperature in for loop = " + nTemp);
return nTemp;
}
//claculate like this
//D Pressure / gas constant * temperature
//this works fine
private static double AirDensity(double pres, double gas, double temp)
{
temp = temp + 273.15; //convert temperautre to Kelvans
double dens = pres / (gas * temp);
dens = dens / 1000;
Console.WriteLine("PResure = " + pres);
Console.WriteLine("Gas cont = " + gas);
Console.WriteLine("Temperture = " + temp);
Console.WriteLine("Air Density is: " + dens);
return dens;
}
private static double TerminalVelocity(double w, double cd, double p, double a)
{
double v = (2 * w) / (cd * p * a) ;
v = Math.Sqrt(v);
Console.WriteLine("Terminal Velocity = " + v);
return v;
}
}
}
Your formula doesn't seem to include gravitational acceleration, and you are also mixing SI and US/imperial units. What unit will your calculated velocity have? It would probably be easier if you stay with SI units only. Another thing that looks a little strange is this line:
const double drag = 0.7; //in meters
The drag coefficient is a dimensionless number. It shouldn't have a physical unit (like meter).
The correct formula is:
v = sqrt((2 * m * g) / (d * A * C))
The variables, with corresponding SI units, are:
m [kg] - Mass of falling body.
g [m/s^2] - Gravitational acceleration.
d [kg/m^3] - Air density.
A [m^2] - Projected area.
C [-] - Drag coefficient.
If you use these units, the formula will yield the velocity in [m/s]. As an example. let's try the following values with units as above: m=80, g=9.8, d=1, A=0.7, C=0.7
This gives the terminal velocity v = 57 m/s which seems reasonable.