algebraic-physics 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- algebraic_physics-0.1.0.dist-info/METADATA +101 -0
- algebraic_physics-0.1.0.dist-info/RECORD +9 -0
- algebraic_physics-0.1.0.dist-info/WHEEL +5 -0
- algebraic_physics-0.1.0.dist-info/licenses/LICENSE +21 -0
- algebraic_physics-0.1.0.dist-info/top_level.txt +2 -0
- geometry/__init__.py +11 -0
- geometry/geom.py +54 -0
- physics/__init__.py +15 -0
- physics/mechanics.py +113 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: algebraic-physics
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A project for math and geometry formulas
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: numpy>=2.4.6
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# algebraic-physics
|
|
12
|
+
|
|
13
|
+
A Python utility library for geometry and physics calculations based on the AP Physics 1 curriculum.
|
|
14
|
+
|
|
15
|
+
This library provides automated functions to solve for unknown variables using standard introductory mechanics equations. It accepts numerical inputs for known physical quantities to compute values across kinematics, dynamics, energy, momentum, and rotational motion.
|
|
16
|
+
|
|
17
|
+
## File Directory
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
mathformulas/
|
|
21
|
+
│
|
|
22
|
+
├── .github/
|
|
23
|
+
│ └── workflows/
|
|
24
|
+
│ └── codeql.yml
|
|
25
|
+
│
|
|
26
|
+
├── assets/
|
|
27
|
+
│ └── ...
|
|
28
|
+
│
|
|
29
|
+
├── src/
|
|
30
|
+
│ ├── geometry/
|
|
31
|
+
│ │ ├── __pycache__/
|
|
32
|
+
│ │ └── geom.py
|
|
33
|
+
│ │
|
|
34
|
+
│ ├── physics/
|
|
35
|
+
│ │ ├── __pycache__/
|
|
36
|
+
│ │ └── mechanics.py
|
|
37
|
+
│ │
|
|
38
|
+
│ └── mathformulas.egg-info/
|
|
39
|
+
│
|
|
40
|
+
├── tests/
|
|
41
|
+
│ └── make_cube.py
|
|
42
|
+
│
|
|
43
|
+
├── .env
|
|
44
|
+
├── .gitignore
|
|
45
|
+
├── LICENSE
|
|
46
|
+
├── pyproject.toml
|
|
47
|
+
├── README.md
|
|
48
|
+
└── requirements.txt
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Tests Example
|
|
52
|
+
|
|
53
|
+
The file 'make_cube.py' under tests/ utilizes a dictionary for holding shapes. The square uses 0.0 floats, and relies on mechanics.py functions for calculations.
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
#make_cube.py
|
|
57
|
+
import geometry.geom as gm
|
|
58
|
+
import physics.mechanics as pm
|
|
59
|
+
|
|
60
|
+
my_cube = {
|
|
61
|
+
"side": 4, # Side length, note that this can be subbed out for the result of a distance formula between two coordinates
|
|
62
|
+
"mass": 10, # Dummy mass
|
|
63
|
+
"volume": 0,
|
|
64
|
+
|
|
65
|
+
"pos_x": 0.0, # Starts at coordinates (0,0)
|
|
66
|
+
"pos_y": 0.0,
|
|
67
|
+
|
|
68
|
+
"velocity_x": 0.0,
|
|
69
|
+
"velocity_y": 0.0,
|
|
70
|
+
}
|
|
71
|
+
...
|
|
72
|
+
|
|
73
|
+
# Volume Calculation:
|
|
74
|
+
my_cube["volume"] = gm.cube_volume(my_cube["side"])
|
|
75
|
+
print(f'The volume is {my_cube["volume"]}')
|
|
76
|
+
|
|
77
|
+
...
|
|
78
|
+
|
|
79
|
+
# Physics Simulation:
|
|
80
|
+
dt = 0.1 # Timestep
|
|
81
|
+
time = 0.0 # Time that increases according to timestep
|
|
82
|
+
max_time = 5.0 # Dummy max_time, in a real simulation this would be undeclared until input
|
|
83
|
+
current_acceleration = 1.0 # Dummy current_acceleration
|
|
84
|
+
speedy_boost = pm.speed_booster(1) # Connects to a speed boost function in 'mechanics.py'
|
|
85
|
+
|
|
86
|
+
while time < max_time:
|
|
87
|
+
current_acceleration = pm.speed_booster(current_acceleration)
|
|
88
|
+
|
|
89
|
+
my_cube["velocity_x"] = pm.find_instantaneous_velocity(
|
|
90
|
+
my_cube["velocity_x"],
|
|
91
|
+
speedy_boost,
|
|
92
|
+
dt
|
|
93
|
+
)
|
|
94
|
+
time += dt
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Source Formulas
|
|
98
|
+
|
|
99
|
+

