Skip to content

Commit

Permalink
Merge branch '185-multi-device-channels' into 'master'
Browse files Browse the repository at this point in the history
Resolve "Multi-Device Channels"

See merge request barkhauseninstitut/wicon/hermespy!190
  • Loading branch information
adlerjan committed May 27, 2024
2 parents 53c4827 + f01bee1 commit 5f8e42c
Show file tree
Hide file tree
Showing 46 changed files with 514 additions and 987 deletions.
4 changes: 2 additions & 2 deletions _examples/library/getting_started_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
rx_device.receivers.add(rx_operator)

# Simulate a channel between the two devices
channel = IdealChannel(tx_device, rx_device)
channel = IdealChannel()

# Simulate the signal transmission over the channel
transmission = tx_operator.transmit()
propagation = channel.propagate(tx_device.transmit())
propagation = channel.propagate(tx_device.transmit(), tx_device, rx_device)
rx_device.process_input(propagation)
reception = rx_operator.receive()

Expand Down
4 changes: 2 additions & 2 deletions _examples/library/getting_started_ofdm_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
link.waveform.plot_grid()

# Simulate a channel between the two devices
channel = IdealChannel(tx_device, rx_device)
channel = IdealChannel()

# Simulate the signal transmission over the channel
transmission = tx_device.transmit()
propagation = channel.propagate(transmission)
propagation = channel.propagate(transmission, tx_device, rx_device)
reception = rx_device.receive(propagation)

# Evaluate bit errors during transmission and visualize the received symbol constellation
Expand Down
6 changes: 0 additions & 6 deletions _examples/library/getting_started_simulation_multidim.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,10 @@
base_station = simulation.scenario.new_device()
terminal = simulation.scenario.new_device()


# Specify the hardware noise model
base_station.noise_level = SNR(dB(20), base_station)
terminal.noise_level = SNR(dB(20), base_station)

# Disable device self-interference by setting the gain
# of the respective self-inteference channels to zero
simulation.scenario.channel(base_station, base_station).gain = 0.
simulation.scenario.channel(terminal, terminal).gain = 0.

# Configure a transmitting modem at the base station
transmitter = TransmittingModem()
transmitter.waveform = RootRaisedCosineWaveform(symbol_rate=1e6, num_preamble_symbols=0, num_data_symbols=100, oversampling_factor=8, roll_off=.9)
Expand Down
29 changes: 11 additions & 18 deletions _examples/settings/chirp_fsk_lora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,17 @@ Devices:

# Channel models between devices
Channels:

# Rayleigh fading between on the device self-interfernce channel
- !<MultipathFading>
devices: [*transmitting_device, *receiving_device]
delays: [ 0 ] # Delay of the channel in seconds
power_profile: [ 0 ] dB # Tap gains
rice_factors: [ .inf ]

# Configure 3GPP standard antenna correlation models at both linked devices
alpha_correlation: !<StandardCorrelation>

device_type: BASE_STATION
correlation: LOW

beta_correlation: !<StandardCorrelation>

device_type: TERMINAL
correlation: MEDIUM
- # Rayleigh fading between on the device self-interfernce channel
- *transmitting_device
- *receiving_device
- !<MultipathFading>
delays: [ 0 ] # Delay of the channel in seconds
power_profile: [ 0 ] dB # Tap gains
rice_factors: [ .inf ]

# Configure 3GPP standard antenna correlation models at both linked devices
antenna_correlation: !<StandardCorrelation>
correlation: MEDIUM


# Operators transmitting or receiving signals over the devices
Expand Down
33 changes: 18 additions & 15 deletions _examples/settings/jcas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,24 @@ Devices:
# Channel models between device models
Channels:

# Single target radar channel
- &radar_channel !<RadarChannel>
devices: [*base_station, *base_station]
target_range: [1, 2] # The target is located within a distance between 1m and 2m to the base station
radar_cross_section: 5 # The target has a cross section of 5m2

