0% found this document useful (0 votes)
20 views2 pages

Project C++

This document contains a Python script that simulates the I-V and P-V characteristics of a solar cell using the Shockley diode equation. It calculates key parameters such as short circuit current, open circuit voltage, maximum power point, and efficiency based on specified solar cell parameters. The script also generates plots for the I-V and P-V curves to visualize the solar cell's performance.

Uploaded by

dh4nhwbgqm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Project C++

This document contains a Python script that simulates the I-V and P-V characteristics of a solar cell using the Shockley diode equation. It calculates key parameters such as short circuit current, open circuit voltage, maximum power point, and efficiency based on specified solar cell parameters. The script also generates plots for the I-V and P-V curves to visualize the solar cell's performance.

Uploaded by

dh4nhwbgqm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import numpy as np

import [Link] as plt

# Constants
q = 1.602e-19 # Elementary charge (C)
k = 1.381e-23 # Boltzmann constant (J/K)
T = 300 # Temperature in Kelvin
Vt = k*T/q # Thermal voltage

# Solar cell parameters (you can change these for different simulations)
I_ph = 0.03 # Photogenerated current (A)
I_0 = 1e-10 # Saturation current (A)
n = 1.3 # Ideality factor
R_s = 0.5 # Series resistance (ohm)
R_sh = 1000 # Shunt resistance (ohm)
A_cell = 10 # Cell area in cm²
Pin = 0.1 # Incident power in Watts (0.1W = 100 mW/cm²)

# Voltage range
V = [Link](0, 0.8, 200)

# Shockley diode equation with resistances


def solar_cell_current(V):
I = np.zeros_like(V)
for i, v in enumerate(V):
# Using iterative method (Newton-Raphson not needed here for simplicity)
I[i] = I_ph - I_0 * ([Link]((v + I[i]*R_s) / (n * Vt)) - 1) - (v +
I[i]*R_s) / R_sh
return I

# Calculate I and P
I = solar_cell_current(V)
P = V * I

# Find maximum power point


P_max = [Link](P)
V_mpp = V[[Link](P)]
I_mpp = I[[Link](P)]

# Open circuit voltage and short circuit current


Voc_index = [Link](I <= 0.001)[0][0]
Voc = V[Voc_index]
Isc = I[0]

# Efficiency
efficiency = (P_max / Pin) * 100

# Print key outputs


print(f"Short Circuit Current (Isc): {Isc:.4f} A")
print(f"Open Circuit Voltage (Voc): {Voc:.4f} V")
print(f"Maximum Power Point (Pmax): {P_max:.4f} W")
print(f"Voltage at MPP (V_mpp): {V_mpp:.4f} V")
print(f"Current at MPP (I_mpp): {I_mpp:.4f} A")
print(f"Efficiency: {efficiency:.2f} %")

# Plot I-V and P-V curves


[Link](figsize=(12, 5))

# I-V Curve
[Link](1, 2, 1)
[Link](V, I, label="I-V Curve", color='blue')
[Link](Voc, 0, color='red', label="Voc")
[Link](0, Isc, color='green', label="Isc")
[Link]("Voltage (V)")
[Link]("Current (A)")
[Link]("Solar Cell I-V Characteristics")
[Link](True)
[Link]()

# P-V Curve
[Link](1, 2, 2)
[Link](V, P, label="P-V Curve", color='orange')
[Link](V_mpp, P_max, color='purple', label="Max Power Point")
[Link]("Voltage (V)")
[Link]("Power (W)")
[Link]("Solar Cell Power Output")
[Link](True)
[Link]()

plt.tight_layout()
[Link]()

You might also like