Skip to content

Commit a489d52

Browse files
authored
Merge pull request #1010 from tpersson/upEndingNewSurveryAndVersionNumber
Version and change in ending for new Survey.
2 parents d10c0ed + 3e2eec7 commit a489d52

File tree

17 files changed

+896
-806
lines changed

17 files changed

+896
-806
lines changed

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
VERSION = 5.06.01
2-
VERSION_NUM = 50601
3-
VERSION_DATE = 2020.09.01
1+
VERSION = 5.07.00
2+
VERSION_NUM = 50700
3+
VERSION_DATE = 2021.05.02

doc/latexuguide/coverpage.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
\begin{center}\LARGE % document title
1919
\textbf{The MAD-X Program} \\
2020
(Methodical Accelerator Design) \\
21-
Version 5.06.01 \\
21+
Version 5.07.00 \\
2222
\textbf{User's Reference Manual}
2323
\end{center}
2424
\vskip 1.5em

doc/latexuguide/error.tex

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ \chapter{Error Definitions}
3838
% Changed by: Werner Herr, 02-Sep-2002
3939
% Changed by: Hans Grote, 25-Sep-2002
4040

41-
\section{EALIGN: Alignment Errors} %EALIGN: Define Misalignments}
41+
\section{EALIGN: Alignment Errors and permanent misalignments} %EALIGN: Define Misalignments}
4242
\label{sec:ealign}
4343

44+
There are two ways of introducing misalignments in MAD-X.
45+
\subsection{EALIGN}
46+
4447
Alignment errors are defined by the \texttt{EALIGN} command.
4548
The misalignments refer to the
4649
\hyperref[sec:reference]{local reference system} for a
@@ -91,7 +94,14 @@ \section{EALIGN: Alignment Errors} %EALIGN: Define Misalignments}
9194
\label{F-XYDISP}
9295
\end{figure}
9396

94-
97+
\subsection{Permanent Misalignments}
98+
The second way of introducing misalignments in MAD-X is
99+
to define them directly in the creation of a sequence. The name
100+
and effect of the orientation is the same as for the \texttt{EALIGN}.
101+
In case EALIGN and permanent misalignment are used togheter the values
102+
are added togheter component by component. The effect of the permanent misalignment
103+
is ignored by SURVEY by default but by adding the \text{PERM\_ALIGN\_SURVEY} the
104+
start and end location of each element is given.
95105
%% \begin{figure}[ht]
96106
%% \centering
97107
%% \setlength{\unitlength}{1pt}

doc/latexuguide/ptdp.tex

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
\chapter{Relation between $p_t$ and $\delta _p$}
2+
\label{chap:pt_rel_dp}
3+
In this chapter we establish the exact relation of $p_t$ and $\delta _p$ and show how it can be approximated.
4+
5+
Note that for simplicity $c$ has been set to 1 in this document. This does not change the outcome of the derivations.
6+
7+
8+
The definition of $p_t$ is the following:
9+
\begin{equation}
10+
p_t = \frac{E-E_0}{P_0}
11+
\label{eqn:pt}
12+
\end{equation}
13+
, where $E$ is the total energy of the particle, $E_0$ is the energy of the reference particle and $P_0$ is the momentum of the reference particle.
14+
15+
$\delta_p$ is defined as:
16+
\begin{equation}
17+
\delta_p = \frac{P-P_0}{P_0}
18+
\end{equation}
19+
, where $P$ is the momentum of the particle.
20+
We will use the following relation in several places in the following document:
21+
$E=\frac{P}{\beta} = \frac{P_0(1+\delta _p)}{\beta}$.
22+
23+
The following part is a derivation of the relation between $p_t$ and $\delta_p$ in the general case.
24+
\begin{equation}
25+
E = \sqrt{P^2+m_0^2}= \sqrt{P_0^2(1+\delta _p)^2+m_0^2}
26+
\label{eqn:e1}
27+
\end{equation}
28+
, where $m_0$ is the rest mass of the particle.
29+
Rearranging equation~\ref{eqn:pt} we can also write the energy as
30+
\begin{equation}
31+
E = P_0 pt + E_0 = P_0 pt + \frac{P_0}{\beta _0}
32+
\label{eqn:e2}
33+
\end{equation}
34+
, where we used the fact that $ E_0 =\frac{P_0}{\beta _0}$
35+
36+
Squaring equation~\ref{eqn:e1} and equation~\ref{eqn:e2} we can write:
37+
\begin{eqnarray}
38+
P_0^2(1+\delta _p)^2+m_0^2 = (P_0pt + \frac{P_0}{\beta _0})^2 = P_0 ^2 p_t ^2 + \frac{2P_0^2 p_t}{\beta_0}+\frac{P_0^2}{\beta_0 ^2}
39+
\label{eqn:squared_long}
40+
\end{eqnarray}
41+
We note that we can write $\beta _0 = \frac{P_0}{E_0} = \frac{P_0}{\sqrt{P_0^2+m_0^2}}$ which gives:
42+
\begin{equation}
43+
\frac{P_0^2}{\beta_0^2} = P_0^2 + m_0^2
44+
\label{eqn:p0b0}
45+
\end{equation}
46+
Substituting equation~\ref{eqn:p0b0} in to equation \ref{eqn:squared_long} gives:
47+
\begin{eqnarray}
48+
P_0^2(1+\delta _p)^2+m_0^2 =P_0 ^2 p_t ^2 + \frac{2P_0^2 p_t}{\beta_0}+P_0^2+m_0 ^2 .
49+
\end{eqnarray}
50+
We can now cancel $m_0$ on both sides, divide by $P_0^2$ and then finally we take the square root and we obtain the relation:
51+
\begin{eqnarray}
52+
1+\delta _p =\sqrt{p_t ^2 + \frac{2p_t}{\beta_0}+1}
53+
\end{eqnarray}
54+
If we now want an approximation to the above formula we again take the square and subtract 1 from both side and we get:
55+
\begin{eqnarray}
56+
2\delta _p+\delta _p^2 =p_t ^2 + \frac{2p_t}{\beta_0}
57+
\end{eqnarray}
58+
In the normal cases $p_t << 1$ so $p_t >> p_t ^2$. We then only use the leading order in $p_t$ and $\delta _p$, which gives us: $\frac{2p_t}{\beta_0} \approx 2 \delta _p$
59+
\begin{eqnarray}
60+
p_t \approx \beta_0 \delta _p
61+
\end{eqnarray}

