steven
About me
Latest Articles
In-Situ Visualization: Integrating Visualization During Computation
Reading Time: 10 minutesTL;DR In-situ visualization processes and analyzes simulation data while the simulation runs, directly in memory, instead of writing raw results to disk for later post-processing. This approach is essential for exascale computing where I/O bandwidth cannot keep up with data generation. By integrating visualization during computation, you can: Avoid I/O bottlenecks that cripple traditional workflows […]
Documentation Best Practices for Scientific Python Packages
Reading Time: 8 minutesExcellent documentation transforms scientific Python packages from unusable code to reproducible research assets. Adopt a Documentation-as-Code approach: store docs alongside code, use Sphinx with NumPy or Google-style docstrings, automate builds with Read the Docs, and integrate documentation updates into every code review. Include a clear README, maintain a CHANGELOG, and test examples with doctest. Treat […]
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 […]
Machine Learning Surrogates for Scientific Simulations: A Practical Guide
Reading Time: 8 minutesMachine learning (ML) surrogates are fast, data-driven approximations of expensive scientific simulations. They enable near real-time predictions, massive design space exploration, and uncertainty quantification that would be impossible with direct simulation alone. Use surrogates when you need iterative optimization or thousands of evaluations; stick with direct simulation for final validation or when high accuracy is […]
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 minutesBattery 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 Lithium-ion […]
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 […]