Exemple #1
0
    def execute(self, obj, event):
        print self.timer_count
        self.textActor.SetInput('Time: %s' % self.timer_count)
        r_vectors = bm.get_boomerang_r_vectors_15(
            self.locations[self.n * TIME_SKIP],
            Quaternion(self.orientations[self.n * TIME_SKIP]))

        for k in range(N_SPHERES):
            self.sources[k].SetCenter(r_vectors[k][0], r_vectors[k][1],
                                      r_vectors[k][2])
        if DRAW_COH:
            coh = bm.calculate_boomerang_coh(
                self.locations[self.n * TIME_SKIP],
                Quaternion(self.orientations[self.n * TIME_SKIP]))
            cod = bm.calculate_boomerang_cod(
                self.locations[self.n * TIME_SKIP],
                Quaternion(self.orientations[self.n * TIME_SKIP]))
            self.coh_source.SetCenter(coh)
            self.cod_source.SetCenter(cod)

        iren = obj
        iren.GetRenderWindow().Render()
        if WRITE:
            self.w2if.Update()
            self.w2if.Modified()
            self.lwr.SetFileName(
                os.path.join('.', 'figures',
                             'frame' + ('%03d' % self.n) + '.png'))
            self.lwr.Write()
        self.timer_count += 0.01 * TIME_SKIP
        self.n += 1
  def execute(self,obj,event):
    print self.timer_count
    self.textActor.SetInput('Time: %s' % self.timer_count)
    r_vectors = bm.get_boomerang_r_vectors_15(
      self.locations[self.n*TIME_SKIP], 
      Quaternion(self.orientations[self.n*TIME_SKIP]))

    for k in range(N_SPHERES):
      self.sources[k].SetCenter(r_vectors[k][0], r_vectors[k][1],
                                r_vectors[k][2])
    if DRAW_COH:
      coh = bm.calculate_boomerang_coh(
        self.locations[self.n*TIME_SKIP], 
        Quaternion(self.orientations[self.n*TIME_SKIP]))
      cod = bm.calculate_boomerang_cod(
        self.locations[self.n*TIME_SKIP], 
        Quaternion(self.orientations[self.n*TIME_SKIP]))
      self.coh_source.SetCenter(coh)
      self.cod_source.SetCenter(cod)

    iren = obj
    iren.GetRenderWindow().Render()
    if WRITE:
      self.w2if.Update()
      self.w2if.Modified()
      self.lwr.SetFileName(os.path.join(
          '.', 'figures',
          'frame'+ ('%03d' % self.n)+'.png'))
      self.lwr.Write()
    self.timer_count += 0.01*TIME_SKIP
    self.n += 1
def calculate_boomerang_parallel_mobility_coh(n_samples, sample_file):
    ''' 
  Calculate the boomerang parallel mobility by taking GB samples from
  file and averaging.
  '''
    parallel_mobility = 0.
    with open(sample_file, 'r') as f:
        line = f.readline()
        # Skip parameters.
        while line != 'Location, Orientation:\n':
            line = f.readline()
        for k in range(n_samples):
            sample = bm.load_equilibrium_sample(f)
            cod = bm.calculate_boomerang_cod(sample[0], sample[1])
            mobility = bm.boomerang_mobility_at_arbitrary_point([sample[0]],
                                                                [sample[1]],
                                                                cod)
            parallel_mobility += mobility[0, 0] + mobility[1, 1]

    parallel_mobility /= (2 * n_samples)
    return parallel_mobility
def calculate_boomerang_parallel_mobility_coh(n_samples, sample_file):
  ''' 
  Calculate the boomerang parallel mobility by taking GB samples from
  file and averaging.
  '''
  parallel_mobility = 0.
  with open(sample_file, 'r') as f:
    line = f.readline()
    # Skip parameters. 
    while line != 'Location, Orientation:\n':
      line = f.readline()
    for k in range(n_samples):
      sample = bm.load_equilibrium_sample(f)
      cod = bm.calculate_boomerang_cod(sample[0], sample[1])
      mobility = bm.boomerang_mobility_at_arbitrary_point(
        [sample[0]], [sample[1]],
        cod)
      parallel_mobility += mobility[0, 0] + mobility[1, 1]
    
  parallel_mobility /= (2*n_samples)
  return parallel_mobility
Exemple #5
0
    blob_sources = []
    for k in range(N_SPHERES):
        blob_sources.append(vtk.vtkSphereSource())
        blob_sources[k].SetCenter(initial_r_vectors[0][0],
                                  initial_r_vectors[0][1],
                                  initial_r_vectors[0][2])
        blob_sources[k].SetRadius(bm.A)

    if DRAW_COH:
        coh_source = vtk.vtkSphereSource()
        coh_point = bm.calculate_boomerang_coh(locations[0],
                                               Quaternion(orientations[0]))
        coh_source.SetCenter(coh_point)
        coh_source.SetRadius(0.1)
        cod_source = vtk.vtkSphereSource()
        cod_point = bm.calculate_boomerang_cod(locations[0],
                                               Quaternion(orientations[0]))
        cod_source.SetCenter(coh_point)
        cod_source.SetRadius(0.1)

    wall_source = vtk.vtkCubeSource()
    wall_source.SetCenter(0., 0., -0.125)
    wall_source.SetXLength(10.)
    wall_source.SetYLength(10.)
    wall_source.SetZLength(0.25)

    #Create a blob mappers and blob actors
    blob_mappers = []
    blob_actors = []
    for k in range(N_SPHERES):
        blob_mappers.append(vtk.vtkPolyDataMapper())
        blob_mappers[k].SetInputConnection(blob_sources[k].GetOutputPort())
  blob_sources = []
  for k in range(N_SPHERES):
    blob_sources.append(vtk.vtkSphereSource())
    blob_sources[k].SetCenter(initial_r_vectors[0][0],
                              initial_r_vectors[0][1],
                              initial_r_vectors[0][2])
    blob_sources[k].SetRadius(bm.A)

  if DRAW_COH:
    coh_source = vtk.vtkSphereSource()
    coh_point = bm.calculate_boomerang_coh(
      locations[0], Quaternion(orientations[0]))
    coh_source.SetCenter(coh_point)
    coh_source.SetRadius(0.1)
    cod_source = vtk.vtkSphereSource()
    cod_point = bm.calculate_boomerang_cod(
      locations[0], Quaternion(orientations[0]))
    cod_source.SetCenter(coh_point)
    cod_source.SetRadius(0.1)

  wall_source = vtk.vtkCubeSource()
  wall_source.SetCenter(0., 0., -0.125)
  wall_source.SetXLength(10.)
  wall_source.SetYLength(10.)
  wall_source.SetZLength(0.25)

  #Create a blob mappers and blob actors
  blob_mappers = []
  blob_actors = []
  for k in range(N_SPHERES):
    blob_mappers.append(vtk.vtkPolyDataMapper())
    blob_mappers[k].SetInputConnection(blob_sources[k].GetOutputPort())