Skip to content

Commit 1c2ada9

Browse files
committed
Add KBSM-BD-AA model in the channel module.
1 parent f7f9e38 commit 1c2ada9

File tree

2 files changed

+107
-12
lines changed

2 files changed

+107
-12
lines changed

commpy/channels.py

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Authors: Veeresh Taranalli <veeresht@gmail.com> & Bastien Trotobas <bastien.trotobas@gmail.com>
1+
# Authors: Veeresh Taranalli < veeresht @ gmail.com > & Bastien Trotobas < bastien.trotobas @ gmail.com >
22
# License: BSD 3-Clause
33

44
"""
@@ -19,7 +19,7 @@
1919

2020
from __future__ import division, print_function # Python 2 compatibility
2121

22-
from numpy import complex, abs, sqrt, sum, zeros, identity, hstack, einsum, trace, kron, absolute, fromiter
22+
from numpy import complex, abs, sqrt, sum, zeros, identity, hstack, einsum, trace, kron, absolute, fromiter, array, exp
2323
from numpy.random import randn, random, standard_normal
2424
from scipy.linalg import sqrtm
2525

@@ -381,6 +381,41 @@ def propagate(self, msg):
381381
self.unnoisy_output = einsum('ijk,ik->ij', self.channel_gains, msg)
382382
return self.unnoisy_output + self.noises
383383

384+
def _update_corr_KBSM(self, betat, betar):
385+
386+
"""
387+
Update the correlation parameters to follow the KBSM-BD-AA.
388+
389+
Parameters
390+
----------
391+
betat : positive float
392+
Constant for the transmitter.
393+
394+
betar : positive float
395+
Constant for the receiver.
396+
397+
Raises
398+
------
399+
ValueError
400+
If betat or betar are negative.
401+
"""
402+
403+
if betar < 0 or betat < 0:
404+
raise ValueError("beta must be positif ")
405+
406+
# Creation or Er and Et
407+
Er = array([[exp(abs(m - n)) for m in range(self.nb_rx)] for n in range(self.nb_rx)])
408+
Et = array([[exp(abs(m - n)) for m in range(self.nb_tx)] for n in range(self.nb_tx)])
409+
410+
# Compute gain to the keep K-factor
411+
NLOS_before = trace(self.fading_param[1]) * trace(self.fading_param[2])
412+
NLOS_after = trace(self.fading_param[1] * Et) * trace(self.fading_param[2] * Er)
413+
414+
alpha = NLOS_before / NLOS_after
415+
416+
# updating of correlation matrices
417+
self.fading_param = self.fading_param[0], alpha * self.fading_param[1] * Et, self.fading_param[2] * Er
418+
384419
@property
385420
def fading_param(self):
386421
""" Parameters of the fading (see class attribute for details). """
@@ -413,12 +448,17 @@ def uncorr_rayleigh_fading(self, dtype):
413448
"""
414449
self.fading_param = zeros((self.nb_rx, self.nb_tx), dtype), identity(self.nb_tx), identity(self.nb_rx)
415450

416-
def expo_corr_rayleigh_fading(self, t, r):
417-
""" Set the fading parameters to a complex correlated Rayleigh channel following the exponential model.
451+
def expo_corr_rayleigh_fading(self, t, r, betat=0, betar=0):
452+
""" Set the fading parameters to a complex correlated Rayleigh channel following the exponential model [1].
453+
A KBSM-BD-AA can be used as in [2] to improve the model.
418454
419-
See: S. L. Loyka, "Channel capacity if MIMO architecture using the exponential correlation matrix ", IEEE
455+
ref: [1] S. L. Loyka, "Channel capacity if MIMO architecture using the exponential correlation matrix ", IEEE
420456
Commun. Lett., vol.5, n. 9, p. 369-371, sept. 2001.
421457
458+
[2] S. Wu, C. Wang, E. M. Aggoune, et M. M. Alwakeel, "A novel Kronecker-based stochastic model for massive
459+
MIMO channels", in 2015 IEEE/CIC International Conference on Communications in China (ICCC), 2015, p. 1‑6.
460+
461+
422462
Parameters
423463
----------
424464
t : complex with abs(t) = 1
@@ -427,10 +467,21 @@ def expo_corr_rayleigh_fading(self, t, r):
427467
r : complex with abs(r) = 1
428468
Correlation coefficient for the receiver.
429469
470+
betat : positive float
471+
Constant for the transmitter.
472+
*Default* = 0 i.e. classic model
473+
474+
betar : positive float
475+
Constant for the receiver.
476+
*Default* = 0 i.e. classic model
477+
430478
Raises
431479
------
432480
ValueError
433481
If abs(t) != 1 or abs(r) != 1
482+
483+
ValueError
484+
If betat or betar are negative.
434485
"""
435486
# Check inputs
436487
if abs(t) - 1 > 1e-4:
@@ -449,6 +500,9 @@ def expo_corr_rayleigh_fading(self, t, r):
449500
# Set fading
450501
self.fading_param = zeros((self.nb_rx, self.nb_tx), complex), t ** expo_tx, r ** expo_rx
451502

503+
# Update Rr and Rt
504+
self._update_corr_KBSM(betat, betar)
505+
452506
def uncorr_rician_fading(self, mean, k_factor):
453507
""" Set the fading parameters to an uncorrelated rician channel.
454508
@@ -467,13 +521,19 @@ def uncorr_rician_fading(self, mean, k_factor):
467521
mean = mean * sqrt(k_factor * NLOS_gain / einsum('ij,ij->', absolute(mean), absolute(mean)))
468522
self.fading_param = mean, identity(self.nb_tx) * NLOS_gain / nb_antennas, identity(self.nb_rx)
469523

