Skip to content

Commit

Permalink
Added function get_SINR_dB
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbriggs committed Dec 21, 2022
1 parent 4e05b5c commit b2d9db0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
Binary file added dist/aimm_simulator-2.0.2-py3-none-any.whl
Binary file not shown.
Binary file added dist/aimm_simulator-2.0.2.tar.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
ue.attach_to_nearest_cell()
sim.add_logger(Logger(sim,logging_interval=10))
sim.run(until=100)
print(f'ue.get_SINR_dB={ue.get_SINR_dB()}')
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "AIMM_simulator"
version = "2.0.1"
version = "2.0.2"
authors = [
{ name="Keith Briggs", email="k.briggs73@btinternet.com" },
]
Expand All @@ -19,9 +19,9 @@ classifiers = [
"Operating System :: OS Independent",
]
dependencies = [
"numpy>=1.23.*",
"simpy>=4.0.*",
"matplotlib>=3.6.*",
"numpy>=1.23",
"simpy>=4.0",
"matplotlib>=3.6",
]

[project.urls]
Expand Down
21 changes: 14 additions & 7 deletions src/AIMM_simulator/AIMM_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# | | |
# UE UE UE UE UE UE ...

__version__='2.0.1'
__version__='2.0.2'
'''The AIMM simulator emulates a cellular radio system roughly following 5G concepts and channel models.'''

from os.path import basename
Expand Down Expand Up @@ -232,10 +232,11 @@ def set_MIMO_gain(s,MIMO_gain_dB):
def get_UE_throughput(s,ue_i): # FIXME do we want an array over subbands?
'''
Return the total current throughput in Mb/s of UE[i] in the simulation.
The value -np.inf indicates that there is no current report.
'''
reports=s.reports['throughput_Mbps']
if ue_i in reports: return reports[ue_i][1]
return -np.inf # [-np.inf]*s.n_subbands # special value to indicate no report
return -np.inf # special value to indicate no report

def get_UE_CQI(s,ue_i):
'''
Expand Down Expand Up @@ -359,6 +360,7 @@ def __init__(s,sim,xyz=None,reporting_interval=1.0,pathloss_model=None,h_UT=2.0,
s.verbosity=verbosity
s.noise_power_dBm=-140.0
s.cqi=None
s.sinr_dB=None
# Keith Briggs 2022-10-12 loops now started in Sim.__init__
#s.sim.env.process(s.run_subband_cqi_report())
#s.sim.env.process(s.loop()) # this does reports to all cells
Expand Down Expand Up @@ -472,6 +474,13 @@ def get_CQI(s):
'''
return s.cqi

def get_SINR_dB(s):
'''
Return the current SINR of this UE, as an array across all subbands.
The return value ``None`` indicates that there is no current report.
'''
return s.sinr_dB

def send_rsrp_reports(s,threshold=-120.0):
'''
Send RSRP reports in dBm to all cells for which it is over the threshold.
Expand Down Expand Up @@ -499,7 +508,7 @@ def send_subband_cqi_report(s):
For this UE, send an array of CQI reports, one for each subband; and a total throughput report, to the serving cell.
What is sent is a 2-tuple (current time, array of reports).
For RSRP reports, use the function ``send_rsrp_reports``.
Also save the CQI[1]s in s.cqi, and return the throughput value.
Also saves the CQI[1]s in s.cqi, and returns the throughput value.
'''
if s.serving_cell is None: return 0.0 # 2022-08-08 detached
interference=from_dB(s.noise_power_dBm)*np.ones(s.serving_cell.n_subbands)
Expand All @@ -517,15 +526,13 @@ def send_subband_cqi_report(s):
received_interference_power=antenna_gain_dB+cell.power_dBm-pl_dB
interference+=from_dB(received_interference_power)*cell.subband_mask
rsrp=from_dB(rsrp_dBm)
sinr_dB=to_dB(rsrp/interference) # scalar/array
s.cqi=cqi=SINR_to_CQI(sinr_dB)
s.sinr_dB=to_dB(rsrp/interference) # scalar/array
s.cqi=cqi=SINR_to_CQI(s.sinr_dB)
spectral_efficiency=np.array([CQI_to_64QAM_efficiency(cqi_i) for cqi_i in cqi])
#print(spectral_efficiency,file=stderr)
now=float(s.sim.env.now)
# per-UE throughput...
throughput_Mbps=s.serving_cell.bw_MHz*(spectral_efficiency@s.serving_cell.subband_mask)/s.serving_cell.n_subbands/len(s.serving_cell.attached)
s.serving_cell.reports['cqi'][s.i]=(now,cqi)
#print(f'UE={s.i} cqi report sent: {cqi}',file=stderr)
s.serving_cell.reports['throughput_Mbps'][s.i]=(now,throughput_Mbps,)
return throughput_Mbps

Expand Down

0 comments on commit b2d9db0

Please sign in to comment.