Skip to content

Commit

Permalink
Merge pull request #1008 from tpersson/updateDocAndWarnings
Browse files Browse the repository at this point in the history
Guide update and removed the last warnings.
  • Loading branch information
tpersson authored Apr 28, 2021
2 parents 4a9f513 + 5c00aea commit 6e07b25
Show file tree
Hide file tree
Showing 79 changed files with 22,147 additions and 22,125 deletions.
15 changes: 15 additions & 0 deletions doc/latexuguide/control.tex
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,21 @@ \section{SELECT}
The \hyperref[chap:plot]{\texttt{PLOT}} command also accepts the new variable
in the table.

\section{Add2expr}
\label{sec:add2expr}
The \texttt{ADD2EXPR} command is used to add a variable to an already defined deferred expression.
\madbox{
ADD2EXPR, \=var=string, expr=string \\
}
An example of how it is used is given below.
\madbox{
a := b + c;
add2expr, var=a, expr=-d;
show, a;
a := b + c - d;
}


%% EOF


8 changes: 5 additions & 3 deletions doc/latexuguide/conventions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,8 @@ \subsection{Linear Lattice Functions (Optical Functions)}
variable.
Dispersive and chromatic functions are hence derivatives with
respect to PT.
And since PT=BETA*DELTAP, where BETA is the relativistic Lorentz
And since PT$\approx$BETA*DELTAP (see derivation in chapter~\ref{chap:pt_rel_dp}),
where BETA is the relativistic Lorentz
factor, those functions given by \madx must be multiplied by BETA a
number of time equal to the order of the derivative to find the
functions given in the literature.
Expand Down Expand Up @@ -664,7 +665,7 @@ \subsection{Chromatic Functions}
Notice also that in \madx, PT substitutes DELTAP as longitudinal
variable. Dispersive and chromatic functions are hence derivatives with
respect to PT.
Since PT=BETA/DELTAP, where BETA is the relativistic Lorentz
Since PT$\approx$BETA*DELTAP (see derivation in chapter~\ref{chap:pt_rel_dp}), where BETA is the relativistic Lorentz
factor, those functions given by \madx must be multiplied by BETA a
number of times equal to the order of the derivative to find the
functions given in the literature.
Expand Down Expand Up @@ -748,7 +749,8 @@ \subsection{Variables in the SUMM Table}
Notice that in \madx, PT substitutes DELTAP as longitudinal
variable. Dispersive and chromatic functions are hence derivatives with
respect to PT.
And since PT=BETA*DELTAP, where BETA is the relativistic Lorentz
And since PT$\approx$BETA*DELTAP (see derivation in chapter~\ref{chap:pt_rel_dp})
,where BETA is the relativistic Lorentz
factor, those functions given by \madx must be multiplied by BETA a
number of time equal to the order of the derivative to find the
functions given in the literature.
Expand Down
3 changes: 2 additions & 1 deletion doc/latexuguide/cororbit.tex
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ \section{CORRECT}
imported from an external file (with the \texttt{READTABLE} command), for
example to use measured BPM data. In that case, the imported twiss
table is allowed to contain coordinate data only at the location of
the monitors.
the monitors. Note that the list has to be in order and that you
cannot skip any locations of the monitors you have included.

\ttitem{NAME\_COL} The name of the column that contains the name of
monitors in the tables. (Default: "\texttt{name}")
Expand Down
3 changes: 2 additions & 1 deletion doc/latexuguide/makethin.tex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ \section{MAKETHIN}
processed to thin slices. The sequence must be active, i.e. it should
have been previously loaded with a \hyperref[sec:use]{\texttt{USE}} command.
The sequence must use the default positioning of elements
({\texttt{REFER=centre}}).
({\texttt{REFER=centre}}). To use the sliced sequence you have to again use the command
\hyperref[sec:use]{\texttt{USE}} with the sequence name.

