kmeans python interation flag_Python / Scipy Integration数组

我正在尝试编写一个执行以下操作的程序:

>从数组中获取V的值

>将V值传递给相对于E的积分

>将积分结果输出到数组I中

>情节I对抗V

这个等式看起来很讨厌,但除了V. Here is the equation之外,一切都是常数.这个等式并不是很重要.

我应该怎么解决这个问题?我的尝试(如下所示)不计算从文件中读取的每个V值的积分.

from scipy import integrate #integrate.quad

from numpy import *

import pylab

import datetime

import time

import os

import math

# import V

fn = 'cooltemp.dat'

V = loadtxt(fn,unpack=True,usecols=[1])

# variables

del1, del2, R, E, fE, fEeV = 1,2,1,2,1,1

e = 1.602176565*10**-19

# eqn = dint(abc)

a = E/( math.sqrt( E**2 - del1**2 ) )

b = ( E+ e*V )/( math.sqrt( ( E + e*V )**2) - del2**2)

c = fE-fEeV

d = 1/(e*R) # integration constant

eqn = a*b*c

# integrate

result = quad(lambda E: eqn,-inf,inf)

# current

I = result*d

# plot IV curve

pylab.plot(V,I,'-r')

## customise graph

pylab.legend(['degree '+str(n),'degree '+str(q),'data'])

pylab.axis([0,max(x),0,max(y)])

pylab.xlabel('voltage (V)')

pylab.ylabel('current (A)')

tc = datetime.datetime.fromtimestamp(os.path.getmtime(fn))

pylab.title('IV curve

'+fn+'

'+str(tc)+'

'+str(datetime.datetime.now()))

pylab.grid(True)

pylab.show()

*更新尝试:

from scipy import integrate

from numpy import *

import pylab

import datetime

import time

import os

import math

# import V

fn = 'cooltemp.dat'

V = loadtxt(fn,unpack=True,usecols=[1])

# print V

# variables

del1, del2, R, E, fE, fEeV = 1.0,2.0,1.0,2.0,1.0,1.0

e = 1.602176565*10**-19

I=[]

for n in range(len(V)):

constant = 1/(e*R) # integration constant

eqn = (E/( math.sqrt( E**2 - del1**2 ) ))*(( E + e*V[n] )/( math.sqrt( ( E + e*V[n] )**2) - del2**2))*(fE-fEeV)

# integrate

result,error = integrate.quad(lambda E: eqn,-inf,inf)

print result

# current

I.append(result*constant)

I = array(I)

# plot IV curve

pylab.plot(V,I,'-b')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值