Repository navigation
|
I have a Sionna OFDM + CDL MIMO simulation (LMMSE equalizer, 5G LDPC, QAM) that works reasonably up to ~8 antennas, but BER/BLER becomes very poor for larger antenna counts (I want to scale up to >16 and eventually 128). How can I increase my simulation antenna size to > 16? The following is the simulation is for a 8 by 8 configuration and for a 16 by 16 it degrade to The following is the code that I am using import os
import sys
# Have to be set before importing sionna and tensorflow
# if not both gpu will be used
gpu_num = 0 # Use "" to use the CPU
os.environ["CUDA_VISIBLE_DEVICES"] = f"{gpu_num}"
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
# os.environ['TF_FORCE_UNIFIED_MEMORY'] = '1'
# os.environ['XLA_PYTHON_CLIENT_MEM_FRACTION'] = '4'
import tensorflow as tf
import numpy as np
from sionna.phy import Block
from sionna.phy.mimo import StreamManagement
from sionna.phy.ofdm import ResourceGrid, ResourceGridMapper, LSChannelEstimator, OFDMDetector, \
OFDMModulator, OFDMDemodulator, RZFPrecoder, RemoveNulledSubcarriers, \
LMMSEEqualizer
from sionna.phy.channel.tr38901 import AntennaArray, CDL
from sionna.phy.channel import subcarrier_frequencies, cir_to_ofdm_channel, cir_to_time_channel, \
time_lag_discrete_time_channel, ApplyOFDMChannel, ApplyTimeChannel
from sionna.phy.mapping import Mapper, BinarySource, Constellation, Demapper
from sionna.phy.utils import ebnodb2no
from sionna.phy.fec.ldpc import LDPC5GEncoder, LDPC5GDecoder
from sionna.phy.utils import sim_ber
TAB = " " * 4
class Model(Block):
def __init__(self,
output,
num_ut_ant,
num_bs_ant,
num_bits_per_symbol,
perf_csi,
channel_family="cdl",
channel_model = "C",
constellation = None,
domain="freq", # "time" or "freq"
direction="downlink", # "uplink" or "downlink"
normalized_detector=True,
verbose=True,
**kwargs):
"""
This block simulates OFDM MIMO transmissions over the 3GPP TDL/CDL model.
Simulates point-to-point transmissions between a UT and a BS.
Uplink and downlink transmissions can be realized with either perfect CSI
or channel estimation. ZF Precoding for downlink transmissions is assumed.
The receiver (in both uplink and downlink) applies LS channel estimation
and MIMO equalization. A 5G LDPC code is assumed to be used with a QAM
modulation scheme.
Parameters
----------
detector : sionna.phy.mimo.Detection
MIMO detector under test.
output : str
Output type. Either "bit", "symbol" or "symbol-bits".
num_ut_ant : int
Number of antennas at the User Terminal (UT).
Must be a multiple of two as dual-polarized antennas are used.
num_bs_ant : int
Number of antennas at the Base Station (BS).
Must be a multiple of two as dual-polarized antennas are used.
num_bits_per_symbol : int
Number of bits per QAM symbol.
perf_csi : bool
If True, perfect CSI is assumed at the receiver.
If False, LS channel estimation is performed.
channel_family : str, optional
Channel family. Either "cdl" or "tdl".
Default is "cdl".
channel_model : str, optional
Channel model. For CDL, either "A", "B", "C", "D", "E" or "F".
For TDL, either "A", "B", "C", "D", "E" or "F".
Default is "C".
constellation : sionna.phy.mapping.Constellation, optional
Constellation to use. If None, a normalized QAM constellation is used.
Default is None.
domain : str, optional
Domain in which the channel is applied. Either "time" or "freq".
Default is "freq".
direction : str, optional
Direction of the transmission. Either "uplink" or "downlink".
Default is "downlink".
normalized_detector : bool, optional
If True, the detector is assumed to be designed for a normalized constellation.
If False, the detector is assumed to be designed for a non-normalized constellation.
Default is True.
**kwargs : keyword arguments
Additional keyword arguments passed to the Block constructor.
Outputs
-------
If output is "bit":
b : tf.Tensor
Transmitted bits of shape [batch_size, num_tx, num_streams_per_tx, k]
b_hat : tf.Tensor
Detected bits of shape [batch_size, num_tx, num_streams_per_tx, k]
If output is "symbol":
x_ind : tf.Tensor
Transmitted symbols of shape [batch_size, num_tx, num_streams_per_tx, n]
x_hat : tf.Tensor
Detected symbols of shape [batch_size, num_tx, num_streams_per_tx, n]
"""
super().__init__(**kwargs)
if verbose:
print(f"Using Realistic P2P 3GPP MIMO with the following configuration:")
print(TAB + f"N_user_ant :{num_ut_ant}")
print(TAB + f"N_base_ant :{num_bs_ant}")
print(TAB + f"Constellation :{2 ** num_bits_per_symbol}-QAM")
print(TAB + f"Detector : LMMSE")
print(TAB + f"Channel Model :{channel_family.upper()}")
print(TAB + f"Model :{channel_model.upper()}")
print(TAB + f"Domain :{domain}")
print(TAB + f"Direction :{direction}")
print(TAB + f"Normalized :{normalized_detector}")
print(TAB + f"Perfect CSI :{'Yes' if perf_csi else 'No'}")
print(TAB + f"Output :{output}")
# Provided parameters
self._domain = domain
self._direction = direction
self._channel_family = channel_family.lower()
self._channel_model = channel_model.upper()
self._perfect_csi = perf_csi
self._output = output
assert self._domain in ["time", "freq"], "domain must be either 'time' or 'freq'"
assert self._direction in ["uplink", "downlink"], "direction must be either 'uplink' or 'downlink'"
assert output in ["bit", "symbol", "symbol-bits"], "output must be either 'bit' or 'symbol'"
assert self._channel_model in ["A", "B", "C", "D", "E"], "channel_model must be one of 'A', 'B', 'C', 'D', or 'E'"
output = "symbol" if output in ["symbol", "symbol-bits"] else "bit"
# System parameters
if constellation is None:
constellation = Constellation("qam",
num_bits_per_symbol,
normalize=True)
self._num_bits_per_symbol = num_bits_per_symbol
# System parameters
self._carrier_frequency = 2.6e9
self._subcarrier_spacing = 15e3
self._fft_size = 128 + 12
self._num_ofdm_symbols = 14
self._num_ut_ant = num_ut_ant # Must be a multiple of two as dual-polarized antennas are used
self._num_bs_ant = num_bs_ant # Must be a multiple of two as dual-polarized antennas are used
self._num_streams_per_tx = self._num_ut_ant
self._dc_null = True
self._num_guard_carriers = [5, 6]
self._pilot_pattern = "kronecker"
self._pilot_ofdm_symbol_indices = [2, 11]
self._coderate = 0.5
self._cyclic_prefix_length = 6
self._speed = 0.0
self._delay_spread = 100e-9
self._coderate = 0.5
if verbose:
print("-" * 50)
print(TAB + "System Parameters")
print("-" * 50)
print(2 * TAB + f"Num bits per symbol :{self._num_bits_per_symbol}")
print(2 * TAB + f"Coderate :{self._coderate}")
print(2 * TAB + f"FFT size :{self._fft_size}")
print(2 * TAB + f"Num ofdm symbols :{self._num_ofdm_symbols}")
print(2 * TAB + f"Subcarrier spacing :{self._subcarrier_spacing/1e3} kHz")
print(2 * TAB + f"Num base antennas :{self._num_bs_ant}")
print(2 * TAB + f"Num streams per user :{self._num_streams_per_tx}")
print(2 * TAB + f"DC null :{'Yes' if self._dc_null else 'No'}")
print(2 * TAB + f"Num guard carriers :{self._num_guard_carriers}")
print(2 * TAB + f"Cyclic prefix length :{self._cyclic_prefix_length}")
print(2 * TAB + f"Pilot ofdm symbol idx :{self._pilot_ofdm_symbol_indices}")
print(2 * TAB + f"Carrier frequency :{self._carrier_frequency/1e9} GHz")
print(2 * TAB + f"Speed :{self._speed} m/s")
print(2 * TAB + f"Delay spread :{self._delay_spread*1e9} ns")
print("-" * 135)
# Configure the resource grid
rg = ResourceGrid(num_ofdm_symbols=self._num_ofdm_symbols,
fft_size=self._fft_size,
subcarrier_spacing = self._subcarrier_spacing,
num_tx=1,
num_streams_per_tx=self._num_streams_per_tx,
cyclic_prefix_length=self._cyclic_prefix_length,
num_guard_carriers=self._num_guard_carriers,
dc_null=self._dc_null,
pilot_pattern="kronecker",
pilot_ofdm_symbol_indices=self._pilot_ofdm_symbol_indices)
self._rg = rg
# Stream management
self._sm = StreamManagement(np.array([[1]]), self._num_streams_per_tx)
# Codeword length and number of information bits per codeword (assume coding is used)
n = int(rg.num_data_symbols*num_bits_per_symbol)
k = int(self._coderate *n)
self._n = n
self._k = k
##################################
# User Terminal (UT)
##################################
self._binary_source = BinarySource()
self._encoder = LDPC5GEncoder(k, n)
self._mapper = Mapper(constellation= constellation,
num_bits_per_symbol=num_bits_per_symbol,
return_indices=True,
normalize=True)
self._rg_mapper = ResourceGridMapper(rg)
self._ut_array = AntennaArray(num_rows=1,
num_cols=int(self._num_ut_ant/2),
polarization="dual",
polarization_type="cross",
antenna_pattern="38.901",
carrier_frequency=self._carrier_frequency)
self._bs_array = AntennaArray(num_rows=1,
num_cols=int(self._num_bs_ant/2),
polarization="dual",
polarization_type="cross",
antenna_pattern="38.901",
carrier_frequency=self._carrier_frequency)
if self._direction == "downlink":
self._zf_precoder = RZFPrecoder(self._rg, self._sm, return_effective_channel=True)
##################################
# Channel
##################################
self._chn = CDL(model=self._channel_model,
delay_spread=self._delay_spread,
carrier_frequency=self._carrier_frequency,
ut_array=self._ut_array,
bs_array=self._bs_array,
direction=self._direction,
min_speed=self._speed)
self._frequencies = subcarrier_frequencies(self._rg.fft_size, self._rg.subcarrier_spacing)
if self._domain == "freq":
self._channel_freq = ApplyOFDMChannel(add_awgn=True)
elif self._domain == "time":
self._l_min, self._l_max = time_lag_discrete_time_channel(self._rg.bandwidth)
self._l_tot = self._l_max - self._l_min + 1
self._channel_time = ApplyTimeChannel(self._rg.num_time_samples,
l_tot=self._l_tot,
add_awgn=True)
self._modulator = OFDMModulator(self._cyclic_prefix_length)
self._demodulator = OFDMDemodulator(self._fft_size, self._l_min, self._cyclic_prefix_length)
###################################
# Base Station (BS)
###################################
self._decoder = LDPC5GDecoder(self._encoder)
self._channel_estimator = LSChannelEstimator(self._rg, interpolation_type="nn")
self._remove_nulled_scs = RemoveNulledSubcarriers(self._rg)
self._detector = LMMSEEqualizer(self._rg, self._sm)
self._demapper = Demapper("app", constellation=constellation)
@tf.function(jit_compile=True)
def call(self, batch_size, ebno_db):
no = ebnodb2no(ebno_db, self._num_bits_per_symbol, self._coderate, self._rg)
##################################
# User Terminal (UT)
##################################
b = self._binary_source([batch_size, 1, self._num_streams_per_tx, self._k])
c = self._encoder(b)
x,x_ind = self._mapper(c)
x_rg = self._rg_mapper(x)
##################################
# Channel
##################################
if self._domain == "time":
# Time-domain simulations
a, tau = self._chn(batch_size, self._rg.num_time_samples+self._l_tot-1, self._rg.bandwidth)
h_time = cir_to_time_channel(self._rg.bandwidth, a, tau,
l_min=self._l_min, l_max=self._l_max, normalize=True)
# As precoding is done in the frequency domain, we need to downsample
# the path gains `a` to the OFDM symbol rate prior to converting the CIR
# to the channel frequency response.
a_freq = a[...,self._rg.cyclic_prefix_length:-1:(self._rg.fft_size+self._rg.cyclic_prefix_length)]
a_freq = a_freq[...,:self._rg.num_ofdm_symbols]
h_freq = cir_to_ofdm_channel(self._frequencies, a_freq, tau, normalize=True)
if self._direction == "downlink":
x_rg, g = self._zf_precoder(x_rg, h_freq)
x_time = self._modulator(x_rg)
y_time = self._channel_time(x_time, h_time, no)
y = self._demodulator(y_time)
elif self._domain == "freq":
# Frequency-domain simulations
cir = self._chn(batch_size, self._rg.num_ofdm_symbols, 1/self._rg.ofdm_symbol_duration)
h_freq = cir_to_ofdm_channel(self._frequencies, *cir, normalize=True)
if self._direction == "downlink":
x_rg, g = self._zf_precoder(x_rg, h_freq)
y = self._channel_freq(x_rg, h_freq, no)
###################################
# Base Station (BS)
###################################
if self._perfect_csi:
if self._direction == "uplink":
h_hat = self._remove_nulled_scs(h_freq)
elif self._direction =="downlink":
h_hat = g
err_var = 0.0
else:
h_hat, err_var = self._ls_est (y, no)
# Detection
x_hat, no_eff = self._detector(y, h_hat, err_var, no)
llr = self._demapper(x_hat, no_eff)
# Output
if self._output == "bit":
b_hat = self._decoder(llr)
b_hat = tf.reshape(b_hat, tf.shape(b))
return b, b_hat
elif self._output == "symbol":
x_hat = tf.reshape(x_hat, tf.shape(x_ind))
return x_ind, x_hat
# Range of SNR (dB)
EBN0_DBs = np.arange(-10, 50.0, 4.0)
# Number of transmitters
NUM_TX = 8
# Number of receivers
NUM_RX = 8
# Modulation order (number of bits per symbol)
NUM_BITS_PER_SYMBOL = 4 # 16-QAM
output = "bit" # "bit" or "symbol"
print("Running LMMSE simulation (uplink)...")
model = Model(output=output,
perf_csi=True,
num_ut_ant=NUM_TX,
num_bs_ant=NUM_RX,
cdl_model = "C",
num_bits_per_symbol=NUM_BITS_PER_SYMBOL,
normalized_detector=True,
direction="uplink")
sim_ber(model,
EBN0_DBs,
batch_size=64,
max_mc_iter=200,
num_target_block_errors=200,
target_bler=0.01); |
Replies: 3 comments 4 replies
|
Hi, Are these results with perfect CSI or with channel estimation? Allocating pilots for so many streams is quite challenging and the Kronecker pattern might simply not work. Moreover, did you check that the channel rank supports so many streams? I would not be surprised if this is not the case. So maybe try something more reasonable, such as 128 RX antennas and 16 TX antennas. |
|
You need to have a look at the singular values of the effective channel matrices in this tensor:
|
|
Yes, I meant As a sanity check, you could replace the channel model by a Rayleigh block-fading channel. This channel has typically far better conditioned channel matrices. |
What it tells you is that realistic channels do not support full-rank transmissions and that the Rayleigh block-fading channel is an ideal case that you do not find in practice. This channel model is used in many papers because of its simplicity and analytical tractability, not because it is realistic. Maybe rather than simulating a 16x16 or 128x128 system, you should look at something more reasonable like 128x16.
Apart from this, as soon as you take channel estimation into account, a 128x128 setup will become impossible due to prohibitive pilot overhead.