Skip to content

Commit

Permalink
rename cwbias to tumblebias and only take microbe as input
Browse files Browse the repository at this point in the history
  • Loading branch information
mastrof committed Dec 28, 2023
1 parent 4053ddc commit 0daee90
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/api.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export position, direction, speed, velocity, motilepattern,
turnrate, rotational_diffusivity, radius, state,
cwbias,
tumblebias,
distance, distancevector

Base.position(m::AbstractMicrobe) = m.pos
Expand Down
2 changes: 1 addition & 1 deletion src/chemotaxis/brown-berg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function affect!(microbe::BrownBerg, model)
chemotaxis!(microbe, model)
end

function cwbias(microbe::BrownBerg, model)
function tumblebias(microbe::BrownBerg)
g = microbe.gain
S = microbe.state
return exp(-g*S)
Expand Down
2 changes: 1 addition & 1 deletion src/chemotaxis/brumley.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function affect!(microbe::Brumley, model)
chemotaxis!(microbe, model)
end

function cwbias(microbe::Brumley, model)
function tumblebias(microbe::Brumley)
Γ = microbe.gain
S = microbe.state
return (1 + exp(-Γ*S))/2
Expand Down
2 changes: 1 addition & 1 deletion src/chemotaxis/celani.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function affect!(microbe::Celani, model)
chemotaxis!(microbe, model)
end

function cwbias(microbe::Celani, model)
function tumblebias(microbe::Celani)
β = microbe.gain
S = microbe.state
return (1 - β*S)
Expand Down
4 changes: 2 additions & 2 deletions src/chemotaxis/xie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function affect!(microbe::Xie, model)
chemotaxis!(microbe, model)
end

function cwbias(microbe::Xie, model)
function tumblebias(microbe::Xie)
S = state(microbe)
if state(motilepattern(microbe)) == Forward
β = microbe.gain_forward
Expand All @@ -94,7 +94,7 @@ function cwbias(microbe::Xie, model)
return (1 + β*S)
end

function turnrate(microbe::Xie, model)
function turnrate(microbe::Xie)
if state(motilepattern(microbe)) == Forward
return microbe.turn_rate_forward
else
Expand Down
13 changes: 4 additions & 9 deletions src/microbe_step.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function microbe_step!(microbe::AbstractMicrobe, model)
# update microbe state
affect!(microbe, model)
# evaluate instantaneous turn rate
ω = turnrate(microbe, model)
ω = turnrate(microbe) * tumblebias(microbe)
if rand(abmrng(model)) < ω * dt # if true reorient microbe
turn!(microbe, model)
end
Expand All @@ -39,20 +39,15 @@ function microbe_pathfinder_step!(microbe::AbstractMicrobe, model)
# update microbe state
affect!(microbe, model)
# evaluate instantaneous turn rate
ω = turnrate(microbe, model)
ω = turnrate(microbe) * tumblebias(microbe)
if rand(abmrng(model)) < ω * dt # if true reorient microbe
turn!(microbe, model)
end
nothing
end

"""
turnrate(microbe, model)
Evaluate instantaneous turn rate of `microbe`.
"""
turnrate(microbe::AbstractMicrobe, model) = turnrate(microbe) * cwbias(microbe, model)
# no CW bias for generic non-chemotactic microbe
cwbias(microbe::AbstractMicrobe, model) = 1.0
# no bias for generic non-chemotactic microbe
tumblebias(microbe::AbstractMicrobe) = 1.0
"""
affect!(microbe, model)
Can be used to arbitrarily update `microbe` state.
Expand Down
4 changes: 2 additions & 2 deletions test/model-creation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ using LinearAlgebra: norm
fieldnames(T)
)

φ(microbe, model) = turnrate(microbe) * cwbias(microbe, model)
φ(microbe, model) = turnrate(microbe) * tumblebias(microbe)
if T == BrownBerg
@test φ(m, model) == m.turn_rate * exp(-m.gain*m.state)
elseif T == Brumley
Expand All @@ -96,7 +96,7 @@ using LinearAlgebra: norm
S = m.state
ω = m.turn_rate_forward
β = m.gain_forward
@test turnrate(m, model) == ω * (1 + β*S)
@test turnrate(m) == ω * (1 + β*S)
end
end
end
Expand Down

0 comments on commit 0daee90

Please sign in to comment.