示例#1
0
文件: view_model.py 项目: Satbek/kttm
 def setSolver(self, action):
     solver_name = action.text()
     logging.info("Set {0} solver".format(solver_name))
     if solver_name == "Simple Verle":
         self.solver = model.VerleSimpleSolver(time_step=self.time_step)
     elif solver_name == "ODEINT":
         self.solver = model.OdeintSolver(time_step=self.time_step)
     self.restartParticleProcessor()
示例#2
0
def test_VerleSimpleSolver_solve(particles):
    solver = model.VerleSimpleSolver(time_step=1, G=1)
    result = solver.solve(particles, 10)
    assert result[0] == particles
    assert result[1][0].x == 1.5
    assert result[1][0].y == 1.5

    assert result[1][1].x == 4.5
    assert result[1][1].y == 4.5

    assert result[1][2].x == 1.375
    assert result[1][2].y == 1.375
示例#3
0
def test_life_time(particles):
    time_interval = 10
    time_step = np.round(random.random(), 2)
    solvers = [
        model.OdeintSolver(time_step=time_step, G=1),
        model.VerleSimpleSolver(time_step=time_step, G=1)
    ]
    for solver in solvers:
        result = solver.solve(particles, time_interval)
        count = len(solver._get_times(time_interval))
        assert len(result) == count
        assert result[count - 1][0].life_time - time_step < time_step and \
            result[count - 1][1].life_time - time_step < 0 and \
            result[count - 1][2].life_time - time_step < 0

        life_time = result[0][0].life_time
        for i, particles in enumerate(result):
            assert particles[0].life_time == life_time - i * solver.time_step
示例#4
0
文件: view_model.py 项目: Satbek/kttm
 def setup(self):
     self.emitter = Emitter(10, 0, (10, 40))
     self.q_in_particles = queue.Queue()
     self.scene().addItem(self.emitter)
     self.time_step = 0.1
     self.time_interval = 1
     self.anim_time = self.time_step * 10**3
     self.solver = model.VerleSimpleSolver(time_step=self.time_step)
     self.scale_factor = 1
     self.particles = []
     self.particle_processor = ParticleProcessor(
         solver=self.solver,
         time_interval=self.time_interval,
         q_in=self.q_in_particles,
     )
     self.particle_processor.send_particles_signal.connect(
         self.applyAnimation)
     self.anim_group = QtCore.QSequentialAnimationGroup()
     self.anim_group.finished.connect(self.resetAnimation)
     self.anim_group.setLoopCount(1)
示例#5
0
def test_getAccelerations(particles):
    solver = model.VerleSimpleSolver(time_step=1, G=1)
    assert solver._getAccelerations(particles) == [[3, 3], [7, 7],
                                                   [-1.25, -1.25]]