|
|
100
|
+
|
|
101
|
+

|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
algebraic_physics-0.1.0.dist-info/licenses/LICENSE,sha256=1WScu-2riEzRDTyZ2tlnLGzRwPRdiT7nqchLpbm25zE,1097
|
|
2
|
+
geometry/__init__.py,sha256=FKPofqxR1ySrLIz2crjvfTWtkDQoni0pjj279JrcCR0,180
|
|
3
|
+
geometry/geom.py,sha256=3uzjohelTDfe3IHrLpOTT5zP1RraJQi6TKN4MZ9o8LE,1026
|
|
4
|
+
physics/__init__.py,sha256=4dSd6eHo5aaeNsxfSgpQBeR-alcevrPMrHwbyrlGp2o,326
|
|
5
|
+
physics/mechanics.py,sha256=m9zgopBUIUvVYQVnxt-njnrJj-8A7yILq1YayzaDYU0,2274
|
|
6
|
+
algebraic_physics-0.1.0.dist-info/METADATA,sha256=Oy8Ef64nadi_898zBcid7jkMz9raHzpor_mWAX7B0Hg,2821
|
|
7
|
+
algebraic_physics-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
8
|
+
algebraic_physics-0.1.0.dist-info/top_level.txt,sha256=Z3yZYLPodyiWulcohbHUWaAHwuNVWAFvj9IiqfrUlGo,17
|
|
9
|
+
algebraic_physics-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Caleb Brooks
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
geometry/__init__.py
ADDED
geometry/geom.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
gravity_m3 = 6.67 * 10**-11
|
|
4
|
+
|
|
5
|
+
one_atm = 1.0 * 10**5
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def rectangle_area(length, width):
|
|
9
|
+
return length * width
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def cube_volume(side_length):
|
|
13
|
+
volume = side_length**3
|
|
14
|
+
return volume
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def triangle_area(base, height):
|
|
18
|
+
return 0.5 * base * height
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def circle(radius):
|
|
22
|
+
area = np.pi * (radius**2)
|
|
23
|
+
circumference = 2 * np.pi * radius
|
|
24
|
+
|
|
25
|
+
return area, circumference
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def rectangular_solid(length, width, height):
|
|
29
|
+
volume = length * width * height
|
|
30
|
+
|
|
31
|
+
return volume
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def cylinder(radius, length):
|
|
35
|
+
volume = np.pi * (radius**2) * length
|
|
36
|
+
surface_area = (2 * np.pi * radius * length) + (2 * np.pi * (radius**2))
|
|
37
|
+
|
|
38
|
+
return volume, surface_area
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def sphere(radius):
|
|
42
|
+
volume = 4/3 * np.pi * (radius**3)
|
|
43
|
+
surface_area = 4 * np.pi * (radius**2)
|
|
44
|
+
return volume, surface_area
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def arc_relations(r, theta):
|
|
48
|
+
s = r*theta
|
|
49
|
+
return s
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def pythag(side1, side2):
|
|
53
|
+
side3 = (side1**2 + side2**2)**(1/2)
|
|
54
|
+
return side3
|
physics/__init__.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from .mechanics import (
|
|
2
|
+
find_instantaneous_velocity,
|
|
3
|
+
find_position,
|
|
4
|
+
find_velocity_squared,
|
|
5
|
+
center_of_mass,
|
|
6
|
+
total_acceleration,
|
|
7
|
+
newtons_law_of_universal_gravitation,
|
|
8
|
+
kinetic_energy,
|
|
9
|
+
work,
|
|
10
|
+
delta_ke,
|
|
11
|
+
momentum,
|
|
12
|
+
centripetal_acceleration,
|
|
13
|
+
density,
|
|
14
|
+
speed_booster
|
|
15
|
+
)
|
physics/mechanics.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import geometry.geom as geom
|
|
3
|
+
|
|
4
|
+
# #1
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def find_instantaneous_velocity(initial_velocity, acceleration, time):
|
|
8
|
+
|
|
9
|
+
v_x = initial_velocity + (acceleration * time)
|
|
10
|
+
return v_x
|
|
11
|
+
|
|
12
|
+
# #2
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def find_position(inital_position, initial_velocity, time, current_acceleration):
|
|
16
|
+
|
|
17
|
+
x = inital_position + (initial_velocity*time) + \
|
|
18
|
+
((1/2)*current_acceleration*(time**2))
|
|
19
|
+
return x
|
|
20
|
+
|
|
21
|
+
# #3
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def find_velocity_squared(initial_velocity, acceleration, current_position, initial_position=0):
|
|
25
|
+
v_x_squared = initial_velocity**2 + 2 * \
|
|
26
|
+
acceleration * (current_position - initial_position)
|
|
27
|
+
return v_x_squared
|
|
28
|
+
|
|
29
|
+
# example: [["Ball", 2, 5, forceof10righthere],["Block", 4, 6, forceof8righthere]]
|
|
30
|
+
|
|
31
|
+
# #4
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def center_of_mass(list_of_object_lists):
|
|
35
|
+
top_part = 0
|
|
36
|
+
total_mass = 0
|
|
37
|
+
for obj in list_of_object_lists:
|
|
38
|
+
top_part += (obj[1]*obj[2])
|
|
39
|
+
total_mass += obj[1]
|
|
40
|
+
|
|
41
|
+
center_of_mass = float(top_part/total_mass)
|
|
42
|
+
return center_of_mass
|
|
43
|
+
|
|
44
|
+
# #5
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def total_acceleration(list_of_object_lists):
|
|
48
|
+
top_part = 0
|
|
49
|
+
bottom_part = 0
|
|
50
|
+
|
|
51
|
+
for obj in list_of_object_lists:
|
|
52
|
+
top_part += obj[3]
|
|
53
|
+
bottom_part += obj[1]
|
|
54
|
+
|
|
55
|
+
total_acceleration = top_part/bottom_part
|
|
56
|
+
return total_acceleration
|
|
57
|
+
|
|
58
|
+
# #6
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def newtons_law_of_universal_gravitation(mass1, mass2, radius):
|
|
62
|
+
attractive_force = geom.gravity_m3 * ((mass1 * mass2)/(radius**2))
|
|
63
|
+
return attractive_force
|
|
64
|
+
|
|
65
|
+
# #10
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def kinetic_energy(mass, velocity):
|
|
69
|
+
KE = (1/2) * mass * (velocity**2)
|
|
70
|
+
return KE
|
|
71
|
+
|
|
72
|
+
# #11
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def work(force, distance, angle):
|
|
76
|
+
|
|
77
|
+
if isinstance(angle, float) or isinstance(angle, int):
|
|
78
|
+
angle = np.radians(angle)
|
|
79
|
+
|
|
80
|
+
work = (force * distance) * np.cos(angle)
|
|
81
|
+
return work
|
|
82
|
+
|
|
83
|
+
# #12
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def delta_ke(*work):
|
|
87
|
+
return sum(work)
|
|
88
|
+
|
|
89
|
+
# #16
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def momentum(mass, velocity):
|
|
93
|
+
momentum = mass * velocity
|
|
94
|
+
|
|
95
|
+
return momentum
|
|
96
|
+
|
|
97
|
+
# #9
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def centripetal_acceleration(velocity, radius):
|
|
101
|
+
centripetal_acceleration = (velocity**2)/radius
|
|
102
|
+
return centripetal_acceleration
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def density(mass, volume):
|
|
106
|
+
density = mass/volume
|
|
107
|
+
return density
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def speed_booster(scalar):
|
|
111
|
+
if scalar < 1000:
|
|
112
|
+
scalar += 1
|
|
113
|
+
return scalar
|