Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Use GetDataModel to improve the way information are cached into the API #5488

Merged
merged 26 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2f20a15
Added GetDataModel first implementation
maxcapodi78 Nov 27, 2024
200cbba
Fixed the way we identify the nets automatically from the sources.
maxcapodi78 Nov 27, 2024
79db490
Merge branch 'fix_compute_power' into Feat_Get_Data_Model
maxcapodi78 Nov 27, 2024
c6439dd
Fixed the way we identify the nets automatically from the sources.
maxcapodi78 Nov 27, 2024
9ac7092
Fixed the way we identify the nets automatically from the sources.
maxcapodi78 Nov 27, 2024
7c25286
Fixed the way we identify the nets automatically from the sources.
maxcapodi78 Nov 27, 2024
2f5f951
Fixed the way we identify the nets automatically from the sources.
maxcapodi78 Nov 27, 2024
036a9dc
Implemented GetDataModel in Setup and Reports
maxcapodi78 Nov 29, 2024
f681f0b
Merge branch 'main' into Feat_Get_Data_Model
maxcapodi78 Dec 9, 2024
40e1c12
Merged with main
maxcapodi78 Dec 9, 2024
644d1fa
Fix unit tests
maxcapodi78 Dec 9, 2024
65ab329
Fix unit tests
maxcapodi78 Dec 9, 2024
7a439ea
Fix unit tests
maxcapodi78 Dec 9, 2024
dcb8d3c
Fix unit tests
maxcapodi78 Dec 9, 2024
cab2aca
Fix unit tests
maxcapodi78 Dec 10, 2024
b4af448
Merge branch 'main' into Feat_Get_Data_Model
maxcapodi78 Dec 10, 2024
1e14335
Fix conflicts
maxcapodi78 Dec 10, 2024
49e077b
Fix unit test
maxcapodi78 Dec 10, 2024
95eec7e
Update hfss docstring
Samuelopez-ansys Dec 10, 2024
b9fa644
Merge remote-tracking branch 'origin/Feat_Get_Data_Model' into Feat_G…
Samuelopez-ansys Dec 10, 2024
68650d4
Fix codacy
Samuelopez-ansys Dec 10, 2024
b3b3a49
improved refresh of trace expressions
maxcapodi78 Dec 10, 2024
0044006
Merge remote-tracking branch 'origin/Feat_Get_Data_Model' into Feat_G…
Samuelopez-ansys Dec 10, 2024
5f90b03
Fix resistive_sheet issue in 2025R1
Samuelopez-ansys Dec 10, 2024
50c6f37
Revert typo
Samuelopez-ansys Dec 11, 2024
5a806c7
Merge branch 'main' into Feat_Get_Data_Model
Samuelopez-ansys Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/ansys/aedt/core/application/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,36 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler


@pyaedt_function_handler()
def _get_data_model(child_object, level=-1):
import json

def _fix_dict(p_list, p_out):
for p, val in p_list.items():
if p == "properties":
for prop in val:
if "value" in prop:
p_out[prop["name"]] = prop["value"]
elif "values" in prop:
p_out[prop["name"]] = prop["values"]
else:
p_out[prop["name"]] = None
elif isinstance(val, dict):
_fix_dict(val, p_out[p])

Check warning on line 42 in src/ansys/aedt/core/application/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/application/__init__.py#L42

Added line #L42 was not covered by tests
elif isinstance(val, list):
p_out[p] = []
for el in val:
children = {}
_fix_dict(el, children)
p_out[p].append(children)
else:
p_out[p] = val

