# Field Calculator (`field.calculator`)

[Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-calculator/)

**Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel

> Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note.

## What it does

Preview. Solves the model as magnetics.fieldSolve meshes it (magnetostatic, linear materials) with the currents given, all at once, and evaluates each quantity on the solved field. Variables (SI): x, y (m; in an axisymmetric model also r = x and z = y), Bx, By, B = |B| (T; axisymmetric also Br, Bz), Hx, Hy, H = |H| (A/m, from each region's μr, a magnet's on its recoil line; axisymmetric also Hr, Hz), A (Wb/m: A\_z planar, A\_φ = ψ/r axisymmetric), J (A/m², the source current density along z, or φ), muR (the region's relative permeability), mu0 (4π·1e-7 H/m), and on a surface nx, ny (the unit normal to the right of travel along the path) and tx, ty (the unit tangent). dV is the element area times the model's depth, or 2πr times it when axisymmetric; dS is the path length times the depth, or 2πr times it. The integrals are exact for the element field up to degree 5 in the position (a 7-point triangle rule, 3-point Gauss along the path), so B\*H/2 over every region is the region table's energy, Bx\*nx+By\*ny along a line is the flux across it, and Hx\*tx+Hy\*ty round a closed path divided by the depth (or by 2\*pi\*r) is the current it encloses. A piece of a path along an edge between two elements takes both sides' mean; a part outside the mesh counts for nothing (insideMm says how much was inside). A quantity that is not finite somewhere is refused with the point and the region. Changes nothing. With "dimension":3 (#3069) the model (a sketch or an E-type design, not an axisymmetric sketch) is extruded as magnetics.fieldSolve {dimension: 3} extrudes it, meshed whole (a ring design is revolved a whole turn about the z axis, "stepDeg" its step, each winding a current sheet on the core named after its circuit; it takes no magnets or layers), solved once linear with the currents given and any magnets (each label's body through the depth on its recoil line, magnetized in the drawing's plane; a drawing of magnets alone has no winding), and each quantity is a volume integral (regions, default every region), a point value (at:\[x,y,z\] mm, z = 0 the middle plane; no path) or a surface integral (surface:{corner:\[x,y,z\],u:\[dx,dy,dz\],v:\[dx,dy,dz\]} mm, a flat parallelogram; its unit normal u × v / |u × v| is nx, ny, nz) of the variables x, y, z (m), Bx, By, Bz, B, Hx, Hy, Hz, H, muR, mu0; B and H are constant in each tetrahedron and the 4-point rule of degree 2 integrates expr exactly up to degree 2 in the position, so B\*H/2 over every region is the 3D energy (model.energyJ; with magnets H = (B − Br)/(μ0 μrec) in a magnet and mu0\*muR\*H^2/2 is the energy); a surface row gives value (∫ expr dS, exact up to degree 2 in the position: Bx\*nx+By\*ny+Bz\*nz is the flux, zero out of a closed box of six surfaces), areaMm2 (the part inside the mesh), surfaceMm2, mean and normal, and a piece on a face between two tetrahedra takes both sides' mean; the reply adds dimension:3, with magnets magnets (each one's demagnetization check at the currents given, as field.force {dimension: 3} gives it) and warnings, and model {family,construction,revolveStepDeg,depthMm,elementMm,layers,nodes,elements,regions,iterations,residual,energyJ,estimatedPeakMemoryBytes}.

## Parameters

- `design`: object? (a magnetics.design reply, or its best design)
- `sketch`: object? (instead of design: the planar drawing magnetics.fieldSolve takes, in mm; field.lineProfile, field.regionTable and field.calculator also take an axisymmetric (r, z) section, axisymmetric: true with no depthMm, revolved a full turn, its magnets' direction \[r, z\] in the section)
- `muR`: number? (design only)
- `clearanceMm`: number=0.1 (design only)
- `elementMm`: number? (largest element in the core and the windings, 0.01 to 50 mm)
- `currents`: object? ({circuit: amperes}; default 1 A in every circuit; a circuit left out carries none)
- `magnets`: \[{region:str (the name of a region of the drawing that is not a coil; with a design, \\"centre-leg gap\\" draws the centre leg's gap as its own region, a slot the magnet fills, refused for a ring or a gapless design),direction:\[x,y\] (the magnetization direction, any length; \[r, z\] in an axisymmetric section),temperatureC:number,grade:str (a built-in grade: Arnold N35, Arnold N42, Arnold N42H or Arnold N42UH, sintered NdFeB, each from its Arnold Magnetic Technologies data sheet) | {name:str,source:str (the data sheet the values come from: document, revision, table),recoilMuR:number (≥ 1),points:\[{temperatureC,brT (remanence),hcjAPerM (intrinsic coercivity),hkAPerM (knee field, H\_k ≤ H\_cJ)}\] (1 to 64, rising temperature)}}\]? (permanent magnets, at most 64: each region becomes a magnet on its recoil line B = μ0 μrec H + Br at the temperature, Br, H\_cJ and H\_k linear between the sheet's points and the nearest point outside them with an outsideMaterialData warning; any other grade's values are the caller's, and the grade must name its sheet; demagCurve:\[\[H,B\]\]? (field.lineProfile, field.regionTable, magnetics.fieldFluxMap, magnetics.fieldSolve {dimension: 3} and field.force {dimension: 3} only, every other command refuses it: the grade's normal demagnetization curve at temperatureC from the same data sheet, A/m and T, 2 to 200 points from \[0, Br\] with H and B both falling through the knee, its Br within 1 % of the grade's; the magnet is then solved by Newton's method on it, a reverse field along the magnetization on the curve and a forward or crosswise one on the recoil line, reversibly, with Br from the curve))
- `quantities`: \[{"name":str? (default q1, q2, …; unique, up to 64 characters),"expr":str (the quantity, an expression of the variables below in SI units, e.g. "B^2/(2\*mu0\*muR)" or "Bx\*nx+By\*ny"; the functions of parameter expressions: sqrt, abs, pow, hypot, if, min, max, sin, …),"regions":\[str\]? (a volume integral over the regions of these label names; the default when neither path nor at is given, over every region),"path":\[\[x,y\]\]? (mm, 2 to 10000 points: a surface integral over the surface the polyline sweeps, through the model's depth, or round the axis when axisymmetric; repeat the first point to close it),"at":\[x,y\]? (mm: the quantity at one point)}\] (1 to 16)
- `dimension`: int=2 (3: the 3D calculator, below)
- `layers`: int? (dimension 3: element layers through the depth, as magnetics.fieldSolve takes them)
- `stepDeg`: num? (dimension 3, a ring design: the revolve step, 1 to 30 degrees, as magnetics.fieldSolve takes it)

## Reply

- currents
- quantities:\[{name,expr,kind:"volume"|"surface"|"point",value (volume: ∫ expr dV, the unit of expr times m³; surface: ∫ expr dS, times m²; point: expr, null outside the mesh),regions? (volume: the region names),volumeMm3?,mean? (volume: value / volume),areaMm2?,lengthMm?,insideMm?,closed? (surface),atMm?,region? (point: the region name, null outside the mesh)}\]
- model
- notes
