Skip to content
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

Patch documentation #919

Merged
merged 60 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
43855d0
Fix documentation
alesanter Nov 6, 2024
412889d
Fix documentation
alesanter Nov 6, 2024
557aad0
Fix documentation
alesanter Nov 6, 2024
0e31e91
Add documentation
alesanter Nov 7, 2024
7e16457
Fix documentation
alesanter Nov 7, 2024
5e43eb2
Fix documentation
alesanter Nov 7, 2024
ee0e58e
Add documentation
alesanter Nov 7, 2024
e4f2728
Fix documentation
alesanter Nov 7, 2024
afe73ba
Fix documentation
alesanter Nov 7, 2024
3308939
Fix documentation
alesanter Nov 7, 2024
c82f834
Fix documentation
alesanter Nov 7, 2024
ef0f992
Fix documentation
alesanter Nov 7, 2024
89ac23f
Fix documentation
alesanter Nov 7, 2024
3c531ef
Fix documentation
alesanter Nov 7, 2024
013a84e
Fix documentation
alesanter Nov 7, 2024
39ccefa
Fix documentation
alesanter Nov 7, 2024
23d7f60
Fix documentation
alesanter Nov 7, 2024
7a3004b
Fix documentation
alesanter Nov 7, 2024
a6fc712
Fix documentation
alesanter Nov 7, 2024
4e8ec0e
Fix documentation
alesanter Nov 7, 2024
ca163fb
Fix documentation
alesanter Nov 7, 2024
daf3c28
Fix documentation
alesanter Nov 7, 2024
1c16ebc
Fix documentation
alesanter Nov 7, 2024
73091eb
Fix documentation
alesanter Nov 7, 2024
44ca4fe
Fix documentation
alesanter Nov 7, 2024
5464039
Fix documentation
alesanter Nov 7, 2024
b9dd061
Fix documentation
alesanter Nov 7, 2024
ef95a05
Fix documentation
alesanter Nov 7, 2024
83b82f3
Fix documentation
alesanter Nov 7, 2024
07d878c
Fix documentation
alesanter Nov 7, 2024
6c6b410
Fix documentation
alesanter Nov 7, 2024
6c04788
Fix documentation
alesanter Nov 7, 2024
c0127f2
Fix documentation
alesanter Nov 7, 2024
b1dd280
Fix documentation
alesanter Nov 7, 2024
5267d02
Fix documentation
alesanter Nov 7, 2024
e70ac8e
Fix documentation
alesanter Nov 7, 2024
cd31f8b
Fix documentation
alesanter Nov 7, 2024
698dc6d
Fix documentation
alesanter Nov 7, 2024
d9d6c21
Fix documentation
alesanter Nov 7, 2024
6bc6860
Fix documentation
alesanter Nov 7, 2024
142c2c3
Fix documentation
alesanter Nov 7, 2024
8034f84
Fix documentation
alesanter Nov 7, 2024
f3c96a6
Fix documentation
alesanter Nov 7, 2024
d072325
Fix documentation
alesanter Nov 7, 2024
9bb39b2
Fix documentation
alesanter Nov 7, 2024
64587f5
Fix documentation
alesanter Nov 7, 2024
5012f7b
Fix documentation
alesanter Nov 7, 2024
50c7224
Fix documentation
alesanter Nov 7, 2024
31eab36
Refactor code test
alesanter Nov 7, 2024
75acf27
Refactor latex test
alesanter Nov 7, 2024
c61b5fc
Rename variable
alesanter Nov 9, 2024
7e8279a
Fix documentation
alesanter Nov 9, 2024
24abfe9
Fix documentation
alesanter Nov 9, 2024
bc55809
Split symbol into two
alesanter Nov 11, 2024
528c022
Remove duplicate law and test
alesanter Nov 11, 2024
e866398
Fix documentation
alesanter Nov 11, 2024
026b716
Fix documentation
alesanter Nov 11, 2024
a581eaf
Merge branch 'master' into patch-documentation-electricity-3
alesanter Nov 11, 2024
079e4b9
Fix tests
alesanter Nov 11, 2024
6c18141
Linter fixes
Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@
from sympy import Eq, exp
from symplyphysics import (
quantities,
dimensionless,
Quantity,
validate_input,
validate_output,
symbols,
convert_to_float,
SymbolNew,
clone_as_symbol,
)

boltzmann_factor = SymbolNew("f", dimensionless)
boltzmann_factor = symbols.boltzmann_factor
"""
Boltzmann factor.
:symbols:`boltzmann_factor`.
"""

energy_of_state = clone_as_symbol(symbols.energy, display_symbol="E[i]", display_latex="E_i")
Expand Down
6 changes: 2 additions & 4 deletions symplyphysics/laws/electricity/charge_is_quantized.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

