Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove leftover tuple conversions #59

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/MicrobeAgents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ microbe type lives (1, 2 and 3 are supported).

All microbe types *must* have at least the following fields:
- `id::Int` id of the microbe (used internally by Agents.jl)
- `pos::NTuple{D,Float64}` position of the microbe
- `vel::NTuple{D,Float64}` velocity of the microbe
- `pos::SVectpr{D,Float64}` position of the microbe
- `vel::SVector{D,Float64}` velocity of the microbe
- `motility::AbstractMotility` motile pattern of the microbe
- `turn_rate::Real` average reorientation rate of the microbe
- `rotational_diffusivity::Real` coefficient of brownian rotational diffusion
Expand Down
6 changes: 2 additions & 4 deletions src/rotations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function turn!(microbe::AbstractMicrobe, model)
# extract new speed and rotation angles
U₁, θ, ϕ = rand(abmrng(model), microbe.motility)
# reorient and update speed
microbe.vel = Tuple(rotate(v, θ, ϕ))
microbe.vel = rotate(v, θ, ϕ)
microbe.speed = U₁
# switch motile state (does nothing if motility is one-step)
switch!(microbe.motility)
Expand All @@ -21,12 +21,10 @@ function rotational_diffusion!(microbe::AbstractMicrobe, model)
σ = sqrt(2*D_rot*dt)
θ = rand(abmrng(model), Normal(0,σ))
ϕ = rand(abmrng(model), Arccos())
microbe.vel = Tuple(rotate(microbe.vel, θ, ϕ))
microbe.vel = rotate(microbe.vel, θ, ϕ)
nothing
end

rotate(w::Tuple, θ, ϕ) = rotate(SVector(w), θ, ϕ)

"""
rotate(w::SVector{D}, θ, ϕ) where D
Rotate `D`-dimensional vector `w` by angles `θ` and `ϕ`.
Expand Down
Loading