steven
About me
Latest Articles
GPU Acceleration for FiPy Simulations: CuPy and Numba Integration Guide
Reading Time: 11 minutesFiPy simulations can achieve 10x to 100x speedups by moving compute-intensive operations to the GPU using CuPy (drop-in NumPy replacement) or Numba (JIT compilation). CuPy excels at array operations and requires minimal code changes, while Numba accelerates Python loops and custom functions. However, GPU acceleration isn’t always beneficial—small problems, memory-bound operations, and complex data structures […]
Adaptive Mesh Refinement in FiPy: Dynamic Resolution for Complex Phenomena
Reading Time: 10 minutesFiPy does not have built-in adaptive mesh refinement (AMR). Current approaches involve external mesh generation with Gmsh (inefficient for dynamic problems), integration with dedicated AMR libraries like libmesh (architecturally challenging), or switching to alternative phase-field codes that support AMR natively (MOOSE, PRISMS-PF). AMR provides significant speedups (often 2–10×) for phase-field problems with localized interfaces, but […]
Electromagnetics Simulations with FiPy: Maxwell’s Equations Implementation Guide
Reading Time: 7 minutesTL;DR Maxwell’s equations describe how electric and magnetic fields evolve and interact. While FiPy was designed for diffusion-type problems, you can simulate electromagnetic waves by treating Maxwell’s equations as a coupled system of transient hyperbolic PDEs. The key is coupling Faraday’s and Ampère’s laws using FiPy’s TransientTerm and custom curl implementations. However, FiPy has limitations […]
HDF5 for Simulation Data: Parallel I/O and Long-Term Storage
Reading Time: 10 minutesHDF5 is the de facto standard for storing large-scale scientific simulation data. Its hierarchical structure, parallel I/O capabilities via MPI, and built-in compression make it ideal for high-performance computing environments. However, improper use—especially poor chunking choices and incorrect parallel access patterns—can lead to severe performance degradation or data corruption. This guide covers HDF5 architecture, parallel […]
Battery Electrochemistry Modeling with PDEs: From Single-Particle to Full Models
Reading Time: 8 minutesTL;DR Battery electrochemistry modeling using partial differential equations (PDEs) provides high-fidelity simulation of lithium-ion cell behavior. The Single Particle Model (SPM) offers computational efficiency for real-time applications, while the Doyle-Fuller-Newman (DFN) model captures full electrolyte dynamics for high-power scenarios. This guide covers the governing equations, implementation with FiPy, and validation techniques for both approaches. Introduction […]
Code Coupling with preCICE: Multi-Physics Simulations in Python
Reading Time: 9 minutesTL;DR Multi-physics simulations often require coupling multiple specialized solvers. preCICE is a mature, open-source coupling library that enables partitioned multi-physics simulations in Python. This tutorial shows how to couple FiPy with another solver using preCICE, covering installation, adapter implementation, configuration, and common pitfalls. You’ll learn when to use partitioned coupling, how to set up data […]