# 5G TDL communication channel model
- !<5GTDL>
devices: [*base_station, *terminal]
model_type: !<TDLType> A # Type of the TDL model. A-E are available

# No self-interference at the terminal
- !<Channel>
devices: [*terminal, *terminal]
gain: 0.
- # Single target radar channel
- *base_station
- *base_station
- &radar_channel !<RadarChannel>
target_range: [1, 2] # The target is located within a distance between 1m and 2m to the base station
radar_cross_section: 5 # The target has a cross section of 5m2

- # 5G TDL communication channel model
- *base_station
- *terminal
- !<5GTDL>
model_type: !<TDLType> A # Type of the TDL model. A-E are available

- # No self-interference at the terminal
- *terminal
- *terminal
- !<Channel>
gain: 0.


# Operators transmitting or receiving signals over the devices
Expand Down
11 changes: 6 additions & 5 deletions _examples/settings/ofdm_5g.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ Devices:
# Specify channel models interconnecting devices
Channels:

# 5G TDL model at the self-interference channel of device_alpha
- &channel !<5GTDL>
devices: [*device_alpha, *device_alpha] # Devices linked by the channel
model_type: !<TDLType> E # Type of the TDL model. A-E are available
rms_delay: 100e-9 # Root mean square delay in seconds
- # 5G TDL model at the self-interference channel of device_alpha
- *device_alpha
- *device_alpha
- &channel !<5GTDL>
model_type: !<TDLType> E # Type of the TDL model. A-E are available
rms_delay: 100e-9 # Root mean square delay in seconds


# Operators transmitting or receiving signals over the devices
Expand Down
11 changes: 6 additions & 5 deletions _examples/settings/ofdm_single_carrier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ Devices:
# Specify channel models interconnecting devices
Channels:

# 5G TDL model at the self-interference channel of device_alpha
- &channel !<5GTDL>
devices: [*device_alpha, *device_alpha]
model_type: !<TDLType> A # Type of the TDL model. A-E are available
rms_delay: 1e-9 # Root mean square delay in seconds
- # 5G TDL model at the self-interference channel of device_alpha
- *device_alpha
- *device_alpha
- &channel !<5GTDL>
model_type: !<TDLType> A # Type of the TDL model. A-E are available
rms_delay: 1e-9 # Root mean square delay in seconds


# Operators transmitting or receiving signals over the devices
Expand Down
45 changes: 31 additions & 14 deletions docssource/notebooks/roc.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docssource/scripts/examples/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
beta_device = SimulatedDevice()

# Create a channel between the two devices
channel = Channel(alpha_device=alpha_device, beta_device=beta_device)
channel = Channel()

# Configure communication link between the two devices
link = SimplexLink(alpha_device, beta_device)
Expand All @@ -32,8 +32,8 @@

# Propagate the transmissions over the channel
channel_realization = channel.realize()
alpha_propagation = channel.propagate(alpha_transmission, alpha_device, beta_device)
beta_propagation = channel.propagate(beta_transmission, beta_device, alpha_device)
alpha_propagation = channel_realization.sample(alpha_device, beta_device).propagate(alpha_transmission)
beta_propagation = channel_realization.sample(beta_device, alpha_device).propagate(beta_transmission)

# Receive the transmissions at both devices
alpha_reception = alpha_device.receive(beta_propagation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
simulation.scenario.set_channel(device, device, target)

# Create a new detection probability evaluator
simulation.add_evaluator(RootMeanSquareError(radar, target))
simulation.add_evaluator(RootMeanSquareError(radar, radar, target))

# Sweep over the target's SNR during the simulation
simulation.new_dimension('noise_level', dB(0, -5, -10, -20, -30), device)
Expand Down
18 changes: 5 additions & 13 deletions hermespy/channel/cdl/cluster_delay_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from enum import Enum, IntEnum
from functools import cache, cached_property
from math import ceil, sin, cos, sqrt
from typing import Generator, Generic, Literal, List, Set, Tuple, TypeVar, TYPE_CHECKING
from typing import Generator, Generic, Literal, List, Set, Tuple, TypeVar

import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -44,9 +44,6 @@
ConsistentSample,
)

