def test(self):
        c = ShapeBasedConstraint()
        w = Wall(normal=[-1, 0, 0])
        c.shape = w
        # Does the shape parameter return the correct lcass
        self.assertEqual(c.shape.__class__, Wall)
        # Do the sciprt object match
        self.assertEqual(c.shape, w)

        # Different shape
        c.shape = Sphere(radius=1)
        # Test class
        self.assertEqual(c.shape.__class__, Sphere)
        # Test parameter retrieval
        self.assertAlmostEqual(c.shape.radius, 1, places=8)
        with self.assertRaises(RuntimeError):
            c.shape = Wall(thisparameterdoesnotexist=0)
예제 #2
0
    delta_N=1,
    corr_operation="componentwise_product")
acc_mean_variance.update()
acc_time_series.update()
acc_correlator.update()
system.part[0].pos = [1.0, 2.0, 3.0]
acc_mean_variance.update()
acc_time_series.update()
acc_correlator.update()

system.auto_update_accumulators.add(acc_mean_variance)
system.auto_update_accumulators.add(acc_time_series)
system.auto_update_accumulators.add(acc_correlator)

# constraints
system.constraints.add(shape=Sphere(center=system.box_l / 2, radius=0.1),
                       particle_type=17)
system.constraints.add(shape=Wall(normal=[1. / np.sqrt(3)] * 3, dist=0.5))
system.constraints.add(constraints.Gravity(g=[1., 2., 3.]))
system.constraints.add(constraints.HomogeneousMagneticField(H=[1., 2., 3.]))
system.constraints.add(
    constraints.HomogeneousFlowField(u=[1., 2., 3.], gamma=2.3))
pot_field_data = constraints.ElectricPotential.field_from_fn(
    system.box_l, np.ones(3), lambda x: np.linalg.norm(10 * np.ones(3) - x))
checkpoint.register("pot_field_data")
system.constraints.add(
    constraints.PotentialField(field=pot_field_data,
                               grid_spacing=np.ones(3),
                               default_scale=1.6))
vec_field_data = constraints.ForceField.field_from_fn(
    system.box_l, np.ones(3), lambda x: 10 * np.ones(3) - x)