Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSagan committed May 18, 2024
2 parents bbf5191 + 4879120 commit 194ef65
Show file tree
Hide file tree
Showing 21 changed files with 13,452 additions and 25,325 deletions.
32 changes: 12 additions & 20 deletions bmad/low_level/calc_super_slave_key.f90
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,28 @@ subroutine calc_super_slave_key (lord1, lord2, slave, create_jumbo_slave)
! * If one element is a drift then slave%key = key of other element.
! * Control elements, etc. cannot be superimposed.


select case (key1)
case (overlay$, group$, girder$, taylor$, match$, patch$, fiducial$, floor_shift$, multipole$, ab_multipole$, sbend$, rf_bend$); return
end select

select case (key2)
case (overlay$, group$, girder$, taylor$, match$, patch$, fiducial$, floor_shift$, multipole$, ab_multipole$, sbend$, rf_bend$); return
end select

select case (key1)
case (drift$)
case (drift$, pipe$)
slave%key = key2
if (key1 == pipe$ .and. key2 == drift$) slave%key = pipe$
slave%sub_key = lord2%sub_key
return
case (overlay$, group$, girder$, taylor$, match$, patch$, fiducial$, floor_shift$, multipole$, ab_multipole$, sbend$, rf_bend$)
return
end select

select case (key2)
case (drift$)
case (drift$, pipe$)
slave%key = key1
slave%sub_key = lord1%sub_key
return
case (overlay$, group$, girder$, taylor$, match$, patch$, fiducial$, floor_shift$, multipole$, ab_multipole$, sbend$, rf_bend$)
return
end select

! If there are misalignments then no superposition is possible
Expand Down Expand Up @@ -104,20 +110,6 @@ subroutine calc_super_slave_key (lord1, lord2, slave, create_jumbo_slave)
return
endif

! If one element is a pipe then slave%key = key of other element.

if (any(key1 == [pipe$])) then
slave%key = key2
slave%sub_key = lord2%sub_key
return
endif

if (any(key2 == [pipe$])) then
slave%key = key1
slave%sub_key = lord1%sub_key
return
endif

! If one element is a rcollimator, monitor, or instrument then slave%key = key of other element.

if (lord1%aperture_type == elliptical$ .or. lord2%aperture_type == elliptical$ ) slave%aperture_type = elliptical$
Expand Down
10 changes: 9 additions & 1 deletion bsim/aperture_by_tracking/aperture_by_tracking_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,21 @@ SUBROUTINE binary_search(lost,delta_m,accuracy,reset) !updates delta_m according
accuracy = ABS(last_high-last_low)/MIN(ABS(last_high),ABS(last_low))
ENDIF

! Check for extreme values. If the aperture is larger then 100%, record 100% and move on.
! Check for extreme values.
! If the aperture is larger then 100%, record 100% and move on.
IF(ABS(delta_m) .gt. 1.0) THEN
accuracy = 0.0
!The next two lines result in 1.0 being recorded as the aperture for this location.
last_high = 1.1_rp
last_low = 0.9_rp
ENDIF
! If the aperture is smaller then 1e-6, record 0% and move on.
IF(ABS(delta_m) .lt. 1.0e-6) THEN
accuracy = 0.0
!The next two lines result in 1e-6 being recorded as the aperture for this location.
last_high = 2.0d-6
last_low = 0.0d0
ENDIF
ENDIF
END SUBROUTINE binary_search

Expand Down
4 changes: 2 additions & 2 deletions bsim/aperture_by_tracking/aperture_by_tracking_mpi_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ SUBROUTINE mympi_initialize(master)
CALL mpi_comm_size(MPI_COMM_WORLD,cluster_size,mpierr)
nslave=cluster_size-1
IF(nslave .eq. 0) THEN
WRITE(*,*) "ERROR: no slaves found in cluster. At least two nodes"
WRITE(*,*) "must be available to run this program."
WRITE(*,*) "ERROR: this code must be run with mpi with at least 2 nodes."
WRITE(*,*) "try the following: mpirun -n 2 aperture_by_tracking aperture_by_tracking.in"
STOP
ENDIF
ENDIF
Expand Down
Loading

0 comments on commit 194ef65

Please sign in to comment.