Skip to content

Commit b2b5b9b

Browse files
MRG: Merge pull request #16 from AndreaBlengino/dev
1.1.0
2 parents 682db65 + 5642ba3 commit b2b5b9b

File tree

147 files changed

+18115
-8411
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+18115
-8411
lines changed

.github/workflows/linux_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
strategy:
77
matrix:
88
os: [ubuntu-latest]
9-
python-version: ["3.9", "3.10", "3.11", "3.12"]
9+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1010

1111
steps:
1212
- uses: actions/checkout@v3

.github/workflows/macos_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
strategy:
77
matrix:
88
os: [macos-latest]
9-
python-version: ["3.9", "3.10", "3.11", "3.12"]
9+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1010

1111
steps:
1212
- uses: actions/checkout@v3

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
- uses: actions/checkout@v3
1212

1313
- name: Set up Python
14-
uses: actions/setup-python@v4
14+
uses: actions/setup-python@v5
1515
with:
16-
python-version: 3.9
16+
python-version: "3.12.0"
1717

1818
- name: Install building tools
1919
run: |
@@ -34,9 +34,9 @@ jobs:
3434
runs-on: ubuntu-latest
3535
steps:
3636
- name: Set up Python
37-
uses: actions/setup-python@v4
37+
uses: actions/setup-python@v5
3838
with:
39-
python-version: '>=3.9 <=3.12'
39+
python-version: '>=3.10 <=3.13'
4040

4141
- name: Give PyPI a chance to update the index
4242
run: sleep 150

.github/workflows/windows_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
strategy:
77
matrix:
88
os: [windows-latest]
9-
python-version: ["3.9", "3.10", "3.11", "3.12"]
9+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1010

1111
steps:
1212
- uses: actions/checkout@v3

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ version: 2
77
build:
88
os: ubuntu-22.04
99
tools:
10-
python: "3.9"
10+
python: "3.12"
1111
jobs:
1212
post_create_environment:
1313
- pip install .[doc]

README.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ Powertrain Analysis
1111
:widths: auto
1212
:width: 100%
1313

14-
* - PyPI
15-
- |pypi_release| |supported_python_versions| |build| |dependencies|
14+
* - Release
15+
- |pypi_release| |build|
16+
* - Versioning
17+
- |supported_python_versions| |semver| |dependencies|
1618
* - Tests
1719
- |linux_tests| |macos_tests| |windows_tests| |test_coverage|
1820
* - Documentation
@@ -26,13 +28,16 @@ Powertrain Analysis
2628
:target: https://pypi.org/project/gearpy/
2729
:alt: PyPI - Library Version
2830

31+
.. |build| image:: https://img.shields.io/github/actions/workflow/status/AndreaBlengino/gearpy/release.yml.svg?logo=github
32+
:target: https://github.com/AndreaBlengino/gearpy/actions/workflows/release.yml
33+
:alt: Package Build
34+
2935
.. |supported_python_versions| image:: https://img.shields.io/pypi/pyversions/gearpy?logo=python&logoColor=gold
3036
:target: https://pypi.org/project/gearpy/
3137
:alt: PyPI - Supported Python Versions
3238

33-
.. |build| image:: https://img.shields.io/github/actions/workflow/status/AndreaBlengino/gearpy/release.yml.svg?logo=github
34-
:target: https://github.com/AndreaBlengino/gearpy/actions/workflows/release.yml
35-
:alt: Package Build
39+
.. |semver| image:: https://img.shields.io/badge/semver-2.0.0-blue.svg
40+
:target: https://semver.org/
3641

3742
.. |dependencies| image:: https://dependency-dash.repo-helper.uk/github/AndreaBlengino/gearpy/badge.svg
3843
:target: https://dependency-dash.repo-helper.uk/github/AndreaBlengino/gearpy

docs/source/conf.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,32 @@
1414
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
1515

1616
project = 'gearpy'
17-
copyright = '2024, Andrea Blengino'
17+
project_copyright = '2024, Andrea Blengino'
1818
author = 'Andrea Blengino'
19-
release = subprocess.run(['git', 'describe', '--tags'], stdout = subprocess.PIPE).stdout.decode('utf-8')
20-
21-
if not release.startswith('v') or not release.endswith('\n') or '-' in release or release.count('.') != 2:
22-
raise ValueError(f"Invalid release name {release}.")
19+
release = subprocess.run(
20+
'git describe --tags'.split(),
21+
stdout=subprocess.PIPE
22+
).stdout.decode('utf-8').strip().split('-')[0]
2323

