Skip to content

Capacitor_FEM

Latest

Choose a tag to compare

@ratwolfzero ratwolfzero released this 21 Aug 06:45
· 2 commits to main since this release

capacitor-fem

A self-contained 2D finite-element electrostatics solver for real capacitor geometries — parallel plates, coaxial cables, and arbitrary shapes built from simple primitives — rather than closed-form formulas that exist only for a few idealized cases.

Pure NumPy / SciPy / Matplotlib. No mesh-generation library, no compiled extensions, no native dependencies. One file, runs anywhere:

python3 capacitor_fem_universal.py
capacitor_fem_universal.py is the single, platform-independent implementation. All future work continues there.

This document covers the physics, mathematics, numerical method, software architecture, and usage of the code. It assumes familiarity with vector calculus, linear algebra, and Python, but not necessarily with finite elements; the derivation starts from Maxwell's equations and builds up from there.

Current status

Structured triangular mesh with optional graded Cartesian refinement for the parallel-plate example.
Independent bottom/top plate widths; optional rounded (filleted) plate edges via edge_radius / RoundedRectangle.
Constructor-time and post-snap_to_grid validation of geometry and material parameters.
General two-run comparison tool (compare_parallel_plate_runs) that plots any two ParallelPlateConfigs on a shared |E| colour scale.
Runs unchanged on desktop, Jupyter / Carnets (static plots), and Pydroid 3 on Android.
Core FEM numerics remain a direct sparse solve; safeguards added for under-determined systems and degenerate triangles.

Known limitations (summary)

Structured (non-conforming) mesh: curved and non-axis-aligned boundaries are staircased (see §10.1–10.3).
Direct sparse LU solve scales poorly in memory and time at very fine h (see §4.6).
Peak |E| near any plate edge (sharp or rounded) is not mesh-converged at the shipped resolutions; only bulk fields and integrated quantities such as C are trustworthy (see §10.5).
Domain-size truncation (domain_margin) is a second, independent convergence axis (see §10.6).
Intended use: practical engineering approximation for education, basic design comparison, and material selection — not a high-accuracy tool for geometries dominated by curved boundaries or sharp singularities.

Recent changes

Graded Cartesian mesh support and independent plate widths.
Robust validation of geometry/material fields (including post-snap checks).
Optional rounded plate edges (edge_radius, RoundedRectangle) with bit-for-bit compatibility at edge_radius=0.
Shared-scale comparison tool (compare_parallel_plate_runs).
Android / Pydroid save-only plotting path and general robustness improvements.
Conservative handling of under-determined solves and degenerate-triangle warnings.