Skip to content

Commit

Permalink
Merge branch 'main' into fix/circuit_linux_2024R1
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxJPRey authored Apr 26, 2024
2 parents 5ea24fe + feb9369 commit d04eeeb
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 30 deletions.
8 changes: 6 additions & 2 deletions _unittest/test_09_Primitives2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ def test_06_create_region(self):
if self.aedtapp.modeler["Region"]:
self.aedtapp.modeler.delete("Region")
assert "Region" not in self.aedtapp.modeler.object_names
assert self.aedtapp.modeler.create_region([20, "50", "100mm", 20], False)
assert self.aedtapp.modeler.create_region([20, "50", "100mm", 20], "Absolute Offset")
self.aedtapp.modeler["Region"].delete()
region = self.aedtapp.modeler.create_region("100", True)
region = self.aedtapp.modeler.create_region("100", "Percentage Offset")
region.delete()
# test backward compatibility
region = self.aedtapp.modeler.create_region(pad_percent=[100, 10, 5, 2], pad_type=True)
region.delete()
#
region = self.aedtapp.modeler.create_region([100, 100, 100, 100])
assert region.solve_inside
assert region.model
Expand Down
13 changes: 7 additions & 6 deletions _unittest_solvers/test_26_emit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest

from pyaedt import Emit
from pyaedt import generate_unique_project_name
from pyaedt.emit_core.emit_constants import EmiCategoryFilter
from pyaedt.emit_core.emit_constants import InterfererType
from pyaedt.emit_core.emit_constants import ResultType
Expand Down Expand Up @@ -373,7 +374,7 @@ def test_07_antenna_component(self, add_app):
reason="Skipped on versions earlier than 2023.2",
)
def test_08_revision_generation(self, add_app):
self.aedtapp = add_app(application=Emit)
self.aedtapp = add_app(application=Emit, project_name=generate_unique_project_name())
assert len(self.aedtapp.results.revisions) == 0
# place components and generate the appropriate number of revisions
rad1 = self.aedtapp.modeler.components.create_component("UE - Handheld")
Expand Down Expand Up @@ -443,7 +444,7 @@ def test_08_revision_generation(self, add_app):
reason="Skipped on versions earlier than 2023.2",
)
def test_09_manual_revision_access_test_getters(self, add_app):
self.aedtapp = add_app(application=Emit)
self.aedtapp = add_app(application=Emit, project_name=generate_unique_project_name())
rad1 = self.aedtapp.modeler.components.create_component("UE - Handheld")
ant1 = self.aedtapp.modeler.components.create_component("Antenna")
rad2 = self.aedtapp.modeler.components.create_component("Bluetooth")
Expand Down Expand Up @@ -512,7 +513,7 @@ def test_09_manual_revision_access_test_getters(self, add_app):
reason="Skipped on versions earlier than 2023.2",
)
def test_10_radio_band_getters(self, add_app):
self.aedtapp = add_app(application=Emit)
self.aedtapp = add_app(application=Emit, project_name=generate_unique_project_name())
rad1, ant1 = self.aedtapp.modeler.components.create_radio_antenna("New Radio")
rad2, ant2 = self.aedtapp.modeler.components.create_radio_antenna("Bluetooth Low Energy (LE)")
rad3, ant3 = self.aedtapp.modeler.components.create_radio_antenna("WiFi - 802.11-2012")
Expand Down Expand Up @@ -729,7 +730,7 @@ def test_14_version(self, add_app):
reason="Skipped on versions earlier than 2023.2",
)
def test_15_basic_run(self, add_app):
self.aedtapp = add_app(application=Emit)
self.aedtapp = add_app(application=Emit, project_name=generate_unique_project_name())
assert len(self.aedtapp.results.revisions) == 0
# place components and generate the appropriate number of revisions
rad1 = self.aedtapp.modeler.components.create_component("UE - Handheld")
Expand Down Expand Up @@ -811,7 +812,7 @@ def test_15_basic_run(self, add_app):
reason="Skipped on versions earlier than 2024.1",
)
def test_16_optimal_n_to_1_feature(self, add_app):
self.aedtapp = add_app(application=Emit)
self.aedtapp = add_app(application=Emit, project_name=generate_unique_project_name())
# place components and generate the appropriate number of revisions
rad1 = self.aedtapp.modeler.components.create_component("Bluetooth")
ant1 = self.aedtapp.modeler.components.create_component("Antenna")
Expand Down Expand Up @@ -867,7 +868,7 @@ def test_16_optimal_n_to_1_feature(self, add_app):
reason="Skipped on versions earlier than 2023.2",
)
def test_17_availability_1_to_1(self, add_app):
self.aedtapp = add_app(application=Emit)
self.aedtapp = add_app(application=Emit, project_name=generate_unique_project_name())
# place components and generate the appropriate number of revisions
rad1 = self.aedtapp.modeler.components.create_component("MD400C")
ant1 = self.aedtapp.modeler.components.create_component("Antenna")
Expand Down
3 changes: 0 additions & 3 deletions pyaedt/emit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import warnings

