ImportError: cannot import name povray

Asked by Temitope

Hi there,

I am running Esys_particle from flash driving and have made a considerable progress with the tutorial. However I am getting an error message for the povray part. Please see the response from the terminal and my script

Response from terminal:

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@ubuntu:~$ export PATH=/usr/local/bin/:$PATH
ubuntu@ubuntu:~$ export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
ubuntu@ubuntu:~$
ubuntu@ubuntu:~$ export LIBRARY_PATH=/usr/local/lib/:$LIBRARY_PATH
ubuntu@ubuntu:~$
ubuntu@ubuntu:~$ export PYTHONPATH=/usr/local/lib/python2.7/site-packages/:$PYTHONPATH
ubuntu@ubuntu:~$ cd /home/ubuntu/Desktop/Esys_tutorial
ubuntu@ubuntu:~/Desktop/Esys_tutorial$ mpirun -np 2 /usr/local/bin/esysparticle bingle_vis.py
CSubLatticeControler::initMPI()
Traceback (most recent call last):
  File "bingle_vis.py", line 3, in <module>
    from esys.lsm.vis import povray
ImportError: cannot import name povray

My script:

from esys.lsm import *
from esys.lsm.util import Vec3, BoundingBox
from esys.lsm.vis import povray

def snapshot(particles=None, index=0):
 pkg = povray

 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=True,
  interactive=False,
  fileName="snap_%.4d.png" % (index),
  size=[800,600]
 )
 return

sim = LsmMpi(numWorkerProcesses=1, mpiDimList=[1,1,1])
sim.initNeighbourSearch (
   particleType="NRotSphere",
   gridSpacing=2.5,
   verletDist=0.5
)
sim.setNumTimeSteps (10000)
sim.setTimeStepSize(0.001)

# specify the spatial domain#
sim.setSpatialDomain (
   BoundingBox(Vec3(-20,-20,-20), Vec3(20,20,20))
)

#particle creation and initialisation#
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 a second particle to the simulation object
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)

#defining interraction between particles using the linear elastic repulsion
sim.createInteractionGroup(
 NRotElasticPrms (
  name = "elastic_repulsion",
  normalK = 10000.0
 )
)

#outputing data
N_max = sim.getNumTimeSteps()
for n in range (N_max):
 sim.runTimeStep()

 if (n%100==0):
  particles = sim.getParticleList()
  snapshot(particles=particles, index=n)

sim.exit()

Please help !

Kind regards
Tope

Question information

Language:
English Edit question
Status:
Answered
For:
ESyS-Particle Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

Revision history for this message
Dion Weatherley (d-weatherley) said :
#1

Hi Tope,

It is possible that ESyS-Particle was installed on your flash drive without povray support included. The simplest work-around is to ignore the povray examples in the Tutorial and just use checkpoint files and Paraview for visualizing particles. Section 3.3 of the Tutorial explains how to do this.

Cheers,

Dion

Revision history for this message
Temitope (temitope) said :
#2

Thank you Dion

Revision history for this message
Temitope (temitope) said :
#3

Hi Dion,

I am running the latest version of Eysparticle on my computer. I installed it from the source-code tarball.
I am trying to run the bingle_vis.py example but I am getting the import error. The message is shown below:

adminuser@temitope-oladele:~$ export PATH=/usr/local/bin/:$PATH
adminuser@temitope-oladele:~$ export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
adminuser@temitope-oladele:~$ export LIBRARY_PATH=/usr/local/lib/:$LIBRARY_PATH
adminuser@temitope-oladele:~$ export PYTHONPATH=/usr/local/lib/python2.7/dist-packages/:$PYTHONPATH
adminuser@temitope-oladele:~$ mpirun -np 2 esysparticle bingle_vis.py
CSubLatticeControler::initMPI()
Traceback (most recent call last):
  File "bingle_vis.py", line 4, in <module>
    from esys.lsm.vis import povray
ImportError: cannot import name povray

the code on the bingle_vis.py example that I am running is shown below:

#import the appropriate ESyS-Particle modules:
from esys.lsm import *
from esys.lsm.util import Vec3, BoundingBox
from esys.lsm.vis import povray
#define the povray
def snapshot (particle=None, index=0):
 pkg = povray

 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=True,
  interactive=False,
  fileName="snap_%.4d.png" % (index),
  size=[800,600]
 )
 return
#initiate 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
)
#set the number of timesteps and timestep increment:
sim.setNumTimeSteps(10000)
sim.setTimeStepSize(0.001)
#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 = "elastic_repulsion",
  normalK = 10000.0,
  scaling = True
 )
)
#compute the specified number of timesteps:
N_max = sim.getNumTimeSteps()
for n in range (N_max):
 sim.runTimeStep()

 if (n%100==0):
  particles = sim.getParticleList()
  snapshot(particles=particles, index=n)
#Exit the simulation.
sim.exit()

Thank you

Revision history for this message
Dion Weatherley (d-weatherley) said :
#4

Hi Tope,

This error is probably because ESyS-Particle has been installed without povray support. This is not a major problem however examples in the tutorial using povray will not work for you. Alternatively, you can visualise simulation outputs by saving checkpoint files (also described in the tutorial) and visualising the models using Paraview.

There are some links to additional information to assist with this in this question:
https://answers.launchpad.net/esys-particle/+question/452885

Cheers,

Dion

Can you help with this problem?

Provide an answer of your own, or ask Temitope for more information if necessary.

To post a message you must log in.