I built an open-source Deep Reinforcement Learning (DRL) environment to explore topology optimization for elastocaloric cooling (solid-state HVAC).
The physical problem: The HVAC industry is trying to replace toxic HFC refrigerants with elastocaloric Shape Memory Alloys like Nitinol. You cool a room by cyclically compressing a porous metal lattice. The paradox is that you need high porosity for air to flow through the metal, but holes create stress concentrators. If the metal is too thin, it snaps after a few thousand cycles from mechanical fatigue. Standard density-based topology optimization (like SIMP) usually outputs jagged, unprintable "grayscale" meshes.
What I built: I wanted to bypass SIMP and enforce manufacturing reality. I wrote an OpenAI Gymnasium wrapper that bridges a PyTorch RL agent with a native CAD-to-Physics pipeline: 1. The PyTorch agent outputs continuous geometric parameters for BCC/Gyroid lattices. 2. The environment checks the resulting wall thickness. If it drops below 0.2mm (the minimum feature size for standard LPBF metal 3D printers), the agent gets a terminal penalty and the episode ends. 3. If printable, OpenCASCADE and Gmsh generate a watertight tetrahedral mesh. 4. FEniCSx crushes it in a virtual hydraulic press (via MPI) to find peak stress. 5. The agent learns to maximize porosity while fortifying high-stress zones.
The whole stack runs locally on Apple Silicon using Metal Performance Shaders (MPS).
Current Limitations (The Next Phase): Right now, the FEniCSx solver is using a linear elastic approximation to save compute time during the DRL training loop. Real Nitinol undergoes a highly non-linear austenitic-martensitic phase transformation. The next major step is integrating a hyperelastic/phase-field model into the FEniCSx step without making the compute cost per episode astronomical.
I’m dropping this here because I know there are people on HN working at the intersection of AI, computational mechanics, and thermal management.
I would love any brutal feedback on the architecture, the FEniCSx integration, or ideas on speeding up non-linear physics solvers for RL loops.
Repo:https://github.com/rao-atreya-01/elastocaloric-ai-optimizati...