-
Notifications
You must be signed in to change notification settings - Fork 2
/
SimulatePassiveBM.m
24 lines (21 loc) · 1.1 KB
/
SimulatePassiveBM.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function passiveStats = SimulatePassiveBM(simStats, stats)
passiveStats.nAgents = stats.nAgents;
passiveStats.speed = 0;
passiveStats.netphi = stats.netphi;
passiveStats.x = zeros(stats.nAgents, simStats.stepCount);
passiveStats.y = zeros(stats.nAgents, simStats.stepCount);
passiveStats.v = zeros(stats.nAgents, simStats.stepCount);
passiveStats.v(:,1) = stats.v(:,1);
passiveStats.dx = zeros(stats.nAgents, simStats.stepCount);
passiveStats.dy = zeros(stats.nAgents, simStats.stepCount);
passiveStats.dv = zeros(stats.nAgents, simStats.stepCount);
DT = mean(stats.DTeff);
for i = 2:simStats.stepCount
passiveStats.dx(:,i) = sqrt(2*DT*simStats.deltaT)*randn(stats.nAgents,1);
passiveStats.dy(:,i) = sqrt(2*DT*simStats.deltaT)*randn(stats.nAgents,1);
passiveStats.v(:,i) = atan2(passiveStats.dy(:,i), passiveStats.dx(:,i));
passiveStats.dv(:,i) = mod(passiveStats.v(:,i) - passiveStats.v(:,i-1), 2*pi);
passiveStats.x(:,i) = passiveStats.x(:,i-1) + passiveStats.dx(:,i);
passiveStats.y(:,i) = passiveStats.y(:,i-1) + passiveStats.dy(:,i);
end
passiveStats = GetDiffusionStats(simStats, passiveStats);