--- id: femm-workflow title: "FEMM Electrostatic Workflow for Spark Capacitance Extraction" status: established source_sections: "spark-physics.txt: Part 7.2 (lines 458-477), Part 8.2 (lines 559-572), Part 6 (lines 389-438)" related_topics: [lumped-model, distributed-model, circuit-topology, capacitive-divider, field-thresholds, equations-and-bounds, open-questions] key_equations: - "C_mut = |C_12| from Maxwell matrix" - "C_sh = C_22 - |C_12|" - "Partial capacitance transformation" - "E_tip from FEMM field solution" - "C_sh validation: 2 pF/foot rule" key_terms: - "FEMM" - "Finite Element Method" - "Maxwell capacitance matrix" - "partial capacitance" - "electrostatic simulation" - "self-capacitance" - "mutual capacitance" - "mesh refinement" - "axisymmetric" - "Dirichlet boundary" images: - femm-geometry-setup-lumped.png - femm-geometry-setup-distributed.png - field-lines-capacitances.png - femm-field-plot-example.png - electric-field-enhancement.png - maxwell-matrix-extraction.png - partial-capacitance-transformation.png - capacitance-matrix-heatmap.png examples: - femm-lumped-extraction.md open_questions: - "How does mesh quality near the spark tip affect E_tip computation accuracy, and what is the optimal element size at the tip?" - "Can FEMM axisymmetric simulations capture non-vertical spark geometries, or is 3D FEA required for curved/angled sparks?" - "What is the systematic error of modeling the spark as a perfect cylinder versus a tapered or irregular channel?" - "How should multiple breakout points be handled in a single FEMM simulation?" --- # FEMM Electrostatic Workflow for Spark Capacitance Extraction FEMM (Finite Element Method Magnetics) is an open-source finite element analysis program that, despite its name, handles electrostatic problems with high accuracy. It is the primary tool for extracting the capacitance values that populate the [[lumped-model]] and [[distributed-model]]. This document covers the complete FEMM workflow: geometry setup, meshing, solution, matrix extraction, sign convention handling, field computation, and validation. FEMM also provides the electric field at the spark tip, which is needed for growth prediction in the [[field-thresholds]] and [[energy-and-growth]] analyses. ## 1. FEMM Fundamentals ### 1.1 What FEMM Computes For electrostatic problems, FEMM solves Laplace's equation (nabla squared V = 0) in air with boundary conditions defined by conductor potentials and far-field grounding. From the solution, FEMM computes: - **Potential field V(r, z)** everywhere in the domain - **Electric field E = -grad(V)** at any point - **Charge on each conductor** Q_i = integral of epsilon_0 * E_n dA over the conductor surface - **Capacitance matrix** C[i,j] relating charges to voltages: Q_i = sum_j C[i,j] * V_j ### 1.2 Problem Type and Symmetry **Problem type:** Electrostatic (DC). Although Tesla coils operate at 50-400 kHz, the wavelength (750-6000 m) is vastly larger than the spark geometry (1-5 m), so the quasi-static approximation is excellent. Capacitance values extracted at DC are accurate at operating frequency. **Symmetry:** Use axisymmetric (r-z) geometry whenever possible. A vertical spark emerging from a centered toroidal topload has cylindrical symmetry, reducing the 3D problem to 2D. This reduces computation time by orders of magnitude and improves accuracy for a given mesh density. **When 3D is needed:** Horizontal sparks, sparks from off-center breakout points, or sparks near asymmetric grounded objects cannot exploit axisymmetry and require full 3D FEA (not available in FEMM; use other tools like Elmer or COMSOL). ### 1.3 Coordinate System In FEMM's axisymmetric mode: - **r-axis:** Radial distance from the axis of symmetry (horizontal) - **z-axis:** Vertical position (typically z = 0 at ground plane) - All geometry is drawn in the r >= 0 half-plane - FEMM automatically revolves it about the z-axis ## 2. Geometry Setup ### 2.1 Topload Model the topload as a toroid in the r-z plane. A toroid of major diameter D_major and minor diameter D_minor centered at height h is represented by its cross-sectional circle: ``` Circle center: (r_center, z_center) r_center = D_major/2 - D_minor/2 z_center = h Circle radius = D_minor/2 ``` Draw the right half of this circle (r >= 0) using arc segments. Close the contour along the axis if needed. Assign the topload surface to Conductor Group 1. ### 2.2 Spark Channel **For the lumped model (single cylinder):** Model the entire spark as one vertical cylinder extending downward from the bottom of the topload. Key parameters: - **Diameter:** 1 mm for burst mode analysis, 3 mm for QCW analysis (nominal values; the weak logarithmic dependence of capacitance on diameter makes the exact choice non-critical) - **Length:** The target spark length L - **Gap:** Leave a 0.1-0.5 mm gap between the topload surface and the top of the spark cylinder for numerical stability In the r-z plane, the cylinder is a thin rectangle from (0, z_base) to (r_spark, z_tip), where r_spark = d/2 and z_tip = z_base - L. Assign the spark surface to Conductor Group 2. **For the distributed model (n segments):** Divide the cylinder into n equal sections, each of length L_seg = L/n. Leave 0.1 mm gaps between segments. Assign each segment to its own Conductor Group (2 through n+1). See [[distributed-model]] for the segment numbering convention. ### 2.3 Ground Plane Model the ground plane as a horizontal line from (0, 0) to (R_boundary, 0), where R_boundary is the outer boundary radius. Assign Dirichlet boundary condition V = 0 to this line. ### 2.4 Outer Boundary Create a rectangular boundary enclosing all geometry: - **Radial extent:** R_boundary = 3 to 10 times the maximum dimension (topload diameter or spark length, whichever is larger) - **Vertical extent:** From well below the spark tip to well above the topload Assign V = 0 (Dirichlet) or a mixed boundary condition to the outer boundary. The boundary must be far enough that C_sh changes by less than 5% when the boundary is moved 50% farther. ### 2.5 Material Properties Assign the material "Air" with relative permittivity epsilon_r = 1.0 to all regions outside the conductors. The conductors themselves are equipotential surfaces (boundary conditions, not material regions). ### 2.6 Mesh Control **Critical near the spark channel:** The thin spark cylinder (1-3 mm diameter) requires fine mesh elements. Set the mesh element size near the spark to be no larger than the spark diameter. For a 2 mm spark, use 2 mm maximum element size. **Near the topload:** Element size of 5-10 mm is typically sufficient. **Far field:** Coarse mesh is acceptable (50-100 mm elements). The far field contributes little to the capacitance between nearby conductors. **Mesh quality check after generation:** - No extremely elongated triangles (aspect ratio below 10:1) - Fine mesh near conductors with smooth transition to coarse mesh - Total element count: typically 15,000-50,000 for lumped models, 30,000-100,000 for distributed models ## 3. Solution and Matrix Extraction ### 3.1 Running the Solver FEMM solves the Laplace equation iteratively. Check: - Convergence: Final residual below 1e-8 - Iteration count: Typically 3-10 iterations for well-conditioned problems - No warnings about poor mesh quality ### 3.2 Visual Verification Before extracting numbers, visually inspect the solution: - Topload should be at the specified potential (uniform color on surface) - Spark should be at a lower, uniform potential (floating conductor acquires a potential determined by coupling) - Ground plane should be at V = 0 - Field lines should emerge from the topload, with some terminating on the spark and others reaching ground - No anomalous hot spots or discontinuities ### 3.3 Extracting the Maxwell Capacitance Matrix **FEMM Circuit Properties dialog** provides: - Voltage of each conductor (specified or computed) - Charge on each conductor - Capacitance matrix elements **For the lumped model (2x2 matrix):** ``` [Topload] [Spark] [Top] [ C_11 C_12 ] [Spk] [ C_21 C_22 ] ``` **For the distributed model ((n+1) x (n+1) matrix):** ``` [Top] [Seg1] [Seg2] ... [Segn] [Top] [C_00 C_01 C_02 ... C_0n ] [Seg1] [C_10 C_11 C_12 ... C_1n ] [Seg2] [C_20 C_21 C_22 ... C_2n ] ... [Segn] [C_n0 C_n1 C_n2 ... C_nn ] ``` ### 3.4 Sign Convention: Maxwell vs. Circuit **Maxwell capacitance matrix convention:** - C_ii > 0: Self-capacitance (total charge on conductor i when i is at 1V and all others are grounded) - C_ij < 0 for i != j: Mutual coupling (charge induced on conductor i when j is at 1V and all others are grounded). The negative sign reflects that positive voltage on j induces negative charge on i. **Circuit element convention:** - All capacitances are positive values **Conversion for the lumped model:** ``` C_mut = |C_12| (take absolute value of negative off-diagonal) C_sh = C_22 - |C_12| (total self-cap minus mutual coupling) ``` **Conversion for the distributed model:** Use the partial capacitance transformation (see Section 4 below). **Warning:** Mixing conventions is the most common source of errors in this workflow. Always write out the absolute value signs explicitly and verify that all circuit element capacitances are positive. ## 4. Partial Capacitance Transformation ### 4.1 Purpose The Maxwell matrix contains negative off-diagonal elements that cannot be directly implemented as capacitors in SPICE. The partial capacitance transformation produces an equivalent network with only positive elements. ### 4.2 Transformation Formulas From the Maxwell matrix C_maxwell, compute: **Capacitance between node i and node j (for i != j):** ``` C_branch[i,j] = -C_maxwell[i,j] = |C_maxwell[i,j]| ``` This is a positive capacitor connected between nodes i and j. **Capacitance from node i to ground:** ``` C_ground[i] = C_maxwell[i,i] + sum_{j != i} C_maxwell[i,j] = C_maxwell[i,i] - sum_{j != i} |C_maxwell[i,j]| ``` This is the residual capacitance to the implicit ground node. It should be non-negative for a valid matrix. If it is slightly negative (numerical noise), it indicates that the conductor is almost entirely coupled to other conductors with negligible direct coupling to ground. ### 4.3 Network Implementation The resulting circuit has: - One capacitor C_branch[i,j] between each pair of nodes (i,j) - One capacitor C_ground[i] from each node to ground - All values are positive For n+1 conductors, this produces up to n*(n+1)/2 branch capacitors plus n+1 ground capacitors. For n = 10 (11 conductors), this is up to 55 branch capacitors plus 11 ground capacitors. In practice, many branch capacitors are negligibly small and can be omitted. ## 5. Electric Field Computation ### 5.1 Tip Field for Growth Prediction FEMM computes the electric field magnitude at any point in the domain. For spark growth analysis (see [[field-thresholds]] and [[energy-and-growth]]), the critical quantity is the electric field at the spark tip. **Procedure:** 1. Set topload to the peak operating voltage V_top 2. Include the spark at its current length L 3. Solve the electrostatic problem 4. Query E_tip = |E| at the tip of the spark cylinder The tip field includes geometric enhancement: ``` E_tip = kappa * E_average ``` where kappa = 2 to 5 is the field enhancement factor due to the small radius of curvature at the spark tip. FEMM automatically captures this enhancement if the mesh is sufficiently fine near the tip. ### 5.2 Calibration of E_propagation The field threshold for sustained spark propagation is determined by combining FEMM with experimental observation: 1. Run the coil with known drive conditions 2. Measure the final (stalled) spark length L_stall 3. From SPICE simulation, determine V_top at the time of stall 4. In FEMM, set up the topload at V_top with a spark of length L_stall 5. Compute E_tip at the stall point 6. This E_tip equals E_propagation for this coil/environment Typical result: E_propagation = 0.4 to 1.0 MV/m, depending on altitude, humidity, and channel condition. ### 5.3 Accuracy Considerations **FEMM field accuracy near the tip:** The field at a sharp geometric feature (like the end of a thin cylinder) is the hardest quantity to compute accurately with FEA. The field diverges as the radius of curvature approaches zero. In practice: - Round the tip of the spark cylinder with a hemispherical cap of radius equal to half the spark diameter - Refine the mesh to at least 5 elements across the hemisphere - Report E_tip averaged over the hemisphere surface, not at a single point **Overall capacitance accuracy:** FEMM capacitance extraction is typically accurate to +/-10% for well-meshed problems. With careful mesh refinement and boundary testing, +/-5% is achievable. ## 6. Practical Workflow Summary ### 6.1 Lumped Model Extraction ``` 1. Create FEMM geometry: topload + single spark cylinder + ground plane 2. Set topload to V = 1V (test voltage) 3. Set spark as floating conductor 4. Mesh and solve 5. Extract 2x2 Maxwell capacitance matrix 6. Compute: C_mut = |C_12|, C_sh = C_22 - |C_12| 7. Validate: C_sh within factor 2-3 of (2 pF/foot * L) 8. Calculate: R = 1/(omega * (C_mut + C_sh)), clip to [1 kilohm, 100 megohm] 9. Build SPICE netlist ``` ### 6.2 Distributed Model Extraction ``` 1. Create FEMM geometry: topload + n spark segments + ground plane 2. Set topload to V = 1V (test voltage) 3. Set all segments as floating conductors 4. Mesh and solve 5. Extract (n+1)x(n+1) Maxwell capacitance matrix 6. Verify: symmetry, positive diagonals, negative off-diagonals 7. Transform to partial capacitances for SPICE implementation 8. Compute per-segment: C_total[i] = sum |C[i,j]| for j != i 9. Calculate: R[i] = 1/(omega * C_total[i]), clip to position-dependent bounds 10. Build SPICE network with partial capacitances and resistances ``` ### 6.3 Parametric Studies FEMM simulations are fast enough (seconds to minutes) to enable parametric sweeps: - **Spark length variation:** Run for L = 0.5, 1.0, 1.5, 2.0, 2.5, 3.0 m to build lookup tables of C_mut(L), C_sh(L) - **Topload size variation:** Compare small, medium, and large toploads to understand the effect on C_mut/C_sh ratio (and hence on the phase constraint from [[circuit-topology]]) - **Ground plane distance:** Vary the ground plane height to assess environmental sensitivity of C_sh - **Spark diameter:** Verify the weak logarithmic dependence of capacitance on diameter ## 7. Common Mistakes and Troubleshooting ### 7.1 Errors in Setup | Mistake | Symptom | Fix | |---------|---------|-----| | Spark touching topload (no gap) | Matrix extraction fails or gives anomalous values | Insert 0.1-0.5 mm gap | | Boundary too close | C_sh varies >5% when boundary moved | Increase to 5-10x max dimension | | Mesh too coarse near spark | Poor convergence or C values change with refinement | Refine mesh to spark diameter | | Wrong conductor assignment | Off-diagonal elements have wrong sign or magnitude | Verify conductor groups | ### 7.2 Errors in Extraction | Mistake | Symptom | Fix | |---------|---------|-----| | C_sh = C_22 + C_12 (wrong formula) | Conceptual error; coincidentally gives correct result | Always use C_sh = C_22 - abs(C_12) | | Forgetting absolute value | Negative C_mut (impossible) | Take abs() of all off-diagonal elements | | Units mismatch | R_opt off by orders of magnitude | FEMM uses cm internally; convert to SI for formulas | | Non-symmetric matrix | Indicates poor convergence or bug | Re-mesh, refine, check boundary conditions | ### 7.3 Validation Failures | Issue | Likely cause | Action | |-------|-------------|--------| | C_sh > 5 * (2 pF/ft * L) | Boundary too close; extra grounded objects | Move boundary; check geometry | | C_sh < 0.2 * (2 pF/ft * L) | Spark shielded by topload; ground too far | Physical; not necessarily wrong | | C_mut < 1 pF | Spark too far from topload; gap too large | Check gap size and topload model | | Negative C_ground[i] after partial transform | Numerical noise in matrix | Add +0.1 pF to diagonal | ## 8. Connection to Other Topics ### Key Relationships - **Serves:** [[lumped-model]] -- FEMM provides the 2x2 matrix from which C_mut and C_sh are extracted for the lumped model. - **Serves:** [[distributed-model]] -- FEMM provides the (n+1)x(n+1) matrix that defines the entire capacitive network of the distributed model. - **Computes:** [[field-thresholds]] -- FEMM computes E_tip for a given V_top and L, enabling growth prediction and E_propagation calibration. - **Informs:** [[capacitive-divider]] -- The voltage distribution along the spark (visible in FEMM's potential plot) directly shows the capacitive divider effect. - **Depends on:** [[circuit-topology]] -- The physical topology (C_mut || R in series with C_sh) motivates what quantities to extract from FEMM. - **Validates against:** [[equations-and-bounds]] -- All extracted capacitances and derived resistances must fall within documented physical ranges. ### Worked Example The `femm-lumped-extraction.md` worked example demonstrates the complete workflow for a 30 cm x 8 cm toroid with a 1.8 m spark at 200 kHz, including mesh convergence testing, boundary sensitivity analysis, and parametric studies.