Python中的Meep中的Vector3 [英] Vector3 in Meep in Python

查看:432
本文介绍了Python中的Meep中的Vector3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的简单python代码出现'module' object has no attribute 'Vector3'错误.

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

这是rightAngle.py文件

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

并获得以下输出:

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'

我要做的就是从这个相当可靠的源代码中复制并粘贴给定代码,但在Vector3对象中出现错误.

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

Python版本:

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

我不知道我在想什么?

深度文档: https://meep.readthedocs.io/en/latest/Python_Tutorials/Basics/

推荐答案

尝试在Ubuntu 16.04上使用它时遇到了同样的问题.

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

对我有用的是为python 2.7安装 Anaconda 并创建

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

此后没有Vector3问题.

No Vector3 problem after that.

这篇关于Python中的Meep中的Vector3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