Inspiration

The global metal recycling industry loses billions of dollars annually due to compositional uncertainty and "downcycling." When complex scrap like e-waste or end-of-life vehicles is melted, without a precise understanding of the thermodynamics, valuable metals are lost to slag or vaporized into thin air. Furthermore, the leftover slag is often sent to landfills because its exact composition is unknown. I wanted to build a tool that goes beyond simple sorting and actually predicts the thermodynamic outcomes of complex scrap to enable true industrial symbiosis.

What it does

The Circular Metals Flow Engine is a decision-support tool that simulates the furnace environment. Users input a scrap composition and adjust the furnace temperature. The engine calculates the exact mass balance across three phases (metal, slag, gas).

It provides three key outputs:

  1. Recovered Metal Yield: Accurately predicting how much metal is recovered.

  2. Environmental & Economic Impact: Instantly calculates kWh saved, CO₂ avoided, and USD saved compared to virgin mining.

  3. Leftover Valorization: Analyzes the chemical composition of the leftover slag and recommends industrial uses (e.g., if rich in Silicon and Oxygen, it recommends it as a Supplementary Cementitious Material).

How I built it

I used a modular, multi-language architecture:

  • The C Kernel (c_kernel/): Performs the heavy thermodynamic mass-balance and temperature-dependent phase partitioning. Written in C for high-performance numerical loops.

  • The Bindings (python/thermo_bindings.py): Uses ctypes to bridge Python and C memory structures, passing data with zero-copy overhead.

  • The Analysis Engine (python/scrap_engine.py): Calculates the economic and environmental impact using industry-standard energy baselines.

The UI (app/): A Streamlit dashboard for real-time interactive simulation, with Plotly for visualization. I also implemented a "graceful degradation" system: local machines use the C DLL, while the cloud uses a pure Python fallback.

Challenges I ran into

Getting the ABI (Application Binary Interface) right between C and Python across Windows (x64 DLLs) and Linux (Cloud). I also had to architect a dynamic fallback system so that the app would still function perfectly on Streamlit Community Cloud, which lacks a C compiler, without sacrificing the C-kernel demonstration on GitHub.

Accomplishments that I am proud of

The 100% accurate mass balance and the seamless C-to-Python bridge. The temperature-dependent vaporization model accurately predicts how volatile elements (like Zinc) are lost to the gas phase at high temperatures, which is a critical real-world industrial challenge.

What I have learned

How to architect robust, multi-language systems and deploy them to the cloud. I also deepened my understanding of the thermodynamics of metal recycling and the economic realities of industrial symbiosis.

What's next for Circular Metals Flow Engine

Implementing a full Gibbs Free Energy minimization model (CALPHAD) in the C kernel to replace the current empirical partition matrix, and integrating real-time market pricing APIs for scrap metals to make the economic calculations dynamic.

Built With

  • c
  • circular-economy
  • ctypes
  • materials-science
  • plotly
  • python
  • streamlit
  • thermodynamics
Share this project:

Updates

Submission history