from sympy import Eq
from symplyphysics import (
SymbolNew,
dimensionless,
Quantity,
validate_input,
validate_output,
Expand All @@ -25,9 +23,9 @@
Total :symbols:`charge` of the body.
"""

integer_factor = SymbolNew("n", dimensionless) # positive, zero or negative
integer_factor = symbols.whole_number
"""
Integer factor of any sign.
:symbols:`whole_number`.
"""

law = Eq(charge, integer_factor * quantities.elementary_charge)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
:symbols:`voltage` across the capacitor.
"""

source_voltage = clone_as_symbol(symbols.voltage, display_symbol="V_0", display_latex="V_0")
source_voltage = clone_as_symbol(symbols.voltage, subscript="0")
"""
:symbols:`voltage` of the source, which is the initial voltage across the resistor.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from sympy import Eq, solve
from symplyphysics import Quantity, validate_input, validate_output, symbols, clone_as_symbol

initial_charge = clone_as_symbol(symbols.charge, display_symbol="q_0", display_latex="q_0")
initial_charge = clone_as_symbol(symbols.charge, subscript="0")
"""
Initial :symbols:`charge` of the system.
"""

final_charge = clone_as_symbol(symbols.charge, display_symbol="q_1", display_latex="q_1")
final_charge = clone_as_symbol(symbols.charge, subscript="1")
"""
Final :symbols:`charge` of the system.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Projection of the electrostatic :symbols:`force` applied to the test charge.
"""

test_charge = clone_as_symbol(symbols.charge, display_symbol="q_0", display_latex="q_0")
test_charge = clone_as_symbol(symbols.charge, subscript="0")
"""
Value of the test :symbols:`charge`.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,27 @@

from sympy import (Eq, Derivative)
from symplyphysics import (
dimensionless,
units,
Quantity,
SymbolNew,
validate_input,
validate_output,
symbols,
clone_as_function,
)
from symplyphysics.core.geometry.line import two_point_function, Point2D

electromotive_force = SymbolNew("E", units.voltage, display_latex="\\mathcal{E}")
electromotive_force = symbols.electromotive_force
r"""
Electromotive force induced in the contour.
:symbols:`electromotive_force` induced in the contour.
"""

current_turn_count = SymbolNew("N", dimensionless)
current_turn_count = symbols.positive_number
"""
Number of turns the current makes around the contour.
Number of turns the current makes around the contour. See :symbols:`positive_number`.
"""

time = SymbolNew("t", units.time)
time = symbols.time
"""
Time.
:symbols:`time`.
"""

magnetic_flux = clone_as_function(symbols.magnetic_flux, [time])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@
#. The rotation of the coil is uniform.
"""

from sympy import (Eq, solve, sin)
from symplyphysics import (Quantity, SymbolNew, validate_input, validate_output, dimensionless,
symbols)
from sympy import Eq, solve, sin
from symplyphysics import Quantity, validate_input, validate_output, symbols

electromotive_force = symbols.electromotive_force
"""
:symbols:`electromotive_force` induced in the coil.
"""

coil_turn_count = SymbolNew("N", dimensionless)
coil_turn_count = symbols.positive_number
"""
Number of turns in the coil.
Number of turns in the coil. See :symbols:`positive_number`.
"""

magnetic_flux_density = symbols.magnetic_flux_density
Expand All @@ -53,7 +52,7 @@

time = symbols.time
"""
Time.
:symbols:`time`.
"""

law = Eq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,74 +22,54 @@
#. The angular speed of the coil's rotation constant.
alesanter marked this conversation as resolved.
Show resolved Hide resolved
"""

from sympy import (Eq, solve, sin)
from symplyphysics import (units, Quantity, Symbol, validate_input, validate_output, dimensionless,
angle_type)
from sympy import Eq, solve, sin
from symplyphysics import Quantity, validate_input, validate_output, symbols
from symplyphysics.core.expr_comparisons import expr_equals
from symplyphysics.laws.electricity import (
electromotive_force_induced_in_moving_contour as _emf_law,
magnetic_flux_from_induction_and_area as _magnetic_flux_law,
)
from symplyphysics.laws.kinematics import (
angular_position_via_constant_angular_speed_and_time as _angle_law,)
angular_position_via_constant_angular_speed_and_time as _angle_law,
)

electromotive_force = Symbol("electromotive_force", units.voltage)
electromotive_force = symbols.electromotive_force
r"""
Electromotive force induced in the coil.

Symbol:
:code:`E`

Latex:
:math:`\mathcal{E}`
:symbols:`electromotive_force` induced in the coil.
"""

coil_turn_count = Symbol("coil_turn_count", dimensionless)
coil_turn_count = symbols.positive_number
"""
Number of turns in the coil.

Symbol:
:code:`N`
Number of turns in the coil. See :symbols:`positive_number`.
"""

magnetic_flux_density = Symbol("magnetic_flux_density", units.magnetic_density)
magnetic_flux_density = symbols.magnetic_flux_density
"""
Magnetic flux density.

Symbol:
:code:`B`
:symbols:`magnetic_flux_density`.
"""

contour_area = Symbol("contour_area", units.area)
contour_area = symbols.area
"""
Cross-sectional area of the contour enclosed by the coil.

Symbol:
:code:`A`
Cross-sectional :symbols:`area` of the contour enclosed by the coil.
"""