input_str = child_object.GetDataModel(level, 1, 1)
props_list = json.loads(input_str)
props = {}
_fix_dict(props_list, props)
return props
14 changes: 8 additions & 6 deletions src/ansys/aedt/core/application/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
from ansys.aedt.core.generic.general_methods import open_file
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
from ansys.aedt.core.generic.settings import settings
from ansys.aedt.core.modules.boundary import MaxwellParameters
from ansys.aedt.core.modules.boundary import NativeComponentObject
from ansys.aedt.core.modules.boundary import NativeComponentPCB
from ansys.aedt.core.modules.boundary.layout_boundary import NativeComponentObject
from ansys.aedt.core.modules.boundary.layout_boundary import NativeComponentPCB
from ansys.aedt.core.modules.boundary.maxwell_boundary import MaxwellParameters
from ansys.aedt.core.modules.design_xploration import OptimizationSetups
from ansys.aedt.core.modules.design_xploration import ParametricSetups
from ansys.aedt.core.modules.solve_setup import Setup
Expand Down Expand Up @@ -1537,14 +1537,16 @@
setup = SetupSBR(self, setuptype, name, is_new_setup=False)
elif self.design_type in ["Q3D Extractor", "2D Extractor", "HFSS"]:
setup = SetupHFSS(self, setuptype, name, is_new_setup=False)
if setup.props and setup.props.get("SetupType", "") == "HfssDrivenAuto":
if setup.properties:
if "Auto Solver Setting" in setup.properties:
setup = SetupHFSSAuto(self, 0, name, is_new_setup=False)
elif setup.props and setup.props.get("SetupType", "") == "HfssDrivenAuto":

Check warning on line 1543 in src/ansys/aedt/core/application/analysis.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/application/analysis.py#L1543

Added line #L1543 was not covered by tests
setup = SetupHFSSAuto(self, 0, name, is_new_setup=False)
elif self.design_type in ["Maxwell 2D", "Maxwell 3D"]:
setup = SetupMaxwell(self, setuptype, name, is_new_setup=False)
else:
setup = Setup(self, setuptype, name, is_new_setup=False)
if setup.props:
self.active_setup = name
self.active_setup = name
return setup

@pyaedt_function_handler()
Expand Down
16 changes: 8 additions & 8 deletions src/ansys/aedt/core/application/analysis_nexxim.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
from ansys.aedt.core.generic.settings import settings
from ansys.aedt.core.modeler.circuits.object_3d_circuit import CircuitComponent
from ansys.aedt.core.modules.boundary import CurrentSinSource
from ansys.aedt.core.modules.boundary import Excitations
from ansys.aedt.core.modules.boundary import PowerIQSource
from ansys.aedt.core.modules.boundary import PowerSinSource
from ansys.aedt.core.modules.boundary import Sources
from ansys.aedt.core.modules.boundary import VoltageDCSource
from ansys.aedt.core.modules.boundary import VoltageFrequencyDependentSource
from ansys.aedt.core.modules.boundary import VoltageSinSource
from ansys.aedt.core.modules.boundary.circuit_boundary import CurrentSinSource
from ansys.aedt.core.modules.boundary.circuit_boundary import Excitations
from ansys.aedt.core.modules.boundary.circuit_boundary import PowerIQSource
from ansys.aedt.core.modules.boundary.circuit_boundary import PowerSinSource
from ansys.aedt.core.modules.boundary.circuit_boundary import Sources
from ansys.aedt.core.modules.boundary.circuit_boundary import VoltageDCSource
from ansys.aedt.core.modules.boundary.circuit_boundary import VoltageFrequencyDependentSource
from ansys.aedt.core.modules.boundary.circuit_boundary import VoltageSinSource
from ansys.aedt.core.modules.setup_templates import SetupKeys
from ansys.aedt.core.modules.solve_setup import SetupCircuit

Expand Down
15 changes: 11 additions & 4 deletions src/ansys/aedt/core/application/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
from ansys.aedt.core.generic.general_methods import settings
from ansys.aedt.core.generic.general_methods import write_csv
from ansys.aedt.core.generic.load_aedt_file import load_entire_aedt_file
from ansys.aedt.core.modules.boundary import BoundaryObject
from ansys.aedt.core.modules.boundary import MaxwellParameters
from ansys.aedt.core.modules.boundary import NetworkObject
from ansys.aedt.core.modules.boundary.circuit_boundary import NetworkObject
from ansys.aedt.core.modules.boundary.common import BoundaryObject
from ansys.aedt.core.modules.boundary.maxwell_boundary import MaxwellParameters

