コード例 #1
0
 def test_pressure_round(self):
     dx = 0.0001
     dy = 0.0001
     Sim = mr_sim.create_simulation(mr_sim.Round, mr_sim.ConstantCurvature)
     sim = Sim(0.2,
               0.2,
               kx=0.2,
               ky=0.4,
               stiffness=1e7,
               dx=dx,
               dy=dy,
               radius=0.05)
     shape = sim.shape(sim.X, sim.Y)
     p = sim.pressure(sim.X, sim.Y)
     self.assertAlmostEqual(np.sum(p) * dx * dy, sim.force)
     self.assertFalse(np.any(p[~shape] != 0))
     sim.set_force(5)
     p = sim.pressure(sim.X, sim.Y)
     self.assertAlmostEqual(np.sum(p) * dx * dy, sim.force, 6)
     self.assertFalse(np.any(p[~shape] != 0))
     sim.set_force(20)
     p = sim.pressure(sim.X, sim.Y)
     self.assertAlmostEqual(np.sum(p) * dx * dy, sim.force, 6)
     self.assertFalse(np.any(p[~shape] != 0))
     sim.set_force(60)
     p = sim.pressure(sim.X, sim.Y)
     self.assertAlmostEqual(np.sum(p) * dx * dy, sim.force, 2)
     self.assertFalse(np.any(p[~shape] != 0))
コード例 #2
0
ファイル: test_util.py プロジェクト: CameronDevine/mr_sim
    def test_create(self):
        class A:
            a = 1

        class B:
            b = 2

        class C:
            c = 3

        Test = mr_sim.create_simulation(A, B)
        test = Test()
        self.assertEqual(test.a, 1)
        self.assertEqual(test.b, 2)
        self.assertFalse(hasattr(test, "c"))
        Test = mr_sim.create_simulation(A, B, C)
        test = Test()
        self.assertEqual(test.a, 1)
        self.assertEqual(test.b, 2)
        self.assertEqual(test.c, 3)
コード例 #3
0
 def test_pressure_flat(self):
     Sim = mr_sim.create_simulation(mr_sim.Round, mr_sim.ConstantCurvature)
     sim = Sim(0.2,
               0.2,
               kx=0,
               ky=0,
               stiffness=1e7,
               dx=0.0001,
               dy=0.0001,
               radius=0.05)
     sim.set_force(5)
     p = sim.pressure(sim.X, sim.Y)
     self.assertTrue(np.allclose(p[p > 0], sim.force / sim.area))
コード例 #4
0
 def test_pressure(self):
     Sim = mr_sim.create_simulation(mr_sim.Flat, mr_sim.Rectangular)
     flat = Sim(1, 1, width=2, height=1.5)
     flat.set_force(6)
     flat.set_torque(-2, 3)
     pressure = flat.pressure(flat.X, flat.Y)
     self.assertTrue(
         np.allclose(
             pressure,
             flat.force / flat.area + flat.X * 3 / flat.Iy -
             flat.Y * -2 / flat.Ix,
         ))
     self.assertGreater(pressure[0, -1], pressure[0, 0])
     self.assertGreater(pressure[-1, 0], pressure[0, 0])
コード例 #5
0
ファイル: example2.py プロジェクト: CameronDevine/mr_sim
from context import mr_sim
import numpy as np
from hilbertcurve.hilbertcurve import HilbertCurve
import matplotlib.pyplot as plt

R = 0.1
spacing = 1.75 * R
velocity = 0.1
dt = 0.05

Simulation = mr_sim.create_simulation(mr_sim.Round, mr_sim.Flat, mr_sim.Rotary,
                                      mr_sim.Preston)

curve = HilbertCurve(3, 2)

points = np.array(
    [curve.coordinates_from_distance(d) for d in range(curve.max_h + 1)],
    np.float)
points -= curve.max_x / 2
points *= spacing

t_final = curve.max_h * spacing / velocity
point_times = np.linspace(0, t_final, points.shape[0])
t = np.arange(0, t_final, dt)

path = np.vstack(
    (np.interp(t, point_times,
               points[:, 0]), np.interp(t, point_times, points[:, 1]))).T

size = spacing * curve.max_x + 2 * R
コード例 #6
0
from context import mr_sim
import numpy as np
import matplotlib.pyplot as plt

R = 3.5 / 2 * 25.4 / 1000
length = 208 / 1000
period = 0.2 * 20
dt = period / 1000
dt = dt / 4
amp = length / 2

Simulation = mr_sim.create_simulation(mr_sim.Round, mr_sim.Flat,
                                      mr_sim.Orbital, mr_sim.Preston)

simulation = Simulation(
    length + 2 * R,
    2 * R,
    kp=1.362e-9,
    radius=R,
    eccentricity=0.1875 * 25.4 / 1000,
    dt=dt,
    auto_velocity=True,
)

simulation.set_speed(620)
simulation.set_force(15)

for t in np.arange(0, period / 2, dt):
    simulation.set_location(amp * np.cos(2 * t * np.pi / period))
    simulation.step()