# Module: EngineeringCalculator::GasDynamics

Defined in:
lib/engineering_calculator/gas_dynamics.rb

## Instance Method Details

### - (Object) fanno(m, gamma)

 ``` 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21``` ```# File 'lib/engineering_calculator/gas_dynamics.rb', line 5 def fanno(m,gamma) 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 } return result end```

### - (Object) isentropic(m, gamma)

 ``` 22 23 24 25 26 27 28 29 30 31 32 33 34``` ```# File 'lib/engineering_calculator/gas_dynamics.rb', line 22 def isentropic(m,gamma) 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 } return result end```

### - (Object) normal_shock(mx, gamma)

 ``` 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49``` ```# File 'lib/engineering_calculator/gas_dynamics.rb', line 35 def 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 } return result end```

### - (Object) oblique(mx, gamma, delta)

 ``` 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80``` ```# File 'lib/engineering_calculator/gas_dynamics.rb', line 50 def oblique(mx,gamma,delta) pi = Math::PI # Initial guess that beta and delta coincide. beta = delta*pi/180 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 } return result end```

### - (Object) prandtl_compression(mx, gamma, turning_angle)

 ``` 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110``` ```# File 'lib/engineering_calculator/gas_dynamics.rb', line 81 def 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, } return result end```

### - (Object) prandtl_expansion(mx, gamma, turning_angle)

 ``` 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140``` ```# File 'lib/engineering_calculator/gas_dynamics.rb', line 111 def 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, } return result end```

### - (Object) rayleigh(m, gamma)

 ``` 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 141 def 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 } return result end```