File Exchange

image thumbnail

3D Ray Tracing For Indoor Radio Propagation

version 20.1.0.0 (414 KB) by Salaheddin Hosseinzadeh
3D Ray Tracing To Estimate Signal Strength in Indoor Environment and Estimate Propagation Loss

44 Downloads

Updated 15 May 2019

View License

This is a 3D ray tracing algorithm for indoor radio propagation based on reflecting image method. This accounts for transmission, primary and secondary reflection of a wave(signal) through and off the walls(panels).
PLEASE USE "RayTracing3D_v02.m" TO RUN THE CODE.
Two examples are included to get you running. In the comments at the beginning of the file it's explained how it works and how to define the geometry or building. Make sure you have as few walls as you can to make the computation less cumbersome. There is no limit on the number of walls (or panels). You can even define windows if you want but have to change the current way the structure is defined (based on 2D model, explained in the code).

"RayTracing3D_v02.m" is only makes the variables and the parameters that needs to be passed to the "RayTracingEng_v02.m". You don't need to change the RayTracingEng_v02.m unless you want to change the algorithm.

You need all the other functions that are provided in the submission to run this. There are few additional tools in the folder "Additional Tools" that helps along further analysis of the generated signal strength map.

Feel free to contact if you've any questions.
All the best
Sal

Cite As

