1 package net.sf.openrocket.aerodynamics;
3 public class AtmosphericConditions implements Cloneable {
5 /** Specific gas constant of dry air. */
6 public static final double R = 287.053;
8 /** Specific heat ratio of air. */
9 public static final double GAMMA = 1.4;
11 /** The standard air pressure (1.01325 bar). */
12 public static final double STANDARD_PRESSURE = 101325.0;
14 /** The standard air temperature (20 degrees Celcius). */
15 public static final double STANDARD_TEMPERATURE = 293.15;
19 /** Air pressure, in Pascals. */
20 public double pressure = STANDARD_PRESSURE;
22 /** Air temperature, in Kelvins. */
23 public double temperature = STANDARD_TEMPERATURE;
27 * Construct standard atmospheric conditions.
29 public AtmosphericConditions() {
34 * Construct specified atmospheric conditions.
36 * @param temperature the temperature in Kelvins.
37 * @param pressure the pressure in Pascals.
39 public AtmosphericConditions(double temperature, double pressure) {
40 this.temperature = temperature;
41 this.pressure = pressure;
47 * Return the current density of air for dry air.
49 * @return the current density of air.
51 public double getDensity() {
52 return pressure / (R*temperature);
57 * Return the current speed of sound for dry air.
59 * The speed of sound is calculated using the expansion around the temperature 0 C
60 * <code> c = 331.3 + 0.606*T </code> where T is in Celcius. The result is accurate
61 * to about 0.5 m/s for temperatures between -30 and 30 C, and within 2 m/s
62 * for temperatures between -55 and 30 C.
64 * @return the current speed of sound.
66 public double getMachSpeed() {
67 return 165.77 + 0.606 * temperature;
72 * Return the current kinematic viscosity of the air.
74 * The effect of temperature on the viscosity of a gas can be computed using
75 * Sutherland's formula. In the region of -40 ... 40 degrees Celcius the effect
76 * is highly linear, and thus a linear approximation is used in its stead.
77 * This is divided by the result of {@link #getDensity()} to achieve the
78 * kinematic viscosity.
80 * @return the current kinematic viscosity.
82 public double getKinematicViscosity() {
83 double v = 3.7291e-06 + 4.9944e-08 * temperature;
84 return v / getDensity();
88 * Return a copy of the atmospheric conditions.
91 public AtmosphericConditions clone() {
93 return (AtmosphericConditions) super.clone();
94 } catch (CloneNotSupportedException e) {
95 throw new RuntimeException("BUG: CloneNotSupportedException encountered!");
101 public String toString() {
102 return String.format("AtmosphericConditions[T=%.2f,P=%.2f]", temperature, pressure);