用于python的ltspice结果文件处理程序

ltspice的Python项目详细描述


用于python的LTSpice数据解析库

安装

$ pip install ltspice

用法

importltspicefilepath='Your ltspice output file (.raw)'l=ltspice.Ltspice(filepath)l.parse()# Data loading sequence. It may take few minutes.time=l.getTime()V1=l.getData('V(N1)')

测试

01-RC电路

ltspice文件(.asc)

python代码(.py)

importltspiceimportmatplotlib.pyplotaspltimportnumpyasnpimportosl=ltspice.Ltspice(os.path.dirname(__file__)+'\\01_RC_circuit.raw')# Make sure that the .raw file is located in the correct pathl.parse()time=l.getTime()V_source=l.getData('V(source)')V_cap=l.getData('V(cap)')plt.plot(time,V_source)plt.plot(time,V_cap)plt.show()

输出结果

02-多点模拟

ltspice文件(.asc)

python代码(.py)

importltspiceimportmatplotlib.pyplotaspltimportnumpyasnpimportosl=ltspice.Ltspice(os.path.dirname(__file__)+'\\02_Rectifier.raw')# Make sure that the .raw file is located in the correct pathl.parse()time=l.getTime()V_source=l.getData('V(source)')V_cap_max=[]plt.plot(time,V_source)foriinrange(l.c_number):# Iteration in simulation cases time=l.getTime(i)# Case number starts from zero# Each case has different time point numbersV_cap=l.getData('V(cap,pgnd)',i)V_cap_max.append(max(V_cap))plt.plot(time,V_cap)print(V_cap_max)plt.xlim((0,1e-3))plt.ylim((-15,15))plt.grid()plt.show()

输出结果

$ [8.299080580472946, 7.855469107627869, 7.391375303268433, 6.944645524024963, 6.529755532741547]

03-多点模拟2d

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
具有“相同”名称的java Multiple IntelliJ/Maven模块?   列出为什么我没有得到java。util。本例中的ConcurrentModificationException?   java可分发文件启动时,如何写入文件?   java能够在organize imports preferences(ScalaIDE)中添加分隔符/换行符   java每次我都要改变一些东西来反映   数字和字符串的java jTextField验证?   JavaSpringMessageSource似乎忽略了属性fallbackToSystemLocale   在java中使用SAXParser解析嵌套XML   JMeterJava包,其中包含自己的JRE   java为什么在安卓 ArrayAdapter中找不到我的文本视图?   Java是否根据结果假定类型?   用于复合编辑的java并发性   java语法错误,请插入“;”完成现场申报