Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/main' into update_get_gr…
Browse files Browse the repository at this point in the history
…aph_api_methods
  • Loading branch information
james-packer committed Oct 23, 2024
2 parents 7488c2f + be844a3 commit 1b82300
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 24 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Ansys code style checks
uses: ansys/actions/code-style@v6
uses: ansys/actions/code-style@v8
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}

Expand All @@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Ansys documentation style checks
uses: ansys/actions/doc-style@v6
uses: ansys/actions/doc-style@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -50,7 +50,7 @@ jobs:
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- name: Build wheelhouse and perform smoke test
uses: ansys/actions/build-wheelhouse@v6
uses: ansys/actions/build-wheelhouse@v8
with:
library-name: ${{ env.LIBRARY_NAME }}
library-namespace: ${{ env.LIBRARY_NAMESPACE }}
Expand Down Expand Up @@ -116,10 +116,12 @@ jobs:
needs: package
steps:
- name: "Deploy development documentation"
uses: ansys/actions/doc-deploy-dev@v6
uses: ansys/actions/doc-deploy-dev@v8
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}

doc-deploy-stable:
name: Doc stable version deploy
Expand All @@ -128,19 +130,21 @@ jobs:
needs: release
steps:
- name: "Deploy stable documentation"
uses: ansys/actions/doc-deploy-stable@v6
uses: ansys/actions/doc-deploy-stable@v8
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}