if TYPE_CHECKING:
from hermespy.simulation import SimulatedDevice # pragma: no cover

__author__ = "Jan Adler"
__copyright__ = "Copyright 2024, Barkhausen Institut gGmbH"
__credits__ = ["Jan Adler"]
Expand Down Expand Up @@ -2016,8 +2013,6 @@ class ClusterDelayLineBase(Channel[CDLRT, ClusterDelayLineSample], Generic[CDLRT

def __init__(
self,
alpha_device: SimulatedDevice | None = None,
beta_device: SimulatedDevice | None = None,
gain: float = 1.0,
delay_normalization: DelayNormalization = DelayNormalization.ZERO,
oxygen_absorption: bool = True,
Expand All @@ -2027,12 +2022,6 @@ def __init__(
"""
Args:
alpha_device (SimulatedDevice, optional):
First device linked by the :class:`.ClusterDelayLineBase` instance that generated this realization.
beta_device (SimulatedDevice, optional):
Second device linked by the :class:`.ClusterDelayLineBase` instance that generated this realization.
gain (float, optional):
Linear gain factor a signal amplitude experiences when being propagated over this realization.
:math:`1.0` by default.
Expand All @@ -2047,10 +2036,13 @@ def __init__(
expected_state (LSST, optional):
Expected large-scale state of the channel.
If `None`, the state is randomly generated during each sample of the channel's realization.
\**kwargs:
Additional keyword arguments passed to the base class.
"""

# Initialize base class
Channel.__init__(self, alpha_device, beta_device, gain, **kwargs)
Channel.__init__(self, gain, **kwargs)

# Initialize class attributes
self.delay_normalization = delay_normalization
Expand Down
13 changes: 4 additions & 9 deletions hermespy/channel/cdl/indoor_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,6 @@ def __init__(
surface: float,
factory_type: FactoryType,
clutter_height: float = 0.0,
alpha_device=None,
beta_device=None,
gain: float = 1.0,
**kwargs: Any,
) -> None:
Expand All @@ -469,19 +467,16 @@ def __init__(
Height of the clutter in the factory hall in meters above the floor.
Zero by default, meaning virtually no clutter.
alpha_device (SimulatedDevice, optional):
First device linked by the :class:`.ClusterDelayLine` instance.
beta_device (SimulatedDevice, optional):
Second device linked by the :class:`.ClusterDelayLine` instance.
gain (float, optional):
Linear power gain factor a signal experiences when being propagated over this realization.
:math:`1.0` by default.
\**kwargs:
Additional arguments passed to the base class.
"""

# Initialize base class
ClusterDelayLineBase.__init__(self, alpha_device, beta_device, gain, **kwargs)
ClusterDelayLineBase.__init__(self, gain, **kwargs)

# Initialize class attributes
self.volume = volume
Expand Down
7 changes: 5 additions & 2 deletions hermespy/channel/cdl/indoor_office.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,18 +396,21 @@ class IndoorOffice(ClusterDelayLineBase[IndoorOfficeRealization, LOSState], Seri

__office_type: OfficeType

def __init__(self, *args, office_type: OfficeType = OfficeType.MIXED, **kwargs) -> None:
def __init__(self, office_type: OfficeType = OfficeType.MIXED, **kwargs) -> None:
"""
Args:
office_type (OfficeType, optional):
Type of the modeled office.
If not specified, a mixed office is assumed.
\**kwargs:
Additional arguments passed to the base class.
"""

# Initialize base class
ClusterDelayLineBase.__init__(self, *args, **kwargs)
ClusterDelayLineBase.__init__(self, **kwargs)

# Initialize class attributes
self.__office_type = office_type
Expand Down
Loading

0 comments on commit 5f8e42c

Please sign in to comment.