from pyaedt import emit_core
from pyaedt import generate_unique_project_name
from pyaedt.application.Design import Design
from pyaedt.emit_core.Couplings import CouplingsEmit
from pyaedt.emit_core.emit_constants import EMIT_VALID_UNITS
Expand Down Expand Up @@ -114,8 +113,6 @@ def __init__(
port=0,
aedt_process_id=None,
):
if projectname is None:
projectname = generate_unique_project_name()
self.__emit_api_enabled = False
self.results = None
"""Constructor for the ``FieldAnalysisEmit`` class"""
Expand Down
4 changes: 2 additions & 2 deletions pyaedt/generic/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ def _export_objects_properties(self, dict_out):
def _export_mesh_operations(self, dict_out):
dict_out["mesh"] = {}
args = ["NAME:Settings"]
args += self._app.mesh.global_mesh_region.settings.parse_settings()
args += self._app.mesh.global_mesh_region.settings.parse_settings_as_args()
mop = OrderedDict({})
_arg2dict(args, mop)
dict_out["mesh"]["Settings"] = mop["Settings"]
Expand All @@ -1683,7 +1683,7 @@ def _export_mesh_operations(self, dict_out):
args = ["NAME:Settings"]
else:
args = ["NAME:" + mesh.name, "Enable:=", mesh.Enable]
args += mesh.settings.parse_settings()
args += mesh.settings.parse_settings_as_args()
args += getattr(mesh, "_parse_assignment_value")()
args += ["UserSpecifiedSettings:=", not mesh.manual_settings]
mop = OrderedDict({})
Expand Down
4 changes: 3 additions & 1 deletion pyaedt/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,9 @@ def create_source_excitation(self, assignment, point1, point2, name, source_type
props = OrderedDict({"Objects": [assignment], "Direction": OrderedDict({"Start": point1, "End": point2})})
return self._create_boundary(name, props, source_type)

@pyaedt_function_handler(face="assignment", nummodes="modes", portname="name", renorm="renormalize")
@pyaedt_function_handler(
face="assignment", nummodes="modes", portname="name", renorm="renormalize", deembed_dist="deembed_distance"
)
def create_floquet_port(
self,
assignment,
Expand Down
15 changes: 9 additions & 6 deletions pyaedt/modeler/cad/Primitives2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ def create_region(self, pad_value=300, pad_type="Percentage Offset", name="Regio
Padding values to apply. If a list is not provided, the same
value is applied to all padding directions. If a list of floats
or strings is provided, the values are
interpreted as padding for ``["+X", "-X", "+Y", "-Y", "+Z", "-Z"]``.
interpreted as padding for ``["+X", "-X", "+Y", "-Y"]`` for XY geometry mode,
and ``["+R", "+Z", "-Z"]`` for RZ geometry mode.
pad_type : str, optional
Padding definition. The default is ``"Percentage Offset"``.
Options are ``"Absolute Offset"``,
Expand Down Expand Up @@ -318,24 +319,26 @@ def create_region(self, pad_value=300, pad_type="Percentage Offset", name="Regio
if kwarg.get("pad_percent", False):
pad_percent = kwarg["pad_percent"]
pad_value = pad_percent
if isinstance(pad_value, list) and len(pad_value) < 6:
pad_value = [pad_value[i // 2 + 3 * (i % 2)] for i in range(6)]
if isinstance(pad_value, list) and len(pad_value) == 4:
pad_value = [pad_value[i // 2 + 2 * (i % 2)] for i in range(4)]
pad_type = ["Absolute Offset", "Percentage Offset"][int(is_percentage)]

if isinstance(pad_type, bool):
pad_type = ["Absolute Offset", "Percentage Offset"][int(pad_type)]

if not isinstance(pad_value, list):
pad_value = [pad_value] * 4
if self._app.design_type == "2D Extractor" or (
self._app.design_type == "Maxwell 2D" and self._app.odesign.GetGeometryMode() == "XY"
):
if not isinstance(pad_value, list):
pad_value = [pad_value] * 4
if len(pad_value) != 4:
self.logger.error("Wrong padding list provided. Four values have to be provided.")
return False
pad_value = [pad_value[0], pad_value[2], pad_value[1], pad_value[3], 0, 0]
else:
if len(pad_value) < 3:
if not isinstance(pad_value, list):
pad_value = [pad_value] * 3
if len(pad_value) != 3:
self.logger.error("Wrong padding list provided. Three values have to be provided for RZ geometry.")
return False
pad_value = [pad_value[0], 0, 0, 0, pad_value[1], pad_value[2]]
Expand Down
60 changes: 50 additions & 10 deletions pyaedt/modules/MeshIcepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ def name(self):
@name.setter
def name(self, value):
try:
self._app.modeler.objects_by_name[self._name].name = value
if self._app.modeler.objects_by_name[self._name].name != value:
self._app.modeler.objects_by_name[self._name].name = value
except KeyError:
if self._app.modeler.objects_by_name[value].history().command == "CreateSubRegion":
self._name = value
Expand Down Expand Up @@ -408,6 +409,13 @@ def parts(self, parts):


class MeshSettings(object):
"""
Class for managing mesh settings.
It can be used like a dictionary. Available keys change according
to the type of settings chosen (manual or automatic).
"""

_automatic_mesh_settings = {"MeshRegionResolution": 3} # min: 1, max: 5
_common_mesh_settings = {
"ProximitySizeFunction": True,
Expand Down Expand Up @@ -464,14 +472,14 @@ def _dim_arg(self, value):
else:
return _dim_arg(value, getattr(self._mesh_class, "_model_units"))

def parse_settings(self):
def parse_settings_as_args(self):
"""
Parse mesh region settings.
Returns
-------
dict
List of strings containing all the parts that must be included in the subregion.
List
Arguments to pass to native APIs.
"""
out = []
for k, v in self._instance_settings.items():
Expand All @@ -481,6 +489,22 @@ def parse_settings(self):
out.append(v)
return out

def parse_settings_as_dictionary(self):
"""
Parse mesh region settings.
Returns
-------
dict
Settings of the subregion.
"""
out = {}
for k, v in self._instance_settings.items():
if k in ["MaxElementSizeX", "MaxElementSizeY", "MaxElementSizeZ", "MinGapX", "MinGapY", "MinGapZ"]:
v = self._dim_arg(v)
out[k] = v
return out

def _key_in_dict(self, key):
if self._mesh_class.manual_settings:
ref_dict = self._manual_mesh_settings
Expand All @@ -489,13 +513,29 @@ def _key_in_dict(self, key):
return key in ref_dict or key in self._common_mesh_settings

def keys(self):
return self.parse_settings().keys()
"""
Get mesh region settings keys.
Returns
-------
dict_keys
Available settings keys.
"""
return self.parse_settings_as_dictionary().keys()

def values(self):
return self.parse_settings().values()
"""
Get mesh region settings values.
Returns
-------
dict_values
Settings values.
"""
return self.parse_settings_as_dictionary().values()

def __repr__(self):
return repr(self.parse_settings())
return repr(self.parse_settings_as_dictionary())

def __getitem__(self, key):
if key == "Level":
Expand Down Expand Up @@ -628,7 +668,7 @@ def update(self):
>>> oModule.EditGlobalMeshRegion
"""
args = ["NAME:Settings"]
args += self.settings.parse_settings()
args += self.settings.parse_settings_as_args()
args += ["UserSpecifiedSettings:=", self.manual_settings]
try:
self._app.omeshmodule.EditGlobalMeshRegion(args)
Expand Down Expand Up @@ -754,7 +794,7 @@ def update(self):
>>> oModule.EditMeshRegion
"""
args = ["NAME:" + self.name, "Enable:=", self.enable]
args += self.settings.parse_settings()
args += self.settings.parse_settings_as_args()
args += self._parse_assignment_value()
args += ["UserSpecifiedSettings:=", self.manual_settings]
try:
Expand Down Expand Up @@ -854,7 +894,7 @@ def create(self):
self._app.logger.error("Cannot create a new mesh region with this Name")
return False
args = ["NAME:" + self.name, "Enable:=", self.enable]
args += self.settings.parse_settings()
args += self.settings.parse_settings_as_args()
args += ["UserSpecifiedSettings:=", not self.manual_settings]
args += self._parse_assignment_value()
self._app.omeshmodule.AssignMeshRegion(args)
Expand Down

0 comments on commit d04eeeb

Please sign in to comment.