Module: EngineeringCalculator::GasDynamics
- Defined in:
- lib/engineering_calculator/gas_dynamics.rb
Class Method Summary collapse
- .fanno(m, gamma) ⇒ Object
- .isentropic(m, gamma) ⇒ Object
- .normal_shock(mx, gamma) ⇒ Object
- .oblique(mx, gamma, delta) ⇒ Object
- .prandtl_compression(mx, gamma, turning_angle) ⇒ Object
- .prandtl_expansion(mx, gamma, turning_angle) ⇒ Object
- .rayleigh(m, gamma) ⇒ Object
Class Method Details
.fanno(m, gamma) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/engineering_calculator/gas_dynamics.rb', line 6 def self.fanno(m,gamma) m = m.to_f gamma = gamma.to_f p_ratio = 1/m * 1/Math.sqrt((2/(gamma+1)*(1+(gamma-1)/2*pow(m, 2)))) rho_ratio = 1/m * Math.sqrt((2/(gamma+1)) * (1+(gamma-1)/2*pow(m, 2))) t_ratio = 1/(2/(gamma+1)*(1+(gamma-1)/2*pow(m, 2))) u_ratio = m * 1/Math.sqrt(2/(gamma+1) * (1 + (gamma-1)/2*pow(m, 2))) po_ratio = 1/m * pow(2/(gamma+1) * (1+(gamma-1)/2*pow(m, 2)),(gamma+1)/(gamma-1)/2) fanno_param = (1-pow(m, 2))/(gamma*pow(m, 2)) + (gamma+1)/(gamma*2)*Math.log(pow(m, 2)/(2/(gamma+1)*(1+(gamma-1)/2*pow(m, 2)))) result = { p_ratio: p_ratio, rho_ratio: rho_ratio, t_ratio: t_ratio, u_ratio: u_ratio, po_ratio: po_ratio, fanno_param: fanno_param } end |
.isentropic(m, gamma) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/engineering_calculator/gas_dynamics.rb', line 27 def self.isentropic(m,gamma) m = m.to_f gamma = gamma.to_f ratio_t = pow(1 + (gamma - 1)/2 * pow(m, 2), -1) ratio_p = pow(1 + (gamma - 1)/2 * pow(m, 2), -gamma/(gamma-1)) ratio_rho = pow(1 + (gamma - 1)/2 * pow(m, 2), -1/(gamma-1)) ratio_a = pow((gamma + 1)/2, -((gamma + 1)/(gamma - 1)/2))/m * pow(1 + (gamma - 1)/2 * pow(m, 2), ((gamma + 1)/(gamma - 1))/2) result = { ratio_t: ratio_t, ratio_p: ratio_p, ratio_rho: ratio_rho, ratio_a: ratio_a } end |
.normal_shock(mx, gamma) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/engineering_calculator/gas_dynamics.rb', line 44 def self.normal_shock(mx,gamma) my = Math.sqrt((pow(mx,2)*(gamma-1)+2)/(2*gamma*pow(mx,2)-(gamma-1))) py_px = 2*gamma* pow(mx,2) /(gamma+1)-(gamma-1)/(gamma+1) rhoy_rhox = (gamma+1)*pow(mx,2)/((gamma-1)*pow(mx,2)+2) ty_tx = (1 + (gamma - 1)/2 * pow(mx, 2))*(2*gamma/(gamma - 1) * pow(mx, 2) - 1)/(pow(mx, 2)*(2*gamma/(gamma - 1) + (gamma - 1)/2)) poy_pox = pow((gamma + 1)/2 * pow(mx, 2)/(1 + (gamma - 1)/2 * pow(mx, 2)), gamma/(gamma - 1)) * pow(1/(2 * gamma/(gamma+1) * pow(mx,2) - (gamma-1)/(gamma+1)), 1/(gamma - 1)); result = { my: my, py_px: py_px, rhoy_rhox: rhoy_rhox, ty_tx: ty_tx, poy_pox: poy_pox } end |
.oblique(mx, gamma, delta) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/engineering_calculator/gas_dynamics.rb', line 60 def self.oblique(mx,gamma,delta) pi = Math::PI beta = delta*pi/180 # Initial guess that beta and delta coincide. e = 1 rhs = Math.tan(delta*pi/180) while (e >= 1*10**(-5)) lhs = 2*(1/Math.tan(beta))*(pow(mx,2)*pow(Math.sin(beta),2)-1)/(pow(mx,2)*(gamma+Math.cos(2*beta))+2) e = rhs - lhs beta = beta + 0.00001 end ratio_rho = (gamma+1) * pow(mx, 2)*pow(Math.sin(beta), 2) / ((gamma-1)*pow(mx, 2)*pow(Math.sin(beta), 2)+2) beta = beta*180/pi; ratio_p = 1+2*gamma/(gamma+1)*(pow(mx,2)*pow(Math.sin(beta*pi/180),2)-1); ratio_t = ratio_p*pow((gamma+1)*pow(mx,2)*pow(Math.sin(beta*pi/180),2)/((gamma-1)*pow(mx,2)*pow(Math.sin(beta*pi/180),2)+2),-1); my = (1/Math.sin((beta-delta)*pi/180))*pow((1+0.5*(gamma-1)*pow(mx,2)*pow(Math.sin(beta*pi/180),2))/(gamma*pow(mx,2)*pow(Math.sin(beta*pi/180),2)-0.5*(gamma-1)),0.5); ratio_px = pow(1 + (gamma - 1)/2 * pow(mx, 2), -gamma/(gamma-1)); ratio_py = pow(1 + (gamma - 1)/2 * pow(my, 2), -gamma/(gamma-1)); ratio_po = ratio_px/ratio_py*ratio_p; result = { my: my, ratio_rho: ratio_rho, beta: beta, ratio_p: ratio_p, ratio_t: ratio_t, ratio_po: ratio_po } end |
.prandtl_compression(mx, gamma, turning_angle) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/engineering_calculator/gas_dynamics.rb', line 91 def self.prandtl_compression(mx,gamma,turning_angle) pi = Math::PI nux = Math.sqrt((gamma+1)/(gamma-1)) * Math.atan(Math.sqrt((gamma-1)/(gamma+1)*(pow(mx, 2)-1))) - Math.atan(Math.sqrt(pow(mx, 2)-1)) turningAngle = turning_angle*pi/180 nuy = nux - turningAngle my = 1 e = 1 while (e >= 0.00001) nuy_test = Math.sqrt((gamma+1)/(gamma-1)) * Math.atan(Math.sqrt((gamma-1)/(gamma+1)*(pow(my, 2)-1))) - Math.atan(Math.sqrt(pow(my, 2)-1)) e = nuy - nuy_test my = my+0.00001 end my = my-0.00001 ty_tx = (1+(gamma-1)/2*pow(mx, 2))/(1+(gamma-1)/2*pow(my, 2)) py_px = pow((1+(gamma-1)/2*pow(mx, 2))/(1+(gamma-1)/2*pow(my, 2)), gamma/(gamma-1)) rhoy_rhox = pow((1+(gamma-1)/2*pow(mx, 2))/(1+(gamma-1)/2*pow(my, 2)), 1/(gamma-1)) mux = Math.asin(1/mx) muy = Math.asin(1/my) result = { ty_tx: ty_tx, py_px: py_px, rhoy_rhox: rhoy_rhox, my: my, nux: nux*180/pi, nuy: nuy*180/pi, mux: mux*180/pi, muy: muy*180/pi, } end |
.prandtl_expansion(mx, gamma, turning_angle) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/engineering_calculator/gas_dynamics.rb', line 125 def self.prandtl_expansion(mx,gamma,turning_angle) pi = Math::PI nux = Math.sqrt((gamma+1)/(gamma-1)) * Math.atan(Math.sqrt((gamma-1)/(gamma+1)*(pow(mx, 2)-1))) - Math.atan(Math.sqrt(pow(mx, 2)-1)) turningAngle = turning_angle*pi/180 nuy = nux + turningAngle my = 1 e = 1 while (e >= 0.00001) nuy_test = Math.sqrt((gamma+1)/(gamma-1)) * Math.atan(Math.sqrt((gamma-1)/(gamma+1)*(pow(my, 2)-1))) - Math.atan(Math.sqrt(pow(my, 2)-1)) e = nuy - nuy_test my = my+0.00001 end my = my-0.00001 ty_tx = (1+(gamma-1)/2*pow(mx, 2))/(1+(gamma-1)/2*pow(my, 2)) py_px = pow((1+(gamma-1)/2*pow(mx, 2))/(1+(gamma-1)/2*pow(my, 2)), gamma/(gamma-1)) rhoy_rhox = pow((1+(gamma-1)/2*pow(mx, 2))/(1+(gamma-1)/2*pow(my, 2)), 1/(gamma-1)) mux = Math.asin(1/mx) muy = Math.asin(1/my) result = { ty_tx: ty_tx, py_px: py_px, rhoy_rhox: rhoy_rhox, my: my, nux: nux*180/pi, nuy: nuy*180/pi, mux: mux*180/pi, muy: muy*180/pi, } end |
.rayleigh(m, gamma) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/engineering_calculator/gas_dynamics.rb', line 159 def self.rayleigh(m,gamma) p_ratio = (gamma+1)/(1+gamma*pow(m, 2)); rho_ratio = (1+gamma*pow(m,2))/((1+gamma)*pow(m,2)); t_ratio = pow(gamma+1, 2)*pow(m, 2)/pow(1+gamma*pow(m, 2), 2); u_ratio = (gamma+1)*pow(m, 2)/(1+gamma*pow(m, 2)); po_ratio = (gamma+1)/(1+gamma*pow(m, 2)) * pow(2/(gamma+1)*(1+(gamma-1)/2*pow(m, 2)), gamma/(gamma-1)); to_ratio = 2*(gamma+1)*pow(m, 2)/pow(1+gamma*pow(m, 2),2) * (1+(gamma-1)/2*pow(m, 2)); result = { p_ratio: p_ratio, rho_ratio: rho_ratio, t_ratio: t_ratio, u_ratio: u_ratio, po_ratio: po_ratio, to_ratio: to_ratio } end |