2424

2525
# -- General configuration ---------------------------------------------------
2626
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
2727

28-
extensions = ['sphinx.ext.autodoc', 'm2r2', 'sphinx.ext.intersphinx']
28+
extensions = [
29+
'sphinx.ext.autodoc',
30+
'm2r2',
31+
'sphinx.ext.intersphinx',
32+
'sphinx_copybutton'
33+
]
2934

3035
templates_path = ['_templates']
3136
exclude_patterns = []
3237

33-
intersphinx_mapping = {'python': ('https://docs.python.org/3', None),
34-
'pandas': ('https://pandas.pydata.org/docs/', None),
35-
'matplotlib': ('https://matplotlib.org/stable/', None)}
38+
intersphinx_mapping = {
39+
'python': ('https://docs.python.org/3', None),
40+
'pandas': ('https://pandas.pydata.org/docs/', None),
41+
'matplotlib': ('https://matplotlib.org/stable/', None)
42+
}
3643

3744

3845
# -- Options for HTML output -------------------------------------------------
@@ -43,3 +50,5 @@
4350
html_css_files = ['custom.css']
4451
add_module_names = False
4552
html_title = 'gearpy'
53+
copybutton_prompt_text = r">>> |\.\.\. |\$ "
54+
copybutton_prompt_is_regexp = True

docs/source/examples/10_time_variables_export/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ After running the simulation, we can export the time variables of each
1414
rotating object in the powertrain with:
1515

1616
```python
17-
powertrain.export_time_variables(folder_path = 'data')
17+
powertrain.export_time_variables(folder_path='data')
1818
```
1919

2020
See
2121
:py:meth:`Powertrain.export_time_variables <gearpy.powertrain.Powertrain.export_time_variables>`
2222
for more details on method parameters.
23-
and write the name of the folder in which to save the files, `'data'` in
24-
this case. In that folder `gearpy` saves a file for each rotating object
25-
in the powertrain, and it uses the name of the rotating object to name
26-
the file.
23+
Set `'folder_path'` to the name of the folder in which to save the
24+
files, `'data'` in this case. In that folder `gearpy` saves a file for
25+
each rotating object in the powertrain, and it uses the name of
26+
the rotating object to name the file.
2727
We can open and analyze these file with [pandas](https://pandas.pydata.org),
2828
which is a dependency of `gearpy`, so it is already installed:
2929

@@ -51,6 +51,6 @@ print(motor_data.head(11).to_string())
5151
10 5.0 4166.363812 1074.527928 25.700699 0.000302 0.003159 0.002858 1
5252
```
5353

54-
We have printed only the first eleven rows of the file.
54+
The code above prints only the first eleven rows of the file.
5555
We can see that there is a column for each available time variable and
5656
each row is a simulated time step.

docs/source/examples/10_time_variables_export/time_variables_export.py

Lines changed: 64 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# Import required packages, classes and functions
22

33
from gearpy.mechanical_objects import DCMotor, Flywheel, SpurGear
4-
from gearpy.units import AngularSpeed, InertiaMoment, Torque, AngularPosition, TimeInterval
4+
from gearpy.units import (
5+
AngularSpeed,
6+
InertiaMoment,
7+
Torque,
8+
AngularPosition,
9+
TimeInterval
10+
)
511
from gearpy.utils import add_fixed_joint, add_gear_mating
612
from gearpy.powertrain import Powertrain
713
from gearpy.solver import Solver
@@ -11,48 +17,65 @@
1117

1218
# Model Set Up
1319

14-
motor = DCMotor(name = 'motor',
15-
no_load_speed = AngularSpeed(15000, 'rpm'),
16-
maximum_torque = Torque(10, 'mNm'),
17-
inertia_moment = InertiaMoment(3, 'gcm^2'))
18-
flywheel = Flywheel(name = 'flywheel',
19-
inertia_moment = InertiaMoment(20, 'kgcm^2'))
20-
gear_1 = SpurGear(name = 'gear 1',
21-
n_teeth = 10,
22-
inertia_moment = InertiaMoment(1, 'gcm^2'))
23-
gear_2 = SpurGear(name = 'gear 2',
24-
n_teeth = 80,
25-
inertia_moment = InertiaMoment(3100, 'gcm^2'))
26-
gear_3 = SpurGear(name = 'gear 3',
27-
n_teeth = 10,
28-
inertia_moment = InertiaMoment(4, 'gcm^2'))
29-
gear_4 = SpurGear(name = 'gear 4',
30-
n_teeth = 60,
31-
inertia_moment = InertiaMoment(5000, 'gcm^2'))
32-
gear_5 = SpurGear(name = 'gear 5',
33-
n_teeth = 10,
34-
inertia_moment = InertiaMoment(12, 'gcm^2'))
35-
gear_6 = SpurGear(name = 'gear 6',
36-
n_teeth = 50,
37-
inertia_moment = InertiaMoment(7600, 'gcm^2'))
38-
39-
40-
add_fixed_joint(master = motor, slave = flywheel)
41-
add_fixed_joint(master = flywheel, slave = gear_1)
42-
add_gear_mating(master = gear_1, slave = gear_2, efficiency = 0.9)
43-
add_fixed_joint(master = gear_2, slave = gear_3)
44-
add_gear_mating(master = gear_3, slave = gear_4, efficiency = 0.9)
45-
add_fixed_joint(master = gear_4, slave = gear_5)
46-
add_gear_mating(master = gear_5, slave = gear_6, efficiency = 0.9)
20+
motor = DCMotor(
21+
name='motor',
22+
no_load_speed=AngularSpeed(15000, 'rpm'),
23+
maximum_torque=Torque(10, 'mNm'),
24+
inertia_moment=InertiaMoment(3, 'gcm^2')
25+
)
26+
flywheel = Flywheel(
27+
name='flywheel',
28+
inertia_moment=InertiaMoment(20, 'kgcm^2')
29+
)
30+
gear_1 = SpurGear(
31+
name='gear 1',
32+
n_teeth=10,
33+
inertia_moment=InertiaMoment(1, 'gcm^2')
34+
)
35+
gear_2 = SpurGear(
36+
name='gear 2',
37+
n_teeth=80,
38+
inertia_moment=InertiaMoment(3100, 'gcm^2')
39+
)
40+
gear_3 = SpurGear(
41+
name='gear 3',
42+
n_teeth=10,
43+
inertia_moment=InertiaMoment(4, 'gcm^2')
44+
)
45+
gear_4 = SpurGear(
46+
name='gear 4',
47+
n_teeth=60,
48+
inertia_moment=InertiaMoment(5000, 'gcm^2')
49+
)
50+
gear_5 = SpurGear(
51+
name='gear 5',
52+
n_teeth=10,
53+
inertia_moment=InertiaMoment(12, 'gcm^2')
54+
)
55+
gear_6 = SpurGear(
56+
name='gear 6',
57+
n_teeth=50,
58+
inertia_moment=InertiaMoment(7600, 'gcm^2')
59+
)
60+
61+
62+
add_fixed_joint(master=motor, slave=flywheel)
63+
add_fixed_joint(master=flywheel, slave=gear_1)
64+
add_gear_mating(master=gear_1, slave=gear_2, efficiency=0.9)
65+
add_fixed_joint(master=gear_2, slave=gear_3)
66+
add_gear_mating(master=gear_3, slave=gear_4, efficiency=0.9)
67+
add_fixed_joint(master=gear_4, slave=gear_5)
68+
add_gear_mating(master=gear_5, slave=gear_6, efficiency=0.9)
4769

4870

4971
def ext_torque(time, angular_position, angular_speed):
5072
return Torque(500, 'mNm')
5173

74+
5275
gear_6.external_torque = ext_torque
5376

5477

55-
powertrain = Powertrain(motor = motor)
78+
powertrain = Powertrain(motor=motor)
5679

5780

5881
# Simulation Set Up
@@ -61,14 +84,16 @@ def ext_torque(time, angular_position, angular_speed):
6184
gear_6.angular_speed = AngularSpeed(0, 'rad/s')
6285

6386

64-
solver = Solver(powertrain = powertrain)
65-
solver.run(time_discretization = TimeInterval(0.5, 'sec'),
66-
simulation_time = TimeInterval(20, 'sec'))
87+
solver = Solver(powertrain=powertrain)
88+
solver.run(
89+
time_discretization=TimeInterval(0.5, 'sec'),
90+
simulation_time=TimeInterval(20, 'sec')
91+
)
6792

6893

6994
# Time Variables Export
7095

71-
powertrain.export_time_variables(folder_path = 'data')
96+
powertrain.export_time_variables(folder_path='data')
7297

7398
motor_data = pd.read_csv(os.path.join('data', 'motor.csv'))
7499

0 commit comments

Comments
 (0)