示例#1
0
def agents_factory(rng, dim, aligned_flag,
                   n=None, rho_0=None,
                   chi=None, onesided_flag=None,
                   tumble_flag=None, p_0=None, tumble_chemo_flag=None,
                   rotation_flag=None, Dr_0=None, rotation_chemo_flag=None,
                   temporal_chemo_flag=None, dt_mem=None, t_mem=None, time=None,
                   spatial_flag=None, v_0=None,
                   periodic_flag=None, L=None, origin_flags=None, obstructor=None,
                   c_field_flag=None, c_field=None):
    if rho_0 is not None:
        try:
            volume_free = obstructor.volume_free
        except AttributeError:
            volume_free = np.product(L)
        n = int(round(rho_0 * volume_free))
    ds = directions_factory(n, dim, aligned_flag=aligned_flag,
                            rng=rng)
    ps = positions_factory(spatial_flag, periodic_flag, n, dim, L,
                           origin_flags, rng, obstructor)
    rudder_sets = rudder_set_factory(temporal_chemo_flag,
                                     ds,
                                     ps, v_0, dt_mem, t_mem, time,
                                     c_field_flag, c_field,
                                     onesided_flag, chi,
                                     tumble_flag, p_0, tumble_chemo_flag,
                                     rotation_flag, Dr_0, dim, rotation_chemo_flag)
    swims = swimmers_factory(spatial_flag, v_0, ds)
    return Agents(ds, ps, rudder_sets, swims)
示例#2
0
 def test_partial_infinite_boundaries(self):
     L = np.array([np.inf, 1.7])
     ps = positions.positions_factory(spatial_flag=True,
                                      periodic_flag=True,
                                      n=self.n, L=L, rng=self.rng)
     dr = self.rng.uniform(-1.0, 1.0, size=ps.r.shape)
     ps.displace(dr)
     r_naive = ps.r_0[:, 0] + dr[:, 0]
     # Check no wrapping along infinite axis
     self.assertTrue(np.allclose(r_naive, ps.r_w[:, 0]))
     self.assertTrue(np.allclose(r_naive, ps.r[:, 0]))
     # Check done wrapping along finite axis
     self.assertTrue(np.all(np.abs(ps.r_w[:, 1]) < L[1] / 2.0))
示例#3
0
 def setUp(self):
     super(TestPeriodicPositions1D, self).setUp()
     self.ps = positions.positions_factory(spatial_flag=True,
                                           periodic_flag=True,
                                           n=self.n, L=self.L,
                                           rng=self.rng)