errors occurs using vtk package

Asked by guo

I am a beginner of esys-particle, and when i changed to vtk model, and also changed the offscreen to false and interactive to true. errors occurs, blew the code following. Could you help me fix it, many thanks.
#bingle_vis.py: A two-particle collision simulation
#
#with visualisation using povray
# Author: D. Weatherley
# Date: 15 May 2007
# Organisation: ESSCC, University of Queensland
# (C) All rights reserved, 2007.
#
#
#import the appropriate ESyS-Particle modules:
from esys.lsm import *
from esys.lsm.util import Vec3, BoundingBox
# from esys.lsm.vis import povray
from esys.lsm.vis import vtk
def snapshot(particles=None, index=0):
 #pkg = povray
 pkg=vtk
 scene = pkg.Scene()
 for pp in particles:
  povsphere = pkg.Sphere(pp.getPosn(), pp.getRadius())
  povsphere.apply(pkg.Colors.Red)
 scene.add(povsphere)
 camera = scene.getCamera()
 camera.setLookAt(Vec3(0,0,0))
 camera.setPosn(Vec3(0,0,20))
 camera.setZoom(0.1)
 scene.render(
  offScreen=False,
  interactive=True,
  fileName="snap_%.4d.png" % (index),
  size=[800,600]
 )
 return
#instantiate a simulation object
#and initialise the neighbour search algorithm:
sim = LsmMpi(numWorkerProcesses=1, mpiDimList=[1,1,1])
sim.initNeighbourSearch(
 particleType="NRotSphere",
 gridSpacing=2.5,
 verletDist=0.5
)
#specify the spatial domain for the simulation:
domain = BoundingBox(Vec3(-20,-20,-20), Vec3(20,20,20))
sim.setSpatialDomain(domain)
#add the first particle to the domain:
particle=NRotSphere(id=0, posn=Vec3(-5,5,-5), radius=1.0, mass=1.0)
particle.setLinearVelocity(Vec3(1.0,-1.0,1.0))
sim.createParticle(particle)
#add the second particle to the domain:
particle=NRotSphere(id=1, posn=Vec3(5,5,5), radius=1.5, mass=2.0)
particle.setLinearVelocity(Vec3(-1.0,-1.0,-1.0))
sim.createParticle(particle)
#specify the type of interactions between colliding particles:
sim.createInteractionGroup(
NRotElasticPrms(
name = "elasticSpheres",
normalK = 10000.0
)
)
#set the number of timesteps and timestep increment:
sim.setNumTimeSteps(10000)
sim.setTimeStepSize(0.001)
#compute the specified number of timesteps:
N_max = sim.getNumTimeSteps()
n=0
while (n < N_max):
 #compute a single timestep:
 sim.runTimeStep()
 # print the particle position to stdout every 100 timesteps:
 if (n%100==0):
  particles = sim.getParticleList()
  snapshot(particles=particles, index=n)
# update the total number of timesteps computed (n):
 n += 1
#Exit the simulation.
sim.exit()

error message:

CSubLatticeControler::initMPI()
Traceback (most recent call last):
  File "bingle_vis2.py", line 14, in <module>
    from esys.lsm.vis import vtk
ImportError: cannot import name vtk

Question information

Language:
English Edit question
Status:
Solved
For:
ESyS-Particle Edit question
Assignee:
No assignee Edit question
Solved by:
guo
Solved:
Last query:
Last reply:
Revision history for this message
guo (kwohoo) said :
#1

i have solved it myself