Commit 122d9e38 authored by Domanski, Marian M.'s avatar Domanski, Marian M.

modify lateral transport bc so 0 is center of cell

parent 49309dc7
......@@ -104,31 +104,24 @@ class LateralTransporter(Transporter):
boundary_length = width - diameter
shifted_next_lateral_position = next_position - diameter / 2
shifted_boundary_location = boundary_length
# 0 is center
r_boundary_location = -boundary_length/2 + diameter/2
l_boundary_location = boundary_length/2 - diameter/2
right_of_boundary = shifted_next_lateral_position < 0
left_of_boundary = \
shifted_next_lateral_position > shifted_boundary_location
out_of_bounds = right_of_boundary | left_of_boundary
right_of_boundary = next_position < r_boundary_location
left_of_boundary = next_position > l_boundary_location
if np.any(out_of_bounds):
reflections = np.floor_divide(shifted_next_lateral_position,
shifted_boundary_location)
remainder = np.mod(shifted_next_lateral_position,
shifted_boundary_location)
while np.any(left_of_boundary | right_of_boundary):
reflection_mod_2 = np.mod(reflections, 2)
odd_reflections = (reflection_mod_2 == 1) & out_of_bounds
even_reflections = (reflection_mod_2 == 0) & out_of_bounds
shifted_next_lateral_position[even_reflections] = \
remainder[even_reflections]
shifted_next_lateral_position[odd_reflections] = \
boundary_length[odd_reflections] - remainder[odd_reflections]
next_position[right_of_boundary] = 2 * \
r_boundary_location[right_of_boundary] - \
next_position[right_of_boundary]
next_position[left_of_boundary] = 2 * \
l_boundary_location[left_of_boundary] - \
next_position[left_of_boundary]
next_position = shifted_next_lateral_position + diameter / 2
right_of_boundary = next_position < r_boundary_location
left_of_boundary = next_position > l_boundary_location
return next_position
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment