Skip to content

Commit

Permalink
Merge branch 'main' into release/0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
SMoraisAnsys committed Aug 20, 2024
2 parents bd0278a + d2c4c75 commit 2275a37
Show file tree
Hide file tree
Showing 13 changed files with 1,024 additions and 262 deletions.
13 changes: 13 additions & 0 deletions _unittest/test_27_Maxwell2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,3 +618,16 @@ def test_39_create_external_circuit(self):
w.delete()
self.m2d_circuit.save_project()
assert not self.m2d_circuit.create_external_circuit()

def test_40_assign_floating(self):
self.aedtapp.insert_design("Floating")
self.aedtapp.solution_type = SOLUTIONS.Maxwell2d.ElectroStaticXY
rect = self.aedtapp.modeler.create_rectangle([0, 0, 0], [3, 1], name="Rectangle1")
floating = self.aedtapp.assign_floating(assignment=rect, charge_value=3, name="floating_test")
assert floating
assert floating.name == "floating_test"
assert floating.props["Objects"][0] == rect.name
assert floating.props["Value"] == "3"
self.aedtapp.solution_type = SOLUTIONS.Maxwell2d.MagnetostaticXY
floating = self.aedtapp.assign_floating(assignment=rect, charge_value=3, name="floating_test1")
assert not floating
14 changes: 14 additions & 0 deletions _unittest/test_28_Maxwell3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,3 +1083,17 @@ def test_58_solution_types_setup(self, add_app):
setup = m3d.create_setup(setup_type=m3d.solution_type)
assert setup
setup.delete()

def test_59_assign_floating(self):
self.aedtapp.insert_design("Floating")
self.aedtapp.solution_type = SOLUTIONS.Maxwell3d.ElectroStatic
box = self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 10], name="Box1")
floating = self.aedtapp.assign_floating(assignment=box, charge_value=3)
assert floating
assert floating.props["Objects"][0] == box.name
assert floating.props["Value"] == "3"
floating1 = self.aedtapp.assign_floating(assignment=[box.faces[0], box.faces[1]], charge_value=3)
assert floating1
self.aedtapp.solution_type = SOLUTIONS.Maxwell3d.Magnetostatic
floating = self.aedtapp.assign_floating(assignment=box, charge_value=3)
assert not floating
175 changes: 120 additions & 55 deletions _unittest/test_98_Icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from ansys.aedt.core.generic.settings import settings
from ansys.aedt.core.modules.boundary import NativeComponentObject
from ansys.aedt.core.modules.boundary import NetworkObject
from ansys.aedt.core.modules.boundary import PCBSettingsDeviceParts
from ansys.aedt.core.modules.boundary import PCBSettingsPackageParts
from ansys.aedt.core.modules.mesh_icepak import MeshRegion
from ansys.aedt.core.modules.setup_templates import SetupKeys
import pytest
Expand Down Expand Up @@ -109,75 +111,138 @@ def test_02b_PCB_filters(self, local_scratch):
custom_y_resolution=500,
extent_type="Polygon",
)
assert cmp2.set_device_parts(True, "Steel-mild-surface")
assert cmp2.disable_device_parts()
assert cmp2.set_package_parts(solderballs="Boxes", connector="Solderbump", solderbumps_modeling="Lumped")
assert cmp2.set_package_parts(
solderballs="Lumped", connector="Bondwire", bondwire_material="Al-Extruded", bondwire_diameter="0.5mm"
)
assert not cmp2.set_package_parts(solderballs="Error1") # invalid input
assert not cmp2.set_package_parts(connector="Error2") # invalid input
assert not cmp2.set_package_parts(solderbumps_modeling="Error3") # invalid input
assert not cmp2.set_package_parts(bondwire_material="Error4") # material does not exist
assert not bool(cmp2.overridden_components)
assert not cmp2.override_component("FCHIP", True) # invalid part import selection
assert cmp2.set_device_parts()
assert cmp2.override_component("FCHIP", True)
cmp2.included_parts = 1
assert isinstance(cmp2.included_parts, PCBSettingsDeviceParts)
cmp2.included_parts = None
assert cmp2.included_parts is None
cmp2.included_parts = "Device"
assert cmp2.included_parts == "Device"
assert not cmp2.included_parts == "Package"
assert cmp2.included_parts == cmp2.included_parts
assert not cmp2.included_parts == "Package"
assert not cmp2.included_parts != "Device"
assert isinstance(cmp2.included_parts, PCBSettingsDeviceParts)
cmp2.included_parts = "Package"
assert not cmp2.included_parts == "Packages"
assert isinstance(cmp2.included_parts, PCBSettingsPackageParts)
assert cmp2.included_parts.set_connectors_modeling(modeling="Solderbump", solderbumps_modeling="Boxes")
assert cmp2.included_parts.set_connectors_modeling(
modeling="Bondwire", bondwire_material="Au-Typical", bondwire_diameter="0.01mm"
)
assert cmp2.included_parts.set_connectors_modeling(modeling="Solderbump", solderbumps_modeling="Lumped")
assert not cmp2.included_parts.set_connectors_modeling(modeling="Error")
assert not cmp2.included_parts.set_connectors_modeling(
modeling="Solderbump", solderbumps_modeling="Error1"
) # invalid input
assert not cmp2.included_parts.set_connectors_modeling(
modeling="Bondwire", bondwire_material="Error4"
) # material does not exist
cmp2.included_parts = "Device"
cmp2.included_parts.simplify_parts = True
assert cmp2.included_parts.simplify_parts
cmp2.included_parts.surface_material = "pt-polished"
assert cmp2.included_parts.surface_material == "pt-polished"
assert cmp2.included_parts.override_instance("FCHIP", True)
assert "Board_w_cmp_FCHIP_device" not in self.aedtapp.modeler.object_names
assert cmp2.override_component("FCHIP", False)
assert cmp2.included_parts.override_instance("FCHIP", False)
assert "Board_w_cmp_FCHIP_device" in self.aedtapp.modeler.object_names
assert cmp2.override_component("FCHIP", False, "10W", "1Kel_per_W", "1Kel_per_W", "0.1mm")
assert cmp2.set_board_settings("Bounding Box")
assert cmp2.set_board_settings("Polygon")
assert cmp2.set_board_settings("Bounding Box")
assert cmp2.set_board_settings("Polygon", "outline:poly_0")
cmp2.disable_device_parts()
cmp2.footprint_filter = "1mm2"
assert cmp2.footprint_filter is None
cmp2.power_filter = "1W"
assert cmp2.power_filter is None
cmp2.type_filters = "Resistors"
assert cmp2.type_filters is None
cmp2.height_filter = "1mm"
assert cmp2.height_filter is None
cmp2.objects_2d_filter = True
assert cmp2.objects_2d_filter is None
assert cmp2.included_parts.override_instance("FCHIP", False, "10W", "1Kel_per_W", "1Kel_per_W", "0.1mm")
if self.aedtapp.settings.aedt_version >= "2024.2":
cmp2.included_parts.override_definition("FCHIP_FCHIP", "FCHIP_FCHIP")
else:
assert not cmp2.included_parts.override_definition("a", "b")
assert cmp2.set_board_extents("Bounding Box")
assert cmp2.set_board_extents("Polygon")
assert cmp2.set_board_extents("Bounding Box")
assert cmp2.set_board_extents("Polygon", "outline:poly_0")
p = cmp2.included_parts
cmp2.included_parts = "None"
p.footprint_filter = "1mm2"
assert p.footprint_filter is None
p.power_filter = "1W"
assert p.power_filter is None
p.type_filters = "Resistors"
assert p.type_filters is None
p.height_filter = "1mm"
assert p.height_filter is None
p.objects_2d_filter = True
assert p.objects_2d_filter is None
assert cmp2.power == "0W"
cmp2.power = "10W"
assert cmp2.power == "10W"
assert not cmp2.set_resolution(0)
assert cmp2.set_resolution(1)
assert cmp2.set_custom_resolution(row=100, col=200)
cmp2.set_high_side_radiation(
True,
surface_material="Stainless-steel-typical",
radiate_to_ref_temperature=True,
view_factor=0.5,
ref_temperature="20cel",
)
cmp2.set_low_side_radiation(
True,
surface_material="Stainless-steel-typical",
radiate_to_ref_temperature=True,
view_factor=0.8,
ref_temperature="25cel",
)
assert cmp2.force_source_solve
cmp2.force_source_solve = True
cmp2.preserve_partner_solution = True
assert cmp2.preserve_partner_solution
cmp2.via_holes_material = "air"
cmp2.board_cutout_material = "copper"
assert cmp2.via_holes_material == "air"
assert cmp2.board_cutout_material == "copper"

component_name = "RadioBoard2"
cmp = self.aedtapp.create_ipk_3dcomponent_pcb(
component_name, link_data, solution_freq, resolution, custom_x_resolution=400, custom_y_resolution=500
)
assert not cmp.filters
assert cmp.set_device_parts()
f = cmp.filters
assert cmp.included_parts is None
cmp.included_parts = "Device"
print(cmp.included_parts)
cmp.included_parts = "Packafe"
assert cmp.included_parts == "Device"
f = cmp.included_parts.filters
assert len(f.keys()) == 1
assert all(not v for v in f["Type"].values())
assert cmp.height_filter is None
assert cmp.footprint_filter is None
assert cmp.power_filter is None
assert not cmp.objects_2d_filter
cmp.height_filter = "1mm"
cmp.objects_2d_filter = True
cmp.power_filter = "4mW"
cmp.type_filters = "Resistors"
cmp.type_filters = "Register" # should not be set
cmp.type_filters = "Inductors"
assert cmp.included_parts.height_filter is None
assert cmp.included_parts.footprint_filter is None
assert cmp.included_parts.power_filter is None
assert not cmp.included_parts.objects_2d_filter
cmp.included_parts.height_filter = "1mm"
cmp.included_parts.objects_2d_filter = True
cmp.included_parts.power_filter = "4mW"
cmp.included_parts.type_filters = "Resistors"
cmp.included_parts.type_filters = "Register" # should not be set
cmp.included_parts.type_filters = "Inductors"
if self.aedtapp.settings.aedt_version >= "2024.2":
cmp.footprint_filter = "0.5mm2"
f = cmp.filters
cmp.included_parts.footprint_filter = "0.5mm2"
else:
assert cmp.included_parts.footprint_filter is None
f = cmp.included_parts.filters
assert len(f.keys()) >= 4 # 5 if version 2024.2
assert f["Type"]["Inductors"]
assert cmp.set_board_settings()
assert not cmp.set_board_settings("Polygon")
assert not cmp.set_board_settings("Bounding Domain")
cmp.set_board_settings("Bounding Box")
cmp.power_filter = None
cmp.height_filter = None
cmp.objects_2d_filter = False
assert cmp.set_board_extents()
assert not cmp.set_board_extents("Polygon")
assert not cmp.set_board_extents("Bounding Domain")
cmp.set_board_extents("Bounding Box")
cmp.included_parts.power_filter = None
cmp.included_parts.height_filter = None
cmp.included_parts.objects_2d_filter = False
if self.aedtapp.settings.aedt_version >= "2024.2":
cmp.footprint_filter = None
f = cmp.filters
cmp.included_parts.footprint_filter = None
f = cmp.included_parts.filters
assert len(f.keys()) == 1
cmp.included_parts = "Package"
print(cmp.included_parts)
assert cmp.included_parts == "Package"
assert cmp.included_parts == cmp.included_parts
assert not cmp.included_parts == "Device"
assert not cmp.included_parts != "Package"
cmp.included_parts.set_solderballs_modeling("Boxes")

def test_02A_find_top(self):
assert self.aedtapp.find_top(0)
Expand Down
25 changes: 18 additions & 7 deletions _unittest/test_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,44 @@
import warnings

from ansys.aedt.core import LATEST_DEPRECATED_PYTHON_VERSION
from ansys.aedt.core import WARNING_MESSAGE
from ansys.aedt.core import PYTHON_VERSION_WARNING
from ansys.aedt.core import deprecation_warning
from pyaedt import ALIAS_WARNING

VALID_PYTHON_VERSION = (LATEST_DEPRECATED_PYTHON_VERSION[0], LATEST_DEPRECATED_PYTHON_VERSION[1] + 1)


@patch.object(warnings, "warn")
def test_deprecation_warning_with_deprecated_python_version(mock_warn, monkeypatch):
"""Test that python version warning is triggered."""
monkeypatch.setattr(sys, "version_info", LATEST_DEPRECATED_PYTHON_VERSION)

deprecation_warning()

mock_warn.assert_called_once_with(WARNING_MESSAGE, FutureWarning)
mock_warn.assert_called_once_with(PYTHON_VERSION_WARNING, FutureWarning)


@patch.object(warnings, "warn")
def test_deprecation_warning_with_valid_python_version(mock_warn, monkeypatch):
"""Test that python version warning is not triggered."""
monkeypatch.setattr(sys, "version_info", VALID_PYTHON_VERSION)

deprecation_warning()

mock_warn.assert_not_called()


@patch.object(warnings, "warn")
def test_alias_deprecation_warning(mock_warn):
from pyaedt import WARNING_MESSAGE
import pyaedt.modules # noqa: F401
def test_alias_deprecation_warning():
"""Test that pyaedt alias warning is triggered."""
import importlib

import pyaedt

# Ensure that the warning will be triggered again
del pyaedt.__warningregistry__

importlib.reload(pyaedt)

mock_warn.assert_called_once_with(WARNING_MESSAGE, FutureWarning)
# Hardcoded test where 28 is the line number associated to the warning call
# TODO: See if pytest.warns can be 'fixed' to work with module reload
assert (ALIAS_WARNING, FutureWarning, 28) in pyaedt.__warningregistry__
49 changes: 45 additions & 4 deletions doc/source/API/Boundaries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,67 @@ app methods and can be used to edit or delete a boundary condition.
:toctree: _autosummary
:nosignatures:

NativeComponentObject
BoundaryObject
BoundaryObject3dLayout
NetworkObject
FarFieldSetup
Matrix
BoundaryObject3dLayout
Sources
Excitations

Example without ``Native Component Object``:
Native components
-----------------

When native components object are created, the ``NativeComponentObject`` class is returned. For PCB components, ``NativeComponentPCB`` is returned.

.. autosummary::
:toctree: _autosummary
:nosignatures:

NativeComponentObject
NativeComponentPCB

``Native Component Object`` example:

.. code:: python
from ansys.aedt.core import Icepak
ipk = Icepak()
component_name = "RadioBoard1"
native_comp = self.aedtapp.create_ipk_3dcomponent_pcb(
pcb_comp = self.aedtapp.create_ipk_3dcomponent_pcb(
component_name, link_data, solution_freq, resolution, custom_x_resolution=400, custom_y_resolution=500
)
# native_comp is a NativeComponentObject
# pcb_comp is a NativeComponentPCB
...
ipk.release_desktop()
Icepak transient assignments
----------------------------
To facilitate transient assignment handling in Icepak, it is possible to use one of the following classes:

.. autosummary::
:toctree: _autosummary
:nosignatures:

LinearDictionary
PowerLawDictionary
ExponentialDictionary
SinusoidalDictionary
SquareWaveDictionary
PieceWiseLinearDictionary

It is possible to initialize the class manually or through a method:

.. code:: python
bc_transient = ipk.create_sinusoidal_transient_assignment(vertical_offset="1W", vertical_scaling="3",
period="2", period_offset="0.5s")
# bc_transient will be SinusoidalDictionary type
ipk.assign_solid_block("Cylinder1", bc_transient)
#or
bc_transient = SinusoidalDictionary(vertical_offset="1W", vertical_scaling="3",
period="2", period_offset="0.5s")
ipk.assign_solid_block("Cylinder1", bc_transient)
Loading

0 comments on commit 2275a37

Please sign in to comment.