Skip to content

Commit

Permalink
Fix bookkeeping when gen grad field scale is changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSagan committed Sep 27, 2023
1 parent af39c18 commit 1f6ab5c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
1 change: 1 addition & 0 deletions bmad/code/attribute_bookkeeper.f90
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ subroutine attribute_bookkeeper (ele, force_bookkeeping)
if (ele%bookkeeping_state%attributes /= stale$ .and. .not. logic_option(.false., force_bookkeeping)) return

else
call attributes_need_bookkeeping(ele)
if (ele%bookkeeping_state%attributes /= stale$ .and. .not. logic_option(.false., force_bookkeeping)) return

if (ele%lord_status /= not_a_lord$) then
Expand Down
3 changes: 2 additions & 1 deletion bmad/code/lattice_bookkeeper.f90
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ subroutine lattice_bookkeeper (lat, err_flag)
type (branch_struct), pointer :: branch
type (bookkeeping_state_struct), pointer :: stat

real(rp) dval(num_ele_attrib$)
integer i, j

logical, optional :: err_flag
Expand All @@ -58,7 +59,7 @@ subroutine lattice_bookkeeper (lat, err_flag)
branch => lat%branch(i)
do j = 0, branch%n_ele_max
call set_ele_status_stale (branch%ele(j), all_groups$, .false.)
call attributes_need_bookkeeping(branch%ele(j))
call attributes_need_bookkeeping(branch%ele(j), dval)
enddo
enddo
endif
Expand Down
40 changes: 33 additions & 7 deletions bmad/modules/bookkeeper_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1901,16 +1901,42 @@ subroutine attributes_need_bookkeeping (ele, dval)
enddo
endif

if (associated(ele%cartesian_map)) then
do i = 1, size(ele%cartesian_map)
ele%value(check_sum$) = ele%value(check_sum$) + ele%cartesian_map(i)%field_scale
enddo
endif

if (associated(ele%cylindrical_map)) then
do i = 1, size(ele%cylindrical_map)
ele%value(check_sum$) = ele%value(check_sum$) + ele%cylindrical_map(i)%field_scale
enddo
endif

if (associated(ele%gen_grad_map)) then
do i = 1, size(ele%gen_grad_map)
ele%value(check_sum$) = ele%value(check_sum$) + ele%gen_grad_map(i)%field_scale
enddo
endif

if (associated(ele%grid_field)) then
do i = 1, size(ele%grid_field)
ele%value(check_sum$) = ele%value(check_sum$) + ele%grid_field(i)%field_scale
enddo
endif

!

dv = abs(ele%value - ele%old_value)
dv(x1_limit$:y2_limit$) = 0 ! Limit changes do not need bookkeeping
if (present(dval)) dval = dv
if (present(dval)) then
dv = abs(ele%value - ele%old_value)
dv(x1_limit$:y2_limit$) = 0 ! Limit changes do not need bookkeeping
dval = dv

if (all(dv == 0) .and. ele%key /= capillary$) then
ele%bookkeeping_state%attributes = ok$
else
ele%bookkeeping_state%attributes = stale$
if (all(dv == 0) .and. ele%key /= capillary$) then
ele%bookkeeping_state%attributes = ok$
else
ele%bookkeeping_state%attributes = stale$
endif
endif

end subroutine attributes_need_bookkeeping
Expand Down
2 changes: 1 addition & 1 deletion tao/version/tao_version_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
!-

module tao_version_mod
character(*), parameter :: tao_version_date = "2023/09/26 02:26:30"
character(*), parameter :: tao_version_date = "2023/09/26 22:48:47"
end module

0 comments on commit 1f6ab5c

Please sign in to comment.