\ttitem{STYLE} the slicing style to be used for all active elements (excluding corrector magnets).
The corrector magnets and the inactive elements are instead sliced so there is a slice in the
Expand Down
2 changes: 1 addition & 1 deletion doc/latexuguide/makethin_HBU.tex
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
See the \href{http://madx.web.cern.ch/madx/madX/examples/makethin/}{examples} for makethin.\\
Compare the main optics parameters like tunes before and after slicing with makethin.
In tests, turn off slicing for some of the main element classes to identify the main sources of changes.
For sextuples and octupoles, a single slice should always be sufficient.
For sextuples and octupoles, a single slice is normally be sufficient.
Increase the number of slices for critical elements like mini-beta quadrupoles. Even there, more than four slices should rarely be required.
Rematch tunes and chromaticity after makethin.

Expand Down
4 changes: 2 additions & 2 deletions doc/latexuguide/match.tex
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ \section{Insertion Matching}
\madbox{
MATCH, \=SEQUENCE= 'name1', 'name2', \ldots , 'name-n',\\
\>BETA0= 'beta01', 'beta02', \ldots , 'beta0n', \\
\>SLOW=logical;
\>SLOW=logical, TAPERING=logical;
}

or
Expand All @@ -133,7 +133,7 @@ \section{Insertion Matching}
\>BETY=real, ALFY=real, MUY=real, \\
\>X=real, PX=real, Y=real, PY=real, \\
\>DX=real, DY=real, DPX=real, DPY=real, \\
\>DELTAP=real, SLOW=logical;
\>DELTAP=real, SLOW=logical, TAPERING=logical;
}

In the second mode, called insertion matching, the matching routine is
Expand Down
2 changes: 2 additions & 0 deletions doc/latexuguide/pitfalls.tex
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,6 @@ \chapter{\madx recipes and pitfalls}

\end{description}



%EOF
4 changes: 3 additions & 1 deletion doc/latexuguide/uguide.tex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
tfs, c6t, sxf, plot, index, rplot_index,
survey, twiss, match, emit, aperture, makethin, error, cororbit, sodd, touschek, ibs, thintrack,
ptc-general, ptc-track, ptc-twiss, ptc-normal, ptc-auxiliaries,
defects, pitfalls
defects, ptdp, pitfalls
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -135,9 +135,11 @@ \part{\ptc Commands}
\part{Trailing Material}
\include{defects} % Known Differences to Other Programs
\include{pitfalls}
\include{ptdp}
\include{contributors}
\include{changelog}


\bibliographystyle{unsrt}
\bibliography{biblio-mad}