doc/latexuguide/uguide.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
%\addeditor{IT}
4545

4646
\usepackage{versions}
47-
\markversion{5.06.01} % update coverpage.tex too
47+
\markversion{5.07.00} % update coverpage.tex too
4848

4949
%\usepackage{comment}
5050

src/mad_extrn_f.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
#define advance_to_pos advance_to_pos_
7777
#define current_node_name current_node_name_
7878
#define node_name node_name_
79+
#define node_name node_name_
80+
#define node_name_f_lower node_name_f_lower_
7981
#define node_string node_string_
8082
#define node_value node_value_ // **
8183
#define retreat_node retreat_node_

src/mad_node.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,14 @@ node_name(char* name, int* l)
700700
strfcpy(name, current_node->name, *l);
701701
stoupper(name);
702702
}
703+
void
704+
node_name_f_lower(char* name, int* l)
705+
/* returns current node name in Fortran format */
706+
/* l is max. allowed length in name */
707+
{
708+
strfcpy(name, current_node->name, *l);
709+
}
710+
703711

704712
int
705713
get_node_count(struct node* node)

src/mad_node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ struct node* expand_node(struct node*, struct sequence* top, struct sequence* se
9191
void dump_node(struct node*);
9292
int advance_node(void);
9393
void node_name(char* name, int* l);
94+
void node_name_f_lower(char* name, int* l);
9495
double node_value(const char* par);
9596

9697
struct node_list* new_node_list(int length);

src/mad_table.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,8 +2130,8 @@ int
21302130
name_to_table_curr(const char* table, int* ending){
21312131
char tmp[strlen(current_node->p_elem->name)+3];
21322132
strcpy(tmp, current_node->p_elem->name);
2133-
if(*ending ==1) strcat(tmp, ".S");
2134-
if(*ending ==2) strcat(tmp, ".E");
2133+
if(*ending ==1) strcat(tmp, ".ENT");
2134+
if(*ending ==2) strcat(tmp, ".EXI");
21352135

21362136
return string_to_table_curr(table,"name", tmp);
21372137
}

src/match.f90

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ subroutine mtgeti(vect,dvect)
3131
parameter(eps = 1.0d-10,eps2 = 1.0d-1,stplim = 2.0d-1)
3232
parameter(vmax=1.e+20,vmin=-1.e+20)
3333
character*(name_len) name
34-
34+
character tmp_c
3535
psum=get_option('match_summary ') .ne. 0
3636
1 continue
3737
j = next_vary(name,name_len,c_min,c_max,step,slope,opt)
@@ -110,20 +110,27 @@ subroutine collect(ncon,fsum,fvect)
110110
&flag,get_option,restart_sequ,advance_to_pos,double_from_table_row, &
111111
&string_from_table_row
112112
double precision fsum,fvect(*),val,valhg,c_min,c_max,weight,f_val
113-
character*(name_len) name, node_name
113+
!character*(name_len) name, node_name
114+
character(len=name_len) name, name_of_node, towire
115+
character (len=name_len) estring
116+
character tmp_c
114117
integer n_pos, next_constr_namepos, advance_node
118+
external:: node_name_f_lower
119+
115120
local=get_option('match_local ') .ne. 0
116121
fprt=get_option('match_print ') .ne. 0
117122
psum=get_option('match_summary ') .ne. 0
118123
slow_match = get_option('slow_match ') .ne. 0
119124
if (local) then
120125
j=restart_sequ()
121126
pos=1
127+
122128
do while (j .gt. 0)
123129
if (slow_match) j=advance_to_pos('twiss ',pos) ! (expensive) NOP?
124130
do while (next_constraint( &
125131
& name,name_len,type, valhg,c_min,c_max,weight, &
126-
& pos,val,node_name,name_len).ne.0)
132+
& pos,val,name_of_node,name_len).ne.0)
133+
127134
select case(type)
128135
case(1); f_val=weight*dim(c_min,val)
129136
case(2); f_val=weight*dim(val,c_max)
@@ -142,11 +149,12 @@ subroutine collect(ncon,fsum,fvect)
142149
end select
143150
endif
144151
if(psum) then
152+
call node_name_f_lower(estring,name_len)
145153
select case(type)
146-
case(4); write(*,830) node_name,name,type,valhg,val,f_val**2
147-
case(2); write(*,830) node_name,name,type,c_max,val,f_val**2
148-
case(1); write(*,830) node_name,name,type,c_min,val,f_val**2
149-
case(3); write(*,832) node_name,name,type,c_min,c_max,val,f_val**2
154+
case(4); write(*,830) estring,name,type,valhg,val,f_val**2
155+
case(2); write(*,830) estring,name,type,c_max,val,f_val**2
156+
case(1); write(*,830) estring,name,type,c_min,val,f_val**2
157+
case(3); write(*,832) estring,name,type,c_min,c_max,val,f_val**2
150158
end select
151159
endif
152160
end do

0 commit comments

Comments
 (0)