Closed abruns123 closed 6 days ago
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
@Cosmos491 please review asap
@laserlab I am on it, professor.
I will start from the beginning:
The first code calculates the electric field produced by a charged sphere. If the point lies inside the sphere, the field magnitude is calculated using a smaller effective radius. The elecField function provides the direction and magnitude of the electric field at point p relative to the sphere center o.
The second code is the unit test code for the electricSphere module.
The explanation concludes with the fact that: Inside the sphere, the electric field has a linear relationship with r. Outside, the electric field has a decreasing parabolic relationship with r. It also mentions that the electric field is a vector quantity and that the derived equations describe the magnitude of the electric field in the radial direction from the center.
Below I will review them in the same manner:
There is a potential issue with dividing by zero in getUVec(), when the magnitude is zero. So, I suggest adding error handling for potential division by zero in getUVec. Simplify the implementation of zeroCondition for better readability.
Simplify and improve the readability of the test_behavior function by breaking down the logic into smaller parts. Replace floating-point equality checks with assert_allclose to prevent errors due to rounding.
The phrase "sphereical shell" should be corrected to "spherical shell". Consider breaking down the explanation into smaller sections for clarity. But, overall the theory looks fine.
At this time, I have made adjustments according to your specifications.
main loop is not for testing, merging anyway
The electricSphere module uses the getField function to produce the vector which defines the electric field of a spherical shell that may be defined by the user in terms of its center relative to the origin, its charge density, and radius. The user also determines the point at which the electric field is measured.
This is all tested by electricSphereTester.
The theory markdown file goes over how to determine the electric field of a sphere with constant volume charge density.