angular_frequency = Symbol("angular_frequency", angle_type / units.time)
angular_frequency = symbols.angular_frequency
r"""
Angular frequency of the coil's rotation.

Symbol:
:code:`w`

Latex:
:math:`\omega`
:symbols:`angular_frequency` of the coil's rotation.
"""

time = Symbol("time", units.time)
time = symbols.time
"""
:symbols:`time`.
"""

law = Eq(
electromotive_force, -1 * coil_turn_count * magnetic_flux_density * contour_area *
angular_frequency * sin(angular_frequency * time))
r"""
:code:`E = -1 * N * B * A * w * sin(w * t)`
"""
:laws:symbol::

Latex:
.. math::
\mathcal{E} = -N B A \omega \sin(\omega t)
:laws:latex::
"""

# Derive law
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,21 @@
"""

from sympy import Eq
from symplyphysics import (
SymbolNew,
units,
Quantity,
validate_input,
validate_output,
)
from symplyphysics import Quantity, validate_input, validate_output, symbols

inductance = SymbolNew("L", units.inductance)
inductance = symbols.inductance
"""
Inductance.
:symbols:`inductance`.
"""

magnetic_flux = SymbolNew("Phi_B", units.magnetic_flux, display_latex="\\Phi_B")
magnetic_flux = symbols.magnetic_flux
"""
Magnetic flux due to the component.
:symbols:`magnetic_flux` due to the component.
"""

current = SymbolNew("I", units.current)
current = symbols.current
"""
Current flowing through the circuit.
:symbols:`current` flowing through the circuit.
"""

law = Eq(inductance, magnetic_flux / current)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,63 @@
from sympy import (Eq, solve)
from sympy.physics.units import magnetic_constant
from symplyphysics import (units, Quantity, Symbol, validate_input, validate_output, dimensionless)
"""
Inductance via number of turns and coil volume
==============================================

# Description
## A solenoid is a cylindrical coil consisting of a large number of turns of wire forming a helical line.
## Inductance of solenoid depends on core material, number of turns per unit length, and volume of core.
The inductance of a coil (a solenoid) can be expressed as a function of the material's
permeability, the number of turns in the coil per unit length and its volume.

## Law is: L = mu * mu0 * n^2 * V, where
## L - inductance,
## mu - relative permeability of the core inside of a solenoid,
## mu0 - magnetic constant,
## n - number of turns per unit length,
## V - volume of solenoid.
..
TODO rename file
"""

inductance = Symbol("inductance", units.inductance)
from sympy import Eq, solve
from symplyphysics import (
Quantity,
validate_input,
validate_output,
symbols,
SymbolNew,
units,
)

relative_permeability = Symbol("relative_permeability", dimensionless)
number_of_turns_per_length = Symbol("number_of_turns", 1 / units.length)
volume = Symbol("volume", units.volume)
inductance = symbols.inductance
"""
:symbols:`inductance` of the coil.
"""

absolute_permeability = symbols.absolute_permeability
"""
:symbols:`absolute_permeability` of the inside of the coil.
"""

specific_coil_turn_count = SymbolNew("n", 1 / units.length)
"""
Number of turns in the coil per unit length.
"""

volume = symbols.volume
"""
:symbols:`volume` of the coil.
"""

law = Eq(inductance,
relative_permeability * magnetic_constant * number_of_turns_per_length**2 * volume)
absolute_permeability * specific_coil_turn_count**2 * volume)
"""
:laws:symbol::

:laws:latex::
"""


@validate_input(relative_permeability_=relative_permeability,
number_of_turns_per_length_=number_of_turns_per_length,
@validate_input(absolute_permeability_=absolute_permeability,
turn_count_=specific_coil_turn_count,
volume_=volume)
@validate_output(inductance)
def calculate_inductance(relative_permeability_: float, number_of_turns_per_length_: Quantity,
def calculate_inductance(absolute_permeability_: Quantity, turn_count_: Quantity,
volume_: Quantity) -> Quantity:
result_inductance_expr = solve(law, inductance, dict=True)[0][inductance]
result_expr = result_inductance_expr.subs({
relative_permeability: relative_permeability_,
number_of_turns_per_length: number_of_turns_per_length_,
absolute_permeability: absolute_permeability_,
specific_coil_turn_count: turn_count_,
volume: volume_
})
return Quantity(result_expr)
9 changes: 4 additions & 5 deletions symplyphysics/laws/electricity/magnetic_field_of_coil.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
#. The magnetic field is measured near the center of the coil.
"""

from sympy import (Eq, solve)
from symplyphysics import (Quantity, SymbolNew, validate_input, validate_output, dimensionless,
symbols, quantities)
from sympy import Eq, solve
from symplyphysics import Quantity, validate_input, validate_output, symbols, quantities

magnetic_flux_density = symbols.magnetic_flux_density
"""
Expand All @@ -34,9 +33,9 @@
:symbols:`length` of the coil.
"""

coil_turn_count = SymbolNew("N", dimensionless)
coil_turn_count = symbols.positive_number
"""
Number of turns in the coil.
Number of turns in the coil. See :symbols:`positive_number`.
"""

law = Eq(magnetic_flux_density, quantities.vacuum_permeability * current * coil_turn_count / length)
Expand Down
Loading
Loading