atmospheric 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.adoc +34 -3
- data/lib/atmospheric/export/target.rb +2 -3
- data/lib/atmospheric/isa.rb +161 -100
- data/lib/atmospheric/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e29f2a7a1728dcceb1b2771ddc124879daa5359658b6c3e3968ed1c18661f11
|
4
|
+
data.tar.gz: b8a4a413763693b0f659e886009c084460766354a42c1ee198540b653d96301c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2dad3faa88a2241f6bcb4817e4f7ecb1b886a16650cb25ed4621f5dc4e76b286341f05a5ac0c46607dcb5d9ad3fecaf24babcb8c73175b46cd148ff11595739
|
7
|
+
data.tar.gz: 50440fcd7c21bbce1677c24290136e72698e73363ac137cb45fa2afdd32b52adefa2644c1aef665a16d387348536519667a9a442667439797392787d5417bc5f
|
data/README.adoc
CHANGED
@@ -14,13 +14,44 @@ units (the ICAO document includes `ft` in addition to `m`).
|
|
14
14
|
|
15
15
|
== Usage
|
16
16
|
|
17
|
+
=== Precision modes
|
18
|
+
|
19
|
+
There are two precision modes available for calculations: high precision and normal precision (default).
|
20
|
+
|
21
|
+
High Precision Mode::
|
22
|
+
Uses more accurate constants and number calculations through Ruby's BigDecimal
|
23
|
+
to provide results with higher precision. Suitable for applications where the
|
24
|
+
utmost accuracy is required.
|
25
|
+
|
26
|
+
Normal Precision Mode (default)::
|
27
|
+
Uses standard constants and number calculations to provide results with
|
28
|
+
sufficient accuracy for most applications.
|
29
|
+
|
30
|
+
To specify the precision mode, set the `precision` attribute when creating an instance of `Atmospheric::Isa`:
|
31
|
+
|
32
|
+
`:high`:: High precision mode
|
33
|
+
`:normal` or not specified:: Normal precision mode
|
34
|
+
|
35
|
+
Example usage:
|
36
|
+
|
37
|
+
[source,ruby]
|
38
|
+
----
|
39
|
+
require 'atmospheric'
|
40
|
+
|
41
|
+
# Normal precision mode (default)
|
42
|
+
normal_precision_instance = Atmospheric::Isa.new
|
43
|
+
|
44
|
+
# High precision mode
|
45
|
+
high_precision_instance = Atmospheric::Isa.new(precision: :high)
|
46
|
+
----
|
47
|
+
|
17
48
|
=== Formulas and calculations
|
18
49
|
|
19
50
|
[source,ruby]
|
20
51
|
----
|
21
|
-
|
22
|
-
|
23
|
-
|
52
|
+
require 'atmospheric'
|
53
|
+
instance = Atmospheric::Isa.{method_name}
|
54
|
+
# {method_name} is one of the following
|
24
55
|
----
|
25
56
|
|
26
57
|
The available methods are:
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "measured"
|
2
1
|
require "yaml"
|
3
2
|
|
4
3
|
module Atmospheric
|
@@ -10,11 +9,11 @@ module Atmospheric
|
|
10
9
|
end
|
11
10
|
|
12
11
|
def m_to_ft(meters)
|
13
|
-
|
12
|
+
meters / 0.3048
|
14
13
|
end
|
15
14
|
|
16
15
|
def ft_to_m(feet)
|
17
|
-
|
16
|
+
feet * 0.3048
|
18
17
|
end
|
19
18
|
|
20
19
|
def to_yaml
|
data/lib/atmospheric/isa.rb
CHANGED
@@ -1,51 +1,102 @@
|
|
1
|
+
require "bigdecimal"
|
2
|
+
require "bigdecimal/math"
|
3
|
+
|
1
4
|
module Atmospheric
|
2
5
|
module Isa
|
3
6
|
# International Standard Atmosphere (ISA) (ISO 2533:1975)
|
4
7
|
# ICAO Standard Atmosphere (ICAO Doc 7488/3, 1994)
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
class << self
|
10
|
+
private
|
11
|
+
|
12
|
+
@precision = :normal # Note the initial make_constants run won't see this
|
13
|
+
|
14
|
+
def num(str)
|
15
|
+
if @precision == :high
|
16
|
+
BigDecimal(str)
|
17
|
+
else
|
18
|
+
str.to_f
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def sqrt(num)
|
23
|
+
if @precision == :high
|
24
|
+
BigMath.sqrt(num, 100)
|
25
|
+
else
|
26
|
+
Math.sqrt(num)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def log10(num)
|
31
|
+
if @precision == :high
|
32
|
+
BigMath.log(num, 100) / BigMath.log(10, 100)
|
33
|
+
else
|
34
|
+
Math.log10(num)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# rubocop:disable Metrics/AbcSize
|
39
|
+
# rubocop:disable Metrics/MethodLength
|
40
|
+
def make_constants
|
41
|
+
# 2.1 Primary constants and characteristics
|
42
|
+
# Table 1 - Main constants and characteristics adopted for
|
43
|
+
# the calculation of the ISO Standard Atmosphere
|
44
|
+
@constants = {
|
45
|
+
# g_n gravitation at mean sea level (m.s-2)
|
46
|
+
g_n: num("9.80665"),
|
47
|
+
|
48
|
+
# Avogadro constant (mol-1)
|
49
|
+
N_A: num("6.02257e+23"),
|
12
50
|
|
13
|
-
|
14
|
-
|
51
|
+
# p_n pressure at mean sea level (Pa)
|
52
|
+
p_n: num("101325"),
|
15
53
|
|
16
|
-
|
17
|
-
|
54
|
+
# rho_n standard air density
|
55
|
+
rho_n: num("1.225"),
|
18
56
|
|
19
|
-
|
20
|
-
|
57
|
+
# T_n standard thermodynamic air temperature at mean sea level
|
58
|
+
T_n: num("288.15"),
|
21
59
|
|
22
|
-
|
23
|
-
|
60
|
+
# universal gas constant
|
61
|
+
R_star: num("8.31432"),
|
24
62
|
|
25
|
-
|
26
|
-
|
63
|
+
# radius of the Earth (m)
|
64
|
+
radius: num("6356766"),
|
27
65
|
|
28
|
-
|
29
|
-
|
66
|
+
# adiabatic index (dimensionless)
|
67
|
+
k: num("1.4"),
|
68
|
+
}
|
30
69
|
|
31
|
-
|
32
|
-
|
33
|
-
|
70
|
+
# 2.2 The equation of the static atmosphere and the perfect gas law
|
71
|
+
# Formula (2)
|
72
|
+
# M: air molar mass at sea level, kg.kmol-1
|
73
|
+
# Value given in 2.1 as M: 28.964720
|
74
|
+
@constants[:M] =
|
75
|
+
(@constants[:rho_n] * @constants[:R_star] * @constants[:T_n]) \
|
76
|
+
/ @constants[:p_n]
|
34
77
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
constants[:M] =
|
40
|
-
(constants[:rho_n] * constants[:R_star] * constants[:T_n]) \
|
41
|
-
/ constants[:p_n]
|
78
|
+
# Formula (3)
|
79
|
+
# R: specific gas constant, J.K-1.kg-1.
|
80
|
+
# Value given in 2.1 as R: 287.05287
|
81
|
+
@constants[:R] = @constants[:R_star] / @constants[:M]
|
42
82
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
83
|
+
@sqrt2 = sqrt(num("2"))
|
84
|
+
@pi = if @precision == :high then BigMath.PI(100) else Math::PI end
|
85
|
+
end
|
86
|
+
# rubocop:enable Metrics/AbcSize
|
87
|
+
# rubocop:enable Metrics/MethodLength
|
47
88
|
|
48
|
-
|
89
|
+
public
|
90
|
+
|
91
|
+
def set_precision(precision)
|
92
|
+
@precision = if precision == :high then :high else :normal end
|
93
|
+
remove_instance_variable(:@pressure_layers) \
|
94
|
+
if defined?(@pressure_layers)
|
95
|
+
make_constants
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
make_constants
|
49
100
|
|
50
101
|
class << self
|
51
102
|
# 2.3 Geopotential and geometric altitides; acceleration of free fall
|
@@ -54,21 +105,23 @@ module Atmospheric
|
|
54
105
|
# H to h
|
55
106
|
# h(m)
|
56
107
|
def geometric_altitude_from_geopotential(geopotential_alt)
|
57
|
-
|
108
|
+
@constants[:radius] * geopotential_alt \
|
109
|
+
/ (@constants[:radius] - geopotential_alt)
|
58
110
|
end
|
59
111
|
|
60
112
|
# 2.3 Formula (9)
|
61
113
|
# h to H
|
62
114
|
# H(m)
|
63
115
|
def geopotential_altitude_from_geometric(geometric_alt)
|
64
|
-
|
116
|
+
@constants[:radius] * geometric_alt \
|
117
|
+
/ (@constants[:radius] + geometric_alt)
|
65
118
|
end
|
66
119
|
|
67
120
|
# 2.3 Formula (7)
|
68
121
|
# g(h)
|
69
122
|
def gravity_at_geometric(geometric_alt)
|
70
|
-
temp =
|
71
|
-
|
123
|
+
temp = @constants[:radius] / (@constants[:radius] + geometric_alt)
|
124
|
+
@constants[:g_n] * temp * temp
|
72
125
|
end
|
73
126
|
|
74
127
|
def gravity_at_geopotential(geopotential_alt)
|
@@ -87,9 +140,9 @@ module Atmospheric
|
|
87
140
|
def temperature_at_layer_from_geopotential(geopotential_alt)
|
88
141
|
lower_layer_index = locate_lower_layer(geopotential_alt)
|
89
142
|
lower_layer = TEMPERATURE_LAYERS[lower_layer_index]
|
90
|
-
beta = lower_layer[:B]
|
91
|
-
capital_t_b = lower_layer[:T]
|
92
|
-
capital_h_b = lower_layer[:H]
|
143
|
+
beta = num(lower_layer[:B])
|
144
|
+
capital_t_b = num(lower_layer[:T])
|
145
|
+
capital_h_b = num(lower_layer[:H])
|
93
146
|
|
94
147
|
capital_t_b + (beta * (geopotential_alt - capital_h_b))
|
95
148
|
end
|
@@ -100,21 +153,23 @@ module Atmospheric
|
|
100
153
|
)
|
101
154
|
end
|
102
155
|
|
156
|
+
# rubocop:disable Metrics/AbcSize
|
103
157
|
def locate_lower_layer(geopotential_alt)
|
104
158
|
# Return first layer if lower than lowest
|
105
|
-
return 0 if geopotential_alt < TEMPERATURE_LAYERS[0][:H]
|
159
|
+
return 0 if geopotential_alt < num(TEMPERATURE_LAYERS[0][:H])
|
106
160
|
|
107
161
|
# Return second last layer if beyond last layer
|
108
162
|
i = TEMPERATURE_LAYERS.length - 1
|
109
|
-
return i - 1 if geopotential_alt >= TEMPERATURE_LAYERS[i][:H]
|
163
|
+
return i - 1 if geopotential_alt >= num(TEMPERATURE_LAYERS[i][:H])
|
110
164
|
|
111
165
|
# find last layer with H smaller than our H
|
112
166
|
TEMPERATURE_LAYERS.each_with_index do |layer, ind|
|
113
|
-
return ind - 1 if layer[:H] > geopotential_alt
|
167
|
+
return ind - 1 if num(layer[:H]) > geopotential_alt
|
114
168
|
end
|
115
169
|
|
116
170
|
nil
|
117
171
|
end
|
172
|
+
# rubocop:enable Metrics/AbcSize
|
118
173
|
|
119
174
|
# Table 4 - Temperature and vertical temperature gradients
|
120
175
|
#
|
@@ -124,18 +179,18 @@ module Atmospheric
|
|
124
179
|
# B is Temperature gradient, "beta", K m^-1
|
125
180
|
|
126
181
|
# This line is from ICAO 7488/3
|
127
|
-
#
|
182
|
+
# { H: "-5000", T: "320.65", B: "-0.0065" },
|
128
183
|
|
129
184
|
# This line is from ISO 2533:1975
|
130
|
-
{ H: -2000, T: 301.15, B: -0.0065 },
|
131
|
-
{ H: 0, T: 288.15, B: -0.0065 },
|
132
|
-
{ H: 11000, T: 216.65, B: 0 },
|
133
|
-
{ H: 20000, T: 216.65, B: 0.001 },
|
134
|
-
{ H: 32000, T: 228.65, B: 0.0028 },
|
135
|
-
{ H: 47000, T: 270.65, B: 0 },
|
136
|
-
{ H: 51000, T: 270.65, B: -0.0028 },
|
137
|
-
{ H: 71000, T: 214.65, B: -0.002 },
|
138
|
-
{ H: 80000, T: 196.65 },
|
185
|
+
{ H: "-2000", T: "301.15", B: "-0.0065" },
|
186
|
+
{ H: "0", T: "288.15", B: "-0.0065" },
|
187
|
+
{ H: "11000", T: "216.65", B: "0" },
|
188
|
+
{ H: "20000", T: "216.65", B: "0.001" },
|
189
|
+
{ H: "32000", T: "228.65", B: "0.0028" },
|
190
|
+
{ H: "47000", T: "270.65", B: "0" },
|
191
|
+
{ H: "51000", T: "270.65", B: "-0.0028" },
|
192
|
+
{ H: "71000", T: "214.65", B: "-0.002" },
|
193
|
+
{ H: "80000", T: "196.65" },
|
139
194
|
].freeze
|
140
195
|
|
141
196
|
# 2.7 Pressure
|
@@ -153,21 +208,21 @@ module Atmospheric
|
|
153
208
|
TEMPERATURE_LAYERS.each_with_index do |_x, i|
|
154
209
|
last_i = i.zero? ? 0 : i - 1
|
155
210
|
last_layer = TEMPERATURE_LAYERS[last_i]
|
156
|
-
beta = last_layer[:B]
|
211
|
+
beta = num(last_layer[:B])
|
157
212
|
|
158
|
-
if last_layer[:H] <= 0
|
159
|
-
p_b =
|
213
|
+
if num(last_layer[:H]) <= 0
|
214
|
+
p_b = @constants[:p_n]
|
160
215
|
capital_h_b = 0
|
161
|
-
capital_t_b =
|
216
|
+
capital_t_b = @constants[:T_n]
|
162
217
|
else
|
163
218
|
p_b = p[last_i]
|
164
|
-
capital_h_b = last_layer[:H]
|
165
|
-
capital_t_b = last_layer[:T]
|
219
|
+
capital_h_b = num(last_layer[:H])
|
220
|
+
capital_t_b = num(last_layer[:T])
|
166
221
|
end
|
167
222
|
|
168
223
|
current_layer = TEMPERATURE_LAYERS[i]
|
169
|
-
geopotential_alt = current_layer[:H]
|
170
|
-
temp = current_layer[:T]
|
224
|
+
geopotential_alt = num(current_layer[:H])
|
225
|
+
temp = num(current_layer[:T])
|
171
226
|
height_diff = geopotential_alt - capital_h_b
|
172
227
|
|
173
228
|
p_i = if beta != 0
|
@@ -190,33 +245,35 @@ module Atmospheric
|
|
190
245
|
# Formula (12)
|
191
246
|
def pressure_formula_beta_nonzero(p_b, beta, temp, height_diff)
|
192
247
|
p_b * (1 + ((beta / temp) * height_diff)) \
|
193
|
-
**(
|
248
|
+
**(-@constants[:g_n] / (beta * @constants[:R]))
|
194
249
|
end
|
195
250
|
|
196
251
|
# Formula (13)
|
197
252
|
def pressure_formula_beta_zero(p_b, temp, height_diff)
|
198
|
-
p_b *
|
253
|
+
p_b *
|
254
|
+
Math.exp(-(@constants[:g_n] / (@constants[:R] * temp)) * height_diff)
|
199
255
|
end
|
200
256
|
|
201
257
|
# puts "PRE-CALCULATED PRESSURE LAYERS:"
|
202
258
|
# pp @pressure_layers
|
203
259
|
|
204
260
|
def pa_to_mmhg(pascal)
|
205
|
-
pascal * 0.007500616827
|
261
|
+
pascal * num("0.007500616827")
|
206
262
|
end
|
207
263
|
|
208
264
|
def pa_to_mbar(pascal)
|
209
|
-
pascal * 0.01
|
265
|
+
pascal * num("0.01")
|
210
266
|
end
|
211
267
|
|
268
|
+
# rubocop:disable Metrics/AbcSize
|
212
269
|
# rubocop:disable Metrics/MethodLength
|
213
270
|
# Pressure for a given geopotential altitude `H` (m) above mean sea level
|
214
271
|
def pressure_from_geopotential(geopotential_alt)
|
215
272
|
i = locate_lower_layer(geopotential_alt)
|
216
273
|
lower_temperature_layer = TEMPERATURE_LAYERS[i]
|
217
|
-
beta = lower_temperature_layer[:B]
|
218
|
-
capital_h_b = lower_temperature_layer[:H]
|
219
|
-
capital_t_b = lower_temperature_layer[:T]
|
274
|
+
beta = num(lower_temperature_layer[:B])
|
275
|
+
capital_h_b = num(lower_temperature_layer[:H])
|
276
|
+
capital_t_b = num(lower_temperature_layer[:T])
|
220
277
|
temp = temperature_at_layer_from_geopotential(geopotential_alt)
|
221
278
|
p_b = pressure_layers[i]
|
222
279
|
height_diff = geopotential_alt - capital_h_b
|
@@ -229,6 +286,7 @@ module Atmospheric
|
|
229
286
|
pressure_formula_beta_zero(p_b, temp, height_diff)
|
230
287
|
end
|
231
288
|
end
|
289
|
+
# rubocop:enable Metrics/AbcSize
|
232
290
|
# rubocop:enable Metrics/MethodLength
|
233
291
|
|
234
292
|
def pressure_from_geopotential_mbar(geopotential_alt)
|
@@ -240,7 +298,7 @@ module Atmospheric
|
|
240
298
|
end
|
241
299
|
|
242
300
|
def p_p_n_from_geopotential(geopotential_alt)
|
243
|
-
pressure_from_geopotential(geopotential_alt) /
|
301
|
+
pressure_from_geopotential(geopotential_alt) / @constants[:p_n]
|
244
302
|
end
|
245
303
|
|
246
304
|
# 2.8 Density and specific weight
|
@@ -252,15 +310,15 @@ module Atmospheric
|
|
252
310
|
temp = temperature_at_layer_from_geopotential(geopotential_alt)
|
253
311
|
p = pressure_from_geopotential(geopotential_alt)
|
254
312
|
|
255
|
-
p / (
|
313
|
+
p / (@constants[:R] * temp)
|
256
314
|
end
|
257
315
|
|
258
316
|
def rho_rho_n_from_geopotential(geopotential_alt)
|
259
|
-
density_from_geopotential(geopotential_alt) /
|
317
|
+
density_from_geopotential(geopotential_alt) / @constants[:rho_n]
|
260
318
|
end
|
261
319
|
|
262
320
|
def root_rho_rho_n_from_geopotential(geopotential_alt)
|
263
|
-
|
321
|
+
sqrt(rho_rho_n_from_geopotential(geopotential_alt))
|
264
322
|
end
|
265
323
|
|
266
324
|
# Specific weight
|
@@ -275,12 +333,12 @@ module Atmospheric
|
|
275
333
|
# Formula (16)
|
276
334
|
# H_p
|
277
335
|
def pressure_scale_height_from_temp(temp)
|
278
|
-
(
|
336
|
+
(@constants[:R] * temp) / @constants[:g_n]
|
279
337
|
end
|
280
338
|
|
281
339
|
def pressure_scale_height_from_geopotential(geopotential_alt)
|
282
340
|
temp = temperature_at_layer_from_geopotential(geopotential_alt)
|
283
|
-
(
|
341
|
+
(@constants[:R] * temp) / gravity_at_geopotential(geopotential_alt)
|
284
342
|
end
|
285
343
|
|
286
344
|
# 2.10 Air number density
|
@@ -290,7 +348,7 @@ module Atmospheric
|
|
290
348
|
temp = temperature_at_layer_from_geopotential(geopotential_alt)
|
291
349
|
p = pressure_from_geopotential(geopotential_alt)
|
292
350
|
|
293
|
-
|
351
|
+
@constants[:N_A] * p / (@constants[:R_star] * temp)
|
294
352
|
end
|
295
353
|
|
296
354
|
# 2.11 Mean air-particle speed
|
@@ -298,7 +356,7 @@ module Atmospheric
|
|
298
356
|
# v_bar
|
299
357
|
# CORRECT
|
300
358
|
def mean_air_particle_speed_from_temp(temp)
|
301
|
-
1.595769 *
|
359
|
+
num("1.595769") * sqrt(@constants[:R] * temp)
|
302
360
|
end
|
303
361
|
|
304
362
|
def mean_air_particle_speed_from_geopotential(geopotential_alt)
|
@@ -310,7 +368,8 @@ module Atmospheric
|
|
310
368
|
# Formula (19)
|
311
369
|
# l
|
312
370
|
def mean_free_path_of_air_particles_from_geopotential(geopotential_alt)
|
313
|
-
1 / (
|
371
|
+
# 1 / (sqrt(2) * Pi * (3.65e-10**2) * air_number_density
|
372
|
+
1 / (@sqrt2 * @pi * num("0.133225e-18") * \
|
314
373
|
air_number_density_from_geopotential(geopotential_alt))
|
315
374
|
end
|
316
375
|
|
@@ -318,9 +377,10 @@ module Atmospheric
|
|
318
377
|
# Formula (20)
|
319
378
|
# omega
|
320
379
|
def air_particle_collision_frequency_from_temp(air_number_density, temp)
|
321
|
-
4 * (3.65e-10**2) *
|
322
|
-
|
323
|
-
|
380
|
+
# 4 * (3.65e-10**2) * ...
|
381
|
+
4 * num("0.133225e-18") *
|
382
|
+
((@pi / (@constants[:R_star] * @constants[:M]))**num("0.5")) *
|
383
|
+
air_number_density * @constants[:R_star] * (temp**num("0.5"))
|
324
384
|
end
|
325
385
|
|
326
386
|
def air_particle_collision_frequency_from_geopotential(geopotential_alt)
|
@@ -335,8 +395,8 @@ module Atmospheric
|
|
335
395
|
# CORRECT
|
336
396
|
def speed_of_sound_from_temp(temp)
|
337
397
|
# `kappa` (ratio of c_p / c_v) = 1.4 (see 2.14)
|
338
|
-
kappa = 1.4
|
339
|
-
|
398
|
+
kappa = num("1.4")
|
399
|
+
sqrt(kappa * @constants[:R] * temp)
|
340
400
|
end
|
341
401
|
|
342
402
|
def speed_of_sound_from_geopotential(geopotential_alt)
|
@@ -349,10 +409,10 @@ module Atmospheric
|
|
349
409
|
# mu (Pa s)
|
350
410
|
def dynamic_viscosity(temp)
|
351
411
|
# Sutherland's empirical constants in the equation for dynamic viscosity
|
352
|
-
capital_b_s = 1.458e-6
|
353
|
-
capital_s = 110.4
|
412
|
+
capital_b_s = num("1.458e-6")
|
413
|
+
capital_s = num("110.4")
|
354
414
|
|
355
|
-
(capital_b_s * (temp**1.5)) / (temp + capital_s)
|
415
|
+
(capital_b_s * (temp**num("1.5"))) / (temp + capital_s)
|
356
416
|
end
|
357
417
|
|
358
418
|
def dynamic_viscosity_from_geopotential(geopotential_alt)
|
@@ -364,7 +424,7 @@ module Atmospheric
|
|
364
424
|
# Formula (23)
|
365
425
|
# v
|
366
426
|
def kinematic_viscosity(temp)
|
367
|
-
dynamic_viscosity(temp) /
|
427
|
+
dynamic_viscosity(temp) / @constants[:rho_n]
|
368
428
|
end
|
369
429
|
|
370
430
|
def kinematic_viscosity_from_geopotential(geopotential_alt)
|
@@ -376,7 +436,8 @@ module Atmospheric
|
|
376
436
|
# Formula (24)
|
377
437
|
# lambda
|
378
438
|
def thermal_conductivity_from_temp(temp)
|
379
|
-
(2.648151e-3 * (temp**1.5))
|
439
|
+
(num("2.648151e-3") * (temp**num("1.5"))) \
|
440
|
+
/ (temp + (num("245.4") * (num("10")**(num("-12") / temp))))
|
380
441
|
end
|
381
442
|
|
382
443
|
def thermal_conductivity_from_geopotential(geopotential_alt)
|
@@ -385,7 +446,7 @@ module Atmospheric
|
|
385
446
|
end
|
386
447
|
|
387
448
|
def kelvin_to_celsius(kelvin)
|
388
|
-
kelvin - 273.15
|
449
|
+
kelvin - num("273.15")
|
389
450
|
end
|
390
451
|
|
391
452
|
# ADD 1
|
@@ -395,29 +456,29 @@ module Atmospheric
|
|
395
456
|
# rubocop:disable Metrics/MethodLength
|
396
457
|
def geopotential_altitude_from_pressure_mbar(pressure)
|
397
458
|
if pressure >= pa_to_mbar(pressure_layers[2]) # H <= 11 000 m
|
398
|
-
(3.731444 - pressure**0.1902631) / 8.41728e-5
|
459
|
+
(num("3.731444") - pressure**num("0.1902631")) / num("8.41728e-5")
|
399
460
|
elsif pressure >= pa_to_mbar(pressure_layers[3]) # H <= 20 000 m
|
400
|
-
(3.1080387 -
|
461
|
+
(num("3.1080387") - log10(pressure)) / num("6.848325e-5")
|
401
462
|
elsif pressure >= pa_to_mbar(pressure_layers[4]) # H <= 32 000 m
|
402
|
-
(1.2386515 - pressure**0.02927125) \
|
403
|
-
/ (5.085177e-6 * pressure**0.02927125)
|
463
|
+
(num("1.2386515") - pressure**num("0.02927125")) \
|
464
|
+
/ (num("5.085177e-6") * pressure**num("0.02927125"))
|
404
465
|
elsif pressure >= pa_to_mbar(pressure_layers[5]) # H <= 47 000 m
|
405
|
-
(1.9630052 - pressure**0.08195949) \
|
406
|
-
/ (2.013664e-5 * pressure**0.08195949)
|
466
|
+
(num("1.9630052") - pressure**num("0.08195949")) \
|
467
|
+
/ (num("2.013664e-5") * pressure**num("0.08195949"))
|
407
468
|
end
|
408
469
|
end
|
409
470
|
|
410
471
|
def geopotential_altitude_from_pressure_mmhg(pressure)
|
411
472
|
if pressure >= pa_to_mmhg(pressure_layers[2]) # H <= 11 000 m
|
412
|
-
(3.532747 - pressure**0.1902631) / 7.96906e-5
|
473
|
+
(num("3.532747") - pressure**num("0.1902631")) / num("7.96906e-5")
|
413
474
|
elsif pressure >= pa_to_mmhg(pressure_layers[3]) # H <= 20 000 m
|
414
|
-
(2.9831357 -
|
475
|
+
(num("2.9831357") - log10(pressure)) / num("6.848325e-5")
|
415
476
|
elsif pressure >= pa_to_mmhg(pressure_layers[4]) # H <= 32 000 m
|
416
|
-
(1.2282678 - pressure**0.02927125) \
|
417
|
-
/ (5.085177e-6 * pressure**0.02927125)
|
477
|
+
(num("1.2282678") - pressure**num("0.02927125")) \
|
478
|
+
/ (num("5.085177e-6") * pressure**num("0.02927125"))
|
418
479
|
elsif pressure >= pa_to_mmhg(pressure_layers[5]) # H <= 47 000 m
|
419
|
-
(1.9172753 - pressure**0.08195949) \
|
420
|
-
/ (2.013664e-5 * pressure**0.08195949)
|
480
|
+
(num("1.9172753") - pressure**num("0.08195949")) \
|
481
|
+
/ (num("2.013664e-5") * pressure**num("0.08195949"))
|
421
482
|
end
|
422
483
|
end
|
423
484
|
# rubocop:enable Metrics/AbcSize
|
data/lib/atmospheric/version.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atmospheric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03
|
11
|
+
date: 2024-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bigdecimal
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
rubygems_version: 3.3.
|
104
|
+
rubygems_version: 3.3.27
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: Implementation of International Standard Atmosphere (ISA) formulas"
|