Version 0.5

Introduction

This example creates and solves a simple U46 Hybrid Undulator made with rectangular blocks. It is important to execute each section in the order of presentation. If not, errors may be reported. Any section can be edited and executed several times. To see the change in the peak field induced by the variation of the magnet size, edit the corresponding parameter in the section entitled "Create the Geometry", execute this section and re-execute the section "Solve". The section "Optimizing Parameters" provides an example of manual optimization of the pole dimensions.
To obtain acceptable precision on the magnetic field, it is essential to increase the segmentation. This is done at the expense of memory and CPU time. The segmentation in this example has been set to np={2,2,5} for the pole and nm={1,3,1} for the magnet. This corresponds to an absolute error in the peak field of the undulator of the order of 1%. The user himself should experience consequences of increasing np and nm and see how CPU time and memory increase, and how the value of the peak field approaches a limit which is the value looked for. To do so, edit the nm or np values in the "Create the Geometry" section, and re-execute both the "Create the Geometry" and "Solve" sections. Using segmentation which is too large segmentation may result in a memory allocation failure. To recover from such situation, the section "Load and Initialize Radia" should be re-executed. Memory allocation failure can be avoided (to some extent) by giving more memory to the Radia.exe process (Macintosh).
It is a fact that iron pieces need much more segmentation than the magnets since the magnetization there is very sensitive to the external field.
One can also compute the field Integral produced by such an undulator, forces on the magnets and poles, etc. One can build a wedge pole undulator by using polyhedrons or extruded polygons instead of rectangular blocks... To learn more, read the Radia documentation, make tests and develop experience.

Load and Initialize Radia

The following instruction loads the Radia package and returns the Radia version number.

 

