Class: Atmospheris::Iso5878::AtmosphereProfile

Inherits:
Atmospheris::Isa::Algorithms show all
Defined in:
lib/atmospheris/iso5878/atmosphere_profile.rb

Overview

Generalized ISA engine for ISO 5878 reference atmospheres.

Extends Isa::Algorithms (open/closed principle) by injecting custom temperature layer structures and latitude-dependent surface conditions. All barometric formula methods (pressure, density, etc.) are inherited and automatically use the custom configuration.

One AtmosphereProfile instance = one atmosphere model (e.g. "15 annual" or "60N winter warm regime").

Examples:

params = SurfaceParameters.new(15)
layers = Iso5878::TemperatureLayerStructure.from_yaml_rows(yaml_rows)
profile = AtmosphereProfile.new(
  surface_params: params,
  surface_temperature: 299.65,
  surface_pressure: 101325.0,
  layers: layers.to_a
)
profile.pressure_from_geopotential_mbar(5000)

Constant Summary collapse

R_SPECIFIC =
287.05287

Constants inherited from Atmospheris::Isa::Algorithms

Atmospheris::Isa::Algorithms::TEMPERATURE_LAYERS

Instance Attribute Summary collapse

Attributes inherited from Atmospheris::Isa::Algorithms

#constants, #pi, #precision, #sqrt2

Instance Method Summary collapse

Methods inherited from Atmospheris::Isa::Algorithms

#air_number_density_from_geopotential, #air_particle_collision_frequency_from_geopotential, #air_particle_collision_frequency_from_temp, #density_from_geopotential, #dynamic_viscosity, #dynamic_viscosity_from_geopotential, #geometric_altitude_from_geopotential, #geopotential_altitude_from_geometric, #geopotential_altitude_from_pressure_mbar, #geopotential_altitude_from_pressure_mmhg, #gravity_at_geometric, #gravity_at_geopotential, #kelvin_to_celsius, #kinematic_viscosity, #kinematic_viscosity_from_geopotential, #mbar_to_mmhg, #mean_air_particle_speed_from_geopotential, #mean_air_particle_speed_from_temp, #mean_free_path_of_air_particles_from_geopotential, #mmhg_to_mbar, #p_p_n_from_geopotential, #pa_to_mbar, #pa_to_mmhg, #pressure_formula_beta_nonzero, #pressure_formula_beta_zero, #pressure_from_geopotential_mbar, #pressure_from_geopotential_mmhg, #pressure_scale_height_from_geopotential, #pressure_scale_height_from_temp, #rho_rho_n_from_geopotential, #root_rho_rho_n_from_geopotential, #set_precision, #specific_weight_from_geopotential, #speed_of_sound_from_geopotential, #speed_of_sound_from_temp, #temperature_at_layer_celcius, #thermal_conductivity_from_geopotential, #thermal_conductivity_from_temp

Constructor Details

#initialize(surface_params:, surface_temperature:, surface_pressure:, layers:) ⇒ AtmosphereProfile

Returns a new instance of AtmosphereProfile.

Parameters:

  • surface_params (SurfaceParameters)
  • surface_temperature (Numeric)

    T at sea level (K)

  • surface_pressure (Numeric)

    P at sea level (Pa)

  • layers (Array<Hash>)

    ISA-format temperature layers [{ H: 0.0, T: 299.65, B: -0.006 }, ...] H in metres, T in Kelvin, B in K/m. Last layer has no :B key.



38
39
40
41
42
43
44
# File 'lib/atmospheris/iso5878/atmosphere_profile.rb', line 38

def initialize(surface_params:, surface_temperature:, surface_pressure:, layers:)
  @surface_params = surface_params
  @surface_temperature = surface_temperature.to_f
  @surface_pressure = surface_pressure.to_f
  @model_layers = layers
  set_precision(:normal)
end

Instance Attribute Details

#model_layersObject (readonly)

Returns the value of attribute model_layers.



30
31
32
# File 'lib/atmospheris/iso5878/atmosphere_profile.rb', line 30

def model_layers
  @model_layers
end

#surface_paramsObject (readonly)

Returns the value of attribute surface_params.



30
31
32
# File 'lib/atmospheris/iso5878/atmosphere_profile.rb', line 30

def surface_params
  @surface_params
end

#surface_pressureObject (readonly)

Returns the value of attribute surface_pressure.



30
31
32
# File 'lib/atmospheris/iso5878/atmosphere_profile.rb', line 30

def surface_pressure
  @surface_pressure
end

#surface_temperatureObject (readonly)

Returns the value of attribute surface_temperature.



30
31
32
# File 'lib/atmospheris/iso5878/atmosphere_profile.rb', line 30

def surface_temperature
  @surface_temperature
end

Instance Method Details

#pressure_from_geopotential(geopotential_alt) ⇒ Object

Override: pressure at altitude uses injected model_layers.



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/atmospheris/iso5878/atmosphere_profile.rb', line 135

def pressure_from_geopotential(geopotential_alt)
  i = locate_lower_layer(geopotential_alt)
  layer = model_layers[i]
  beta = layer[:B] || 0.0
  h_b = layer[:H]
  t_b = layer[:T]
  temp = temperature_at_layer_from_geopotential(geopotential_alt)
  p_b = pressure_layers[i]
  dh = geopotential_alt - h_b

  if beta.zero?
    pressure_formula_beta_zero(p_b, temp, dh)
  else
    pressure_formula_beta_nonzero(p_b, beta, t_b, dh)
  end
end

#temperature_at_layer_from_geopotential(geopotential_alt) ⇒ Object

Override: temperature lookup uses injected model_layers.



125
126
127
128
129
130
131
132
# File 'lib/atmospheris/iso5878/atmosphere_profile.rb', line 125

def temperature_at_layer_from_geopotential(geopotential_alt)
  idx = locate_lower_layer(geopotential_alt)
  layer = model_layers[idx]
  beta = layer[:B] || 0.0
  t_b = layer[:T]
  h_b = layer[:H]
  t_b + beta * (geopotential_alt - h_b)
end