Skip to content

Commit

Permalink
Merge pull request #623 from bmad-sim/devel/50
Browse files Browse the repository at this point in the history
Fix field_master toggle for multipole and ab_multipole elements.
  • Loading branch information
DavidSagan authored Nov 6, 2023
2 parents 4bf61a4 + b1941fc commit b3f0bf2
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions bmad/modules/changed_attribute_bookkeeper.f90
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,37 @@ subroutine set_flags_for_changed_logical_attribute (ele, attrib, set_dependent)

integer i

real(rp) dummy
real(rp) dummy, f

logical, target :: attrib
logical, pointer :: a_ptr
logical, optional :: set_dependent

! Call to set_flags_for_changed_real_attribute will set some generic flags

call set_flags_for_changed_real_attribute (ele, dummy, set_dependent)

a_ptr => attrib
if (associated(a_ptr, ele%field_master)) then
f = ele%value(p0c$) / (charge_of(ele%ref_species) * c_light)
if (ele%key == multipole$) then
if (attrib) then
ele%a_pole = ele%a_pole * f
else
ele%a_pole = ele%a_pole / f
endif

elseif (ele%key == ab_multipole$) then
if (attrib) then
ele%a_pole = ele%a_pole * f
ele%b_pole = ele%b_pole * f
else
ele%a_pole = ele%a_pole / f
ele%b_pole = ele%b_pole / f
endif
endif

else
call set_flags_for_changed_real_attribute (ele, dummy, set_dependent)
endif

! Set independent stuff in multipass lord

Expand Down

0 comments on commit b3f0bf2

Please sign in to comment.