是德科技
直播中

郑聪

7年用户 191经验值
私信 关注
[问答]

如何调用随机数生成器函数

我成功编写了一个EMPro脚本,用于构建多层Luneberg镜头天线模型,定义局部网格设置并开始模拟。
我理解如何构建一个几何体并插入一个descreet feed端口(来自示例脚本)和远场监视器,但是我没有尝试理解如何在脚本设计中插入一个平面波激励和一个近场监视器。
我也有兴趣知道如何调用随机数生成器函数 - 我有一些使用ramdom(),math.random()等尝试失败。我会感谢你帮我解决这个问题。

以上来自于谷歌翻译


     以下为原文

  I was successful in writing a EMPro script that build a multilayer Luneberg Lens antenna model, define local mesh settings and start the simulation. I understood how to build a geometry and insert a descreet feed port (from example scripts) and far-field monitors, but I have failed attempts to understand how I can insert in a script design a plane wave exitation and a near field monitor.
I also interested to know how one can call a random number generator function - I have some failed attempts using ramdom(), math.random()  etc.
I'll thank you to help me with this problem.  

回帖(1)

马念

2019-7-19 13:02:07
您好,这是设置平面波激发的简短片段。
您能否提供一些关于您想要设置哪种近场传感器的更多详细信息?
这将有助于创造一个例子。
#addalwave excitation planewave = empro.excitation.PlaneWave(“my planewave”)planewave.waveform = empro.activeProject.waveforms()[0]#将获取项目的第一个波形,确保你有一个。
planewave.incidentPhi =“30 deg”planewave.incidentTheta =“45 deg”planewave.polarization =“EPhi”#或ETheta planewave.amplitudeMultiplier =“1 V”empro.activeProject.externalExcitations()。append(planewave)simSetup = empro。
activeProject.createSimulationData()simSetup.excitationType =“ExternalExcitation”对于随机数,您可以随机使用Python标准库模块中的函数。
您应该在调用其函数之前导入库。
以下是如何获得0到1之间的随机数。更多函数可用并在此处记录:http://docs.python.org/2/library/random import random print random.random()谢谢,Bram。

以上来自于谷歌翻译


     以下为原文

  Hello,

Here's a short snippet to setup a plane wave excitation.
Can you provide some more details about what kind of near field sensor you want to setup?  That'll help creating an example.

# adding planewave excitation
planewave = empro.excitation.PlaneWave("my planewave")
planewave.waveform = empro.activeProject.waveforms()[0] # will take first waveform of project, make sure you have one.
planewave.incidentPhi = "30 deg"
planewave.incidentTheta = "45 deg"
planewave.polarization = "EPhi" # or ETheta
planewave.amplitudeMultiplier = "1 V"
empro.activeProject.externalExcitations().append(planewave)
simSetup = empro.activeProject.createSimulationData()
simSetup.excitationType = "ExternalExcitation"


For random numbers, you can use functions from Python's standard library module random.  You should import the library before calling its functions.  Here's how you get a random number between 0 and 1.  More functions are available and documented here: http://docs.python.org/2/library/random

import random
print random.random()

Thanks,
Bram.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分