Source code for openworld_radio_twin.simulation.water_material

"""Fresh and sea water as Sionna radio materials.

Sionna RT's ITU-R P.2040 table has no water. The permittivity here follows Recommendation
ITU-R P.527-6, sections 5.1.1 (pure water) and 5.1.2 (sea water), equations (5) to (27),
at a fixed water temperature. Scenes declare the material as ``owrt-water-material`` with a
``salinity`` property; the plugin must be registered before Sionna loads such a scene.
"""

from __future__ import annotations

import math

WATER_TEMPERATURE_C = 20.0
SEA_WATER_SALINITY = 35.0  # g/kg
# Salinity of each water material named in the RF material profile.
WATER_SALINITY = {"p527_fresh_water": 0.0, "p527_sea_water": SEA_WATER_SALINITY}
VACUUM_PERMITTIVITY = 8.8541878128e-12  # F/m


[docs] def water_permittivity( frequency_hz: float, temperature_c: float = WATER_TEMPERATURE_C, salinity: float = 0.0, ) -> tuple[float, float]: """Real and imaginary parts of the relative permittivity, eps' - j eps'' (ITU-R P.527-6).""" f = frequency_hz / 1e9 t, s = temperature_c, salinity theta = 300.0 / (t + 273.15) - 1.0 # (11) eps_s = 77.66 + 103.3 * theta # (8) eps_1 = 0.0671 * eps_s # (9) eps_inf = 3.52 - 7.52 * theta # (10) f_1 = 20.20 - 146.4 * theta + 316.0 * theta**2 # (12) f_2 = 39.8 * f_1 # (13) eps_ss = eps_s * math.exp(-3.33330e-3 * s + 4.74868e-6 * s**2) # (17) f_1s = f_1 * ( # (18) 1.0 + s * (2.3232e-3 - 7.9208e-5 * t + 3.6764e-6 * t**2 + 3.5594e-7 * t**3 + 8.9795e-9 * t**4) ) eps_1s = eps_1 * math.exp(-6.28908e-3 * s + 1.76032e-4 * s**2 - 9.22144e-5 * t * s) # (19) f_2s = f_2 * (1.0 + s * (-1.99723e-2 + 1.81176e-4 * t)) # (20) eps_infs = eps_inf * (1.0 + s * (-2.04265e-3 + 1.57883e-4 * t)) # (21) sigma_35 = ( # (23) 2.903602 + 8.607e-2 * t + 4.738817e-4 * t**2 - 2.991e-6 * t**3 + 4.3047e-9 * t**4 ) r_15 = s * (37.5109 + 5.45216 * s + 1.4409e-2 * s**2) / (1004.75 + 182.283 * s + s**2) # (24) alpha_0 = (6.9431 + 3.2841 * s - 9.9486e-2 * s**2) / (84.850 + 69.024 * s + s**2) # (26) alpha_1 = 49.843 - 0.2276 * s + 0.198e-2 * s**2 # (27) r_t15 = 1.0 + alpha_0 * (t - 15.0) / (alpha_1 + t) # (25) sigma_sw = sigma_35 * r_15 * r_t15 # (22) first = 1.0 + (f / f_1s) ** 2 second = 1.0 + (f / f_2s) ** 2 real = (eps_ss - eps_1s) / first + (eps_1s - eps_infs) / second + eps_infs # (15) imaginary = ( # (16) (f / f_1s) * (eps_ss - eps_1s) / first + (f / f_2s) * (eps_1s - eps_infs) / second + 18.0 * sigma_sw / f ) return real, imaginary
[docs] def water_radio_parameters( frequency_hz: float, temperature_c: float = WATER_TEMPERATURE_C, salinity: float = 0.0, ) -> tuple[float, float]: """Sionna's relative permittivity and conductivity [S/m] for water at ``frequency_hz``.""" real, imaginary = water_permittivity(frequency_hz, temperature_c, salinity) return real, imaginary * 2.0 * math.pi * frequency_hz * VACUUM_PERMITTIVITY
_registered_variants: set[str] = set()
[docs] def register_water_material() -> None: """Register ``owrt-water-material`` for the active Mitsuba variant, once.""" import mitsuba as mi from sionna.rt import RadioMaterial variant = mi.variant() if variant in _registered_variants: return class WaterRadioMaterial(RadioMaterial): """Water whose permittivity and conductivity follow the scene frequency.""" def __init__(self, props: mi.Properties) -> None: salinity = float(props["salinity"]) del props["salinity"] temperature = WATER_TEMPERATURE_C if "temperature" in props: temperature = float(props["temperature"]) del props["temperature"] self.salinity = salinity self.temperature_c = temperature def update(frequency): return water_radio_parameters(float(frequency[0]), temperature, salinity) super().__init__(frequency_update_callback=update, props=props) mi.register_bsdf("owrt-water-material", lambda props: WaterRadioMaterial(props)) _registered_variants.add(variant)