Mesh issues

35 views
Skip to first unread message

jonah quirk

unread,
Apr 13, 2017, 7:16:32 PM4/13/17
to VPython-users
Hello, I am trying to run a vpython simulation using the mesh function.

Code in question:

import vpm
import numpy as np
import math as ma

def gaussian(x):
    return np.exp(-(x-5.)**2)

L, N= 10, 40
x=np.linspace(0., L, N+1)
x, y=np.meshgrid(x,x)
u=gaussian(x)*gaussian(y)

mesh=vpm.mesh(x, y, 2*u)

Error
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-30-ea23b8b79d3d> in <module>()
     11 u=gaussian(x)*gaussian(y)
     12 
---> 13 mesh=vpm.mesh(x, y, 2*u)

C:\Users\myname\vpm.pyc in __init__(self, x, y, z, topcolor, botcolor)
     92         other input: top and bottom surface colors """
     93     def __init__(self, x, y, z, topcolor=(1,0,0), botcolor=(0,1,1)):
---> 94         self.t = vp.faces(color=topcolor)         # top, bot faces
     95         self.b = vp.faces(color=botcolor)
     96         self.move(x, y, z)          # set initial position

C:\Anaconda2\lib\site-packages\vpython\vpython.pyc in __init__(self, **args)
   2250 class faces(object):
   2251     def __init__(self, **args):
-> 2252         raise NameError('faces is no longer supported; use vertex and triangle and quad, which will be available soon')
   2253 
   2254 class label(standardAttributes):

NameError: faces is no longer supported; use vertex and triangle and quad, which will be available soon



Is this an issue with vpython or am I trying to use the mesh function incorrectly.

Thanks.

Bruce Sherwood

unread,
Apr 13, 2017, 9:53:44 PM4/13/17
to VPython-users
The error message is clear: "NameError: faces is no longer supported; use vertex and triangle and quad, which will be available soon". Classic VPython had a faces object but Jupyter VPython does not. The error message is out of date, because the vertex, triangle, and quad objects are available in Jupyter VPython. See the Help at glowscript.org.
Reply all
Reply to author
Forward
0 new messages