Skip to content

Commit

Permalink
Merge pull request #1010 from tpersson/upEndingNewSurveryAndVersionNu…
Browse files Browse the repository at this point in the history
…mber

Version and change in ending for new Survey.
  • Loading branch information
tpersson authored May 2, 2021
2 parents d10c0ed + 3e2eec7 commit a489d52
Show file tree
Hide file tree
Showing 17 changed files with 896 additions and 806 deletions.
6 changes: 3 additions & 3 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = 5.06.01
VERSION_NUM = 50601
VERSION_DATE = 2020.09.01
VERSION = 5.07.00
VERSION_NUM = 50700
VERSION_DATE = 2021.05.02
2 changes: 1 addition & 1 deletion doc/latexuguide/coverpage.tex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
\begin{center}\LARGE % document title
\textbf{The MAD-X Program} \\
(Methodical Accelerator Design) \\
Version 5.06.01 \\
Version 5.07.00 \\
\textbf{User's Reference Manual}
\end{center}
\vskip 1.5em
Expand Down
14 changes: 12 additions & 2 deletions doc/latexuguide/error.tex
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ \chapter{Error Definitions}
% Changed by: Werner Herr, 02-Sep-2002
% Changed by: Hans Grote, 25-Sep-2002

\section{EALIGN: Alignment Errors} %EALIGN: Define Misalignments}
\section{EALIGN: Alignment Errors and permanent misalignments} %EALIGN: Define Misalignments}
\label{sec:ealign}

There are two ways of introducing misalignments in MAD-X.
\subsection{EALIGN}

Alignment errors are defined by the \texttt{EALIGN} command.
The misalignments refer to the
\hyperref[sec:reference]{local reference system} for a
Expand Down Expand Up @@ -91,7 +94,14 @@ \section{EALIGN: Alignment Errors} %EALIGN: Define Misalignments}
\label{F-XYDISP}
\end{figure}


\subsection{Permanent Misalignments}
The second way of introducing misalignments in MAD-X is
to define them directly in the creation of a sequence. The name
and effect of the orientation is the same as for the \texttt{EALIGN}.
In case EALIGN and permanent misalignment are used togheter the values
are added togheter component by component. The effect of the permanent misalignment
is ignored by SURVEY by default but by adding the \text{PERM\_ALIGN\_SURVEY} the
start and end location of each element is given.
%% \begin{figure}[ht]
%% \centering
%% \setlength{\unitlength}{1pt}
Expand Down
61 changes: 61 additions & 0 deletions doc/latexuguide/ptdp.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
\chapter{Relation between $p_t$ and $\delta _p$}
\label{chap:pt_rel_dp}
In this chapter we establish the exact relation of $p_t$ and $\delta _p$ and show how it can be approximated.

Note that for simplicity $c$ has been set to 1 in this document. This does not change the outcome of the derivations.


The definition of $p_t$ is the following:
\begin{equation}
p_t = \frac{E-E_0}{P_0}
\label{eqn:pt}
\end{equation}
, 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.

$\delta_p$ is defined as:
\begin{equation}
\delta_p = \frac{P-P_0}{P_0}
\end{equation}
, where $P$ is the momentum of the particle.
We will use the following relation in several places in the following document:
$E=\frac{P}{\beta} = \frac{P_0(1+\delta _p)}{\beta}$.

The following part is a derivation of the relation between $p_t$ and $\delta_p$ in the general case.
\begin{equation}
E = \sqrt{P^2+m_0^2}= \sqrt{P_0^2(1+\delta _p)^2+m_0^2}
\label{eqn:e1}
\end{equation}
, where $m_0$ is the rest mass of the particle.
Rearranging equation~\ref{eqn:pt} we can also write the energy as
\begin{equation}
E = P_0 pt + E_0 = P_0 pt + \frac{P_0}{\beta _0}
\label{eqn:e2}
\end{equation}
, where we used the fact that $ E_0 =\frac{P_0}{\beta _0}$

Squaring equation~\ref{eqn:e1} and equation~\ref{eqn:e2} we can write:
\begin{eqnarray}
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}
\label{eqn:squared_long}
\end{eqnarray}
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:
\begin{equation}
\frac{P_0^2}{\beta_0^2} = P_0^2 + m_0^2
\label{eqn:p0b0}
\end{equation}
Substituting equation~\ref{eqn:p0b0} in to equation \ref{eqn:squared_long} gives:
\begin{eqnarray}
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 .
\end{eqnarray}
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:
\begin{eqnarray}
1+\delta _p =\sqrt{p_t ^2 + \frac{2p_t}{\beta_0}+1}
\end{eqnarray}
If we now want an approximation to the above formula we again take the square and subtract 1 from both side and we get:
\begin{eqnarray}
2\delta _p+\delta _p^2 =p_t ^2 + \frac{2p_t}{\beta_0}
\end{eqnarray}
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$
\begin{eqnarray}
p_t \approx \beta_0 \delta _p
\end{eqnarray}
2 changes: 1 addition & 1 deletion doc/latexuguide/uguide.tex
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
%\addeditor{IT}

