Skip to content

Commit

Permalink
Merge branch 'main' into feat/toolkit_installer
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys committed Apr 23, 2024
2 parents 80d5f01 + 91289ce commit ca66ccc
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 90 deletions.
6 changes: 5 additions & 1 deletion _unittest/test_41_3dlayout_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,6 @@ def test_41_test_create_polygon(self):
@pytest.mark.skipif(config["desktopVersion"] < "2023.2", reason="Working only from 2023 R2")
def test_42_post_processing(self, add_app):
test_post1 = add_app(project_name=test_post, application=Maxwell3d, subfolder=test_subfolder)

assert test_post1.post.create_fieldplot_layers(
[],
"Mag_H",
Expand Down Expand Up @@ -692,6 +691,11 @@ def test_42_post_processing(self, add_app):
intrinsics={"Freq": "1GHz", "Phase": "0deg"},
plot_name="Test_Layers4",
)
assert test_post2.post.create_fieldplot_layers(
["TOP"],
"Mag_E",
intrinsics={"Freq": "1GHz", "Phase": "0deg"},
)
assert test_post2.post.create_fieldplot_layers(
["TOP", "UNNAMED_004"],
"Mag_E",
Expand Down
2 changes: 1 addition & 1 deletion doc/source/API/SetupTemplatesIcepak.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You can edit a setup after it is created. Here is an example:
# Any property of this setup can be found on this page.
setup = app.create_setup(MaxIterations=5)
Available turbulent models are: ``"ZeroEquation"``, ``"TwoEquation"``, ``"EnhancedTwoEquation"``, ``"RNG"``, ``"EnhancedRNG"``, ``"RealizableTwoEquation"``, ``"EnhancedRealizableTwoEquation"``, ``"SpalartAllmaras"``, ``"kOmegaSST"``.

.. pprint:: pyaedt.modules.SetupTemplates.TransientFlowOnly
.. pprint:: pyaedt.modules.SetupTemplates.TransientTemperatureOnly
Expand Down
19 changes: 7 additions & 12 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ PyAEDT documentation |version|
`Source Repository <https://github.com/ansys/pyaedt>`_ |
`Issues <https://github.com/ansys/pyaedt/issues>`_

PyAEDT is a Python library that interacts directly with the Ansys Electronics Desktop (AEDT) API,
PyAEDT is a Python client library that interacts directly with the Ansys Electronics Desktop (AEDT) API,
enabling straightforward and efficient automation in your workflow.

.. note::
Also consider viewing the `PyEDB documentation <https://edb.docs.pyansys.com/version/stable/>`_.
PyEDB is a Python client library for processing complex and large layout designs in the Ansys
Electronics Database (EDB) format, which stores information describing designs for AEDT.

.. grid:: 2

Expand All @@ -26,19 +30,12 @@ enabling straightforward and efficient automation in your workflow.

.. grid:: 2

.. grid-item-card:: AEDT API reference :fa:`book-bookmark`
.. grid-item-card:: API reference :fa:`book-bookmark`
:link: API/index
:link-type: doc

This section contains descriptions of the functions and modules included in PyAEDT.
It describes how the methods work and the parameter that can be used.

.. grid-item-card:: EDB API reference :fa:`book-bookmark`
:link: https://edb.docs.pyansys.com/version/stable/
:link-type: url

Contains descriptions of the functions and modules included in PyEDB.
It describes how the methods work and the parameter that can be used.
It describes how the methods work and the parameters that can be used.

.. jinja:: main_toctree

Expand Down Expand Up @@ -70,5 +67,3 @@ enabling straightforward and efficient automation in your workflow.
{% if run_examples %}
examples/index
{% endif %}


4 changes: 3 additions & 1 deletion examples/05-Q3D/Q3D_DC_IR.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@
# ~~~~~~~~
# Compute ACL solutions and plot them.

plot1 = q3d.post.create_fieldplot_surface(q3d.modeler.get_objects_by_material("copper"), quantity=drop_name)
plot1 = q3d.post.create_fieldplot_surface(q3d.modeler.get_objects_by_material("copper"),
quantity=drop_name,
intrinsics={"Freq": "1GHz"})

q3d.post.plot_field_from_fieldplot(plot1.name, project_path=q3d.working_directory, mesh_plot=False, image_format="jpg",
view="isometric", show=False, plot_cad_objs=False, log_scale=False)
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/generic/general_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def deprecate_kwargs(func_name, kwargs, aliases):
msg += "{} is deprecated, use {} instead.".format(alias, new)
raise TypeError(msg)
pyaedt_logger.warning(
'`{}` is deprecated as an argument to `{}`; use" f" `{}` instead.'.format(alias, func_name, new)
"Argument `{}` is deprecated for method `{}`; use `{}` instead.".format(alias, func_name, new)
)
kwargs[new] = kwargs.pop(alias)

Expand Down
19 changes: 18 additions & 1 deletion pyaedt/generic/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,24 @@ def _read_mesh_files(self, read_frames=False):
if ".case" in field.path:
reader = pv.get_reader(os.path.abspath(field.path)).read()
field._cached_polydata = reader[reader.keys()[0]].extract_surface()
field.scalar_name = field._cached_polydata.point_data.active_scalars_name

if (
hasattr(field._cached_polydata.point_data, "active_vectors")
and field._cached_polydata.point_data.active_vectors_name
):
field.scalar_name = field._cached_polydata.point_data.active_scalars_name
vector_scale = (max(field._cached_polydata.bounds) - min(field._cached_polydata.bounds)) / (
10
* (
np.vstack(field._cached_polydata.active_vectors).max()
- np.vstack(field._cached_polydata.active_vectors).min()
)
)
field._cached_polydata["vectors"] = field._cached_polydata.active_vectors * vector_scale

field.is_vector = True
else:
field.scalar_name = field._cached_polydata.point_data.active_scalars_name

elif ".aedtplt" in field.path:
vertices, faces, scalars, log1 = _parse_aedtplt(field.path)
Expand Down
63 changes: 40 additions & 23 deletions pyaedt/modules/MeshIcepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ def parts(self, parts):


class MeshSettings(object):
automatic_mesh_settings = {"MeshRegionResolution": 3} # min: 1, max: 5
common_mesh_settings = {
_automatic_mesh_settings = {"MeshRegionResolution": 3} # min: 1, max: 5
_common_mesh_settings = {
"ProximitySizeFunction": True,
"CurvatureSizeFunction": True,
"EnableTransition": False,
Expand All @@ -419,7 +419,7 @@ class MeshSettings(object):
"Enforce2dot5DCutCell": False,
"StairStepMeshing": False,
}
manual_mesh_settings = {
_manual_mesh_settings = {
"MaxElementSizeX": "0.02mm",
"MaxElementSizeY": "0.02mm",
"MaxElementSizeZ": "0.03mm",
Expand All @@ -437,7 +437,7 @@ class MeshSettings(object):
"MinGapY": "1mm",
"MinGapZ": "1mm",
}
aedt_20212_args = [
_aedt_20212_args = [
"ProximitySizeFunction",
"CurvatureSizeFunction",
"EnableTransition",
Expand All @@ -450,12 +450,12 @@ class MeshSettings(object):
def __init__(self, mesh_class, app):
self._app = app
self._mesh_class = mesh_class
self.instance_settings = self.common_mesh_settings.copy()
self.instance_settings.update(self.manual_mesh_settings.copy())
self.instance_settings.update(self.automatic_mesh_settings.copy())
self._instance_settings = self._common_mesh_settings.copy()
self._instance_settings.update(self._manual_mesh_settings.copy())
self._instance_settings.update(self._automatic_mesh_settings.copy())
if settings.aedt_version < "2021.2":
for arg in self.aedt_20212_args:
del self.instance_settings[arg]
for arg in self._aedt_20212_args:
del self._instance_settings[arg]

@pyaedt_function_handler()
def _dim_arg(self, value):
Expand All @@ -474,7 +474,7 @@ def parse_settings(self):
List of strings containing all the parts that must be included in the subregion.
"""
out = []
for k, v in self.instance_settings.items():
for k, v in self._instance_settings.items():
out.append(k + ":=")
if k in ["MaxElementSizeX", "MaxElementSizeY", "MaxElementSizeZ", "MinGapX", "MinGapY", "MinGapZ"]:
v = self._dim_arg(v)
Expand All @@ -483,16 +483,25 @@ def parse_settings(self):

def _key_in_dict(self, key):
if self._mesh_class.manual_settings:
ref_dict = self.manual_mesh_settings
ref_dict = self._manual_mesh_settings
else:
ref_dict = self.automatic_mesh_settings
return key in ref_dict or key in self.common_mesh_settings
ref_dict = self._automatic_mesh_settings
return key in ref_dict or key in self._common_mesh_settings

def keys(self):
return self.parse_settings().keys()

def values(self):
return self.parse_settings().values()

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

def __getitem__(self, key):
if key == "Level":
key = "MeshRegionResolution"
if self._key_in_dict(key):
return self.instance_settings[key]
return self._instance_settings[key]
else:
raise KeyError("Setting not available.")

Expand All @@ -515,21 +524,21 @@ def __setitem__(self, key, value):
value = 5
except TypeError:
pass
self.instance_settings[key] = value
self._instance_settings[key] = value
else:
self._app.logger.error("Setting not available.")

def __delitem__(self, key):
self._app.logger.error("Setting cannot be removed.")

def __iter__(self):
return self.instance_settings.__iter__()
return self._instance_settings.__iter__()

def __len__(self):
return self.instance_settings.__len__()
return self._instance_settings.__len__()

def __contains__(self, x):
return self.instance_settings.__contains__(x)
return self._instance_settings.__contains__(x)


class MeshRegionCommon(object):
Expand Down Expand Up @@ -783,10 +792,20 @@ def assignment(self):
"""
if isinstance(self._assignment, SubRegion):
# try to update name
try:
parts = self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropValue("Parts")
if self.name in self._app.odesign.GetChildObject("Mesh").GetChildNames():
parts = []
subparts = []
if "Parts" in self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropNames():
parts = self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropValue("Parts")
if "Submodels" in self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropNames():
subparts = (
self._app.odesign.GetChildObject("Mesh").GetChildObject(self.name).GetPropValue("Submodels")
)
if not isinstance(parts, list):
parts = [parts]
if not isinstance(subparts, list):
subparts = [subparts]
parts += subparts
sub_regions = self._app.modeler.non_model_objects
for sr in sub_regions:
p1 = []
Expand All @@ -802,8 +821,6 @@ def assignment(self):
p1 += p2
if "CreateSubRegion" == self._app.modeler[sr].history().command and all(p in p1 for p in parts):
self._assignment.name = sr
except GrpcApiError:
pass
return self._assignment
elif isinstance(self._assignment, list):
return self._assignment
Expand Down Expand Up @@ -1374,7 +1391,7 @@ def assign_mesh_region(self, assignment=None, level=5, name=None, **kwargs):
added_obj = [i for i in objectlist2 if i not in all_objs or i in assignment]
meshregion.Objects = added_obj
meshregion.SubModels = None
meshregion.update()
meshregion.update()
return meshregion
else:
return False
Expand Down
42 changes: 11 additions & 31 deletions pyaedt/modules/PostProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3333,33 +3333,15 @@ def _get_3d_layers_nets(self, layers, nets):
new_layers = []
for k, v in self._app.modeler.user_defined_components.items():
if v.layout_component:
if not layers and not nets:
new_layers.extend(
[
"{}:{}#t=fill".format(k, i)
for i in v.layout_component.edb_object.stackup.signal_layers.keys()
]
)
new_layers.extend(
["{}:{}".format(k, i) for i in v.layout_component.edb_object.stackup.dielectric_layers.keys()]
)
elif not nets:
for layer in layers:
if layer in v.layout_component.edb_object.stackup.signal_layers:
new_layers.append("{}:{}#t=fill".format(k, layer))
elif layer in v.layout_component.edb_object.stackup.dielectric_layers:
new_layers.append("{}:{}".format(k, layer))
elif not layers:
for v in self._app.modeler.user_defined_components.values():
new_layers.extend(
[[i] + nets for i in v.layout_component.edb_object.stackup.signal_layers.keys()]
)
else:
for layer in layers:
if layer in v.layout_component.edb_object.stackup.signal_layers:
new_layers.append([layer] + nets)
elif layer in v.layout_component.edb_object.stackup.dielectric_layers:
dielectrics.append("{}:{}".format(k, layer))
if not layers:
layers = [i for i in v.layout_component.edb_object.stackup.stackup_layers.keys()]
if not nets:
nets = [""] + [i for i in v.layout_component.edb_object.nets.nets.keys()]
for layer in layers:
if layer in v.layout_component.edb_object.stackup.signal_layers:
new_layers.append([layer] + nets)
elif layer in v.layout_component.edb_object.stackup.dielectric_layers:
dielectrics.append("{}:{}".format(k, layer))
return dielectrics, new_layers

@pyaedt_function_handler()
Expand Down Expand Up @@ -3433,12 +3415,10 @@ def create_fieldplot_layers(
return self._create_fieldplot(lst_faces, quantity, setup, intrinsics, "FacesList", name)
else:
dielectrics, new_layers = self._get_3d_layers_nets(layers, nets)
if nets and plot_on_surface:
if plot_on_surface:
plot_type = "LayerNetsExtFace"
elif nets:
plot_type = "LayerNets"
else:
plot_type = "ObjList"
plot_type = "LayerNets"
if new_layers:
plt = self._create_fieldplot(
new_layers, quantity, setup, intrinsics, plot_type, name, create_plot=False
Expand Down
Loading

0 comments on commit ca66ccc

Please sign in to comment.