Skip to content

Commit

Permalink
Add documentation (#895)
Browse files Browse the repository at this point in the history
* Add documentation

* Add documentation

* Add documentation

* Add documentation

* Rename files

* Add documentation and rename

* Add documentation and rename files

* Add documentation

* Add documentation

* Add documentation

* Add documentation

* Add documentation, rename and move files

* Add documentation

* Rename files

* Add documentation

* Add documentation and rename files

* Add documentation

* Rename files

* Add law and test

* Add documentation and rename files

* Fix documentation

* Add documentation and rename files

* Add documentation

* Add documentation

* Add documentation

* Add documentation and rename files

* Add documentation

* Add documentation

* Fix documentation

* Add documentation

* Add documentation

* Add documentation and rename files

* Add documentation

* Add documentation and rename files

* Add documentation and rename files

* Fix import

* Fix issues

* Rename directory

* Rename test directory

* Add documentation and rename files

* Add documentation and rename files

* Add documentation and rename files

* Add documentation and rename files

* Fix documentation and rename files

* Add documentation and rename files

* Fix files

* Add documentation and rename files

* Add documentation and rename files

* Add documentation

* Add documentation and rename files

* Add documentation

* Add documentation and rename files

* Add documentation and rename files

* Fix issues

* Add documentation and rename files

* Add documentation and rename files

* Add documentation

* Add documentation and rename files

* Add documentation

* Add documentation

* Add documentation

* Add documentation

* Add documentation and fix issues

* Add documentation

* Add documentation

* Add documentation and rename files

* Add documentation

* Add documentation and rename files

* Add documentation

* Add documentation

* Add documentation

* Add documentation and rename files

* Add documentation and rename files

* Add documentation

* Add documentation and rename files

* Add documentation

* Add documentation and rename files

* Rename files

* Fix documentation

* Add documentation and rename files

* Fix issues

* Add documentation

* Add documentation and rename files

* Add documentation and rename files

* Add documentation and rename files

* Add documentation and rename files

* Add documentation

* Add documentation and rename files

* Add documentation and rename files

* Add documentation, rename and move files

* Fix issues

* Fix issues

* Fix test

* Add documentation

* Add documentation

* Add documentation

* Add documentation

* Add documentation

* Linter

* Fix spellings

* Fix issues

Installed a spell checker and fix some spelling mistakes as well

* Fix documentation

* Fix test

* Fix documentation

---------

Co-authored-by: Andrey Lekar <[email protected]>
  • Loading branch information
alesanter and Andrey Lekar authored Aug 26, 2024
1 parent c1e3f65 commit 6ed63c8
Show file tree
Hide file tree
Showing 271 changed files with 6,836 additions and 4,055 deletions.
8 changes: 4 additions & 4 deletions examples/dynamics/measuring_acceleration_due_to_gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from symplyphysics import units, print_expression
from symplyphysics.laws.dynamics import (
period_of_physical_pendulum as pendulum_law,)
from symplyphysics.laws.kinematic.rotational_inertia.geometries import (
from symplyphysics.laws.kinematics.rotational_inertia.geometries import (
thin_rod_about_axis_through_center_perpendicular_to_length as rod_inertia_law)
from symplyphysics.laws.kinematic.rotational_inertia import (
from symplyphysics.laws.kinematics.rotational_inertia import (
rotational_inertia_about_axis_and_through_center_of_mass as parallel_axis_theorem,)

# Description
Expand All @@ -23,13 +23,13 @@

rod_rotational_inertia_through_pivot = parallel_axis_theorem.law.rhs.subs({
parallel_axis_theorem.rotational_inertia_through_com: rod_rotational_inertia_through_com,
parallel_axis_theorem.mass: rod_inertia_law.rod_mass,
parallel_axis_theorem.mass: rod_inertia_law.mass,
parallel_axis_theorem.distance_between_axes: distance_to_pivot,
})

acceleration_due_to_gravity = solve(pendulum_law.law, units.acceleration_due_to_gravity)[0].subs({
pendulum_law.rotational_inertia: rod_rotational_inertia_through_pivot,
pendulum_law.mass: rod_inertia_law.rod_mass,
pendulum_law.mass: rod_inertia_law.mass,
pendulum_law.distance_to_pivot: distance_to_pivot,
})

Expand Down
16 changes: 8 additions & 8 deletions examples/dynamics/rotating_pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
relative_acceleration_from_force as motion_law,
acceleration_from_force as force_law,
)
from symplyphysics.laws.kinematic.vector import (
acceleration_of_transfer_between_relative_frames as tranfer_law,
from symplyphysics.laws.kinematics.vector import (
acceleration_of_transfer_between_relative_frames as transfer_law,
centripetal_acceleration_via_cross_product as centripetal_law,
coriolis_acceleration as coriolis_law,
)
from symplyphysics.laws.kinematic import (
tangential_acceleration_of_rotating_body as tangential_law,)
from symplyphysics.laws.kinematics import (
tangential_acceleration_via_angular_acceleration_and_radius as tangential_law,)
from symplyphysics.laws.geometry import planar_projection_is_cosine as cosine_law

# Description
Expand All @@ -60,7 +60,7 @@

ZERO = Vector([0, 0, 0])

# The z axis is vertical and codirectional to the disk's angular velocity. The y axis runs from
# The z axis is vertical and co-directional to the disk's angular velocity. The y axis runs from
# left to right and is parallel to the plane where the pendulum's oscillations occur. The x
# axis is thus perpendicular to that plane.

Expand Down Expand Up @@ -103,10 +103,10 @@

ball_centripetal_acceleration_vector = centripetal_law.centripetal_acceleration_law(
angular_velocity_=disk_angular_velocity_vector,
position_vector_=ball_position_vector,
radius_vector_=ball_position_vector,
)

ball_transfer_acceleration_vector = tranfer_law.transfer_acceleration_law(
ball_transfer_acceleration_vector = transfer_law.transfer_acceleration_law(
moving_frame_acceleration_=ZERO, # the frame is fixed
centripetal_acceleration_=ball_centripetal_acceleration_vector,
rotation_acceleration_=ZERO, # the disk's rotation is uniform
Expand Down Expand Up @@ -148,7 +148,7 @@

ball_tangential_acceleration_via_angle = tangential_law.law.rhs.subs({
tangential_law.angular_acceleration: ball_angular_acceleration,
tangential_law.rotation_radius: rod_length,
tangential_law.radius_of_curvature: rod_length,
})

oscillation_eqn_derived = Eq(
Expand Down
4 changes: 2 additions & 2 deletions examples/dynamics/rotational_energy_of_rotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from symplyphysics import Quantity, convert_to, print_expression, units
from symplyphysics.laws.dynamics import (kinetic_energy_from_rotational_inertia_and_angular_speed as
rotational_energy_law)
from symplyphysics.laws.kinematic.rotational_inertia.geometries import (
from symplyphysics.laws.kinematics.rotational_inertia.geometries import (
solid_disk_about_central_axis as disk_formula)

# Description
Expand All @@ -26,7 +26,7 @@
}

rotational_inertia = disk_formula.law.rhs.subs({
disk_formula.disk_mass: mass,
disk_formula.mass: mass,
disk_formula.radius: radius,
})

Expand Down
4 changes: 2 additions & 2 deletions examples/dynamics/simple_harmonic_oscillations_of_spring.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from symplyphysics.definitions import period_from_angular_frequency as period_def
from symplyphysics.laws.dynamics import (
period_of_spring_from_mass as spring_period_law,)
from symplyphysics.laws.kinematic import (
from symplyphysics.laws.kinematics import (
displacement_in_simple_harmonic_motion as harmonic_law,)

# Description
Expand Down Expand Up @@ -42,7 +42,7 @@
position_expr = harmonic_law.law.rhs.subs({
harmonic_law.amplitude: amplitude,
harmonic_law.angular_frequency: angular_frequency_expr,
harmonic_law.phase_lag: phase_lag,
harmonic_law.phase_shift: phase_lag,
harmonic_law.time: time,
})

Expand Down
6 changes: 3 additions & 3 deletions examples/dynamics/thin_rod_as_conical_pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
acceleration_from_force as force_law,
torque_vector_of_twisting_force as torque_def,
)
from symplyphysics.laws.kinematic.vector import (
from symplyphysics.laws.kinematics.vector import (
centripetal_acceleration_via_vector_rejection as centripetal_law,
centrifugal_acceleration_via_centripetal_acceleration as centrifugal_law,
)
Expand All @@ -50,7 +50,7 @@
)

# Let us consider a non-inertial reference frame in which the rod is at rest, i.e. it is in equilibrium.
# The `z` axis is codirectional to the pseudovector of angular velocity and the `y` axis is the line passing
# The `z` axis is co-directional to the pseudovector of angular velocity and the `y` axis is the line passing
# through both the `z` axis and the hanging end of the rod. Namely, assuming a cylindrical coordinate system,
# the origin is at the fixed end of the rod, the longitudinal axis is the `z` axis and the polar axis is
# the `y` axis.
Expand Down Expand Up @@ -115,7 +115,7 @@

element_centripetal_acceleration_vector = centripetal_law.centripetal_acceleration_law(
angular_velocity_=angular_velocity_vector,
position_vector_=element_position_vector,
radius_vector_=element_position_vector,
)

element_centrifugal_acceleration_vector = centrifugal_law.centrifugal_law(
Expand Down
11 changes: 6 additions & 5 deletions examples/dynamics/traction_force_and_drag_force.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from sympy import Idx, solve, Symbol, Eq
from symplyphysics import print_expression, global_index
from symplyphysics.laws.dynamics import acceleration_is_force_over_mass as second_newton_law
from symplyphysics.laws.kinematic import constant_acceleration_movement_is_parabolic as distance_law
from symplyphysics.laws.kinematics import position_via_constant_acceleration_and_time as distance_law
from symplyphysics.definitions import net_force_is_sum_of_individual_forces as superposition_law

# A trolleybus with a mass of 12 tons, starting from a place,
Expand Down Expand Up @@ -32,10 +32,11 @@
}).rhs

distance_value = distance_law.law.subs({
distance_law.movement_time: time_of_motion,
distance_law.constant_acceleration: acceleration_value,
distance_law.initial_velocity: 0,
distance_law.distance(distance_law.movement_time): distance
distance_law.time: time_of_motion,
distance_law.acceleration: acceleration_value,
distance_law.initial_speed: 0,
distance_law.initial_position: 0,
distance_law.final_position: distance
})
print(f"Final equation:\n{print_expression(distance_value)}")
traction_force_equation = solve(distance_value, traction_force, dict=True)[0][traction_force]
Expand Down
21 changes: 11 additions & 10 deletions examples/electricity/charged_particle_in_electric_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from symplyphysics import print_expression, Vector, Quantity, units, convert_to
from symplyphysics.laws.electricity.vector import electric_field_is_force_over_test_charge as electric_field_law
from symplyphysics.laws.dynamics import acceleration_is_force_over_mass
from symplyphysics.laws.kinematic import constant_acceleration_movement_is_parabolic as const_acceleration_law
from symplyphysics.laws.kinematic import distance_from_constant_velocity as const_velocity_law
from symplyphysics.laws.kinematics import position_via_constant_acceleration_and_time as const_acceleration_law
from symplyphysics.laws.kinematics import position_via_constant_speed_and_time as const_velocity_law

# Description
## A charged drop with a mass of m = 1.5e-7 g and a negative charge of magnitude Q = 2.8e-13 C enters
Expand Down Expand Up @@ -43,21 +43,22 @@

# Since no forces act on the drop along the x axis, the projection of the acceleration on it is zero
horizontal_movement_law = const_velocity_law.law.subs({
const_velocity_law.constant_velocity: drop_speed_x,
const_velocity_law.speed: drop_speed_x,
const_velocity_law.initial_position: 0,
const_velocity_law.distance(const_velocity_law.movement_time): plate_length_x,
const_velocity_law.movement_time: movement_time,
const_velocity_law.final_position: plate_length_x,
const_velocity_law.time: movement_time,
})

vertical_movement_law = const_acceleration_law.law.subs({
const_acceleration_law.constant_acceleration: drop_acceleration_y,
const_acceleration_law.initial_velocity: 0,
const_acceleration_law.movement_time: movement_time,
const_acceleration_law.acceleration: drop_acceleration_y,
const_acceleration_law.initial_speed: 0,
const_acceleration_law.time: movement_time,
const_acceleration_law.initial_position: 0,
})

vertical_deflection = solve([horizontal_movement_law, vertical_movement_law],
(movement_time, const_acceleration_law.distance(movement_time)),
dict=True)[0][const_acceleration_law.distance(movement_time)]
(movement_time, const_acceleration_law.final_position),
dict=True)[0][const_acceleration_law.final_position]

vertical_deflection_expr = Quantity(vertical_deflection.subs(values))
vertical_deflection_value = convert_to(vertical_deflection_expr, units.millimeter).evalf(3)
Expand Down
8 changes: 4 additions & 4 deletions examples/gravity/satellite_velocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sympy import solve, Eq, simplify
from symplyphysics import (print_expression, units, convert_to, Quantity)
from symplyphysics.laws.kinematic import centripetal_acceleration_is_squared_velocity_by_radius as centripetal_acceleration_law
from symplyphysics.laws.kinematics import centripetal_acceleration_via_linear_speed_and_radius as centripetal_acceleration_law
from symplyphysics.laws.gravity import free_fall_acceleration_from_height as free_fall_law

# This example calculates the velocity an object has to reach to become a satellite of the planet.
Expand All @@ -16,13 +16,13 @@
## Note, that satellite is non-inertial system, so we cannot apply first Newton's law to solve this problem.

solution = Eq(centripetal_acceleration_law.law.rhs, free_fall_law.law.rhs)
solution_applied = solution.subs(centripetal_acceleration_law.curve_radius,
solution_applied = solution.subs(centripetal_acceleration_law.radius_of_curvature,
free_fall_law.planet_radius + free_fall_law.height_above_surface)

# first solution is negative and corresponds to the backwards direction of velocity - ignore it
satellite_velocity = solve(solution_applied,
centripetal_acceleration_law.linear_velocity,
dict=True)[1][centripetal_acceleration_law.linear_velocity]
centripetal_acceleration_law.speed,
dict=True)[1][centripetal_acceleration_law.speed]

print(
f"The formula for satellite linear velocity is: {print_expression(simplify(satellite_velocity))}"
Expand Down
10 changes: 5 additions & 5 deletions examples/hydro/pressure_balance_in_u_tube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from sympy import dsolve, solve, symbols, Eq
from symplyphysics import units, convert_to, Quantity, print_expression
from symplyphysics.laws.hydro import inner_pressure_of_fluid as inner_pressure
from symplyphysics.laws.hydro import hydrostatic_pressure_from_density_and_depth as hydrostatic_pressure
from symplyphysics.laws.hydro import inner_pressure_of_fluid_is_constant as constant_pressure_law
from symplyphysics.laws.hydro import inner_pressure_is_sum_of_pressures as inner_pressure
from symplyphysics.laws.hydro import hydrostatic_pressure_via_density_and_height as hydrostatic_pressure
from symplyphysics.laws.hydro import inner_pressure_is_constant as constant_pressure_law

# Description
## A U-tube contains two liquids at static equilibrium:
Expand All @@ -31,7 +31,7 @@

hydrostatic_pressure_left_arm_law = hydrostatic_pressure.law.subs({
hydrostatic_pressure.density: oil_density,
hydrostatic_pressure.depth: oil_column_height,
hydrostatic_pressure.height: oil_column_height,
})
hydrostatic_pressure_left_arm = solve(hydrostatic_pressure_left_arm_law,
hydrostatic_pressure.hydrostatic_pressure)[0]
Expand All @@ -47,7 +47,7 @@

hydrostatic_pressure_right_arm_law = hydrostatic_pressure.law.subs({
hydrostatic_pressure.density: water_density,
hydrostatic_pressure.depth: water_column_height,
hydrostatic_pressure.height: water_column_height,
})
hydrostatic_pressure_right_arm = solve(hydrostatic_pressure_right_arm_law,
hydrostatic_pressure.hydrostatic_pressure)[0]
Expand Down
28 changes: 15 additions & 13 deletions examples/kinematics/accelerated_rotation_of_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
angular_acceleration_is_angular_speed_derivative as angular_acceleration_def,
angular_speed_is_angular_distance_derivative as angular_velocity_def,
)
from symplyphysics.laws.kinematic import (
linear_velocity_from_angular_velocity_and_radius as linear_velocity_law,
tangential_acceleration_of_rotating_body as tangential_acceleration_law,
centripetal_acceleration_is_squared_velocity_by_radius as centripetal_acceleration_law,
from symplyphysics.laws.kinematics import (
centripetal_acceleration_via_linear_speed_and_radius as centripetal_acceleration_law,
speed_via_angular_speed_and_radius as linear_velocity_law,
tangential_acceleration_via_angular_acceleration_and_radius as tangential_acceleration_law,
)
from symplyphysics.laws.kinematics.vector import (
acceleration_is_normal_plus_tangential_acceleration as total_acceleration_law,
)
from symplyphysics.laws.kinematic.vector import acceleration_of_rotating_body as total_acceleration_law

# Description
## A wheel is rotating about a fixed axis so that the angular displacement is expressed as k*t^2, where
Expand Down Expand Up @@ -53,28 +55,28 @@

rotation_radius = solve(
linear_velocity_law.law,
linear_velocity_law.curve_radius,
linear_velocity_law.radius_of_curvature,
)[0].subs({
linear_velocity_law.linear_velocity: linear_velocity,
linear_velocity_law.angular_velocity: angular_velocity,
linear_velocity_law.speed: linear_velocity,
linear_velocity_law.angular_speed: angular_velocity,
})

tangential_acceleration = tangential_acceleration_law.law.rhs.subs({
tangential_acceleration_law.angular_acceleration: angular_acceleration,
tangential_acceleration_law.rotation_radius: rotation_radius,
tangential_acceleration_law.radius_of_curvature: rotation_radius,
})

centripetal_acceleration = centripetal_acceleration_law.law.rhs.subs({
centripetal_acceleration_law.linear_velocity: linear_velocity,
centripetal_acceleration_law.curve_radius: rotation_radius,
centripetal_acceleration_law.speed: linear_velocity,
centripetal_acceleration_law.radius_of_curvature: rotation_radius,
})

# Tangential and centripetal accelerations are perpendicular to one another. Therefore, we can
# align the tangential acceleration with the x axis, and the centripetal one with the y axis.
total_acceleration = vector_magnitude(
total_acceleration_law.acceleration_law(
Vector([tangential_acceleration, 0]),
Vector([0, centripetal_acceleration]),
tangential_acceleration_=Vector([tangential_acceleration, 0]),
normal_acceleration_=Vector([0, centripetal_acceleration]),
)).simplify()
total_acceleration_value = convert_to(
Quantity(total_acceleration.subs(values)),
Expand Down
15 changes: 8 additions & 7 deletions examples/kinematics/average_angular_velocity_during_dive.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from sympy import solve, symbols, pi
from symplyphysics import units, print_expression
from symplyphysics.laws.kinematic import average_angular_frequency_is_angular_distance_over_time as angular_velocity_law
from symplyphysics.laws.kinematic import constant_acceleration_movement_is_parabolic as const_acceleration_law
from symplyphysics.laws.kinematics import average_angular_speed_is_angular_distance_over_time as angular_velocity_law
from symplyphysics.laws.kinematics import position_via_constant_acceleration_and_time as const_acceleration_law

# Description
## A diver makes 2.5 revolutions on the way from a 10-m-high platform to the water. Assuming zero initial
Expand All @@ -13,12 +13,13 @@
height = symbols("height")

const_acceleration_law_sub = const_acceleration_law.law.subs({
const_acceleration_law.constant_acceleration: units.acceleration_due_to_gravity,
const_acceleration_law.initial_velocity: 0,
const_acceleration_law.distance(const_acceleration_law.movement_time): height,
const_acceleration_law.acceleration: units.acceleration_due_to_gravity,
const_acceleration_law.initial_speed: 0,
const_acceleration_law.initial_position: 0,
const_acceleration_law.final_position: height,
})
# First solution is negative
dive_time = solve(const_acceleration_law_sub, const_acceleration_law.movement_time)[1]
dive_time = solve(const_acceleration_law_sub, const_acceleration_law.time)[1]

# Average angular velocity can be found as ratio of total angular displacement to total rotation time.
# This is analogous to average linear velocity being ratio of total distance traveled to total travel time.
Expand All @@ -30,7 +31,7 @@
# are interchangeable terms in this context.
average_angular_velocity = solve(
angular_velocity_law_sub,
angular_velocity_law.average_angular_frequency,
angular_velocity_law.average_angular_speed,
)[0]

average_angular_velocity_value = average_angular_velocity.subs({
Expand Down
10 changes: 5 additions & 5 deletions examples/kinematics/hitting_the_target_on_merry_go_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
angular_speed_is_angular_distance_derivative as angular_velocity_def,
period_from_angular_frequency as period_def,
)
from symplyphysics.laws.kinematic import (
distance_from_constant_velocity as distance_law,)
from symplyphysics.laws.kinematics import (
position_via_constant_speed_and_time as distance_law,)

# Description
## A shooter and a target are positioned on a merry-go-round opposite to one another.
Expand Down Expand Up @@ -51,10 +51,10 @@
})

distance_eqn = distance_law.law.subs({
distance_law.distance(distance_law.movement_time): 2 * ride_radius,
distance_law.final_position: 2 * ride_radius,
distance_law.initial_position: 0,
distance_law.constant_velocity: bullet_speed,
distance_law.movement_time: time,
distance_law.speed: bullet_speed,
distance_law.time: time,
})

ride_rotation_angle_expr = ride_rotation_angle_expr.subs(
Expand Down
Loading

0 comments on commit 6ed63c8

Please sign in to comment.