Expand Down
2 changes: 1 addition & 1 deletion src/mad_aper.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ else if (!strcmp(apertype,"racetrack")) {
// zero horizontal or vertical explosion factors, and zero radius should be allowed.
// 2015-Mar-09 14:43:33 ghislain: change meaning of parameters: ap1 and ap2 are now full rectangle extension,
// 2015-Mar-10 10:18:46 ghislain: change rounded corners from circular to generalized elliptical shape
if ( (*ap1) < 0 || (*ap2) < 0 || (*ap3) <= 0 || (*ap4) < 0 || (*ap1) < (*ap3) || (*ap2) < (*ap4)) {
if ( (*ap1) < 0 || (*ap2) < 0 || (*ap3) <= 0 || (*ap4) <= 0 || (*ap1) < (*ap3) || (*ap2) < (*ap4)) {
if (debug)
printf("+++ aper_build screen, racetrack parameters: %10.5f %10.5f %10.5f %10.5f -- exiting 0\n", *ap1, *ap2, *ap3, *ap4);
return 0;
Expand Down
39 changes: 19 additions & 20 deletions src/mad_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ myatof(const char *instr){
return atof(instr);
}
void
mystrcpy(struct char_array* target, char* source)
mystrcpy(struct char_array* target, const char *source)
{
// LD: 2021.04.27, fixed bug, switch to strncpy to avoid warning
/* string copy to char_array with size adjustment */
int len = strlen(source);
while (len >= target->max) grow_char_array(target);
strncat((*target->c=0, target->c), source, len);
strncpy(target->c, source, len+1);
}

char*
Expand Down Expand Up @@ -65,33 +66,31 @@ mystrstr(char* string, const char* s)
}

void
myrepl(const char* in, const char* out, char* string_in, char* string_out)
myrepl(const char* in, const char* out, const char* restrict string_in, char* restrict string_out)
/* replaces all occurrences of "in" in string_in by "out"
in output string string_out */
{
int n, add, l_in = strlen(in), l_out = strlen(out);
char* cp;
char tmp[8];
while ((cp = strstr(string_in, in)) != NULL)
// LD: 2021.04.27, fixed bug, speed-up.
char tmp[16];

if (*out == '$') {
int n = get_variable(&out[1]);
sprintf(tmp, "%d", n); out = tmp;
}

int l_in = strlen(in), l_out = strlen(out);

for (char *cp; (cp=strstr(string_in, in)); )
{
while (string_in != cp) *string_out++ = *string_in++;
string_in += l_in;
if (*out == '$')
{
n = get_variable(&out[1]);
sprintf(tmp,"%d", n); add = strlen(tmp);
strncpy(string_out, tmp, add);
string_out += add;
}
else
{
strncpy(string_out, out, l_out);
string_out += l_out;
}
strncpy(string_out, out, l_out+1);
string_in += l_in;
string_out += l_out;
}
strcpy(string_out, string_in);
}


char*
mystrchr(char* string, char c)
/* returns strchr for character c, but only outside strings included
Expand Down
4 changes: 2 additions & 2 deletions src/mad_str.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ struct char_p_array;
double myatof(const char *instr);
char* mycpy(char* sout, const char* sin);
char* mystrchr(char* string, char c);
void mystrcpy(struct char_array* target, char* source);
void mystrcpy(struct char_array* target, const char *source);
char* mystrstr(char* string, const char* s);
void myrepl(const char* in, const char* out, char* string_in, char* string_out);
void myrepl(const char* in, const char* out, const char* string_in, char* string_out);
int mysplit(char* buf, struct char_p_array* list);

void conv_char(const char* string, struct int_array* tint);
Expand Down
8 changes: 4 additions & 4 deletions src/twiss.f90
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ SUBROUTINE tmclor(guess,fsec,ftrk, eig_tol, opt_fun0,rt,tt,eflag)
end SUBROUTINE tmclor

SUBROUTINE tmcheckstab(rt,tol, debug)
use math_constfi, only : one
use math_constfi, only : one, zero
!----------------------------------------------------------------------*
! Purpose: *
! Check the stability of the one turn matrix *
Expand Down Expand Up @@ -669,7 +669,7 @@ SUBROUTINE tmcheckstab(rt,tol, debug)
tmp1 = reval(1)**2 + aival(1)**2
tmp2 = reval(2)**2 + aival(2)**2

write (warnstr,'(a)') 'Horizontal plane might be unstable (values should be less than one)' // &
write (warnstr,'(a)') 'Horizontal plane might be unstable' // &
' More information with the debug flag on.'
call fort_warn('TWCLORB: ',warnstr)
if(debug .ne. zero) print *, 'Eigenvalue(1)**2 ', tmp1, " Eigenvalue(2)**2", tmp2
Expand All @@ -679,7 +679,7 @@ SUBROUTINE tmcheckstab(rt,tol, debug)
tmp1 = reval(1)**2 + aival(1)**2
tmp2 = reval(2)**2 + aival(2)**2

write (warnstr,'(a)') 'Vertical plane might be unstable (values should be less than one)' // &
write (warnstr,'(a)') 'Vertical plane might be unstable' // &
' More information with the debug flag on.'
call fort_warn('TWCLORB: ',warnstr)
if(debug .ne. zero) print *, 'Eigenvalue(3)**2 ', tmp1, " Eigenvalue(4)**2", tmp2
Expand All @@ -688,7 +688,7 @@ SUBROUTINE tmcheckstab(rt,tol, debug)
if (stabt) then
tmp1 = reval(5)**2 + aival(5)**2
tmp2 = reval(6)**2 + aival(6)**2
write (warnstr,'(a)') 'Longitudinal plane might be unstable. (values should be less than one)' // &
write (warnstr,'(a)') 'Longitudinal plane might be unstable.' // &
' Try change lag with 0.5. More information with the debug flag on.'
call fort_warn('TWCLORB: ',warnstr)
if(debug .ne. zero) print *, 'Eigenvalue(5)**2 ', tmp1, " Eigenvalue(6)**2", tmp2
Expand Down
2 changes: 1 addition & 1 deletion testing/updateFromList.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#copyfile(src, dst)
mypath_orig = '../tests/'
file1 = open('../myfail.txt', 'r')
file1 = open('../onlyfail.out', 'r')
Lines = file1.readlines()
loc = os.getcwd()
count = 0
Expand Down
6 changes: 3 additions & 3 deletions tests/test-lhc/ap_ir1b1.tfs.ref
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
@ N1MIN %le 11.0545
@ AT_ELEMENT %12s "MQXFA.B3L1:1"
@ TITLE %08s "no-title"
@ ORIGIN %16s "5.05.02 Linux 64"
@ DATE %08s "10/08/20"
@ TIME %08s "21.45.48"
@ ORIGIN %16s "5.06.01 Linux 64"
@ DATE %08s "28/04/21"
@ TIME %08s "19.09.36"
* NAME KEYWORD PARENT S X Y PX PY BETX BETY ALFX ALFY MUX MUY DX DY DPX DPY N1 APERTYPE APER_1 APER_2 APER_3 APER_4 RTOL XTOL YTOL K0L K1L K2L K3L K4L K5L K0SL K1SL K2SL K3SL K4SL K5SL
$ %s %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %s %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le
"S.DS.L1.B1" 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 4.875386741785218e-05 7.978156530959646e-05 -1.976083222032789e-06 -1.340821147904173e-05 7.267356604800351e+01 6.093186187869521e+01 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.172075824243292e+00 -5.517436945358494e-01 0.000000000000000e+00 0.000000000000000e+00 9.999990000000000e+05 "RECTELLIPSE" 9.999999000000001e+00 9.999999000000001e+00 9.999999000000001e+00 9.999999000000001e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
Expand Down
6 changes: 3 additions & 3 deletions tests/test-lhc/ap_ir1b1_-0.0002.tfs.ref
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
@ N1MIN %le 11.0648
@ AT_ELEMENT %12s "MQXFA.B3L1:1"
@ TITLE %08s "no-title"
@ ORIGIN %16s "5.05.02 Linux 64"
@ DATE %08s "10/08/20"
@ TIME %08s "21.46.00"
@ ORIGIN %16s "5.06.01 Linux 64"
@ DATE %08s "28/04/21"
@ TIME %08s "19.09.47"
* NAME KEYWORD PARENT S X Y PX PY BETX BETY ALFX ALFY MUX MUY DX DY DPX DPY N1 APERTYPE APER_1 APER_2 APER_3 APER_4 RTOL XTOL YTOL K0L K1L K2L K3L K4L K5L K0SL K1SL K2SL K3SL K4SL K5SL
$ %s %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %s %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le
"S.DS.L1.B1" 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 -1.871770646184029e-04 1.910085838908869e-04 1.165499479436770e-06 -1.204612511094191e-05 7.702958282733179e+01 5.813151541356777e+01 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.187157874476673e+00 -5.605311563343568e-01 0.000000000000000e+00 0.000000000000000e+00 9.999990000000000e+05 "RECTELLIPSE" 9.999999000000001e+00 9.999999000000001e+00 9.999999000000001e+00 9.999999000000001e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
Expand Down
6 changes: 3 additions & 3 deletions tests/test-lhc/ap_ir1b1_-0.0006.tfs.ref
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
@ N1MIN %le 10.7158
@ AT_ELEMENT %12s "MQXFA.B3L1:1"
@ TITLE %08s "no-title"
@ ORIGIN %16s "5.05.02 Linux 64"
@ DATE %08s "10/08/20"
@ TIME %08s "21.46.03"
@ ORIGIN %16s "5.06.01 Linux 64"
@ DATE %08s "28/04/21"
@ TIME %08s "19.09.50"
* NAME KEYWORD PARENT S X Y PX PY BETX BETY ALFX ALFY MUX MUY DX DY DPX DPY N1 APERTYPE APER_1 APER_2 APER_3 APER_4 RTOL XTOL YTOL K0L K1L K2L K3L K4L K5L K0SL K1SL K2SL K3SL K4SL K5SL
$ %s %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %s %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le
"S.DS.L1.B1" 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 -6.686879870135916e-04 4.191027275408107e-04 7.536290784374036e-06 -9.259358004203650e-06 8.627128118239112e+01 5.858039337716804e+01 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 1.220029225226893e+00 -5.798384348421618e-01 0.000000000000000e+00 0.000000000000000e+00 9.999990000000000e+05 "RECTELLIPSE" 9.999999000000001e+00 9.999999000000001e+00 9.999999000000001e+00 9.999999000000001e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00 0.000000000000000e+00
Expand Down
Loading

0 comments on commit 6e07b25

Please sign in to comment.