Salaheddin Hosseinzadeh (2019). 3D Ray Tracing For Indoor Radio Propagation (https://www.mathworks.com/matlabcentral/fileexchange/64695-3d-ray-tracing-for-indoor-radio-propagation), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (39)

Dear @khaled whi,

I have created a new .csv. Then I wrote in A1 0;0;0 and in A2 36;0;0. Doing this, the code run without any error.

Hope this help you.

@Salaheddin Hosseinzadeh, thanks for your code!

khaled whi

khaled whi

THANK YOU for your help

i am trying to run this code and i had the following error and i would like some help. i already did as you answer in your comment (Put/change the format of number in one cell)
when i run it with simpletest.csv

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

Error in CSV23D_V1 (line 26)
Y(i,1) = str2num(strtok(remain{i},';'));

Error in RayTracing3D_v20 (line 218)
[wallxyz1, wallxyz2, wallxyz3, wallxyz4,wallX,wallY,wallZ] = CSV23D_V1(demoMode,groundLevel,ceilingLevel,Tx.xyz);

thanks again
apreciate

@Salageddin Hosseinzadeh
Thank you for help

@Pavel Mezhevov
All the walls in your simulation are numbered from 1 to ... n (lets say n is the total number of the walls you have), all the ceilings are numbered as well (from n+1 to m).
the size of wall.relativePerm must be the same size as your total number of walls and ceilings/floor.
You need to manually set the permittivity of each wall. If you activate the demoMode (by setting it to 1, check the code to see how to do it) then you get all the walls and ceilings shown to you during the initialization. So you see whats the number of a particular wall. Once you figured what is your specific wall number and you have its permittivity you can set them manually one by one.
For example wall number 8 has permittivity of 4
wall.relativePerm (8) =4;

or say wall 1 has permittivity of 9
wall.relativePerm(1) = 9;

say your ceiling number 12 has permitttivity of 3
wall.relativePerm(12) = 3;

Do not remove this "wall.relativePerm = 6*ones(size(wall.xyz1,1)+size(ceillFloor.xyz1,1),1);" just add anything that you want to change after this line of code.
wall.relativePerm = 6*ones(size(wall.xyz1,1)+size(ceillFloor.xyz1,1),1);
wall.relativePerm (8) =4;
wall.relativePerm(1) = 9;
wall.relativePerm(12) = 3;

Anything that you don't manually set is going to be defaulted to 6.
Hope this helps.

Dear Salaheddin Hosseinzadeh,
Thank you for your answer, but I don’t understand how I can change this line of code
wall.relativePerm = 6*ones(size(wall.xyz1,1)+size(ceillFloor.xyz1,1),1);
Thanks a lot.

@Pavel Mezhevov
The energy of the wave that passes through or reflects depends on the dielectric constant (permittivity), please search for Fresnel equations, and the angle of the incident of the beam on the wall or ceiling.
You can set these parameters within the code depending on the material of walls (there are researches that provide these info one of which is the ITU, I think ITU Chapter 4).

@ sylvere pagna
I hope you're problem is solved by now.
Usually people don't define the new geometry int he format that it should be. Please have a look at the example CSV files. The coordinates MUST be separated by the same delimiter and all be in the 1 cell I believe.
If the example CSV files don't work either then you most likely don't have a compatible microsoft excel installed on your PC.

Dear Salaheddin Hosseinzadeh,
Could you explain how it is necessary to set the dielectric constant of a specific wall or ceiling? unfortunately for me it is not trivial from your description in the code.
Thanks a lot.

Hello to everyone,

i am trying to test the algorithm with the provided data but i am facing the following problem: Error using xlsread (line 260)
Unable to read XLS file /Users/dannylefeeling/Downloads/3D Ray Tracing/3D Ray Tracing/SimpleTest.csv. File is not in recognized
format.
can someone help?

Thank you.

shan bao

This code is really valuable to me,thank you!

zaza

jing zhou

Hi
Thank you for sharing information with us for a better understanding of Raytracing simulation, The problem that I have found after runnig your code on MATLAB2014a is and for solving This error Error in CSV23D_V1 (line 26)
Y(i,1) = str2num(strtok(remain{i},';'));

Error in RayTracing3D_v20 (line 218)
[wallxyz1, wallxyz2, wallxyz3, wallxyz4,wallX,wallY,wallZ] = CSV23D_V1(demoMode,groundLevel,ceilingLevel,Tx.xyz);

The CSV file format that you define is not how it should be. The x;y;z coordinates of the end points of the line should be in 1 excel cell (for instant the A1 should have 0;1;0. There is no spacing between the coordinates only ";"
Thanks a lot

Hello Ubaid

As the formula for the path loss, you can find it in the 3D ray tracing engine file. the exact name of the file is "RayTracingEng_V02.m".
And the formula looks like this

Rx.LosRssi(k) = Rx.LosRssi(k) + 10.^((Tx.power(i) - (FPSLRefLoss + 20 .* log10(4*pi*((RxTx.dist(k,1,i) >= refDistance) .* RxTx.dist(k,1,i) + (RxTx.dist(k,1,i) < refDistance)*refDistance) .* freq ./ lightVel) ...
- 10.*log10(prod(tempFresnelCoeff))) + (TxAntennaGainAE(round(losBeamAngle.Tx.AziIndex(k,i)),round(losBeamAngle.Tx.ZenIndex(k,i)))) + ...
(RxAntennaGainAE(round(losBeamAngle.Rx.AziIndex(k,i)),round(losBeamAngle.Rx.ZenIndex(k,i)))))/10) .* complex(cos(2*pi*freq*RxTx.dist(k,1,i)./lightVel + pi) , sin(2*pi*freq*RxTx.dist(k,1,i)./lightVel + pi));

This is the overall formula, if you follow the variables, you can see how each individual parameter is calculated in the code as well.
I have also included tons of references in one of my previous comments, you can have a look at those if you wish, thy would clarify the algorithm used to implement this.

Now answering your second question, using it for outdoors.
There are a few things to consider:

1- You need to have a 3D model of the city. At least the buildings in the city. This is not any 3D file, it needs to be in a specific format that I have defined here. So even if you manage to find a 3D model of the city or outdoor environment, you won't be able to use it in this implementation.
2- The 3D ray tracing of this kind is not really used for the outdoor environments to my knowledge due to it being computationally expensive and time taking.

I used the model a few times for indoor propagation modeling and checked it against practical measurements, one of the results is also published (I'll put the links at the end), it yielded respectable results compared to other indoor propagation models.
However, I do NOT recommend this for outdoor at all. You can instead take advantage of hybrid models for outdoors (I put a link to that as well)

I hope this explanation helps.
All the best,
Sal

Checked these links for the published results
https://ieeexplore.ieee.org/document/8104741
https://ieeexplore.ieee.org/document/8016211

Hybrid model
https://www.mdpi.com/2504-2289/1/1/7

Ubaid Ullah

Dear Salaheddin Hosseinzadeh,
Could you please share the propagation loss formula or model on which this code is based?
Can I use this could for outdoor macro path loss?

Dear Mr. Rashid

Were you able to solve the issue regarding .CSV file? I am facing a similar problem and would appreciate your response on this matter.

TIA

Regards

Komal

Hi Sir

I have gone through your code but I have difficulties in running it as I am working towards the same space of raytracing but more intending to optimise path loss in an indoor environment. The error code I am getting is as "Error in RayTracingEng_V02 (line 13)
alpha.x = (1 - mesh_.xNodeNum .* imageRSSIScale)./(boundary(1,1) - boundary(1,2));"

Please kindly assist. my email is milasobs@gmail.com.

Regards
Mila

Salaheddin Hosseinzadeh, look at the mail.

Hello Rashid

I'm sorry that you're facing difficulties running it.
You're not the first one though, and you're problem will be easily solved. I'll explain it here but if you couldn't figure it out feel free to drop me an email, my email address is on the submission and my profile.

Quick answer as I wrote to other people as well and solved their problem is that:

"I'm afraid the data that you defined is not the right format. Not one that is compatible with my code. Pay a bit more attention to how the points in the examples are defined and define your points like that."

The CSV file format that you define is not how it should be! if you open your CSV file with excel, its format should be similar to the comma separated values I've defined in the examples.
That is the x;y;z coordinates of the end points of the line you're defining should be in 1 excel cell (for instant the A1 should have 0;1;0. There is no spacing between the coordinates only ";"
If you define it in a different format then it doesn't work! Just look at the examples that I included, open them in excel and you'll understand.

Please if my explanation is wage or you managed to understand what I mean by the correct format, post it here and should hopefully help other people. I designed this myself so it's quite clear to me and perhaps I can't explain it for other to make them understand.

Thanks a lot,
Sal

Dear Mohammad Reza, did you solve your problem? The fact is that I faced a similar problem. And I do not know how to solve it.

APS502

apologies - that should read "intersect" not "interest"

Hi Salahaddin,
Thank you for the code. But where can I find the formula of propagation loss?

rashi

dear sir
with the best for you best regard for your efforts
i review your project and i found very useful , but i have a problem in running,as i run the RayTracingEng_v02.m after the plot of antenna radiation, it seems to need introduce a cv file for load of the other data, i confused to itroduce wich one of cv file,after a few moment i have this error :

Error in RayTracing3D_v20 (line 217)
[wallxyz1, wallxyz2, wallxyz3, wallxyz4,wallX,wallY,wallZ] =
CSV23D_V1(demoMode,groundLevel,ceilingLevel,Tx.xyz);
please let me know about it.
thanks a lot , more and more.
M.R.Pouryeganeh
pooryeganeh@gmail.com

rashi

Thanks Jiayi and Masoud for posting your questions. I have included some of the references that help toward understanding this code better.
Some are about the 3D ray tracing, and some are additional articles that also helped me.

All the best

References

[1] J. W. McKown and R. L. Hamilton, "Ray tracing as a design tool for radio networks," Network, IEEE, vol. 5, pp. 27-30, 1991.
[2] C.-F. Yang, B.-C. Wu and C.-J. Ko, "A ray-tracing method for modeling indoor wave propagation and penetration," Antennas and Propagation, IEEE Transactions on, vol. 46, pp. 907-919, 1998.
[3] F. Villanese, W. G. Scanlon, N. E. Evans and E. Gambi, "Hybrid image/ray-shooting UHF radio propagation predictor for populated indoor environments," Electronics Letters, vol. 35, pp. 1804-1805, 1999.
[4] R. A. Valenzuela, "A ray tracing approach to predicting indoor wireless transmission," in Vehicular Technology Conference, 1993., 43rd IEEE, 1993.
[5] S. Y. Seidel and T. S. Rappaport, "A ray tracing technique to predict path loss and delay spread inside buildings," in Global Telecommunications Conference, 1992. Conference Record., GLOBECOM'92. Communication for Global Users., IEEE, 1992.
[6] B. D. Seckler and J. B. Keller, "Geometrical theory of diffraction in inhomogeneous media," The Journal of the Acoustical Society of America, vol. 31, pp. 192-205, 1959.
[7] S.-W. Lee and G. Deschamps, "A uniform asymptotic theory of electromagnetic diffraction by a curved wedge," IEEE transactions on antennas and propagation, vol. 24, pp. 25-34, 1976.
[8] M. C. Lawton, R. L. Davies and J. P. McGeehan, "A ray launching method for the prediction of indoor radio channel characteristics," in Personal, Indoor and Mobile Radio Communications., IEEE International Symposium on, 1991.
[9] R. G. Kouyoumjian and P. H. Pathak, "A uniform geometrical theory of diffraction for an edge in a perfectly conducting surface," Proceedings of the IEEE, vol. 62, pp. 1448-1461, 1974.
[10] J. B. Keller, "Geometrical theory of diffraction," JOSA, vol. 52, pp. 116-130, 1962.
[11] T. Holt, K. Pahlavan and J.-F. Lee, "A graphical indoor radio channel simulator using 2D ray tracing," in Personal, Indoor and Mobile Radio Communications, 1992. Proceedings, PIMRC'92., Third IEEE International Symposium on, 1992.
[12] H. Hashemi, "Impulse response modeling of indoor radio propagation channels," Selected Areas in Communications, IEEE Journal on, vol. 11, pp. 967-978, 1993.
[13] S. Hosseinzadeh, H. Larijani, K. Curtis, A. Wixted and A. Amini, "Empirical propagation performance evaluation of LoRa for indoor environment," in Industrial Informatics (INDIN), 2017 IEEE 15th International Conference on, 2017.
[14] S. Hosseinzadeh, H. Larijani and K. Curtis, "An enhanced modified multi wall propagation model," in Global Internet of Things Summit (GIoTS), 2017, 2017.

Jiayi Lin

Hi Salahaddin,
Thank you for your code, could please share with us some related articles about ray tracing?

Hello Dear Salahaddin
I have some other questions
First would you mind proposing some proper references to help us understand ray tracing algorithm for propagation better?
2nd question is that how can I consider just one point as a receiver point? not a plane as a receiver?
Thanks a lot

Thanks a lot Pang
You are quite right. l believe it is a typo however. You're the first bringing this to my attention. Thanks a lot for this.

The "epsm" needs to be changed to "eps".

I may fix and upload the code again. However this is quite minor and I'm hopping to find more time to improve the code by building the optimization into it and make it run much faster by use of parallel computing.

Haitao Pang

Hi, thank you very much for your work and sharing.

I am using matlab R2017b, and got the following error:

Undefined function or variable 'epsm'.

Error in RayTracingEng_V02 (line 465)
if (reflectPointj2Rxd < 1 && reflectPointj2Rxd > 0 && abs(reflectPointj2Rxd - 1) > eps
&& not(reflectPointj2Rxd < epsm))

This has to do with the obsolete function of epsm after R2014. (https://jp.mathworks.com/help/map/ref/epsm.html)
It works perfectly after I changed the epsm for numbers such as 1.0E-6.

Le Vanhuy

Thanks Salaheddin,
Every success in your job.

Mohanned,
Thanks for your feedback and question.
You can use this for MMWave frequency, there is no limitation with the algorithm. I'm not 100% sure of what's your project or aim, however, there are few things you may want to consider.
1- To get a visible pattern as how the waves interact you need to put the mesh size to at least half the wavelength, or less. This is just simple Nyquist theory consideration.
This is possible, but I made this code for relatively large environments, if you want to mesh a whole building with less than a few mm, you will have a lot of meshes and computation may last for a very very long time, specially that my code is not optimized for such purposes.
Although there is a great solution for this. You don't need to mesh the whole structure, you can just put probes where you are interested to see the signal strength. I did that for my optimization. However, ray tracing provides the “small scale” fading which varies with order of wavelength, whereas, small scale fading is not predictable for ranges beyond half-wavelengths (see the refs)
As I only took measurements as specific locations and not the whole structure, and I just wanted to see how it works about the same areas.
2- I'm not sure what wall parameters you want to consider in your study, I simply wanted to attenuation caused by the structure, therefore instead of using the thickness of the walls I used what's called effective permittivity, and since the permeability does not make a huge difference I ignored that as I was mainly working in 900 MHz. I'm not sure if this is an important parameter in mmWaves or not.
All the best

Ref#1 - Teal, P. D., & Kennedy, R. A. (2004). Bounds on extrapolation of field knowledge for long-range prediction of mobile signals. IEEE transactions on wireless communications, 3(2), 672-676.
Ref#2- Qiu, L., Jiang, D., & Hanlen, L. (2005, February). Neural network prediction of radio propagation. In communications Theory Workshop, 2005. Proceedings. 6th Australian (pp. 272-277). IEEE.

Hello Salaheddin Hosseinzadeh,

First of all I would like to congratulate you on this marvelous code. I wanted inquire if it's possible to use the tracer at MMWave frequencies.

Thank you.

Thuan Huu

Updates

20.1.0.0

Fresnel Coefficient function is changed and simplified, Further details and explanations are added for the formulation

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: Image overlay, Bresenham optimized for Matlab