470-
def expo_corr_rician_fading(self, mean, k_factor, t, r):
471-
""" Set the fading parameters to a complex correlated rician channel following the exponential model.
524+
def expo_corr_rician_fading(self, mean, k_factor, t, r, betat=0, betar=0):
525+
""" Set the fading parameters to a complex correlated rician channel following the exponential model [1].
526+
A KBSM-BD-AA can be used as in [2] to improve the model.
472527
473-
See: S. L. Loyka, "Channel capacity if MIMO architecture using the exponential correlation matrix ", IEEE
528+
ref: [1] S. L. Loyka, "Channel capacity if MIMO architecture using the exponential correlation matrix ", IEEE
474529
Commun. Lett., vol.5, n. 9, p. 369-371, sept. 2001.
475530
476-
mean and correlation matricies will be scaled to fit the required k-factor.
531+
[2] S. Wu, C. Wang, E. M. Aggoune, et M. M. Alwakeel, "A novel Kronecker-based stochastic model for massive
532+
MIMO channels", in 2015 IEEE/CIC International Conference on Communications in China (ICCC), 2015, p. 1‑6.
533+
534+
535+
mean and correlation matricies will be scaled to fit the required k-factor. The k-factor is also preserved is
536+
beta are provided.
477537
478538
Parameters
479539
----------
@@ -489,10 +549,21 @@ def expo_corr_rician_fading(self, mean, k_factor, t, r):
489549
r : complex with abs(r) = 1
490550
Correlation coefficient for the receiver.
491551
552+
betat : positive float
553+
Constant for the transmitter.
554+
*Default* = 0 i.e. classic model
555+
556+
betar : positive float
557+
Constant for the receiver.
558+
*Default* = 0 i.e. classic model
559+
492560
Raises
493561
------
494562
ValueError
495563
If abs(t) != 1 or abs(r) != 1
564+
565+
ValueError
566+
If betat or betar are negative.
496567
"""
497568
# Check inputs
498569
if abs(t) - 1 > 1e-4:
@@ -516,6 +587,9 @@ def expo_corr_rician_fading(self, mean, k_factor, t, r):
516587
# Set fading
517588
self.fading_param = mean, t ** expo_tx * NLOS_gain / nb_antennas, r ** expo_rx
518589

590+
# Update Rr and Rt
591+
self._update_corr_KBSM(betat, betar)
592+
519593

520594
def bec(input_bits, p_e):
521595
"""

commpy/tests/test_channels.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33

44
from __future__ import division, print_function # Python 2 compatibility
55

6+
from commpy.channels import SISOFlatChannel, MIMOFlatChannel
7+
from commpy.utilities import signal_power
68
from numpy import ones, inf, sqrt, array, identity, zeros, dot, trace, einsum, absolute, exp, pi, fromiter, kron, \
79
zeros_like
810
from numpy.random import seed, choice, randn
911
from numpy.testing import run_module_suite, assert_raises, assert_equal, assert_allclose, \
1012
assert_array_equal, dec
1113

12-
from commpy.channels import SISOFlatChannel, MIMOFlatChannel
13-
from commpy.utilities import signal_power
14-
1514

1615
class TestSISOFlatChannel:
1716
msg_length = 100000
@@ -386,6 +385,28 @@ def check_correlation(chan, Rt, Rr):
386385
assert_allclose(chan.k_factor, 10,
387386
err_msg='Wrong k-factor with correlated rician fading')
388387

388+
# Test with beta > 0
389+
chan.expo_corr_rayleigh_fading(exp(-0.2j*pi), exp(-0.1j*pi), 1, 0.5)
390+
check_chan_gain(mod, chan)
391+
assert_allclose(chan.k_factor, 0,
392+
err_msg='Wrong k-factor with correlated Rayleigh fading')
393+
Rt, Rr = expo_correlation(exp(-0.2j*pi), exp(-0.1j*pi))
394+
# ET ER, et version chapea de R
395+
Er = array([[exp(abs(m - n)) for m in range(nb_rx)] for n in range(nb_rx)])
396+
Et = array([[exp(abs(m - n)) for m in range(nb_tx)] for n in range(nb_tx)])
397+
398+
Rr = chan.fading_param[1] * Er
399+
Rt = chan.fading_param[2] * Et
400+
401+
check_correlation(chan, Rt, Rr)
402+
403+
mean = randn(nb_rx, nb_tx) + randn(nb_rx, nb_tx) * 1j
404+
chan.expo_corr_rician_fading(mean, 5, exp(-0.1j*pi), exp(-0.2j*pi), 3, 2)
405+
check_chan_gain(mod, chan)
406+
assert_allclose(chan.k_factor, 5,
407+
err_msg='Wrong k-factor with correlated rician fading')
408+
409+
389410

390411
@dec.slow
391412
class TestMIMONoiseGeneration(MIMOTestCase):

0 commit comments

Comments
 (0)