Skip to content

Commit

Permalink
New write_foreign_test regression test. (#1192)
Browse files Browse the repository at this point in the history
* New write_foreign_test regression test.
  • Loading branch information
DavidSagan committed Sep 16, 2024
1 parent 8168fc9 commit 34fb068
Show file tree
Hide file tree
Showing 35 changed files with 11,666 additions and 4,563 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ bmad-doc/tutorial_ring_design/doc/tutorial_ring_design.pdf
**/doit

regression_tests/*/output.now
regression_tests/write_foreign_test/write_foreign_test.*.now
regression_tests/*/lat.bmad
regression_tests/*/r
regression_tests/*/rr
Expand Down
29 changes: 24 additions & 5 deletions bmad/doc/attributes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,34 @@ \section{Orientation: Offset, Pitch, Tilt, and Roll Attributes}
\item\vn{Girder Elements} (\sref{s:girder.orient}) \Newline
%
\item\vn{Control Elements} \Newline
Control elements are elements that control attributes of other
elements. The control elements are:
Control elements are elements that control attributes of other elements. Except for \vn{girder}
control elements, these elements do not have orientational attributes. Control elements that fall
into this list are:
\begin{example}
group
overlay
ramper
\end{example}
These elements do not have orientational attributes.
\end{enumerate}
%-----------------------------------------------------------------
\subsection{Global Random Misalignment of Elements}
\label{s:global.mis}
It is often convenient to randomly misalign sets of elements. This can be done using the \vn{ran}
and \vn{ran_gauss} functions (\sref{s:functions}). For example:
\begin{example}
quadrupole::bnd10:bnd20[y_offset] = 1.4e-6*ran_gauss(5)
\end{example}
The above line sets the \vn{y_offset} of all the quadrupoles in the range from element \vn{BND10} to
element \vn{BND20}.
When \vn{ran} or \vn{ran_gauss} is used in a lattice file, each time the file is read in, a new set
of random numbers are generated unless \vn{parameter[ran_seed]} is set to a non-zero value in the
lattice file before \vn{ran} or \vn{ran_gauss} is used. To save a particular set of generated
random values, write out the lattice file (the \vn{write bmad} command can be used if running \tao)
after it has been read in.
%-----------------------------------------------------------------
\subsection{Straight Line Element Orientation}
\label{s:straight.orient}
Expand Down Expand Up @@ -1154,7 +1173,7 @@ \section{X-Rays Crystal \& Compound Materials}
\section{X-Ray Reflectivity Tables}
\label{s:reflect}
Reflectivity tables are used to define reflectivity propabilities as functions of incidence angle and
Reflectivity tables are used to define reflectivity probabilities as functions of incidence angle and
photon energy for \vn{crystal} and \vn{mirror} elements.
The general syntax is:
Expand All @@ -1181,7 +1200,7 @@ \section{X-Ray Reflectivity Tables}
\begin{example}
pi ! Table is for pi mode
sigma ! Table is for sigma mode
both ! Table is for both polarizations. Defalut.
both ! Table is for both polarizations. Default.
\end{example}
An element needs a single table with \vn{polarization} marked as \vn{both} or two tables,
one for \vn{sigma} and the other for \vn{pi}.
Expand Down
2 changes: 1 addition & 1 deletion bmad/doc/cover-page.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

\begin{flushright}
\large
Revision: September 6, 2024 \\
Revision: September 13, 2024 \\
\end{flushright}

\pdfbookmark[0]{Preamble}{Preamble}
Expand Down
2 changes: 1 addition & 1 deletion bmad/interface/opal_interface_mod.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module opal_interface_mod

use write_lat_file_mod
use write_lattice_file_mod

private write_opal_line

Expand Down
42 changes: 39 additions & 3 deletions bmad/modules/bmad_routine_interface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3362,12 +3362,48 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or
logical, optional :: use_matrix_model, include_apertures, err
end subroutine

subroutine write_lattice_in_julia (bmad_name, lat, julia_name)
subroutine write_lattice_in_mad_format (out_type, out_file_name, lat, ref_orbit, use_matrix_model, &
include_apertures, dr12_drift_max, ix_branch, converted_lat, err)
import
implicit none
type (lat_struct), target :: lat
type (lat_struct), optional, target :: converted_lat
type (coord_struct), allocatable, optional :: ref_orbit(:)
real(rp), optional :: dr12_drift_max
integer, optional :: ix_branch
character(*) out_type, out_file_name
logical, optional :: use_matrix_model, include_apertures, err
end subroutine

subroutine write_lattice_in_elegant_format (out_file_name, lat, ref_orbit, use_matrix_model, &
include_apertures, dr12_drift_max, ix_branch, converted_lat, err)
import
implicit none
type (lat_struct), target :: lat
character(*) bmad_name
character(*), optional :: julia_name
type (lat_struct), optional, target :: converted_lat
type (coord_struct), allocatable, optional :: ref_orbit(:)
real(rp), optional :: dr12_drift_max
integer, optional :: ix_branch
character(*) out_file_name
logical, optional :: use_matrix_model, include_apertures, err
end subroutine

subroutine write_lattice_in_sad_format (out_file_name, lat, include_apertures, ix_branch, converted_lat, err)
import
implicit none
type (lat_struct), target :: lat
type (lat_struct), optional, target :: converted_lat
integer, optional :: ix_branch
character(*) out_file_name
logical, optional :: include_apertures, err
end subroutine

subroutine write_lattice_in_julia (julia_name, lat, err_flag)
import
implicit none
type (lat_struct), target :: lat
character(*) :: julia_name
logical, optional :: err_flag
end subroutine

subroutine xsif_parser (xsif_file, lat, make_mats6, digested_read_ok, use_line, err_flag)
Expand Down
6 changes: 5 additions & 1 deletion bmad/modules/bookkeeper_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1080,11 +1080,15 @@ subroutine makeup_super_slave (lat, slave, err_flag)
T_end(4,1) = ks / 2
T_end(2,3) = -ks / 2

call init_ele (sol_quad)

call transfer_ele (slave, sol_quad)
sol_quad%key = sol_quad$
sol_quad%value(ks$) = ks
sol_quad%value(k1$) = k1
sol_quad%value(l$) = l_slave
call set_flags_for_changed_attribute(sol_quad, sol_quad%value(ks$))
call set_flags_for_changed_attribute(sol_quad, sol_quad%value(k1$))
call set_flags_for_changed_attribute(sol_quad, sol_quad%value(l$))
call make_mat6 (sol_quad, branch%param)
T_tot = sol_quad%mat6(1:4,1:4)

Expand Down
2 changes: 1 addition & 1 deletion bmad/output/write_bmad_lattice_file.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

subroutine write_bmad_lattice_file (bmad_file, lat, err, output_form, orbit0)

use write_lat_file_mod, dummy => write_bmad_lattice_file
use write_lattice_file_mod, dummy => write_bmad_lattice_file
use expression_mod, only: end_stack$, variable$, split_expression_string, expression_stack_to_string

implicit none
Expand Down
Loading

0 comments on commit 34fb068

Please sign in to comment.