Skip to content

Commit c771a51

Browse files
Merge pull request #2 from ViniViniAntunes/feature/ViniAntunes/add_magnetic_flux_implementation
Feature/vini antunes/add magnetic flux implementation
2 parents 78aba63 + 9a4ce09 commit c771a51

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

physics/magnetic_flux.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""
2-
Magnetic flux (Φ) is a scalar quantity that measures the number of magnetic field lines (B)
3-
that pass through a closed area (A). Furthermore, the magnetic flux depends on the angle
4-
formed between the magnetic field and the normal line (N) in area A. Check out the formula
5-
used to calculate this flux:
2+
________________________________________________________________________________________
3+
Magnetic flux (Φ) is a scalar quantity that measures the number of magnetic field
4+
lines (B) that pass through a closed area (A). Furthermore, the magnetic flux depends
5+
on the angle formed between the magnetic field and the normal line (N) in area A.
6+
Check out the formula used to calculate this flux:
67
------------
78
| Φ = B.A.cos(θ) |
89
------------
@@ -15,8 +16,7 @@
1516
(Description adapted from https://en.wikipedia.org/wiki/Ideal_gas_law )
1617
"""
1718

18-
from math import cos, radians as deg_to_rad
19-
19+
from math import cos, radians
2020

2121
def check_args(magnetic_field: float, area: float, angle: float) -> None:
2222
"""
@@ -50,8 +50,8 @@ def magnetic_flux(magnetic_field: float, area: float, angle: float) -> float:
5050
"""
5151
>>> magnetic_flux(50.0, 2, 0.0)
5252
100.0
53-
>>> magnetic_flux(1.5, 3.0, 60.0)
54-
2.25
53+
>>> magnetic_flux(50, 2, 60.0)
54+
50.0
5555
>>> magnetic_flux(0.5, 4.0, 90.0)
5656
0.0
5757
>>> magnetic_flux(1, 2.0, 180.0)
@@ -67,8 +67,8 @@ def magnetic_flux(magnetic_field: float, area: float, angle: float) -> float:
6767
... ValueError: Invalid area. Should be a positive number.
6868
"""
6969
check_args(magnetic_field, area, angle)
70-
radians = deg_to_rad(angle)
71-
return magnetic_field * area * cos(radians)
70+
rad = radians(angle)
71+
return magnetic_field * area * cos(rad)
7272

7373

7474
if __name__ == "__main__":

0 commit comments

Comments
 (0)