Skip to content

Commit

Permalink
Use timestep
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Jan 21, 2025
1 parent f5d4f6a commit 17d7a06
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/parakeet/sample/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@


def update_particle_position_and_direction(
position, direction, global_drift, interaction_range, velocity, noise_magnitude
position,
direction,
global_drift,
interaction_range,
velocity,
noise_magnitude,
time_step=1,
):
"""
Update the particle positions and directions using the Vicsek model
Expand All @@ -21,7 +27,7 @@ def update_particle_position_and_direction(
"""

# The time step
dt = 1
dt = time_step

# For the noise draw random samples form a normal distribution
nu = np.random.normal(0, noise_magnitude, size=position.shape[0])
Expand All @@ -40,6 +46,7 @@ def update_particle_position_and_direction(
global_drift = np.array(global_drift)

# Compute the new position of the particle
position = position.copy()
position[:, :2] = position[:, :2] + dt * (
global_drift
+ velocity * np.stack([np.cos(direction), np.sin(direction)], axis=1)
Expand Down

0 comments on commit 17d7a06

Please sign in to comment.