Vector3 in Meep in Python

2019-06-05 21:13发布

问题:

I'm getting 'module' object has no attribute 'Vector3' error in my simple python code.

This is rightAngle.py file

import meep as mp
import math

cell = mp.Vector3(16, 8, 0)
geometry = [mp.Bloack(mp.Vector3(1e20, 1, 1e20),
                      center = mp.Vector3(0, 0),
                      material = mp.Medium(epsilon = 12))]
sources = [mp.Source(mp.ContinuousSource(frequency = 0.15),
                     component = mp.Ez,
                     center = mp.Vector3(-7, 0))]
pml_layers = [mp.PML(1.0)]
resolution = 10

Compling using:

python rightAngle.py >& rightAngle.out

And getting this output:

Traceback (most recent call last):
  File "rightAngle.py", line 4, in <module>
    cell = mp.Vector3(16, 8, 0)
AttributeError: 'module' object has no attribute 'Vector3'

All I'm doing is copy and pasting given code from this fairly reliable source but getting error in Vector3 object.

Python version:

Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2

I don't know what I'm missing?

Meep Documentation: https://meep.readthedocs.io/en/latest/Python_Tutorials/Basics/

回答1:

Got the same problem while trying to use it on Ubuntu 16.04.

What worked for me was installing Anaconda for python 2.7 and create their recommended environment using:

conda create -n mp -c chogan -c defaults -c conda-forge pymeep

No Vector3 problem after that.