\usepackage{versions}
\markversion{5.06.01} % update coverpage.tex too
\markversion{5.07.00} % update coverpage.tex too

%\usepackage{comment}

Expand Down
2 changes: 2 additions & 0 deletions src/mad_extrn_f.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
#define advance_to_pos advance_to_pos_
#define current_node_name current_node_name_
#define node_name node_name_
#define node_name node_name_
#define node_name_f_lower node_name_f_lower_
#define node_string node_string_
#define node_value node_value_ // **
#define retreat_node retreat_node_
Expand Down
8 changes: 8 additions & 0 deletions src/mad_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,14 @@ node_name(char* name, int* l)
strfcpy(name, current_node->name, *l);
stoupper(name);
}
void
node_name_f_lower(char* name, int* l)
/* returns current node name in Fortran format */
/* l is max. allowed length in name */
{
strfcpy(name, current_node->name, *l);
}


int
get_node_count(struct node* node)
Expand Down
1 change: 1 addition & 0 deletions src/mad_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ struct node* expand_node(struct node*, struct sequence* top, struct sequence* se
void dump_node(struct node*);
int advance_node(void);
void node_name(char* name, int* l);
void node_name_f_lower(char* name, int* l);
double node_value(const char* par);

struct node_list* new_node_list(int length);
Expand Down
4 changes: 2 additions & 2 deletions src/mad_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -2130,8 +2130,8 @@ int
name_to_table_curr(const char* table, int* ending){
char tmp[strlen(current_node->p_elem->name)+3];
strcpy(tmp, current_node->p_elem->name);
if(*ending ==1) strcat(tmp, ".S");
if(*ending ==2) strcat(tmp, ".E");
if(*ending ==1) strcat(tmp, ".ENT");
if(*ending ==2) strcat(tmp, ".EXI");

return string_to_table_curr(table,"name", tmp);
}
Expand Down
22 changes: 15 additions & 7 deletions src/match.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ subroutine mtgeti(vect,dvect)
parameter(eps = 1.0d-10,eps2 = 1.0d-1,stplim = 2.0d-1)
parameter(vmax=1.e+20,vmin=-1.e+20)
character*(name_len) name

character tmp_c
psum=get_option('match_summary ') .ne. 0
1 continue
j = next_vary(name,name_len,c_min,c_max,step,slope,opt)
Expand Down Expand Up @@ -110,20 +110,27 @@ subroutine collect(ncon,fsum,fvect)
&flag,get_option,restart_sequ,advance_to_pos,double_from_table_row, &
&string_from_table_row
double precision fsum,fvect(*),val,valhg,c_min,c_max,weight,f_val
character*(name_len) name, node_name
!character*(name_len) name, node_name
character(len=name_len) name, name_of_node, towire
character (len=name_len) estring
character tmp_c
integer n_pos, next_constr_namepos, advance_node
external:: node_name_f_lower

local=get_option('match_local ') .ne. 0
fprt=get_option('match_print ') .ne. 0
psum=get_option('match_summary ') .ne. 0
slow_match = get_option('slow_match ') .ne. 0
if (local) then
j=restart_sequ()
pos=1

do while (j .gt. 0)
if (slow_match) j=advance_to_pos('twiss ',pos) ! (expensive) NOP?
do while (next_constraint( &
& name,name_len,type, valhg,c_min,c_max,weight, &
& pos,val,node_name,name_len).ne.0)
& pos,val,name_of_node,name_len).ne.0)

select case(type)
case(1); f_val=weight*dim(c_min,val)
case(2); f_val=weight*dim(val,c_max)
Expand All @@ -142,11 +149,12 @@ subroutine collect(ncon,fsum,fvect)
end select
endif
if(psum) then
call node_name_f_lower(estring,name_len)
select case(type)
case(4); write(*,830) node_name,name,type,valhg,val,f_val**2
case(2); write(*,830) node_name,name,type,c_max,val,f_val**2
case(1); write(*,830) node_name,name,type,c_min,val,f_val**2
case(3); write(*,832) node_name,name,type,c_min,c_max,val,f_val**2
case(4); write(*,830) estring,name,type,valhg,val,f_val**2
case(2); write(*,830) estring,name,type,c_max,val,f_val**2
case(1); write(*,830) estring,name,type,c_min,val,f_val**2
case(3); write(*,832) estring,name,type,c_min,c_max,val,f_val**2
end select
endif
end do
Expand Down
4 changes: 2 additions & 2 deletions tests/test-match-10/test-match-10.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
1-1500 * skip # head * any abs=6e-10 rel=4e-7
1501-1550 * any abs=6e-9 rel=4e-7
1-1360 * skip # head * any abs=6e-10 rel=4e-7
* * any abs=6e-9 rel=4e-7

Loading

0 comments on commit a489d52

Please sign in to comment.