How to use field_map
-
- Beginner
- Posts: 8
- Joined: Sun 17 Sep 2023 16:22
- Country:
China (cn)
How to use field_map
Dear Didier,
I used CST software to complete the RFQ model.
I refer to the TrcaeWin manual, but I still don't know how to export the field file for TraceWin.
Can you tell me the details of the format and how I should convert the CST exported field file?
I exported the grid used by the place as 25*25*121
In CST software, RFQ models are located at -3956 to 11
Thank you in advance for your answer.
Best regards,
Chen
I used CST software to complete the RFQ model.
I refer to the TrcaeWin manual, but I still don't know how to export the field file for TraceWin.
Can you tell me the details of the format and how I should convert the CST exported field file?
I exported the grid used by the place as 25*25*121
In CST software, RFQ models are located at -3956 to 11
Thank you in advance for your answer.
Best regards,
Chen
- Attachments
-
- E.txt
- Efield from CST
- (11.18 MiB) Downloaded 414 times
Re: How to use field_map
Dear Chen,
The details of the field map file format are given in the section "Magnetic or electric Field map." For example, for the 3D field map, the format is
"
nz zmax
nx xmin xmax
ny ymin ymax
Norm
for k=0 to nz
for j=0 to ny
for i=0 to nx
Fz(k×zmax/nz, ymin+j×(ymax-ymin)/ny, xmin+i×(xmax-xmin)/nx)
Return
"
where,
nz zmax: This line specifies that the grid will be divided into nz sections along the z-axis, extending up to zmax.
nx xmin xmax: This line specifies that the grid along the x-axis starts at xmin and ends at xmax, and is divided into nx sections.
ny ymin ymax: This line specifies that the grid along the y-axis starts at ymin and ends at ymax, and is divided into ny sections.
Norm: 1
The next section describes three nested loops, which iterate through the grid points:
for k=0 to nz: This loop iterates along the z-axis from 0 to nz.
for j=0 to ny: Nested within the z-axis loop, this loop iterates along the y-axis from 0 to ny.
for i=0 to nx: Nested within both the z and y-axis loops, this loop iterates along the x-axis from 0 to nx.
Inside the innermost loop, F(k×zmax/nz, ymin+j×(ymax-ymin)/ny, xmin+i×(xmax-xmin)/nx) represents the value of the field component F at the grid point determined by (k, j, i).
In case you are interested, I have a tool that directly converts the CST fields to the TraceWin format (attached).
Thank you
With Regards
Abhishek Pathak
The details of the field map file format are given in the section "Magnetic or electric Field map." For example, for the 3D field map, the format is
"
nz zmax
nx xmin xmax
ny ymin ymax
Norm
for k=0 to nz
for j=0 to ny
for i=0 to nx
Fz(k×zmax/nz, ymin+j×(ymax-ymin)/ny, xmin+i×(xmax-xmin)/nx)
Return
"
where,
nz zmax: This line specifies that the grid will be divided into nz sections along the z-axis, extending up to zmax.
nx xmin xmax: This line specifies that the grid along the x-axis starts at xmin and ends at xmax, and is divided into nx sections.
ny ymin ymax: This line specifies that the grid along the y-axis starts at ymin and ends at ymax, and is divided into ny sections.
Norm: 1
The next section describes three nested loops, which iterate through the grid points:
for k=0 to nz: This loop iterates along the z-axis from 0 to nz.
for j=0 to ny: Nested within the z-axis loop, this loop iterates along the y-axis from 0 to ny.
for i=0 to nx: Nested within both the z and y-axis loops, this loop iterates along the x-axis from 0 to nx.
Inside the innermost loop, F(k×zmax/nz, ymin+j×(ymax-ymin)/ny, xmin+i×(xmax-xmin)/nx) represents the value of the field component F at the grid point determined by (k, j, i).
In case you are interested, I have a tool that directly converts the CST fields to the TraceWin format (attached).
Thank you
With Regards
Abhishek Pathak
- Attachments
-
- Field_Map_Generator.zip
- (1.11 MiB) Downloaded 454 times
Re: How to use field_map
Dear Abhishek,
Thank you very much for your reply and tool shared.
Could you explain how to use it?
What is the role of the "MyAppInstaller_web.exe" executable?
When I run "fiela_map_generator.exe", I got an error message "Could not find version 8.3 of the MCR...." !
Regards,
Didier
Thank you very much for your reply and tool shared.
Could you explain how to use it?
What is the role of the "MyAppInstaller_web.exe" executable?
When I run "fiela_map_generator.exe", I got an error message "Could not find version 8.3 of the MCR...." !
Regards,
Didier
Re: How to use field_map
Dear Didier,
I extend my sincerest apologies for the oversight in failing to provide the requisite instructions for utilizing the tool. The tool has been generated using Matlab's App Designer and subsequently deployed via the Matlab Compiler. To ameliorate this lapse, I have taken the liberty of attaching a video tutorial that elucidates the process of operating the tool.
If you find it more convenient, I am more than willing to furnish the underlying Matlab scripts. I initially opted to provide only the compiled tool, given the relatively infrequent availability of Matlab licenses.
Thank you
With Regards,
Abhishek Pathak
I extend my sincerest apologies for the oversight in failing to provide the requisite instructions for utilizing the tool. The tool has been generated using Matlab's App Designer and subsequently deployed via the Matlab Compiler. To ameliorate this lapse, I have taken the liberty of attaching a video tutorial that elucidates the process of operating the tool.
If you find it more convenient, I am more than willing to furnish the underlying Matlab scripts. I initially opted to provide only the compiled tool, given the relatively infrequent availability of Matlab licenses.
Thank you
With Regards,
Abhishek Pathak
- Attachments
-
- Steps_To_Use_Field_map_generator_tool.zip
- (18.18 MiB) Downloaded 428 times
Re: How to use field_map
Dear Abhishek,
Thanks again for all your work, including the video.
Despite all this I'm stuck and I can't view the fields or output a non-empty TraceWin file.
So using the E.txt file provided by Chen, here's what I tried without success, probably I'm wrong somewhere.
Regards,
Didier
Thanks again for all your work, including the video.
Despite all this I'm stuck and I can't view the fields or output a non-empty TraceWin file.
So using the E.txt file provided by Chen, here's what I tried without success, probably I'm wrong somewhere.
Regards,
Didier
Re: How to use field_map
Dear Didier,
The tool needs both files, that is, the electric and magnetic field map (for RF) files from CST. Here for this case, we can use the same file name in both the boxes ('E.txt') and use the .edz files only.
I also noticed that the z coordinates in 'E.txt' are all <0 and my GUI calculates the z using max(of the z column).
For this file, I would advise using 'E.txt' in both boxes (see attached). and use the TW.edx, TW.edy, and TW.edz.
After the files are generated, Chen needs to change the z lengths in the generated files. I checked for the x and y dimensions, and they are correct.
It may take some time, but I would generalize my tool and share it with the community as soon as possible.
Thank you
With Regards
Abhishek Pathak
The tool needs both files, that is, the electric and magnetic field map (for RF) files from CST. Here for this case, we can use the same file name in both the boxes ('E.txt') and use the .edz files only.
I also noticed that the z coordinates in 'E.txt' are all <0 and my GUI calculates the z using max(of the z column).
For this file, I would advise using 'E.txt' in both boxes (see attached). and use the TW.edx, TW.edy, and TW.edz.
After the files are generated, Chen needs to change the z lengths in the generated files. I checked for the x and y dimensions, and they are correct.
It may take some time, but I would generalize my tool and share it with the community as soon as possible.
Thank you
With Regards
Abhishek Pathak
- Attachments
-
- sample.JPG (46.69 KiB) Viewed 8087 times
Re: How to use field_map
For simplicity, here is my function. The user can understand the logic and modify it as per their needs.
"function [ ] = FMG( ef,hf,of,unit ,nx,ny,nz,dx,dy,dz)
'In progress.....'
f1=fopen([of,'.edx'],'w');
f2=fopen([of,'.edy'],'w');
f3=fopen([of,'.edz'],'w');
f4=fopen([of,'.bdx'],'w');
f5=fopen([of,'.bdy'],'w');
f6=fopen([of,'.bdz'],'w');
data=importdata(ef);
data2=importdata(hf);
nx=nx-1;ny=ny-1;nz=nz-1;
se=size(data.data);
sh=size(data2.data)
sh(1,2)^1/3
ex=data.data(:,4)*1e-6;
ey=data.data(:,6)*1e-6;
ez=data.data(:,8)*1e-6;
ezmax=max(ez);
bx=data2.data(:,5)*4*pi*1e-7;
by=data2.data(:,7)*4*pi*1e-7;
bz=data2.data(:,9)*4*pi*1e-7;
if(unit=='cm')
fac=100;
end
if (unit=='mm')
fac=1000;
end
z=(max(data2.data(:,3))-min(data2.data(:,3)))/fac
ymin=(data.data(1,2))/fac
xmin=(data.data(1,1))/fac
ymax=-(data.data(1,2))/fac
xmax=-(data.data(1,1))/fac
fprintf(f1,[num2str(nz),' ',num2str(z),'\n' ,num2str(ny),' ', num2str(ymin),' ', num2str(ymax),'\n',num2str(nx),' ', num2str(xmin),' ',num2str(xmax) ,'\n 1\n '])
fprintf(f2,[num2str(nz),' ',num2str(z),'\n' ,num2str(ny),' ', num2str(ymin),' ', num2str(ymax),'\n',num2str(nx),' ', num2str(xmin),' ',num2str(xmax) ,'\n 1\n '])
fprintf(f3,[num2str(nz),' ',num2str(z),'\n' ,num2str(ny),' ', num2str(ymin),' ', num2str(ymax),'\n',num2str(nx),' ', num2str(xmin),' ',num2str(xmax) ,'\n 1\n '])
fprintf(f4,[num2str(nz),' ',num2str(z),'\n' ,num2str(ny),' ', num2str(ymin),' ', num2str(ymax),'\n',num2str(nx),' ', num2str(xmin),' ',num2str(xmax) ,'\n 1\n '])
fprintf(f5,[num2str(nz),' ',num2str(z),'\n' ,num2str(ny),' ', num2str(ymin),' ', num2str(ymax),'\n',num2str(nx),' ', num2str(xmin),' ',num2str(xmax) ,'\n 1\n '])
fprintf(f6,[num2str(nz),' ',num2str(z),'\n' ,num2str(ny),' ', num2str(ymin),' ', num2str(ymax),'\n',num2str(nx),' ', num2str(xmin),' ',num2str(xmax) ,'\n 1\n '])
se=size(ex);
for i=1:se(1,1)
fprintf(f1,'%2.15f\n',ex(i));
fprintf(f2,'%2.15f\n',ey(i));
fprintf(f3,'%2.15f\n',ez(i));
fprintf(f4,'%2.15f\n',bx(i));
fprintf(f5,'%2.15f\n',by(i));
fprintf(f6,'%2.15f\n',bz(i));
end
fclose(f1);
fclose(f2);
fclose(f3);
fclose(f4);
fclose(f5);
fclose(f6);
end
"
Please note the input to the function.
ef-cst input field map for electric field
hf-cst input field map for magnetic field
of-TraceWin field map file name.
unit - mm/cm
nx - # of points in x
ny - # of points in y
nz - # of points in z
dx - Step size in x
dy- Step size in y
dz- Step size in z
I hope this will help.
Thank you
With Regards
Abhishek Pathak
"function [ ] = FMG( ef,hf,of,unit ,nx,ny,nz,dx,dy,dz)
'In progress.....'
f1=fopen([of,'.edx'],'w');
f2=fopen([of,'.edy'],'w');
f3=fopen([of,'.edz'],'w');
f4=fopen([of,'.bdx'],'w');
f5=fopen([of,'.bdy'],'w');
f6=fopen([of,'.bdz'],'w');
data=importdata(ef);
data2=importdata(hf);
nx=nx-1;ny=ny-1;nz=nz-1;
se=size(data.data);
sh=size(data2.data)
sh(1,2)^1/3
ex=data.data(:,4)*1e-6;
ey=data.data(:,6)*1e-6;
ez=data.data(:,8)*1e-6;
ezmax=max(ez);
bx=data2.data(:,5)*4*pi*1e-7;
by=data2.data(:,7)*4*pi*1e-7;
bz=data2.data(:,9)*4*pi*1e-7;
if(unit=='cm')
fac=100;
end
if (unit=='mm')
fac=1000;
end
z=(max(data2.data(:,3))-min(data2.data(:,3)))/fac
ymin=(data.data(1,2))/fac
xmin=(data.data(1,1))/fac
ymax=-(data.data(1,2))/fac
xmax=-(data.data(1,1))/fac
fprintf(f1,[num2str(nz),' ',num2str(z),'\n' ,num2str(ny),' ', num2str(ymin),' ', num2str(ymax),'\n',num2str(nx),' ', num2str(xmin),' ',num2str(xmax) ,'\n 1\n '])
fprintf(f2,[num2str(nz),' ',num2str(z),'\n' ,num2str(ny),' ', num2str(ymin),' ', num2str(ymax),'\n',num2str(nx),' ', num2str(xmin),' ',num2str(xmax) ,'\n 1\n '])
fprintf(f3,[num2str(nz),' ',num2str(z),'\n' ,num2str(ny),' ', num2str(ymin),' ', num2str(ymax),'\n',num2str(nx),' ', num2str(xmin),' ',num2str(xmax) ,'\n 1\n '])
fprintf(f4,[num2str(nz),' ',num2str(z),'\n' ,num2str(ny),' ', num2str(ymin),' ', num2str(ymax),'\n',num2str(nx),' ', num2str(xmin),' ',num2str(xmax) ,'\n 1\n '])
fprintf(f5,[num2str(nz),' ',num2str(z),'\n' ,num2str(ny),' ', num2str(ymin),' ', num2str(ymax),'\n',num2str(nx),' ', num2str(xmin),' ',num2str(xmax) ,'\n 1\n '])
fprintf(f6,[num2str(nz),' ',num2str(z),'\n' ,num2str(ny),' ', num2str(ymin),' ', num2str(ymax),'\n',num2str(nx),' ', num2str(xmin),' ',num2str(xmax) ,'\n 1\n '])
se=size(ex);
for i=1:se(1,1)
fprintf(f1,'%2.15f\n',ex(i));
fprintf(f2,'%2.15f\n',ey(i));
fprintf(f3,'%2.15f\n',ez(i));
fprintf(f4,'%2.15f\n',bx(i));
fprintf(f5,'%2.15f\n',by(i));
fprintf(f6,'%2.15f\n',bz(i));
end
fclose(f1);
fclose(f2);
fclose(f3);
fclose(f4);
fclose(f5);
fclose(f6);
end
"
Please note the input to the function.
ef-cst input field map for electric field
hf-cst input field map for magnetic field
of-TraceWin field map file name.
unit - mm/cm
nx - # of points in x
ny - # of points in y
nz - # of points in z
dx - Step size in x
dy- Step size in y
dz- Step size in z
I hope this will help.
Thank you
With Regards
Abhishek Pathak
Re: How to use field_map
Yes, it does seem simple and clear, thank
Didier
Didier
-
- Beginner
- Posts: 8
- Joined: Sun 17 Sep 2023 16:22
- Country:
China (cn)
Re: How to use field_map
Dear Didier,
Below I attach the file I exported from CST.
I noticed that the z-coordinate I used was -3956-- 11 in the generated file so I changed 0.011 to 3.967, I don't know if I made a mistake in this operation.
Then I wrote it to Tracewin and something went wrong. I don't know if something was wrong with my tracewin Settings or if the field file was incorrect.
I hope you can spare some time to help me see how to solve it.
My requirement is to use FIELD_MAP run-through RFQ in tracewin. At present, I have built the RFQ model with CST, which can accelerate 20mA, 0.02Mev proton to 2.5Mev. I can confirm that the Twiss parameters and frequency of RFQ inlet are correct. i also know L--Field map length (mm) θi--RF input field phase (°)
I ran into some problems while reading the tracewin manual on my own, and I didn't know how to solve them.
Please forgive my limited English ability.
Thank you
With Regards
Chen
Below I attach the file I exported from CST.
I noticed that the z-coordinate I used was -3956-- 11 in the generated file so I changed 0.011 to 3.967, I don't know if I made a mistake in this operation.
Then I wrote it to Tracewin and something went wrong. I don't know if something was wrong with my tracewin Settings or if the field file was incorrect.
I hope you can spare some time to help me see how to solve it.
My requirement is to use FIELD_MAP run-through RFQ in tracewin. At present, I have built the RFQ model with CST, which can accelerate 20mA, 0.02Mev proton to 2.5Mev. I can confirm that the Twiss parameters and frequency of RFQ inlet are correct. i also know L--Field map length (mm) θi--RF input field phase (°)
I ran into some problems while reading the tracewin manual on my own, and I didn't know how to solve them.
Please forgive my limited English ability.
Thank you
With Regards
Chen
Re: How to use field_map
Dear Chen,
The *.dat file is missing, so it's complicated to solve your problem without knowing what you're doing.
Regards,
Didier
The *.dat file is missing, so it's complicated to solve your problem without knowing what you're doing.
Regards,
Didier