<<Radia`;
[Graphics:Example3gr2.gif][Graphics:Example3gr1.gif]
[Graphics:Example3gr2.gif][Graphics:Example3gr3.gif]

Functions

The following function builds an array of rectangular permanent magnets with their mirror symmetric counterparts, distributes the colors, magnetic materials and sets the segmentation. The function is very generic and can be used to build almost any hybrid undulator (without optimizing the design of terminations).

 

und[]:=Module[{},
zer={0,0,0};
Grp=radObjCnt[{}];

(* Principal Poles and Magnets *)

y=lp[[2]]/4;
Pole=RadObjFullMag[{lp[[1]]/4,y,-lp[[3]]/2-gap/2},{lp[[1]]/2,lp[[2]]/2,lp[[3]]},zer,np,Grp,mp,cp];
y+=lp[[2]]/4;

For[i=1, i<=Nper,i++,(
initm={0,Mod[i+1,2]-Mod[i,2],0};
y+=lm[[2]]/2;
Magnet=RadObjFullMag[{lm[[1]]/4,y,-lm[[3]]/2-gap/2-gapoffset},{lm[[1]]/2,lm[[2]],lm[[3]]},initm,nm,Grp,mm,cm];
y+=(lm[[2]]+lp[[2]])/2;
Pole=RadObjFullMag[{lp[[1]]/4,y,-lp[[3]]/2-gap/2},{lp[[1]]/2,lp[[2]],lp[[3]]},zer,np,Grp,mp,cp];
y+=lp[[2]]/2;
)];

initm={0,Mod[Nper,2]-Mod[Nper+1,2],0};
y+=lm[[2]]/4;
Magnet=RadObjFullMag[{lm[[1]]/4,y,-lm[[3]]/2-gap/2-gapoffset},{lm[[1]]/2,lm[[2]]/2,lm[[3]]},initm,nm,Grp,mm,cm];

(* Mirrors *)

RadTrfZerPerp[Grp,{0,0,0},{1,0,0}];
RadTrfZerPara[Grp,zer,{0,0,1}];
RadTrfZerPerp[Grp,zer,{0,1,0}];
Grp
]

Create the Geometry

The following instructions build an undulator with NdFeB magnets and poles made of Vanadium Permendur.

 

radUtiDelAll[];

(* General Parameters *)
gap=20;Nper=2;per=46;gapoffset=1;

(* Pole Parameters *)
lp={45,5,25};np={2,2,5};cp={1,0,1};
ll=per/2-lp[[2]];
mp=RadMatXc06[];

(* Magnet Parameters *)
lm={65,ll,45};nm={1,3,1};cm={0,1,1};
mm=RadMatNdFeB[];

(* Build the Structure *)
Grp=und[];

Plot the Geometry

The following instructions create a set of 3D graphical primitives representing the structure in space, and plot it.

 

draw=radObjDrw[Grp];

 

RadPlot3DOptions[];
Show[Graphics3D[draw]
,ViewPoint->{5,-1.5,2}
,PlotRange->All
,AmbientLight -> GrayLevel[0.1]];

[Graphics:Example3gr2.gif] [Graphics:Example3gr4.gif]

Solve

The following instructions Solve for the magnetization of each sub-block which constitutes the Undulator.

 

t0=AbsoluteTime[];
re=RadSolve[Grp,0.0003,300];
t1=AbsoluteTime[];

Print["Solved  in : ",Round[t1-t0],"  seconds"];
Print["Number of Iterations : ",re[[4]]];
Print["Average Stability of Magnetization at the last iteration : ",N[re[[1]],2],"  T"];
Print["Maximum Absolute Magnetization at the last iteration : ",N[re[[2]],4],"  T"];
Print["Maximum H vector at the last iteration : ",N[re[[3]],4],"  T"];
Print[""];
Print["Central Field Bz(0,0,0) : ",N[radFld[Grp,"Bz",zer],4],"  T"];
[Graphics:Example3gr2.gif][Graphics:Example3gr5.gif]
[Graphics:Example3gr2.gif][Graphics:Example3gr6.gif]
[Graphics:Example3gr2.gif][Graphics:Example3gr7.gif]
[Graphics:Example3gr2.gif][Graphics:Example3gr8.gif]
[Graphics:Example3gr2.gif][Graphics:Example3gr9.gif]
[Graphics:Example3gr2.gif][Graphics:Example3gr10.gif]
[Graphics:Example3gr2.gif][Graphics:Example3gr11.gif]

Plot the Magnetic Field

 

RadPlotOptions[];
Plot[radFld[Grp,"Bz",{0,y,0}],{y,-(Nper+1)/2*per,(Nper+1)/2*per}
,AxesOrigin->{0,0}
,FrameLabel->{"Y [mm]","Bz [T]","X = Z = 0",""}];

[Graphics:Example3gr2.gif] [Graphics:Example3gr12.gif]

Checking the Magnetic Material

This cell presents a plot of the Magnetization vs Field Strength for the materials in use. Note that the NdFeB is anisotropic.

 

RadPlotOptions[];
Plot[radMatMvsH[Pole, "mz", {0,0,hz}],{hz,-0.01,0.01}
,FrameLabel->"Xc06 "
,AxesLabel->{"H","M"}
];

Plot[
{radMatMvsH[Magnet, "mz", {0,0,h}]
,radMatMvsH[Magnet, "my", {0,h,0}]}
,{h,-1,1}
,FrameLabel->"NdFeB "
,AxesLabel->{"H","M"}
];

[Graphics:Example3gr2.gif] [Graphics:Example3gr13.gif] [Graphics:Example3gr2.gif] [Graphics:Example3gr14.gif]

Optimizing Parameters

In this section, some iterations are made on solving and computing the peak field of the undulator as a function of the horizontal width of the pole. The segmentation in the pole and magnet has been set to {1,1,1} resulting in a quick but inaccurate computation.

 

gap=20;Nper=2;per=46;gapoffset=1; 

lp={45,5,25};np={1,1,1};cp={1,0,1};    
ll=per/2-lp[[2]];

lm={65,ll,45};nm={1,1,1};cm={0,1,1};  

F[]:=Module[{},
radUtiDelAll[];
mm=RadMatNdFeB[];
mp=RadMatAFK502[];
Grp=und[];
re=RadSolve[Grp,0.001,1000];
N[radFld[Grp,"Bz",{0,0,0}],5]
]

t=Table[{y,(lp[[1]]=y;F[])},{y,4,40,5}];

ListPlot[t,PlotJoined->True,AxesLabel->{"Pole Width","Peak Field"}];

[Graphics:Example3gr2.gif] [Graphics:Example3gr15.gif]

How to Get Help

The following command lists all the functions defined in the Radia.exe file.

 

?rad*
radFld          radFldUnits     radObjDpl       radTrfCmbR
radFldCmpCrt    radMatApl       radObjDrw       radTrfInv
radFldCmpPrc    radMatLin       radObjDrwAtr    radTrfMlt
radFldEnr       radMatMvsH      radObjFlmCur    radTrfOrnt
radFldEnrFrc    radMatSatAniso  radObjPolyhdr   radTrfPlSym
radFldEnrTrq    radMatSatIso    radObjRaceTrk   radTrfRot
radFldFocPot    radObjAddToCnt  radObjRecCur    radTrfTrsl
radFldFrc       radObjArcCur    radObjRecMag    radUtiDel
radFldFrcShpRtg radObjBckg      radObjThckPgn   radUtiDelAll
radFldInt       radObjCnt       radRlxAuto      radUtiDmp
radFldLenTol    radObjCntStuf   radRlxMan       radUtiIntrptTim
radFldLst       radObjDegFre    radRlxPre       radUtiVer
radFldPtcTrj    radObjDivMag    radTrfCmbL

The following command gives the template and the description of the function "radObjArcCur".

 

?radObjArcCur
[Graphics:Example3gr2.gif][Graphics:Example3gr16.gif]

The following command lists all the functions defined in the Radia.m file.

 

?Rad*
Rad              RadMatAFK502     RadMatSteel42    RadSolve
Radia            RadMatFerrite    RadMatXc06       RadTrfAxisPerm
RadicalBox       RadMatNdFeB      RadObjExtRtg     RadTrfZerPara
RadLinkPattern   RadMatSm2Co17    RadObjFullMag    RadTrfZerPerp
Radlk            RadMatSmCo5      RadPlot3DOptions RadUtiMem
RadMatAFK1       RadMatSteel37    RadPlotOptions   RadUtiVer