Python - Solar Cell Current Delivered by Illuminated Diode
by matt392 in Circuits > Software
49 Views, 1 Favorites, 0 Comments
Python - Solar Cell Current Delivered by Illuminated Diode


Code to calculate current delivered by an illuminated diode from a solar cell.
Includes PDF diagram of how the program broke the equation down into parts for calculation.
Python code is attached and below.
print ("This program will calculate solar cell current delivered by illuminated diode.") import math from decimal import Decimal # Formula for calculating the solar cell current delivered by illuminated diode: # SolarCellCurrent = (GreatestCurrent - ReverseSaturationCurrent) * # ((EulersNumber**((ElementaryCharge*Voltage)/((IdealityFactor*BoltzmannConstant)*AbsoluteTemp))) - 1) ########################################### # 1 function: solve for the solar cell current delivered by illuminated diode # Enter the GreatestCurrent, ReverseSaturationCurrent, Voltage, IdealityFactor, AbsoluteTemp # Constants: Euler's Number: math.e # ElementaryCharge: (1.60217662*(10**-19)) # BoltzmannConstant: (1.38064852*(10**-23)) def SolveForSolarCellCurrent(): print ("Solving for the solar cell current.") # Enter the GreatestCurrent, ReverseSaturationCurrent, Voltage, IdealityFactor, AbsoluteTemp GreatestCurrent = float(input("Enter the greatest current: ") ) ReverseSaturationCurrent = float(input("Enter the reverse saturation current: ") ) Voltage = float(input("Enter the voltage: ") ) IdealityFactor = float(input("Enter the ideality factor: ") ) AbsoluteTemp = float(input("Enter the absolute temperature: ") ) print("Euler's number is: ", math.e) ElementaryCharge = (1.60217662*(10**-19)) print ("The elementary charge is: ", ElementaryCharge) BoltzmannConstant = (1.38064852*(10**-23)) print ("The Boltzmann Constant is: ", BoltzmannConstant) # Get difference in current CurrentDifference = (GreatestCurrent - ReverseSaturationCurrent) print ("The current difference is: ", CurrentDifference) # Calculate top of fraction ElementaryChargeTimesVoltage = float(ElementaryCharge * Voltage) print ("The elementary charge times voltage: ", ElementaryChargeTimesVoltage) # Calculate the bottom of fraction IdealityTimesBoltzmann = float(IdealityFactor*BoltzmannConstant) print("The ideality times Boltzmann is: ", IdealityTimesBoltzmann) IdealityTimesBoltzmannTimesTemp = float(IdealityTimesBoltzmann * AbsoluteTemp) print ("Ideality times Boltzmann times temp is: ", IdealityTimesBoltzmannTimesTemp) # Divide fraction ElementaryDividedIdealityBoltzmann = float(ElementaryChargeTimesVoltage/IdealityTimesBoltzmannTimesTemp) print ("Elementary divided by IdealityBoltzmann: ", ElementaryDividedIdealityBoltzmann) # Euler's Number to power EulersNumberToPower = float((math.e)**ElementaryDividedIdealityBoltzmann) print ("Euler's number to power: ", EulersNumberToPower) # Subtract 1 EulersNumberToPowerMinusOne = EulersNumberToPower - 1 # Multiply by current difference SolarCellCurrent = CurrentDifference * EulersNumberToPowerMinusOne print("The solar cell current is: ", SolarCellCurrent) ContinueCalculations = "y" # Check to see if the user wants to continue to calculate the solar cell current while (ContinueCalculations=="y"): SolveForSolarCellCurrent() ContinueCalculations = input("Would like to do another calculation for the solar cell current? (y/n): ") print("==================================") print ("Thank you to www.fxsolver.com for assistance with this formula.")