python - How to plot a power curve by following code?
问题描述
In the code, I tried to plot a graph Power(p) vs voltage (Vpv) but my code is not giving the result.
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()
Is also tried to use array multiplication like no.multiply(arr1,arr2)
but this is also not working.
I am getting the following graph using array multiplication -
but it should come in the following shape -
Any suggestion Welcome.
解决方案
我已经解决了我的问题。我得到了正确的图表。
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()
推荐阅读
- android - Andriod Studio Gradle - 无法解析超过 2.24 的任何版本的匕首
- azure-active-directory - Azure AD 域服务域控制器的复制测试失败
- python - 安装numpy时的循环依赖
- javascript - 谷歌表格使用脚本检查单元格是否有边框
- c# - 我收到 Command find failed: Error=16500, RetryAfterMs=64, Error while Fetching Record Count in Azure Cosmos Db
- c# - 如何使用 Selenium 和 C# 单击此特定元素
- typescript - 在 Oclif CLI 中包含以空格分隔的参数
- javascript - 添加自定义 fa-icons 添加到 JsTree
- php - 如何在 PHP 中将文件分组为一定大小的组
- java - 如何在java中修剪字符串目录