Skip to content

Commit 522b936

Browse files
authored
Merge branch 'main' into dependabot/github_actions/codecov/codecov-action-5
2 parents 2e933cf + affdbbd commit 522b936

26 files changed

+4594
-149
lines changed

.github/workflows/ci_cd.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
needs: smoke-tests
6565
runs-on: [self-hosted, pymotorcad, tests]
6666
steps:
67-
- uses: actions/checkout@v4
67+
- uses: actions/checkout@v5
6868

6969
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
7070
uses: actions/setup-python@v4
@@ -88,7 +88,7 @@ jobs:
8888
runs-on: [self-hosted, pymotorcad, docs]
8989
needs: doc-style
9090
steps:
91-
- uses: actions/checkout@v4
91+
- uses: actions/checkout@v5
9292

9393
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
9494
uses: actions/setup-python@v4
@@ -161,7 +161,7 @@ jobs:
161161
twine-username: __token__
162162
twine-token: ${{ secrets.PYPI_TOKEN }}
163163

164-
- uses: actions/checkout@v4
164+
- uses: actions/checkout@v5
165165
- uses: actions/download-artifact@v4
166166

167167
- name: Display structure of downloaded files

.github/workflows/label.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: Syncer
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v4
20+
- uses: actions/checkout@v5
2121
- uses: micnncim/action-label-syncer@v1
2222
env:
2323
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/nightly-motorcad-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
fail-fast: false
2727

2828
steps:
29-
- uses: actions/checkout@v4
29+
- uses: actions/checkout@v5
3030

