Is there a way to stop raytracing with parallel Toolbox from ignoring Buildings
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Marcel
am 23 Aug. 2024
Kommentiert: Madheswaran
am 9 Sep. 2024
Background:
I'm searching for a way to speed up raytracing to multiple receivers (about 500-2000) so I tried to run it with the parallel Toolbox.
Bug/Problem:
The result is what you see in the Image below, there are no rays to the first site (that is worked on by the first core).
But for every site is following (here site 2 in the middle) matlab keeps ignoring the buildings and the terrain (if there is one).
I'm Aware that this happens because the site viewer with the buildings is only loaded on the first instance and the other
instances of matlab are calculation without any site information.
Question:
Is there any way to avoid this bug or to speed up the raytrcaing process?
Thank you in advance for your help
Marcel
Example:
clear
clc
close all
%Model constants
f=500e6;%in Hz
%% Load Map
%for the map I chose a Part of Munich
%(48.139105,48.135141,11.571326,11.578850) downloaded from https://www.openstreetmap.org/export#map=17/48.137203/11.576350
viewer = siteviewer("Buildings","map.osm","Basemap","topographic");
%% Creating TX sites
site1 = txsite("Name","TX_1", ...
"Latitude",48.139, ...
"Longitude", 11.5715, ...
"AntennaHeight",1, ... %in m
"TransmitterPower", 5, ... %in W
"TransmitterFrequency",f);
site2 = txsite("Name","TX_2", ...
"Latitude",48.138, ...
"Longitude", 11.5715, ...
"AntennaHeight",1, ... %in m
"TransmitterPower", 5, ... %in W
"TransmitterFrequency",f);
show(site1);
show(site2);
tx=[site1 site2]
%% Creatin RX sites
rx = cell(1,2);
rx{1,1} = rxsite("Name","rx1", ...
"Latitude",48.1352,...
"Longitude",11.578, ...
"AntennaHeight",1.5, ...
"Antenna",'isotropic', ...
'ReceiverSensitivity',-103);
rx{1,2} = rxsite("Name","rx2", ...
"Latitude",48.137,...
"Longitude",11.575, ...
"AntennaHeight",1.5, ...
"Antenna",'isotropic', ...
'ReceiverSensitivity',-103);
show(rx{1,1})
show(rx{1,2})
% propagation model
rtpm = propagationModel("raytracing", ...
"Method","sbr", ...
"MaxNumReflections",2, ...
"BuildingsMaterial","concrete", ...
"TerrainMaterial","vegetation");
%% raytracing
size(rx,2)
%%
rays= cell(size(tx,2),size(rx,2));
lenght= size(tx,2);
parfor i=1:size(rx,2);
ray = raytrace(tx,rx{1,i},rtpm);
for j=1:lenght
rays{j,i} = ray{j,1};
end
end
%% plot existing rays
disp("plotting rays")
for i=1:size(rays,1)
for j=1:size(rays,2)
if (~isempty(rays{i,j}))
plot(rays{i,j});
end
end
end
0 Kommentare
Akzeptierte Antwort
Madheswaran
am 28 Aug. 2024
Hello Marcel,
As you mentioned the problem is with the parallel workers not being able to access the building information from the ‘siteviewer’. To work around this issue, you could try to create a ‘siteviewer’ inside each iteration of the ‘parfor’ loop using ‘Hidden’ parameter, so that each worker has its own ‘siteviewer’ object. The following answer discusses the use of ‘hidden’ parameter inside the ‘siteviewer’ function: https://mathworks.com/matlabcentral/answers/2118951
You can modify your code as follows:
f = 500e6;
tx(1) = txsite( %...existing code
tx(2) = txsite( %...existing code
rx(1) = rxsite( %...existing code
rx(2) = rxsite( %...existing code
rtpm = propagationModel( %...existing code
rx_size = 2;
tx_size = 2;
rays = cell(tx_size, rx_size);
parfor i = 1:rx_size
siteviewer("Buildings","map.osm","Basemap","topographic", "Hidden", true);
ray = raytrace(tx, rx(i));
for j=1:tx_size
rays{j,i} = ray{j,1};
end
end
The above method would not offer any graphic visuals but you can notice that ‘rays’ is calculated as expected.
Hope this helps!
2 Kommentare
Madheswaran
am 9 Sep. 2024
@Marcel, Each iteration of the `parfor` loop runs in differnt processes with its own memory space and `siteviewer` is not shared across those parallel processes. So, leaving the `siteviewer` open might not help since each parallel process requires its own `siteviewer` in the memory concurrently.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Propagation and Channel Models finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!