Skip to content

Commit

Permalink
update constructors in all examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mastrof committed Sep 28, 2024
1 parent a4f5a2e commit 6415fdb
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/src/examples/Chemotaxis/1_linear_ramp.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ for i in 1:n
p0 = spacesize(model) ./ 2
delta = rand(abmrng(model), SVector{2}) .* 10
pos = p0 .+ delta # random scatter around center
motility = RunTumble(0.67, [30.0], Isotropic(2), 0.1)
motility = RunTumble([30.0], 0.67, Isotropic(2); tumble_duration=0.1)
add_agent!(pos, model; motility)
end
model
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/Chemotaxis/2_celani_gauss2D.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ properties = Dict(
)
model = StandardABM(Celani{2,2}, space, timestep; properties)
motility = RunTumble(0.67, [30.0], Isotropic(2), 0.1)
motility = RunTumble([30.0], 0.67, Isotropic(2); tumble_duration=0.1)
for _ in 1:300
add_agent!(model; motility,
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/Chemotaxis/3_xie_response-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ we suppress their tumbles, and (just for total consistency with experiments)
we also set their speed to 0.

````@example 3_xie_response-function
add_agent!(model; motility=RunReverseFlick(Inf, [0], 0.0, [0]))
add_agent!(model; motility=RunReverseFlick(0.0, [0], Inf, [0]))
add_agent!(model; motility=RunReverseFlick([0], Inf, [0], 0.0))
add_agent!(model; motility=RunReverseFlick([0], Inf, [0], 0.0))
model[2].motility.current_state = 3 # manually set to backward run state
````

Expand Down
6 changes: 3 additions & 3 deletions docs/src/examples/Chemotaxis/4_response_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ properties = Dict(
model = StandardABM(Union{BrownBerg{3},Celani{3}}, space, dt; properties)
add_agent!(BrownBerg{3}, model; motility=RunTumble(1.0, [0], Isotropic(3)),
add_agent!(BrownBerg{3}, model; motility=RunTumble([0], 1.0, Isotropic(3)),
memory=1,
)
add_agent!(Celani{3}, model; motility=RunTumble(1.0, [0], Isotropic(3)), gain=4)
add_agent!(Celani{3}, model; motility=RunTumble(1.0, [0], Isotropic(3)), gain=4,
add_agent!(Celani{3}, model; motility=RunTumble([0], 1.0, Isotropic(3)), gain=4)
add_agent!(Celani{3}, model; motility=RunTumble([0], 1.0, Isotropic(3)), gain=4,
chemotactic_precision=50.0
)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/Chemotaxis/5_drift_exponential.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ n = 200
for Π in Πs
for i in 1:n
pos = SVector{3}(0.0, rand()*Ly, rand()*Lz)
motility = RunReverseFlick(0.45, [46.5], 0.45, [46.5])
motility = RunReverseFlick([46.5], 0.45, [46.5], 0.45)
add_agent!(pos, model; chemotactic_precision=Π, motility)
end
end
Expand Down
9 changes: 5 additions & 4 deletions docs/src/examples/RandomWalks/1_randomwalk1D.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,23 @@ from position `(0,)`.

Moreover, it's always required to specify the motility of the microbes via
the keyword argument `motility`.
For example, `RunTumble` needs as inputs the average duration of runs,
the distribution of run speeds and the distribution of reorientation angles.
For example, `RunTumble` needs as inputs the distribution of run speed,
the average run duration and the distribution of reorientation angles.
The latter is irrelevant in 1D, since the bacterium can only revert its
direction along the line, but we still have to pass it.
We can just use an empty vector.
Passing a one-element vector `[U]` as the speed distribution
means that all runs will have the same velocity `U`.
We could have also specified the average duration of tumbles
(equal to reversals in 1 dimension) via an optional 4th argument (try it! e.g. 0.5);
(equal to reversals in 1 dimension) via a keyword argument
`tumble_duration`.
when unspecified, the tumbles are taken to be instantaneous.

````@example 1_randomwalk1D
n = 10 # number of microbes to add
τ_run = 1.0 # average run duration in s
U = 30.0 # swimming speed in μm/s
motility = RunTumble(τ_run, [U], [], 0.5)
motility = RunTumble([U], τ_run, []; tumble_duration=0.2)
foreach(_ -> add_agent!((0,), model; motility), 1:n)
````

Expand Down
10 changes: 5 additions & 5 deletions docs/src/examples/RandomWalks/2_randomwalk2D_motilepatterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ The motile pattern can be customized through the `motility` keyword.

The `RunTumble` motility consists of straight runs interspersed with
reorientations (tumbles).
With the first argument, we set the average duration of tumbles, 1 s in this case.
We can then define the speed to follow a a `Normal` distribution
With the first argument, we set the speed to follow a a `Normal` distribution
(from Distributions.jl) with mean 30 μm/s and standard deviation 6 μm/s.
This means that, after every tumble, the microbe will change its speed following
this distribution.
With the second argument, we set the average duration of tumbles, 1 s in this case.
We should then specify the distribution of angular reorientations.
For convenience, MicrobeAgents implements an `Isotropic` function
which produces the appropriate distribution to have isotropic reorientations
Expand All @@ -38,7 +38,7 @@ of angles between -π and +π.
Finally, we can set tumbles to also have a finite duration, let's say 0.1 s.

````@example 2_randomwalk2D_motilepatterns
add_agent!(model; motility=RunTumble(1.0, Normal(30,6), Isotropic(2), 0.1))
add_agent!(model; motility=RunTumble(Normal(30,6), 1.0, Isotropic(2); tumble_duration=0.1))
````

The `RunReverse` motility consists of alternating straight runs and 180-degree reversals.
Expand All @@ -53,7 +53,7 @@ rotational diffusion, the run reverse motility is pathologically incapable of
exploring space efficiently.

````@example 2_randomwalk2D_motilepatterns
add_agent!(model; motility=RunReverse(1.0, [30.0], 0.7, [20.0]), rotational_diffusivity=0.2)
add_agent!(model; motility=RunReverse([30.0], 1.0, [20.0], 0.7), rotational_diffusivity=0.2)
````

The `RunReverseFlick` motility consists of a straight run, a 180-degree reversal, then another
Expand All @@ -64,7 +64,7 @@ Again, we will set only run durations and speeds.
We also set the rotational diffusivity to 0.1 rad²/s.

````@example 2_randomwalk2D_motilepatterns
add_agent!(model; motility=RunReverseFlick(2.0, [25.0], 0.5, [25.0]), rotational_diffusivity=0.1)
add_agent!(model; motility=RunReverseFlick([25.0], 2.0, [25.0], 0.5), rotational_diffusivity=0.1)
````

Now we can run (collecting the microbe positions at each timestep), unfold the trajectories,
Expand Down
6 changes: 3 additions & 3 deletions docs/src/examples/RandomWalks/3_randomwalk3D.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ space = ContinuousSpace((L,L,L))
dt = 0.1
model = StandardABM(Microbe{3}, space, dt)
add_agent!(model; motility=RunReverse(1.0, [55], 1.0, [55]), rotational_diffusivity=0.2)
add_agent!(model; motility=RunTumble(2.0, Normal(30,6), Isotropic(3)))
add_agent!(model; motility=RunReverseFlick(1.0, [30], 1.0, [6]), rotational_diffusivity=0.1)
add_agent!(model; motility=RunReverse([55], 1.0, [55], 1.0), rotational_diffusivity=0.2)
add_agent!(model; motility=RunTumble(Normal(30,6), 2.0, Isotropic(3)))
add_agent!(model; motility=RunReverseFlick([30], 1.0, [6], 1.0), rotational_diffusivity=0.1)
nsteps = 600
adata = [position]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/validation/msd_runtumble.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ U = 30.0 # μm/s
models = map(_ -> StandardABM(Microbe{3}, space, dt; container=Vector), θs)
nmicrobes = 100
for (i,θ) in enumerate(θs)
motility = RunTumble(τ, [U], [θ,-θ])
motility = RunTumble([U], τ, [θ,-θ])
foreach(_ -> add_agent!(models[i]; motility), 1:nmicrobes)
end
Expand Down
4 changes: 2 additions & 2 deletions docs/src/validation/velocity_autocorrelations.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ model = StandardABM(Microbe{3}, space, Δt; container=Vector)
n = 200
for Mot in (RunTumble, RunReverse, RunReverseFlick), i in 1:n
if Mot == RunTumble
motility = RunTumble(τ_run, [U], Isotropic(3), 0.0)
motility = RunTumble([U], τ_run, Isotropic(3))
else
motility = Mot(τ_run, [U], τ_run, [U])
motility = Mot([U], τ_run, [U], τ_run)
end
add_agent!(model; motility)
end
Expand Down

0 comments on commit 6415fdb

Please sign in to comment.