3131
- name: Set up Python ${{ matrix.python-version }}
3232
uses: actions/setup-python@v4

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* [Husain Adam](https://github.com/HusainAdam)
1515
* [Jack](https://github.com/JackB-Ansys)
1616
* [James Packer](https://github.com/james-packer)
17+
* [Jamie MacLeod](https://github.com/jmacleod-ansys)
1718
* [jgoss30](https://github.com/jgoss30)
1819
* [Joel H.](https://github.com/Joel-H-dot)
1920
* [Kathy Pippert](https://github.com/PipKat)

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ To install in developer mode, complete these steps:
101101
.. code:: bash
102102
103103
git clone https://github.com/ansys/pymotorcad
104+
cd pymotorcad
104105
105106
#. Create a fresh-clean Python environment and then activate it with these
106107
commands:
@@ -130,7 +131,7 @@ To install in developer mode, complete these steps:
130131

131132
.. code:: bash
132133
133-
python -m pip install --editable ansys-motorcad-core
134+
python -m pip install --editable .[tests,doc]
134135
135136
#. Verify your development installation with this command:
136137

doc/source/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Run this code to clone and install the latest version of PyMotorCAD in developme
2020
2121
git clone https://github.com/ansys/pymotorcad
2222
cd pymotorcad
23-
pip install --editable ansys-motorcad-core
23+
pip install --editable .[tests,doc]
2424
2525
2626
Post issues

pyproject.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,26 @@ dependencies = [
3131
"requests >= 2.27.1",
3232
"packaging >= 21.3",
3333
"importlib-metadata>=4.0",
34+
"openpyxl >=3.1.5",
3435
]
3536

3637
[project.optional-dependencies]
3738
tests = [
3839
"pytest==8.3.5",
3940
"pytest-cov==6.2.1",
4041
"ansys.platform.instancemanagement>=1.0.2",
41-
"matplotlib>=3.6.3"
42+
"matplotlib>=3.6.3",
43+
"scipy"
4244
]
4345
doc = [
4446
"Sphinx==8.1.3",
45-
"numpydoc==1.8.0",
46-
"ansys-sphinx-theme==1.2.7",
47+
"numpydoc==1.9.0",
48+
"ansys-sphinx-theme==1.3.3",
4749
"sphinx-copybutton==0.5.2",
48-
"sphinx-gallery==0.18.0",
50+
"sphinx-gallery==0.19.0",
4951
"matplotlib",
5052
"scipy",
51-
"pypandoc==1.14",
53+
"pypandoc==1.15",
5254
"bezier>=2023.7.28",
5355
"networkx"
5456
]
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Copyright (C) 2022 - 2025 ANSYS, Inc. and/or its affiliates.
2+
# SPDX-License-Identifier: MIT
3+
#
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, 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.
22+
23+
# Keywords: **Tapered Bar**, **Induction Motor**, **motor**
24+
"""
25+
Converting IM parallel tooth bar to tapered tooth bar
26+
=========================================
27+
28+
This script applies the adaptive templates functionality to change
29+
the points at the bottom of parallel tooth to create a tapered tooth bar geometry.
30+
"""
31+
32+
33+
import math
34+
import sys
35+
36+
import ansys.motorcad.core as pymotorcad
37+
from ansys.motorcad.core.geometry import Coordinate, rt_to_xy, xy_to_rt
38+
39+
# Connect to Motor-CAD, using existing instance
40+
# Alternatively, we could open a new instance and load a file with mc.load_from_file()
41+
mc = pymotorcad.MotorCAD()
42+
43+
# Reset geometry to default
44+
mc.reset_adaptive_geometry()
45+
46+
# Disable popup messages
47+
mc.set_variable("MessageDisplayState", 2)
48+
49+
50+
# function to return angle based on chord length
51+
# Used for finding new point based on tooth width at bottom of bar
52+
def chord_angle(cord_length, r):
53+
angle = 2 * math.asin(cord_length / (2 * r))
54+
return angle * 180 / math.pi
55+
56+
57+
# Set IM motor type if not already
58+
if not pymotorcad.is_running_in_internal_scripting():
59+
mc.load_template("i6a")
60+
61+
62+
# Get the bar region
63+
bar = mc.get_region("TopRotorBar")
64+
65+
# Get the points at the bottom corners of bar
66+
# Point1 is away from x axis
67+
point1 = bar.points[3]
68+
point2 = bar.points[5]
69+
70+
# Get the top bar tooth width
71+
# Define adaptive parameter for booth bar tooth width
72+
tooth_width_top = mc.get_variable("Rotor_Tooth_Width_T")
73+
mc.set_adaptive_parameter_default("Rotor Tooth Width Bottom", 4)
74+
tooth_width_bottom = mc.get_adaptive_parameter_value("Rotor Tooth Width Bottom")
75+
76+
# Get the point 1 polar coordinates and modify
77+
point1_r, point_1_t = xy_to_rt(point1.x, point1.y)
78+
chord_length = (tooth_width_top - tooth_width_bottom) / 2
79+
del_angle = chord_angle(chord_length, point1_r)
80+
point1_t_new = point_1_t + del_angle
81+
82+
# Get the point 2 polar coordinates and modify
83+
point2_r, point_2_t = xy_to_rt(point2.x, point2.y)
84+
chord_length = (tooth_width_top - tooth_width_bottom) / 2
85+
del_angle = chord_angle(chord_length, point2_r)
86+
point_2_t_new = point_2_t - del_angle
87+
88+
# Get new region coordinates
89+
x, y = rt_to_xy(point1_r, point1_t_new)
90+
point1_new = Coordinate(x, y)
91+
x, y = rt_to_xy(point2_r, point_2_t_new)
92+
point2_new = Coordinate(x, y)
93+
94+
# Edit points at the bottom of the bar
95+
bar.edit_point(point1, point1_new)
96+
bar.edit_point(point2, point2_new)
97+
98+
# Set corner rounding if needed
99+
bar.round_corner(point1_new, 0.2)
100+
bar.round_corner(point2_new, 0.2)
101+
102+
# Set new region
103+
mc.set_region(bar)
104+
105+
# If we're running this externally, load adaptive template script into Motor-CAD
106+
if not pymotorcad.is_running_in_internal_scripting():
107+
mc.set_variable("GeometryTemplateType", 1)
108+
mc.load_adaptive_script(sys.argv[0])

0 commit comments

Comments
 (0)