package:
name: Package library
runs-on: ubuntu-latest
needs: [doc-build, tests]
steps:
- name: Build library source and wheel artifacts
uses: ansys/actions/build-library@v6
uses: ansys/actions/build-library@v8
with:
library-name: ${{ env.LIBRARY_NAME }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
Expand All @@ -152,7 +156,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Release to PyPI repository
uses: ansys/actions/release-pypi-public@v6
uses: ansys/actions/release-pypi-public@v8
with:
library-name: ${{ env.LIBRARY_NAME }}
twine-username: __token__
Expand Down
14 changes: 14 additions & 0 deletions doc/source/methods/geometry_drawing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _ref_geometry_drawing:
.. currentmodule:: ansys.motorcad.core.geometry_drawing
Geometry drawing
================
Geometry drawing functions are used to visualise Motor-CAD
geometry objects using PyMotorCAD.
More information on Adaptive Templates is available
in the :ref:`ref_user_guide` under :ref:`ref_adaptive_templates_UG`.

.. autosummary::
:toctree: _autosummary_geometry_drawing

draw_objects
draw_objects_debug
6 changes: 0 additions & 6 deletions doc/source/methods/geometry_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,3 @@ Geometry functions
get_entities_have_common_coordinate
xy_to_rt
rt_to_xy

.. currentmodule:: ansys.motorcad.core.geometry_drawing
.. autosummary::
:toctree: _autosummary_geometry_functions

draw_regions
9 changes: 9 additions & 0 deletions doc/source/methods/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ Geometry objects and functions are used for
defining and modifying Adaptive Templates geometries in Python.
For descriptions of the objects and functions, see :ref:`ref_geometry_functions`.

Geometry drawing
------------------------------
The ``ansys.motorcad.core.geometry_drawing`` library contains functions for drawing
geometry objects as static visualisations in Python. Geometry drawing is used for plotting

Check warning on line 38 in doc/source/methods/index.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/methods/index.rst#L38

[Google.OxfordComma] Use the Oxford comma in 'Geometry drawing is used for plotting objects such as regions, lines, arcs and'.
Raw output
{"message": "[Google.OxfordComma] Use the Oxford comma in 'Geometry drawing is used for plotting objects such as regions, lines, arcs and'.", "location": {"path": "doc/source/methods/index.rst", "range": {"start": {"line": 38, "column": 54}}}, "severity": "WARNING"}
objects such as regions, lines, arcs and coordinates within the x-y plane. Drawing Motor-CAD
geometry objects can make it easier to test and create Adaptive Templates scripts.
For descriptions of the geometry drawing functions, see :ref:`ref_geometry_drawing`.

Geometry shapes
------------------------------
The ``ansys.motorcad.core.geometry_shapes`` library contains geometry functions
Expand All @@ -47,4 +55,5 @@ For descriptions of the functions, see :ref:`ref_geometry_shapes`.
MotorCAD_object
MotorCADCompatibility_object
geometry_functions
geometry_drawing
geometry_shapes
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,23 @@ def updateMotfile(self):
## TB model will not include this logic
self.mcad.set_variable("BearingLossSource", 0)

# 9 Workaround for models created in Motor-CAD 2025R1 - ensure the old fluid heat flow
# method is used
try:
heatFlowMethod = self.mcad.get_variable("FluidHeatFlowMethod")
if heatFlowMethod == 1:
# Revert model to use the old fluid heat flow method
warnings.warn(
"The Improved Fluid Heat Flow Method setting in this .mot file is incompatible "
+ "with the Twin Builder Thermal ROM. The setting has been changed from "
+ "Improved to Original."
)
self.mcad.set_variable("FluidHeatFlowMethod", 0)
except:
# variable does not exist due to using older version of Motor-CAD
# no need to perform any action
pass

# save the updated model so it is clear which Motor-CAD file can be used to validate
# the Twin Builder Motor-CAD ROM component
self.motFileName = Path(self.inputMotFilePath).stem + "_TwinModel"
Expand Down Expand Up @@ -423,12 +440,10 @@ def generateCoolingSystemNetwork(self):
connectedNodes = self.returnConnectedNodes(
node, self.nodeNumbers_fluid, resistanceMatrix
)
if len(connectedNodes) > 0:
# non isolated node
if node not in graphNodes:
graphNodes.append(node)
for connectedNode in connectedNodes:
graphEdges.append([node, connectedNode])
if node not in graphNodes:
graphNodes.append(node)
for connectedNode in connectedNodes:
graphEdges.append([node, connectedNode])

G = nx.DiGraph()
G.add_nodes_from(graphNodes)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tests = [
doc = [
"Sphinx==8.1.3",
"numpydoc==1.8.0",
"ansys-sphinx-theme==1.1.5",
"ansys-sphinx-theme==1.1.6",
"sphinx-copybutton==0.5.2",
"sphinx-gallery==0.18.0",
"matplotlib",
Expand Down
12 changes: 10 additions & 2 deletions src/ansys/motorcad/core/methods/rpc_methods_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,21 @@ def save_external_circuit(self, circuit_file_name):
return self.connection.send_and_receive(method, params)

def save_transient_power_values(self, file_name):
"""Save transient power results to a CSV file."""
"""Save transient power results to a text file.
Text file separator defined using the
``"ExportTextSeparator"`` parameter (default is semicolon).
"""
method = "SaveTransientPowerValues"
params = [file_name]
return self.connection.send_and_receive(method, params)

def save_transient_temperatures(self, file_name):
"""Save transient temperature results to a CSV file."""
"""Save transient temperature results to a text file.
Text file separator defined using the
``"ExportTextSeparator"`` parameter (default is semicolon).
"""
method = "SaveTransientTemperatures"
params = [file_name]
return self.connection.send_and_receive(method, params)
Expand Down
4 changes: 4 additions & 0 deletions tests/RPC_Test_Common.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def almost_equal(a, b, decimal_places=1):
return round(a - b, decimal_places) == 0


def almost_equal_percentage(a, b, percentage):
return abs(a - b) < abs(a * (percentage / 100))


def almost_equal_fixed(a, b, allowed_difference=0):
return abs(a - b) < +allowed_difference

Expand Down
9 changes: 9 additions & 0 deletions tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1926,3 +1926,12 @@ def test_get_set_region_compatibility(mc, monkeypatch):

with pytest.warns(UserWarning):
mc.set_region(test_region)


def test_region_material_assignment(mc):
rotor = mc.get_region("Rotor")
rotor.material = "M470-50A"

mc.set_region(rotor)

assert rotor == mc.get_region("Rotor")
4 changes: 2 additions & 2 deletions tests/test_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# import pytest

from RPC_Test_Common import almost_equal, reset_to_default_file
from RPC_Test_Common import almost_equal, almost_equal_percentage, reset_to_default_file


def test_get_magnetic_graph_point(mc):
Expand All @@ -34,7 +34,7 @@ def test_get_magnetic_graph_point(mc):

x, y = mc.get_magnetic_graph_point("TorqueVW", 3)
assert almost_equal(x, 360)
assert almost_equal(y, 182, 0)
assert almost_equal_percentage(y, 182, 20)


def test_get_temperature_graph_point(mc):
Expand Down

0 comments on commit 1b82300

Please sign in to comment.