source: MML/trunk/at/simulator/element/user/atphyslibNew.c

Last change on this file was 5, checked in by zhangj, 11 years ago

ThomX MML version on the LAL server @ 17/12/2013

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1/*   File: atphyslib.c
2     Common physics functions for Accelerator Toolbox
3(1)
4     A. Terebilo   10/28/04
5(2) 
6   Laurent S. NAdolski, April 8th, 2007
7          add energy dependance in edge_fringe and edge
8(3)
9Added flags to turn on dipole fringe field and edge effects
10in dipoles.
11
12Modified by Jianfeng Zhang @ LAL, 30/04/2013.
13
14(4)
1505/06/2013 written by Jianfeng Zhang @ LAL
16Added Alex Loulergue's geometric correction of the
17dipole fringe field, but without the correction
18term 1+r[4] of py in Forest: SSC-141; because this
19correction term only works for Soleil lattice, but not works
20for ThomX and SuperB DR.
21
22*/
23       
24#include "mex.h"
25void edge(double* r, double inv_rho, double edge_angle)
26{       /* Edge focusing in dipoles with hard-edge field; geometric rotation */
27  double psi = inv_rho*tan(edge_angle);
28 
29  /* r[1]+=r[0]*psi; */
30  r[1]+=r[0]*psi/(1+r[4]*1); 
31  r[3]-=r[2]*psi/(1+r[4]*1);
32
33
34
35
36
37
38}
39
40
41void edge_fringe(double* r, double inv_rho, double edge_angle, double fint, double gap, int entrance)
42{   /* Edge focusing in dipoles with fringe field */
43  double fx = inv_rho*tan(edge_angle);
44  double fy = 0.0;
45  /*  double psi_bar = edge_angle-inv_rho*gap*fint*(1+sin(edge_angle)*sin(edge_angle))/cos(edge_angle)/(1+r[4]); */
46
47double psi_bar = edge_angle-inv_rho*gap*fint*(1+sin(edge_angle)*sin(edge_angle))/cos(edge_angle)/(1+r[4]*0);
48
49  /*modification for ThomX; Loulergue's geometric correction */
50 if(entrance == 1)
51   fy = inv_rho*tan(psi_bar + r[1]/(1+r[4]));
52 else
53   fy = inv_rho*tan(psi_bar - r[1]/(1+r[4]));
54
55  /* r[1]+=r[0]*fx;
56     r[3]-=r[2]*fy; */
57  /*  r[1]+=r[0]*fx/(1+r[4]);
58      r[3]-=r[2]*fy/(1+r[4]); */
59
60 /*remove geometric correction to py in Forest: SSC-141, only correct
61   to Soleil lattice, but not correct to ThomX and SuperB DR lattice.*/
62  r[1]+=r[0]*fx/(1+r[4]*0);
63  r[3]-=r[2]*fy/(1+r[4]*0);
64}
65
66
67/* /\*Alex Dragt's model...*\/ */
68/* void edge_fringe(double* r, double inv_rho, double edge_angle, double fint, double gap, int entrance) */
69/* {   /\* Edge focusing in dipoles with fringe field *\/ */
70/*   double fx = inv_rho*tan(edge_angle); */
71/*   double fy = 0.0; */
72/*   /\*  double psi_bar = edge_angle-inv_rho*gap*fint*(1+sin(edge_angle)*sin(edge_angle))/cos(edge_angle)/(1+r[4]); *\/ */
73
74/* double psi_bar = edge_angle-inv_rho*gap*fint*(1+sin(edge_angle)*sin(edge_angle))/cos(edge_angle)/(1+r[4]*0); */
75
76/*  double phi_bar = sqrt((1+r[4])*(1+r[4])-r[1]*r[1]); */
77/*  double phi_bar2= phi_bar*phi_bar; */
78/*  double phi_bar3 = phi_bar2*phi_bar; */
79 
80
81/*  r[3]-=inv_rho*r[2]*r[1]/phi_bar+inv_rho*tan(edge_angle-psi_bar); */
82/*  r[0]+=inv_rho*0.5*r[2]*r[2]*(1+r[4])*(1+r[4])/phi_bar3; */
83/*  r[1]+=r[0]*fx; */
84
85/* } */
Note: See TracBrowser for help on using the repository browser.