Professional Documents
Culture Documents
SW160131
MATLAB can directly calculate the magnetic properties of a geometry. There is a tool called
“pdetool” that will do most of the work via a graphical interface.
1. Draw your geometry. In the example a rectangle (R1) is drawn for the complete region to study. In
the example then a rectangle (R2) and an ellipse (E1) were drawn.
By default all edges of the outer geometry (R1) are set to Dirichlet conditions. This is ok if the
complete system is within the drawing. If there are symmetries and only part of the problem is
drawn the boundaries should be set to Neumann conditions.
In the example the right and left edges of R1 are set to Neumann boundary conditions.
The R1 region (named “1”) should be air in this case: mu=1, J=0
4. Create a mesh.
Click the big triangle. You will get a rough mesh (see below) with nodes for the calculation. To get
better precision, refine the mesh by clicking the “double triangle”.
Plot the magnetic flux density (B). You will see that it is normally high inside the iron. If you want to
see what happens in the gap where the electrons will pass it is more convenient to plot the magnetic
field (H). Remember the relation: B=H, or B=r0H and that r= 5000 for iron.
Save the results by after doing the calculations “export mesh” and “ export solution”. This will create
four parameters in workspace (u and p t e). Where “u” is the vector potential in in each mesh point.
(observe that while the vector potential is described in all three dimensions (xyz) it is only given in
the two dimensions of the defined problem. Take this in mind if calculating the magnetic flux
density.) “pte” describes the mesh and can be translated from triangular mesh to ordinary x-y grid
by “tri2grid”.
Analysis can from here be done by similar components as the following script. (this is for another
geometry than the example. To be refined!)
x=-60:1:40;
y=0:1:100;
uxy=tri2grid(p,t,u,x,y);
% Geometry description:
pderect([-1 1 0.80000000000000004 -0.80000000000000004],'R1');
pderect([-0.5 0.5 0.60000000000000009 0.20000000000000018],'R2');
pdeellip(0,-0.099999999999999978,0.5,0.099999999999999978,...
0,'E1');
set(findobj(get(pde_fig,'Children'),'Tag','PDEEval'),'String','R1+R2+E1')
% Boundary conditions:
pdetool('changemode',0)
pdesetbd(5,...
'dir',...
1,...
'1',...
'0')
pdesetbd(4,...
'neu',...
1,...
'0',...
'0')
pdesetbd(2,...
'dir',...
1,...
'1',...
'0')
pdesetbd(1,...
'neu',...
1,...
'0',...
'0')
% Mesh generation:
setappdata(pde_fig,'Hgrad',1.3);
setappdata(pde_fig,'refinemethod','regular');
setappdata(pde_fig,'jiggle',char('on','mean',''));
pdetool('initmesh')
pdetool('refine')
% PDE coefficients:
pdeseteq(1,...
'1./(1.0)!1./(5000)!1./(1.0)',...
'0.0!0.0!0.0',...
'0!0!1.0',...
'1.0!1.0!1.0',...
'0:10',...
'0.0',...
'0.0',...
'[0 100]')
setappdata(pde_fig,'currparam',...
['1.0!5000!1.0';...
'0!0!1.0 '])
% Solve parameters:
setappdata(pde_fig,'solveparam',...
char('0','1584','10','pdeadworst',...
'0.5','longest','0','1E-4','','fixed','Inf'))
% Solve PDE:
pdetool('solve')