[英]How to plot a power curve by following code?
在代碼中,我嘗試繪制功率(p)與電壓(Vpv)的關系圖,但我的代碼未給出結果。
import numpy as np
import math
from numpy import *
import matplotlib.pyplot as plt
plt.style.use('ggplot')
r = 50
Vpv = np.linspace(0,0.6,r) # Vpv = panel voltage
Rs = 0 # series resistance
Rsh = math.inf # parallel resistance
n = 2 # ideality constant depends on semiconductor material
m = 1.5 # another constant depends on dopping
T = 298 # temperature in kelvin
Eg = 1.14 # band gap energy in ev
K = 0.13 # constant
Vt = T/11600 #thermal voltage
Io = K*(T**m)*exp(-Eg/(n*Vt)) # Io = diode current
print(Io)
Isc = Io*(10**9)
def current():
current = [] #initializing current array as null
for t in Vpv:
Ipv = np.zeros(r) #initializing panel current(Ipv) as zero
Ipv = Isc - Io *(exp((t + Rs*Ipv)/(n*Vt)) - 1) - (t + Rs*Ipv)/Rsh
current.append(Ipv)
return np.array(current)
Icurrent = current()
#power = Vpv * Icurrent
power = np.multiply(Vpv, Icurrent)
plt.plot(Vpv,power,'b')
#plt.plot(Vpv,Icurrent,'r')
plt.xlabel('Panel VOltage(V)')
plt.ylabel('Panel Current(A) and Power(W)')
plt.show()
還嘗試使用數組乘法,如no.multiply(arr1,arr2)
但這也無法正常工作。
我正在使用數組乘法獲取以下圖形-
但它應具有以下形狀-
任何建議歡迎。
我已經解決了我的問題。 我得到正確的圖表。
import numpy as np
import math
from numpy import *
import matplotlib.pyplot as plt
plt.style.use('ggplot')
r = 50
Vpv = np.linspace(0,1.1,r) # Vpv = panel voltage
Rs = 0 # series resistance
Rsh = math.inf # parallel resistance
n = 2 # ideality constant depends on semiconductor material
m = 1.5 # another constant depends on dopping
T = 298 # temperature in kelvin
Eg = 1.14 # band gap energy in ev
K = 0.13 # constant
Vt = T/11600 #thermal voltage
Io = K*(T**m)*exp(-Eg/(n*Vt)) # Io = diode current
print(Io)
Isc = Io*(10**9)
def current():
current = [] #initializing current array as null
for t in Vpv:
Ipv = 0 #initializing panel current(Ipv) as zero
Ipv = Isc - Io *(exp((t + Rs*Ipv)/(n*Vt)) - 1) - (t + Rs*Ipv)/Rsh
current.append(Ipv)
return np.array(current)
Icurrent = current()
p = Vpv * Icurrent
plt.plot(Vpv,p,'b')
plt.plot(Vpv,Icurrent,'r')
plt.xlabel('Panel VOltage(V)')
plt.ylabel('Panel Current(A)')
plt.ylim(0,max(Icurrent)+ 10)
plt.plot((-0.1, max(Vpv)), (0,0), 'k')
plt.plot((0,0),(-3,8), 'k')
plt.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.