Satellite communications toolbox with parallel computing

6 次查看(过去 30 天)
I would like to run a script containing functions of Satellite communications toolbox with parallel computing in order to save time,
but something is not right and have no clue what.
if I try to run the following commands on an array of satellites using a parfor loop, the final outcome is that no object in the array is affected by them, as in, all values remain the same.
but if I run the commands in a for loop then everything changes as it should.
startTime = datetime(2021,12,10,18,27,57); % 10 December 2021, 6:27:57 PM UTC
stopTime = startTime + hours(3); % 10 December 2021, 9:27:57 PM UTC
sampleTime = 60; % Seconds
sc = satelliteScenario(startTime,stopTime,sampleTime,"AutoSimulate",false)
sat = satellite(sc,"largeConstellation.tle");
numSatellites = numel(sat);
gainToNoiseTemperatureRatio1 = 5; % dB/K
systemLoss1 = 3;
TxMountingLocation = [0;0;1];
RxMountingLocation = [0;0;1];
frequency1 = 27e9; % Hz
%% power between 19 and 26 dBW
power1 = 19+(26-19)*rand(numSatellites,1); % dBW
%% bitRate between 16 and 27 Mbps
bitRate1 = 16 + (27-16)*rand(numSatellites,1); % Mbps
parfor SatNum = 1:15
gimbalrxSat = gimbal(sat(SatNum),"MountingLocation",[0;-1;2]);
gimbaltxSat = gimbal(sat(SatNum),"MountingLocation",[0;1;2]);
rxSat1 = receiver(gimbalrxSat,"Name",'Satellite Receiver',"GainToNoiseTemperatureRatio" ...
,gainToNoiseTemperatureRatio1,"SystemLoss",systemLoss1,"MountingLocation",RxMountingLocation);
txSat1 = transmitter(gimbaltxSat,"Name",'Satellite Transmitter',"Frequency",frequency1, ...
"power",power1(SatNum),"BitRate",bitRate1(SatNum),"SystemLoss",systemLoss1,"MountingLocation",TxMountingLocation);
gaussianAntenna(rxSat1, ...
"DishDiameter",0.5); % meters
gaussianAntenna(txSat1, ...
"DishDiameter",0.5); % meters
display(SatNum)
end
the array contains 1,000 satellite objects and the aim is to add two gimbals to each satellite object, one for a transmitter and the other for a receiver, and afterwards to add the recveiver object and transmitter object to their appropriate gimbals.
  • I have a quad intel i7 processor.
  • the loop at the snippet runs until the 15th iteration as part of my trial and error with the commands, but it needs to run on the entire satellite array.
it takes a very long time to do this with a regular for loop.
will appreciate any suggestions,
thank you

回答(1 个)

Abhishek
Abhishek 2023-4-14
Hello Etai,
I understand your objective to expedite certain operations on satellitescenario objects. However, it appears that sat objects are not being updated in the parfor loop.
Note that the sat variable is not shared between the different workers in parallel pool and is distinct for each worker. Therefore, any changes made to sat in one worker are not reflected in the other workers. As a result, the changes made to the variable in the parfor loop are not visible outside the loop.
To mitigate this issue, it is recommended to use a temporary variable. For instance, you can declare mySatArr as an empty cell array and use this subset for all subsequent operations. Please refer to the code snippet below:
startTime = datetime(2021,12,10,18,27,57); % 10 December 2021, 6:27:57 PM UTC
stopTime = startTime + hours(3); % 10 December 2021, 9:27:57 PM UTC
sampleTime = 60; % Seconds
sc = satelliteScenario(startTime,stopTime,sampleTime,"AutoSimulate",false);
sat = satellite(sc,"largeConstellation.tle");
numSatellites = numel(sat);
gainToNoiseTemperatureRatio1 = 5; % dB/K
systemLoss1 = 3;
TxMountingLocation = [0;0;1];
RxMountingLocation = [0;0;1];
frequency1 = 27e9; % Hz
%% power between 19 and 26 dBW
power1 = 19+(26-19)*rand(numSatellites,1); % dBW
%% bitRate between 16 and 27 Mbps
bitRate1 = 16 + (27-16)*rand(numSatellites,1); % Mbps
mySatArr = cell(1,1000);
parfor SatNum = 1:15
mySatArr{SatNum} = sat(SatNum);
gimbalrxSat = gimbal(mySatArr{SatNum},"MountingLocation",[0;-1;2]);
gimbaltxSat = gimbal(mySatArr{SatNum},"MountingLocation",[0;1;2]);
rxSat1 = receiver(gimbalrxSat,"Name",'Satellite Receiver',"GainToNoiseTemperatureRatio" ...
,gainToNoiseTemperatureRatio1,"SystemLoss",systemLoss1,"MountingLocation",RxMountingLocation);
txSat1 = transmitter(gimbaltxSat,"Name",'Satellite Transmitter',"Frequency",frequency1, ...
"power",power1(SatNum),"BitRate",bitRate1(SatNum),"SystemLoss",systemLoss1,"MountingLocation",TxMountingLocation);
gaussianAntenna(rxSat1, "DishDiameter",0.5); % meters
gaussianAntenna(txSat1, "DishDiameter",0.5); % meters
end
%First gimbal of 6th satellite
disp(mySatArr{6}.Gimbals(1))
For more information, you can refer to the following documentation pages:
  1 个评论
etai nardi
etai nardi 2023-4-21
编辑:etai nardi 2023-5-5
@Abhishek thank you it works great!
only now I have a new problem.
before the parfor loop I have defined ground stations as part of the scenario besides the satellite array:
gsSource = groundStation(sc,42.3001,-71.3504, ... % Latitude and longitude in degrees
"Name","Source Ground Station");
gsTarget = groundStation(sc,17.4351,78.3824, ... % Latitude and longitude in degrees
"Name","Target Ground Station");
gimbalGsSource = gimbal(gsSource, ...
"MountingAngles",[0;180;0], ... % degrees
"MountingLocation",[0;0;-5]); % meters
gimbalGsTarget = gimbal(gsTarget, ...
"MountingAngles",[0;180;0], ... % degrees
"MountingLocation",[0;0;-5]); % meters
GsSourceTx = transmitter(gimbalGsSource, ...
"Name","Ground Station 1 Transmitter", ...
"MountingLocation",[0;0;1], ... % meters
"Frequency",30e9, ... % Hz
"Power",30); % decibel watts
gaussianAntenna(GsSourceTx, ...
"DishDiameter",2); % meters
GsTargetRx = receiver(gimbalGsTarget, ...
"Name","Ground Station 2 Receiver", ...
"MountingLocation",[0;0;1], ... % meters
"GainToNoiseTemperatureRatio",3, ... % decibels/Kelvin
"RequiredEbNo",1); % decibels
gaussianAntenna(GsTargetRx, ...
"DishDiameter",2); % meters
now after the parfor loop I am trying to run a link between the ground stations through some of the satllites with the line:
lnk = link(GsSourceTx,rxSat1,txSat1,GsTargetRx)
but I get an error stating that the ground stations and the satellites belong to two different scenarios (SC), which means that by using the parfor loop along with the temporary variable mySatArr, a new satellite scenario has been created (which I think is not intended).
how can I do all the necessary actions on the array all the while staying in the same satellite scenario and not break into a new one?
how can I overcome this?
thank you again

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Scenario Generation and Visualization 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by