-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sionna RT result error #400
Comments
Hello @fanyimeng0, I am pasting the contents of your report below for visibility. %matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import time
# Import Sionna RT components
from sionna.rt import load_scene, Transmitter, Receiver, PlanarArray, Camera
# For link-level simulations
from sionna.channel import cir_to_ofdm_channel, subcarrier_frequencies, OFDMChannel, ApplyOFDMChannel, CIRDataset
from sionna.nr import PUSCHConfig, PUSCHTransmitter, PUSCHReceiver
from sionna.utils import compute_ber, ebnodb2no, PlotBER
from sionna.ofdm import KBestDetector, LinearDetector
from sionna.mimo import StreamManagement
import os
gpu_num = 0 # Use "" to use the CPU
os.environ["CUDA_VISIBLE_DEVICES"] = f"{gpu_num}"
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import tensorflow as tf
# Import Sionna
try:
import sionna
except ImportError as e:
# Install Sionna if package is not already installed
import os
os.system("pip install sionna")
import sionna
# Load the required Sionna components
from sionna.nr import PUSCHConfig, PUSCHTransmitter, PUSCHReceiver
from sionna.channel import AWGN, RayleighBlockFading, OFDMChannel, TimeChannel, time_lag_discrete_time_channel
from sionna.channel.tr38901 import AntennaArray, UMi, UMa, RMa
from sionna.channel import gen_single_sector_topology as gen_topology
from sionna.utils import compute_ber, ebnodb2no, sim_ber
from sionna.ofdm import KBestDetector, LinearDetector
from sionna.mimo import StreamManagement
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import sys
from sionna.utils import BinarySource, QAMSource, ebnodb2no, compute_ser, compute_ber, PlotBER
from sionna.channel import FlatFadingChannel, KroneckerModel
from sionna.channel.utils import exp_corr_mat
from sionna.mimo import lmmse_equalizer
from sionna.mapping import SymbolDemapper, Mapper, Demapper
from sionna.fec.ldpc.encoding import LDPC5GEncoder
from sionna.fec.ldpc.decoding import LDPC5GDecoder
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pickle
import time
from sionna.mimo import StreamManagement
from sionna.ofdm import ResourceGrid, ResourceGridMapper, LSChannelEstimator, LMMSEEqualizer
from sionna.ofdm import OFDMModulator, OFDMDemodulator, ZFPrecoder, RemoveNulledSubcarriers
from sionna.channel.tr38901 import AntennaArray, CDL, Antenna
from sionna.channel import subcarrier_frequencies, cir_to_ofdm_channel, cir_to_time_channel, time_lag_discrete_time_channel
from sionna.channel import ApplyOFDMChannel, ApplyTimeChannel, OFDMChannel, TimeChannel
from sionna.fec.ldpc.encoding import LDPC5GEncoder
from sionna.fec.ldpc.decoding import LDPC5GDecoder
from sionna.mapping import Mapper, Demapper
from sionna.utils import BinarySource, ebnodb2no, sim_ber
from sionna.utils.metrics import compute_ber
import tensorflow as tf
# Configure the notebook to use only a single GPU and allocate only as much memory as needed
# For more details, see https://www.tensorflow.org/guide/gpu
gpus = tf.config.list_physical_devices('GPU')
if gpus:
try:
tf.config.experimental.set_memory_growth(gpus[0], True)
except RuntimeError as e:
print(e)
# Avoid warnings from TensorFlow
tf.get_logger().setLevel('ERROR')
scene = load_scene("../test_bg/test.xml") scene.remove("tx")
scene.remove("rx")
scene.tx_array = PlanarArray(num_rows=1,
num_cols=1,
vertical_spacing=0.5,
horizontal_spacing=0.5,
pattern="tr38901",
polarization="V")
# Configure antenna array for all receivers
scene.rx_array = PlanarArray(num_rows=9,
num_cols=9,
vertical_spacing=0.5,
horizontal_spacing=0.5,
pattern="tr38901",
polarization="V")
# Create transmitter
tx = Transmitter(name="tx",
position=[0,-10,17])
# Add transmitter instance to scene
scene.add(tx)
# Create a receiver
rx = Receiver(name="rx",
position=[0,-10,17],
orientation=[0,0,0])
# Add receiver instance to scene
scene.add(rx)
#tx.look_at(rx) # Transmitter points towards receiver
scene.frequency = 2.6e9 # in Hz; implicitly updates RadioMaterials
scene.synthetic_array = True # If set to False, ray tracing will be done per antenna element (slower for large arrays)
# Compute propagation paths
paths = scene.compute_paths(max_depth=2,
num_samples=1e6) # Number of rays shot into directions defined
# by a Fibonacci sphere , too few rays can
# lead to missing paths
# Visualize paths in the 3D preview
a, tau = paths.cir()
print("Shape of `a` after applying Doppler shifts: ", paths.a.shape)
re = np.diff(np.angle(a[0,0,:,0,0,1,0]))*180/np.pi
re[re < 0] += 360
print(re)
#scene.preview(paths, show_devices=True, show_paths=True) # Use the mouse to focus on the visualized paths
scene.remove("tx")
scene.remove("rx")
scene.tx_array = PlanarArray(num_rows=1,
num_cols=1,
vertical_spacing=0.5,
horizontal_spacing=0.5,
pattern="tr38901",
polarization="V")
# Configure antenna array for all receivers
scene.rx_array = PlanarArray(num_rows=9,
num_cols=9,
vertical_spacing=0.5,
horizontal_spacing=0.5,
pattern="tr38901",
polarization="V")
# Create transmitter
tx = Transmitter(name="tx",
position=[0,-10,17])
# Add transmitter instance to scene
scene.add(tx)
# Create a receiver
rx = Receiver(name="rx",
position=[0,-10,17],
orientation=[0,0,0])
# Add receiver instance to scene
scene.add(rx)
#tx.look_at(rx) # Transmitter points towards receiver
scene.frequency = 2.6e9 # in Hz; implicitly updates RadioMaterials
scene.synthetic_array = True # If set to False, ray tracing will be done per antenna element (slower for large arrays)
# Compute propagation paths
paths = scene.compute_paths(max_depth=2,
num_samples=1e6) # Number of rays shot into directions defined
# by a Fibonacci sphere , too few rays can
# lead to missing paths
# Visualize paths in the 3D preview
a, tau = paths.cir()
print("Shape of `a` after applying Doppler shifts: ", paths.a.shape)
re = np.diff(np.angle(a[0,0,:,0,0,1,0]))*180/np.pi
re[re < 0] += 360
print(re)
#scene.preview(paths, show_devices=True, show_paths=True) # Use the mouse to focus on the visualized paths
|
Hi @fanyimeng0, I was trying to look into your issue but I do not have access to the scene that you are using. |
Hello,I reproduced this issue in sionna.rt.scene.munich. The third code cell in the Jupyter notebook is the same as the second one. I'm running the same code twice to demonstrate that the same code can lead to different results. The printed results are the phase difference between antennas. `a, tau = paths.cir() print("Shape of re = np.diff(np.angle(a[0,0,:,0,0,1,0]))*180/np.pi re[re < 0] += 360 print(re)` And the attacked file is the result in munich scene. |
Hi, The reason you observe different outputs is because the frequency is set before defining the antenna arrays in your code, leading to using an antenna spacing that does not match the frequency you set but the default one in the first run. |
Thanks for your response. Setting frequency correctly works well. But I find the tutorial Sionna_Ray_Tracing_Introduction have the same problem, scene.frequency is defined before antenna array. Therefore I suggest changing this tutorial or making a modification if possible. |
You are right, this issue will be fixed in the next release of Sionna. |
Hello,I have encountered an issue where the results of ray tracing are inconsistent under the same conditions. When using Sionna RT in Jupyter Notebook, I calculated the phase differences between each antenna for 'rx'. I found that the results of two calculations were inconsistent, despite using the exact same code. The result is shown in the attached file. Could you please help me identify why the ray tracing results vary between these two instances? Thank you for your response.
RTtest.md
The text was updated successfully, but these errors were encountered: