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

1.1.0 #15

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0620218
ENH: remove Python 3.9 legacy annotations
AndreaBlengino Sep 22, 2024
690dd32
REL: drop Python 3.9 support
AndreaBlengino Sep 22, 2024
9f9ab69
ENH: enhance code style wrapping
AndreaBlengino Sep 24, 2024
58d0794
DOC: add copybutton in documentation code blocks
AndreaBlengino Sep 24, 2024
8244aab
DOC: enhance code style wrapping
AndreaBlengino Sep 24, 2024
3d2974b
ENH: update type check statements
AndreaBlengino Sep 24, 2024
e3d35ba
TST: enhance code style wrapping
AndreaBlengino Oct 4, 2024
f4eb9af
TST: update type check statements
AndreaBlengino Oct 4, 2024
e4685eb
REL: update Python version support in workflows
AndreaBlengino Oct 4, 2024
1a22d17
ENH: improve imports
AndreaBlengino Oct 4, 2024
1a69c8d
ENH: enhance code style wrapping
AndreaBlengino Oct 4, 2024
d45380a
DOC: remove version label check in documentation building
AndreaBlengino Oct 4, 2024
967c0fd
DOC: enhance code style wrapping
AndreaBlengino Oct 4, 2024
bbbc383
ENH: enhance code style wrapping
AndreaBlengino Oct 4, 2024
f3f2c0a
ENH: add missing type hinting
AndreaBlengino Oct 4, 2024
e68bf26
DOC: update supported versions in documentation
AndreaBlengino Oct 20, 2024
7f053ec
REL: update ReadTheDocs Python version
AndreaBlengino Oct 20, 2024
ac4b592
REL: extend support to Python 3.13
AndreaBlengino Oct 20, 2024
6b20151
REL: update dependencies
AndreaBlengino Oct 20, 2024
7f0205c
DOC: update installation instructions
AndreaBlengino Oct 20, 2024
7387872
REL: update release workflow Python version
AndreaBlengino Oct 20, 2024
92fb63a
DOC: add release notes
AndreaBlengino Oct 20, 2024
5a53d9c
DOC: add SemVer badge to README
AndreaBlengino Oct 22, 2024
5016fbd
DOC: fix examples prompt syntax
AndreaBlengino Oct 23, 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
2 changes: 1 addition & 1 deletion .github/workflows/linux_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
matrix:
os: [macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.12.0"

- name: Install building tools
run: |
Expand All @@ -34,9 +34,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '>=3.9 <=3.12'
python-version: '>=3.10 <=3.13'

- name: Give PyPI a chance to update the index
run: sleep 150
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
matrix:
os: [windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.9"
python: "3.12"
jobs:
post_create_environment:
- pip install .[doc]
Expand Down
15 changes: 10 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ Powertrain Analysis
:widths: auto
:width: 100%

* - PyPI
- |pypi_release| |supported_python_versions| |build| |dependencies|
* - Release
- |pypi_release| |build|
* - Versioning
- |supported_python_versions| |semver| |dependencies|
* - Tests
- |linux_tests| |macos_tests| |windows_tests| |test_coverage|
* - Documentation
Expand All @@ -26,13 +28,16 @@ Powertrain Analysis
:target: https://pypi.org/project/gearpy/
:alt: PyPI - Library Version

.. |build| image:: https://img.shields.io/github/actions/workflow/status/AndreaBlengino/gearpy/release.yml.svg?logo=github
:target: https://github.com/AndreaBlengino/gearpy/actions/workflows/release.yml
:alt: Package Build

.. |supported_python_versions| image:: https://img.shields.io/pypi/pyversions/gearpy?logo=python&logoColor=gold
:target: https://pypi.org/project/gearpy/
:alt: PyPI - Supported Python Versions

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

.. |dependencies| image:: https://dependency-dash.repo-helper.uk/github/AndreaBlengino/gearpy/badge.svg
:target: https://dependency-dash.repo-helper.uk/github/AndreaBlengino/gearpy
Expand Down
27 changes: 18 additions & 9 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,32 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'gearpy'
copyright = '2024, Andrea Blengino'
project_copyright = '2024, Andrea Blengino'
author = 'Andrea Blengino'
release = subprocess.run(['git', 'describe', '--tags'], stdout = subprocess.PIPE).stdout.decode('utf-8')

if not release.startswith('v') or not release.endswith('\n') or '-' in release or release.count('.') != 2:
raise ValueError(f"Invalid release name {release}.")
release = subprocess.run(
'git describe --tags'.split(),
stdout=subprocess.PIPE
).stdout.decode('utf-8').strip().split('-')[0]


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

extensions = ['sphinx.ext.autodoc', 'm2r2', 'sphinx.ext.intersphinx']
extensions = [
'sphinx.ext.autodoc',
'm2r2',
'sphinx.ext.intersphinx',
'sphinx_copybutton'
]

templates_path = ['_templates']
exclude_patterns = []

intersphinx_mapping = {'python': ('https://docs.python.org/3', None),
'pandas': ('https://pandas.pydata.org/docs/', None),
'matplotlib': ('https://matplotlib.org/stable/', None)}
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'pandas': ('https://pandas.pydata.org/docs/', None),
'matplotlib': ('https://matplotlib.org/stable/', None)
}


# -- Options for HTML output -------------------------------------------------
Expand All @@ -43,3 +50,5 @@
html_css_files = ['custom.css']
add_module_names = False
html_title = 'gearpy'
copybutton_prompt_text = r">>> |\.\.\. |\$ "
copybutton_prompt_is_regexp = True
12 changes: 6 additions & 6 deletions docs/source/examples/10_time_variables_export/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ After running the simulation, we can export the time variables of each
rotating object in the powertrain with:

```python
powertrain.export_time_variables(folder_path = 'data')
powertrain.export_time_variables(folder_path='data')
```

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

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

We have printed only the first eleven rows of the file.
The code above prints only the first eleven rows of the file.
We can see that there is a column for each available time variable and
each row is a simulated time step.
103 changes: 64 additions & 39 deletions docs/source/examples/10_time_variables_export/time_variables_export.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Import required packages, classes and functions

from gearpy.mechanical_objects import DCMotor, Flywheel, SpurGear
from gearpy.units import AngularSpeed, InertiaMoment, Torque, AngularPosition, TimeInterval
from gearpy.units import (
AngularSpeed,
InertiaMoment,
Torque,
AngularPosition,
TimeInterval
)
from gearpy.utils import add_fixed_joint, add_gear_mating
from gearpy.powertrain import Powertrain
from gearpy.solver import Solver
Expand All @@ -11,48 +17,65 @@

# Model Set Up

motor = DCMotor(name = 'motor',
no_load_speed = AngularSpeed(15000, 'rpm'),
maximum_torque = Torque(10, 'mNm'),
inertia_moment = InertiaMoment(3, 'gcm^2'))
flywheel = Flywheel(name = 'flywheel',
inertia_moment = InertiaMoment(20, 'kgcm^2'))
gear_1 = SpurGear(name = 'gear 1',
n_teeth = 10,
inertia_moment = InertiaMoment(1, 'gcm^2'))
gear_2 = SpurGear(name = 'gear 2',
n_teeth = 80,
inertia_moment = InertiaMoment(3100, 'gcm^2'))
gear_3 = SpurGear(name = 'gear 3',
n_teeth = 10,
inertia_moment = InertiaMoment(4, 'gcm^2'))
gear_4 = SpurGear(name = 'gear 4',
n_teeth = 60,
inertia_moment = InertiaMoment(5000, 'gcm^2'))
gear_5 = SpurGear(name = 'gear 5',
n_teeth = 10,
inertia_moment = InertiaMoment(12, 'gcm^2'))
gear_6 = SpurGear(name = 'gear 6',
n_teeth = 50,
inertia_moment = InertiaMoment(7600, 'gcm^2'))


add_fixed_joint(master = motor, slave = flywheel)
add_fixed_joint(master = flywheel, slave = gear_1)
add_gear_mating(master = gear_1, slave = gear_2, efficiency = 0.9)
add_fixed_joint(master = gear_2, slave = gear_3)
add_gear_mating(master = gear_3, slave = gear_4, efficiency = 0.9)
add_fixed_joint(master = gear_4, slave = gear_5)
add_gear_mating(master = gear_5, slave = gear_6, efficiency = 0.9)
motor = DCMotor(
name='motor',
no_load_speed=AngularSpeed(15000, 'rpm'),
maximum_torque=Torque(10, 'mNm'),
inertia_moment=InertiaMoment(3, 'gcm^2')
)
flywheel = Flywheel(
name='flywheel',
inertia_moment=InertiaMoment(20, 'kgcm^2')
)
gear_1 = SpurGear(
name='gear 1',
n_teeth=10,
inertia_moment=InertiaMoment(1, 'gcm^2')
)
gear_2 = SpurGear(
name='gear 2',
n_teeth=80,
inertia_moment=InertiaMoment(3100, 'gcm^2')
)
gear_3 = SpurGear(
name='gear 3',
n_teeth=10,
inertia_moment=InertiaMoment(4, 'gcm^2')
)
gear_4 = SpurGear(
name='gear 4',
n_teeth=60,
inertia_moment=InertiaMoment(5000, 'gcm^2')
)
gear_5 = SpurGear(
name='gear 5',
n_teeth=10,
inertia_moment=InertiaMoment(12, 'gcm^2')
)
gear_6 = SpurGear(
name='gear 6',
n_teeth=50,
inertia_moment=InertiaMoment(7600, 'gcm^2')
)


add_fixed_joint(master=motor, slave=flywheel)
add_fixed_joint(master=flywheel, slave=gear_1)
add_gear_mating(master=gear_1, slave=gear_2, efficiency=0.9)
add_fixed_joint(master=gear_2, slave=gear_3)
add_gear_mating(master=gear_3, slave=gear_4, efficiency=0.9)
add_fixed_joint(master=gear_4, slave=gear_5)
add_gear_mating(master=gear_5, slave=gear_6, efficiency=0.9)


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


gear_6.external_torque = ext_torque


powertrain = Powertrain(motor = motor)
powertrain = Powertrain(motor=motor)


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


solver = Solver(powertrain = powertrain)
solver.run(time_discretization = TimeInterval(0.5, 'sec'),
simulation_time = TimeInterval(20, 'sec'))
solver = Solver(powertrain=powertrain)
solver.run(
time_discretization=TimeInterval(0.5, 'sec'),
simulation_time=TimeInterval(20, 'sec')
)


# Time Variables Export

powertrain.export_time_variables(folder_path = 'data')
powertrain.export_time_variables(folder_path='data')

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

Expand Down
Loading
Loading