# Numerical model of simple magnetic circuit

## Homework Statement

I have to build a 2D model of simple magnetic circuit, that is iron core (2) with coil(1) and air gap(3) applied to it. Model has to be solved on numerical basis, by finite difference or element method (whichever is easier to implement). Number 4 on drawing represents boundary condition, that would be magnitude of magnetic field density B = 0.

http://img813.imageshack.us/img813/4049/trafon.th.jpg [Broken]

## Homework Equations

What equations to use and how properly discretize them?

## The Attempt at a Solution

I started with differential form of Ampere law, which is:
curl(H) = J, where H is vector of magnetic field strength and J is vector of current density.
Because B has only 2 space components (third iz zero), curl(H) translates to:
(dHy/dx - dHx/dy) *ez = J * ez, where Hy is y component of H, Hx is x component of H and ez is the direction in z-axis.
ez falls out, so final form is:
dHy/dx -dHx/dy = J

First derivatives are substituted with differences, i'll use central difference approximation:
du/dx = (u(i+1) - u(i-1))/(2*deltax)

Hy(i+1,j) - Hy(i-1,j) - Hx(i,j+1) + Hx(i ,j-1) = J*2*deltah
Grid is equidistant, so for both dimensions deltah is same.

I used the formula above for the coil region, elsewhere I set equation to (where no current density):
Hy(i+1,j) - Hy(i-1,j) - Hx(i,j+1) + Hx(i ,j-1) = 0

I got some strange and most possible, wrong results.