-
-
Notifications
You must be signed in to change notification settings - Fork 46.9k
Added Builtin Voltage #7850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Added Builtin Voltage #7850
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d04780b
Added Builtin Voltage
sadiqebrahim 736147b
Update builtin_voltage.py
sadiqebrahim 400dc60
Update electronics/builtin_voltage.py
sadiqebrahim 4fa61ec
Update electronics/builtin_voltage.py
sadiqebrahim 1fb06aa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6655b04
Apply suggestions from code review
sadiqebrahim 9bf6332
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 00442af
Create elf.py
cclauss 26cd9e6
Merge branch 'master' into master
cclauss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from __future__ import annotations | ||
|
||
from math import log | ||
|
||
Q = 1.6021e-19 # ELECTRON CHARGE (units = C) | ||
K = 1.380649e-23 # BOLTZMAN'S CONSTANT (unit = kg m^2 s^-2 K^-1) | ||
sadiqebrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
T = 300 # TEMPERATURE (unit = K) | ||
|
||
|
||
def builtin_voltage( | ||
donor_conc: float, # donor concentration | ||
acceptor_conc: float, # acceptor concentration | ||
intrinsic_conc: float, # intrinsic concentration | ||
) -> float: | ||
""" | ||
This function can calculate the Builtin Voltage of a pn junction diode. | ||
This is calculated from the given three values. | ||
Examples - | ||
>>> builtin_voltage(donor_conc=1e17, acceptor_conc=1e17, intrinsic_conc=1e10) | ||
0.8334098736308577 | ||
>>> builtin_voltage(donor_conc=0, acceptor_conc=1600, intrinsic_conc=200) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: Donor concentration should be positive | ||
>>> builtin_voltage(donor_conc=1000, acceptor_conc=0, intrinsic_conc=1200) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: Acceptor concentration should be positive | ||
>>> builtin_voltage(donor_conc=1000, acceptor_conc=1000, intrinsic_conc=0) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: Intrinsic concentration should be positive | ||
>>> builtin_voltage(donor_conc=1000, acceptor_conc=3000, intrinsic_conc=2000) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: Donor concentration should be greater than intrinsic concentration | ||
>>> builtin_voltage(donor_conc=3000, acceptor_conc=1000, intrinsic_conc=2000) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: Acceptor concentration should be greater than intrinsic concentration | ||
""" | ||
|
||
if donor_conc <= 0: | ||
raise ValueError("Donor concentration should be positive") | ||
elif acceptor_conc <= 0: | ||
raise ValueError("Acceptor concentration should be positive") | ||
elif intrinsic_conc <= 0: | ||
raise ValueError("Intrinsic concentration should be positive") | ||
elif donor_conc <= intrinsic_conc: | ||
raise ValueError( | ||
"Donor concentration should be greater than intrinsic concentration" | ||
) | ||
elif acceptor_conc <= intrinsic_conc: | ||
raise ValueError( | ||
"Acceptor concentration should be greater than intrinsic concentration" | ||
) | ||
else: | ||
return K * T * log((donor_conc * acceptor_conc) / intrinsic_conc**2) / Q | ||
|
||
|
||
if __name__ == "__main__": | ||
import doctest | ||
|
||
doctest.testmod() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.