if sys.version_info.major > 2:
import base64
Expand Down Expand Up @@ -376,6 +376,12 @@ def boundaries(self):
current_excitation_types = ee[1::2]
ff = [i.split(":")[0] for i in ee]
bb.extend(ff)
for i in set(current_excitation_types):
if "GetExcitationsOfType" in self.oboundary.__dir__():
ports = list(self.oboundary.GetExcitationsOfType(i))
for p in ports:
bb.append(p)
bb.append(i)
elif (
self.oboundary
and "Excitations" in self.get_oo_name(self.odesign)
Expand Down Expand Up @@ -431,6 +437,7 @@ def boundaries(self):
del self._boundaries[k]
for boundary, boundarytype in zip(current_boundaries, current_types):
if boundary in self._boundaries:
self._boundaries[boundary]._initialize_bynary_tree()
continue
if boundarytype == "MaxwellParameters":
maxwell_parameter_type = self.get_oo_property_value(self.odesign, f"Parameters\\{boundary}", "Type")
Expand Down Expand Up @@ -3796,7 +3803,7 @@ def save_project(self, file_name=None, overwrite=True, refresh_ids=False):
self.oproject.Save()
if refresh_ids:
self.modeler.refresh_all_ids()
self.modeler._refresh_all_ids_from_aedt_file()
self.modeler._refresh_all_ids_wrapper()
self.mesh._refresh_mesh_operations()
self._project_name = None
self._project_path = None
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/aedt/core/application/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ def _find_used_variable_history(self, history, var_name):

"""
used = False
for _, v in history.props.items():
for _, v in history.properties.items():
if isinstance(v, str) and var_name in re.findall("[a-zA-Z0-9_]+", v):
return True
for el in history.children.values():
Expand Down
14 changes: 7 additions & 7 deletions src/ansys/aedt/core/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
from ansys.aedt.core.generic.general_methods import read_configuration_file
from ansys.aedt.core.generic.settings import settings
from ansys.aedt.core.hfss3dlayout import Hfss3dLayout
from ansys.aedt.core.modules.boundary import CurrentSinSource
from ansys.aedt.core.modules.boundary import PowerIQSource
from ansys.aedt.core.modules.boundary import PowerSinSource
from ansys.aedt.core.modules.boundary import Sources
from ansys.aedt.core.modules.boundary import VoltageDCSource
from ansys.aedt.core.modules.boundary import VoltageFrequencyDependentSource
from ansys.aedt.core.modules.boundary import VoltageSinSource
from ansys.aedt.core.modules.boundary.circuit_boundary import CurrentSinSource
from ansys.aedt.core.modules.boundary.circuit_boundary import PowerIQSource
from ansys.aedt.core.modules.boundary.circuit_boundary import PowerSinSource
from ansys.aedt.core.modules.boundary.circuit_boundary import Sources
from ansys.aedt.core.modules.boundary.circuit_boundary import VoltageDCSource
from ansys.aedt.core.modules.boundary.circuit_boundary import VoltageFrequencyDependentSource
from ansys.aedt.core.modules.boundary.circuit_boundary import VoltageSinSource
from ansys.aedt.core.modules.circuit_templates import SourceKeys


Expand Down
8 changes: 4 additions & 4 deletions src/ansys/aedt/core/generic/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
from ansys.aedt.core.modeler.cad.components_3d import UserDefinedComponent
from ansys.aedt.core.modeler.cad.modeler import CoordinateSystem
from ansys.aedt.core.modeler.geometry_operators import GeometryOperators
from ansys.aedt.core.modules.boundary import BoundaryObject
from ansys.aedt.core.modules.boundary import BoundaryProps
from ansys.aedt.core.modules.boundary import NativeComponentObject
from ansys.aedt.core.modules.boundary import NativeComponentPCB
from ansys.aedt.core.modules.boundary.common import BoundaryObject
from ansys.aedt.core.modules.boundary.common import BoundaryProps
from ansys.aedt.core.modules.boundary.layout_boundary import NativeComponentObject
from ansys.aedt.core.modules.boundary.layout_boundary import NativeComponentPCB
from ansys.aedt.core.modules.design_xploration import SetupOpti
from ansys.aedt.core.modules.design_xploration import SetupParam
from ansys.aedt.core.modules.material_lib import Material
Expand Down
55 changes: 0 additions & 55 deletions src/ansys/aedt/core/generic/data_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,61 +205,6 @@ def _arg2dict(arg, dict_out):
raise ValueError("Incorrect data argument format")


@pyaedt_function_handler()
def create_list_for_csharp(input_list, return_strings=False):
"""

Parameters
----------
input_list :

return_strings :
(Default value = False)

Returns
-------

"""
from ansys.aedt.core.generic.clr_module import Double
from ansys.aedt.core.generic.clr_module import List

if return_strings:
col = List[str]()
else:
col = List[Double]()

for el in input_list:
if return_strings:
col.Add(str(el))
else:
col.Add(el)
return col


@pyaedt_function_handler()
def create_table_for_csharp(input_list_of_list, return_strings=True):
"""

Parameters
----------
input_list_of_list :

return_strings :
(Default value = True)

Returns
-------

"""
from ansys.aedt.core.generic.clr_module import List

new_table = List[List[str]]()
for col in input_list_of_list:
newcol = create_list_for_csharp(col, return_strings)
new_table.Add(newcol)
return new_table


@pyaedt_function_handler()
def format_decimals(el):
"""
Expand Down
62 changes: 22 additions & 40 deletions src/ansys/aedt/core/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""This module contains these classes: ``Hfss`` and ``BoundaryType``."""
"""This module contains the ``Hfss`` class."""

from __future__ import absolute_import # noreorder

Expand All @@ -49,10 +49,10 @@
from ansys.aedt.core.modeler.cad.component_array import ComponentArray
from ansys.aedt.core.modeler.cad.components_3d import UserDefinedComponent
from ansys.aedt.core.modeler.geometry_operators import GeometryOperators
from ansys.aedt.core.modules.boundary import BoundaryObject
from ansys.aedt.core.modules.boundary import FarFieldSetup
from ansys.aedt.core.modules.boundary import NativeComponentObject
from ansys.aedt.core.modules.boundary import NearFieldSetup
from ansys.aedt.core.modules.boundary.common import BoundaryObject
from ansys.aedt.core.modules.boundary.hfss_boundary import FarFieldSetup
from ansys.aedt.core.modules.boundary.hfss_boundary import NearFieldSetup
from ansys.aedt.core.modules.boundary.layout_boundary import NativeComponentObject
from ansys.aedt.core.modules.setup_templates import SetupKeys


Expand Down Expand Up @@ -249,10 +249,17 @@ def field_setups(self):
Returns
-------
List of :class:`ansys.aedt.core.modules.boundary.FarFieldSetup` and
:class:`ansys.aedt.core.modules.boundary.NearFieldSetup`
:class:`ansys.aedt.core.modules.hfss_boundary.NearFieldSetup`
"""
if not self._field_setups:
self._field_setups = self._get_rad_fields()
for field in self.field_setup_names:
obj_field = self.odesign.GetChildObject("Radiation").GetChildObject(field)
type_field = obj_field.GetPropValue("Type")
if type_field == "Infinite Sphere":
self._field_setups.append(FarFieldSetup(self, field, {}, "FarFieldSphere"))
else:
self._field_setups.append(NearFieldSetup(self, field, {}, f"NearField{type_field}"))
# if not self._field_setups:
# self._field_setups = self._get_rad_fields()
return self._field_setups

@property
Expand Down Expand Up @@ -372,31 +379,6 @@ def _get_unique_source_name(self, source_name, root_name):
source_name = generate_unique_name(source_name)
return source_name

@pyaedt_function_handler()
def _get_rad_fields(self):
if not self.design_properties:
return []
fields = []
if self.design_properties.get("RadField"):
if self.design_properties["RadField"].get("FarFieldSetups"):
for val in self.design_properties["RadField"]["FarFieldSetups"]:
p = self.design_properties["RadField"]["FarFieldSetups"][val]
if isinstance(p, dict) and p.get("Type") == "Infinite Sphere":
fields.append(FarFieldSetup(self, val, p, "FarFieldSphere"))
if self.design_properties["RadField"].get("NearFieldSetups"):
for val in self.design_properties["RadField"]["NearFieldSetups"]:
p = self.design_properties["RadField"]["NearFieldSetups"][val]
if isinstance(p, dict):
if p["Type"] == "Near Rectangle":
fields.append(NearFieldSetup(self, val, p, "NearFieldRectangle"))
elif p["Type"] == "Near Line":
fields.append(NearFieldSetup(self, val, p, "NearFieldLine"))
elif p["Type"] == "Near Box":
fields.append(NearFieldSetup(self, val, p, "NearFieldBox"))
elif p["Type"] == "Near Sphere":
fields.append(NearFieldSetup(self, val, p, "NearFieldSphere"))
return fields

@pyaedt_function_handler()
def _create_boundary(self, name, props, boundary_type):
"""Create a boundary.
Expand Down Expand Up @@ -1482,7 +1464,7 @@ def create_sbr_antenna(

Returns
-------
:class:`ansys.aedt.core.modules.boundary.NativeComponentObject`
:class:`ansys.aedt.core.modules.layout_boundary.NativeComponentObject`
NativeComponentObject object.

References
Expand Down Expand Up @@ -1608,7 +1590,7 @@ def create_sbr_file_based_antenna(

Returns
-------
:class:`ansys.aedt.core.modules.boundary.NativeComponentObject`
:class:`ansys.aedt.core.modules.layout_boundary.NativeComponentObject`

References
----------
Expand Down Expand Up @@ -5139,7 +5121,7 @@ def insert_infinite_sphere(

Returns
-------
:class:`ansys.aedt.core.modules.boundary.FarFieldSetup`
:class:`ansys.aedt.core.modules.hfss_boundary.FarFieldSetup`
"""
if not self.oradfield:
self.logger.error("Radiation Field not available in this solution.")
Expand Down Expand Up @@ -5231,7 +5213,7 @@ def insert_near_field_sphere(

Returns
-------
:class:`ansys.aedt.core.modules.boundary.NearFieldSetup`
:class:`ansys.aedt.core.modules.hfss_boundary.NearFieldSetup`
"""
if not self.oradfield:
self.logger.error("Radiation Field not available in this solution.")
Expand Down Expand Up @@ -5308,7 +5290,7 @@ def insert_near_field_box(

Returns
-------
:class:`ansys.aedt.core.modules.boundary.NearFieldSetup`
:class:`ansys.aedt.core.modules.hfss_boundary.NearFieldSetup`
"""
if not self.oradfield:
self.logger.error("Radiation Field not available in this solution.")
Expand Down Expand Up @@ -5377,7 +5359,7 @@ def insert_near_field_rectangle(

Returns
-------
:class:`ansys.aedt.core.modules.boundary.NearFieldSetup`
:class:`ansys.aedt.core.modules.hfss_boundary.NearFieldSetup`
"""
if not self.oradfield:
self.logger.error("Radiation Field not available in this solution.")
Expand Down Expand Up @@ -5432,7 +5414,7 @@ def insert_near_field_line(

Returns
-------
:class:`ansys.aedt.core.modules.boundary.NearFieldSetup`
:class:`ansys.aedt.core.modules.hfss_boundary.NearFieldSetup`
"""
if not self.oradfield:
self.logger.error("Radiation Field not available in this solution.")
Expand Down
Loading
Loading