-
-
Notifications
You must be signed in to change notification settings - Fork 46.5k
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
Added Coulomb_Law #8714
Added Coulomb_Law #8714
Conversation
physics/coulomb_law.py
Outdated
@@ -0,0 +1,63 @@ | |||
""" | |||
Description : The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges is directly proportional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ruff .
then ruff . --fix
to fix ruff and pre-commit issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that the header docstring is too verbose and some parts, such as the paragraph about Coulomb discovering the formula, are either a bit repetitive or not particularly important to include. Instead of directly quoting the cited article for most of the documentation, consider briefly summarizing what the formula calculates and discussing the intuition behind it
physics/coulomb_law.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider changing the file name from coulomb_law.py
to coulombs_law.py
, since the name is "Coulomb's Law"
physics/coulomb_law.py
Outdated
Charles-Augustin de Coulomb, a French physicist in 1784, measured the force between two point charges and he came up with | ||
the theory that the force is inversely proportional to the square of the distance between the charges. | ||
He also found that this force is directly proportional to the product of charges (magnitudes only). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Charles-Augustin de Coulomb, a French physicist in 1784, measured the force between two point charges and he came up with | |
the theory that the force is inversely proportional to the square of the distance between the charges. | |
He also found that this force is directly proportional to the product of charges (magnitudes only). |
The history of the formula isn't particularly important to understanding the formula itself, imo
physics/coulomb_law.py
Outdated
|
||
def coulombs_law(q1: float, q2: float, radius: float) -> float: | ||
""" | ||
The Electrostatic Force formula is given as: (k*q1*q2)/(r**2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifying the units of q1
, q2
, radius
, and the output would be helpful
physics/coulomb_law.py
Outdated
Where, F is the Electrostatic force,q1 q2 are the intensity of two charges respecticvely , | ||
r is the radius and k is coulombs constant and its value is 9×10^9 N⋅m^2⋅C^−2 . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where, F is the Electrostatic force,q1 q2 are the intensity of two charges respecticvely , | |
r is the radius and k is coulombs constant and its value is 9×10^9 N⋅m^2⋅C^−2 . | |
where F is the electrostatic force, q1 and q2 are the magnitudes of the two charges respectively, | |
r is the radius and k = 9×10^9 N⋅m^2/C^2 is Coulomb's constant. |
physics/coulomb_law.py
Outdated
|
||
where k is proportionality constant and equals to 1/4πε0. | ||
|
||
Here, ε0 is the epsilon naught and it signifies permittivity of a vacuum. The value of k comes 9 × 10^9 Nm^2/ C^2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9 x 10^9 N * m^2 / C^2 is only an approximation for Coulomb's constant. Wikipedia gives a much more precise value of 8.9875517923 x 10^9 N * m^2 / C^2
physics/coulomb_law.py
Outdated
|
||
if radius <= 0: | ||
raise ValueError("The radius is always a positive non zero integer") | ||
return ((9 * 10**9) * q1 * q2) / (radius**2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ((9 * 10**9) * q1 * q2) / (radius**2) | |
k = 8.9875517923 * 10**9 | |
return (k * q1 * q2) / (radius**2) |
Updated code with more precise value of Coulomb's constant
for more information, see https://pre-commit.ci
physics/coulombs_law.py
Outdated
@@ -0,0 +1,37 @@ | |||
""" | |||
The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line no.2,3,5 should be break into multiple as it is long ....use 'ruff . --fix'
physics/coulombs_law.py
Outdated
@@ -0,0 +1,37 @@ | |||
""" | |||
The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges | |
Coulomb's law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges |
For clarity
physics/coulombs_law.py
Outdated
|
||
Coulomb studied the repulsive force between bodies having electrical charges of the same sign. | ||
|
||
F = k*q1*q2/ r^2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F = k*q1*q2/ r^2 | |
F = k*q1*q2/r^2 |
Spacing
physics/coulombs_law.py
Outdated
|
||
F = k*q1*q2/ r^2 | ||
|
||
k is proportionality constant and equals 1/4πε0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k is proportionality constant and equals 1/4πε0. | |
k is the Coulomb constant and equals 1/(4π * ε0). |
According to Wikipedia,
Added parentheses for clarity, because otherwise it looks like
physics/coulombs_law.py
Outdated
F = k*q1*q2/r^2 | ||
|
||
k is Coulomb's constant and equals 1/(4π*ε0). | ||
q1 is charge of first body (C) | ||
q2 is charge of second body (C) | ||
r is distance between two charged bodies (m) | ||
""" | ||
|
||
|
||
def coulombs_law(q1: float, q2: float, radius: float) -> float: | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F = k*q1*q2/r^2 | |
k is Coulomb's constant and equals 1/(4π*ε0). | |
q1 is charge of first body (C) | |
q2 is charge of second body (C) | |
r is distance between two charged bodies (m) | |
""" | |
def coulombs_law(q1: float, q2: float, radius: float) -> float: | |
""" | |
F = k*q1*q2/r^2 | |
k is Coulomb's constant and equals = 1/(4π*ε0). | |
""" | |
def coulombs_law(q1: float, q2: float, radius: float) -> float: | |
""" | |
:param float q1: charge of first body (C) | |
:param float q2: charge of second body (C) | |
:param float r: distance between the two bodies |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Will you please guide me with ruff checking? |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
physics/coulombs_law.py
Outdated
@@ -0,0 +1,37 @@ | |||
""" | |||
Coulombs law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coulombs law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges | |
Coulomb's law states that the magnitude of the electrostatic force of attraction or repulsion between two point charges |
Small grammar fix. Other than that, it looks good to go 👍
* Create coulomb_law.py * Update coulomb_law.py * Update coulomb_law.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update and rename coulomb_law.py to coulombs_law.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update coulombs_law.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update coulombs_law.py * Update coulombs_law.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update coulombs_law.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update coulombs_law.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
Describe your change:
I have added a Coulomb law python code under physics to calculate force between two charges.
Checklist:
Fixes: #{$ISSUE_NO}
.