This is an automated archive made by the Lemmit Bot.

The original was posted on /r/rust by /u/Smil3More on 2025-02-11 11:48:43+00:00.


Hey everyone,

I am planning a Master’s thesis in which I need to modernize and parallelize an existing scientific C program for electromagnetic wave propagation calculation/simulation. The goal is to migrate the program to Rust to improve long-term maintainability, safety, and performance.

It’s a Linux command-line program that takes a TXT input file with room and material specifications, calculates the electromagnetic spread (heatmap), and outputs a TXT file, which is later converted into a graphical solution in another program.

My focus is solely on the calculation part.

Brief Overview of the Program:

  • Simulates electromagnetic wave propagation using ray tracing. (only mathematical, no graphical conversion)
  • BSP tree (Binary Space Partitioning) as the core data structure for geometry management.
  • C-based, currently single-threaded, running on a single CPU core. (takes a loooong time to calculate)
  • Future goals: CPU parallelization & potential GPU extension (OpenCL, Vulkan Compute).

My Questions & Challenges:

  1. BSP Tree in Rust – Feasible or alternative approaches?
    • Is Rust well-suited for BSP trees, or are there better parallel alternatives?
    • Are there existing Rust crates that could be useful for ray tracing & BSP trees?
  2. Rust beginner with decent programming experience – Is migration realistic?
    • I have solid programming experience in C++, Python, Dart but very little Rust knowledge.
    • Is Rust a good choice for complex scientific simulations, or is the learning curve too steep?
  3. Full migration vs. partial migration & C/Rust interoperability
    • Would it make more sense to migrate only the core algorithm to Rust and keep the rest in C?
    • Has anyone worked with C/Rust interop via FFI or bindgen for a mixed-language approach?
    • How practical is a step-by-step migration, running Rust and C in parallel?

I would appreciate any best practices, experiences, and resources on using Rust for scientific applications! 🚀