CALM is the only available model with viewable source code so I've been comparing my model against that and looking at the source code when I've had problems. Any problems I've had so far have been minor compared to what I have now.
My model does the same process as CALM and probably GGDT. I wrote some differential equations that control flow, pressure, and the forces on the projectile. My model figures out how much air flows through the valve in an interval, moves the projectile, changes the pressures accordingly, and repeats until the projectile leaves. This is rather rudimentary, yes, but it should be plenty adequate for a small air gun like what I intend to build.
There are two problems with my model, and they likely are related:
1) My model deviates from CALM at low volumes.
2) My model can produce impossible efficiencies.
At volumes at or higher than about 5 cubic inches, my model and CALM are within 1% of each other. At lower than 5 cubic inches, they deviate a small to substantial amount. I could post some examples, but you can run my model and CALM with the same data and see what's going on too.
I've also noticed that my model can produce situations with efficiency greater than 100%. I've looked at my code over and over again and can't seem to figure out where I've gone wrong. I think this problem is related to the deviation from CALM at low volumes because the impossible efficiencies occur at low volumes with high pressures and high Cv values.
Does anyone have any ideas about where my model goes wrong? If it would be helpful I can write out which specific equations I used on paper with explanations. Below is the Python code of my model at the moment.
Code: Select all
# internal.py - Internal ballistics
from math import *
# inputs
# Vc = input("Volume of air chamber (in^3) = ")
# L = input("Barrel length (in) = ")
# d = input("Barrel diameter (in) = ")
# P = input("Pressure (psig) = ")
# W = input("Projectile weight (lb) = ")
# Pf = input("Equivalent pressure of friction (psi) = ")
# Vd = input("Dead volume (in^3) = ")
# Cv = input("Cv = ")
# Vp = input("Pilot volume (in^3) =")
Vc = 20
L = 12
d = 0.5
P = 150
W = 0.1/16
Pf = 2
Vd = 0.5
Cv = 3
Vp = 0.3
# program specs
h = 0.00001 # interval in seconds
# constants
T = 530 # atmospheric temperature in degrees Rankine
Patm = 14.7 # atmospheric pressure in psia
g = 32.2 # acceleration due to gravity in ft/s^2
# convert P in gauge pressure to absolute pressure
Pc = Patm + P;
# convert weight W in lb to mass m in slug
m = W/g;
def Vb():
# Finds current barrel volume from X and d
return (pi/4) * pow(d,2) * x + Vd
# before looping...
t = 0
x = 0
x_dot = 0
Pb = Patm
PVb = Pb * Vb()
PVc = Pc * Vc
while x < L and t < (0.1 - h):
# keep accelerating the projectile until it leaves the barrel
if Pc < Pb:
Pc = Pb
PVb_dot = 462.24 * Cv * sqrt((pow(Pc,2) - pow(Pb,2))/T) * Patm
PVb = PVb + PVb_dot * h
PVc = PVc - PVb_dot * h
Pb = PVb/Vb()
Pc = PVc/Vc
x1_dot = ((12 * pi * pow(d,2))/(m * 4)) * (Pb - Patm - Pf)
x_dot = x_dot + h * x1_dot
x = x + h * x_dot
t = t + h
print "Vf =", x_dot/12
print "Tf =", t
print "Pf =", Pb
ke = 0.5 * pow(x_dot/12,2) * m
pe = (1.0/12) * (P + Patm) * (Vc + Vp) * log((P + Patm)/Patm)
print "KE =", ke
print "PE =", pe
print "eta =", ke/pe
input("Done.")While I'm on the subject of efficiency, what are the best ways to improve efficiency? I've varied pressure and volume while keeping muzzle velocity constant (yes, it took a good deal of calculation), and found this interesting curve:

This is a line plotted in 3D space. The height is efficiency, the lower right is pressure in psi, and the lower left is volume in cubic inches. You can see the beginning of the impossible increase in efficiency at low volumes on the left--this occurs in all cases actually, but it's most pronounced at higher Cv values.
Achieving efficiencies greater than about 25% seems to be difficult. I've tried other things like increasing the Cv value, and that doesn't seem to increase efficiency beyond maybe 2 or 3 percent after a certain saturation point. Decreasing the dead volume helps too, but not substantially.





