RayTraceHeatTransfer.jl: A repository for 2D Monte Carlo ray tracing and heat transfer

Hi Julia people,

I just wanted to share that I made this new repository for radiative heat transfer which is essentially a collection of functions I developed during my 9th semester at university.

This repository can be used for radiation heat transfer calculations in an enclosure including a participating medium. It contains a number of functions which collectively enables the user to ray trace a user defined geometry. The result of the ray tracing are four ‘exchange factor’ matrices which together describe how the enclosure is radiatively connected. Using the exchange factor matrices it is possible to quickly perform a heat transfer calculation on the entire enclosure, which would otherwise be computationally expensive to ray trace.


  • Define a custom geometry
  • Ray trace the geometry
  • Option to view the ray tracing as it takes place (warning: computationally demanding, use few rays per emitter)
  • ‘Save’ ray tracing result as Exchange Factor matrices (also as CSV-files)
  • Quickly calculate heat transfer in the geometry using the Exchange Factors
  • Avoid ray tracing the same geometry multiple times

This repository is limited to a uniformly distributed gray participating medium (but I might add the option of generating weighted gray gasses matrices to approximate a nongray gas). It is only possible to use diffuse surface emission/reflection (but the emissivity can be set between 0 and 1). Furthermore the repository is also limited to 2D enclosures (or more accurately: specular/mirrorlike front and back, since the sampled distributions are 3D). Be aware that the Exchange Factor matrices can become very large for highly discretized domains (to the point where memory becomes a limitation). The scattering is limited to be isotropic.

Work-in-progress: Couple this radiation solver to a computational fluid dynamics solver, potentially including combustion.

I did not manage to get this registered as a package even though I attempted to do so (I think I might have done something wrong in the process).


I managed to register my package last weekend.

Today I published a new version featuring a simplified way of defining the geometry, faster execution speed and an improved basic algorithm. The readme has been updated to match the new release (use the link above).

I see that not many people were interested in this subject.
This made me question whether I had published a ‘personal package’.
However, the following quote from the paper “The Past and Future of the
Monte Carlo Method in Thermal Radiation Transfer” by Howell and Daun (2021) reassured me:

“Finally, most problems solved using the Monte Carlo method
have been addressed using “one-off” in-house research codes constructed
for a particular problem. To the best of our knowledge, a
general “open-source” code incorporating all the attributes of
Monte Carlo (like OPENFOAM for CFD problems [186]) is not yet
available. The development of a verified and validated general
code would be a valuable contribution, particularly if it exploited
recent advancements in GPUs and parallel processing.”

My code is open-source, it is validated against an analytical result, it runs in parallel, it works on several different geometries (general) and the basic algorithm I developed is suitable for 3D ray tracing, which I plan to implement in a future release. :slight_smile:

I am aware that I might not yet be an accomplished Julia programmer, but I take this as an opportunity for growth. I have already learned a lot, and I am very motivated for improving my package.


RayTraceHeatTransfer.jl is now version 0.2.1, refer to the github link above.
I used Documenter.jl to create docs (thanks for that package :slight_smile:) which can be found here: Home · Documentation

Geometry specification has been made modular and flexible which was made possible by improving my meshing algorithm.
My repository now also include a translated utility analytical function for calculating 3D view factors between arbitrary polygons (by permission from original Matlab authors).
Lastly, the matrix heat transfer problem is now solved directly as opposed to iteratively, due to an improved solution method I developed.

Future work:
Improving the ray tracing speed, by looking a allocations and profiling.
Making my code 3D, my fundamental algorithm has no dimensional limitations, so this should be relatively straight forward.
Looking into possibilities for porting the code to GPU. :slight_smile:

1 Like