Skip to content

Commit

Permalink
Merge branch 'main' into release/0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcapodi78 authored and maxcapodi78 committed Oct 14, 2022
2 parents 9e70777 + a128394 commit f44d785
Show file tree
Hide file tree
Showing 26 changed files with 188 additions and 55 deletions.
3 changes: 3 additions & 0 deletions _unittest/example_models/T03/mats.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Material Name;Conductivity;permittivity
copper_3;5800000;1
aluminum_3;5700000;0.5
Binary file added _unittest/example_models/T03/mats.xlsx
Binary file not shown.
6 changes: 6 additions & 0 deletions _unittest/test_02_2D_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# Setup paths for module imports

try:
import filecmp

import pytest # noqa: F401
except ImportError:
import _unittest_ironpython.conf_unittest as pytest # noqa: F401
Expand Down Expand Up @@ -136,6 +138,10 @@ def test_09_plot(self):
)
obj = self.aedtapp.plot(show=False, export_path=os.path.join(self.local_scratch.path, "image.jpg"))
assert os.path.exists(obj.image_file)
obj2 = self.aedtapp.plot(show=False, export_path=os.path.join(self.local_scratch.path, "image.jpg"), view="xy")
assert os.path.exists(obj2.image_file)
obj3 = self.aedtapp.plot(show=False, export_path=os.path.join(self.local_scratch.path, "image.jpg"), view="xy1")
assert filecmp.cmp(obj.image_file, obj3.image_file)

def test_10_edit_menu_commands(self):
rect1 = self.aedtapp.modeler.create_rectangle([1, 0, -2], [8, 3])
Expand Down
15 changes: 15 additions & 0 deletions _unittest/test_03_Materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from _unittest.conftest import local_path
from pyaedt import Icepak
from pyaedt import Maxwell3d
from pyaedt import is_ironpython
from pyaedt.modules.Material import MatProperties
from pyaedt.modules.Material import SurfMatProperties

Expand Down Expand Up @@ -188,6 +189,20 @@ def test_08_import_materials(self):
assert "al-extruded1" in self.aedtapp.materials.material_keys.keys()
assert self.aedtapp.materials["al-extruded1"].thermal_conductivity.thermalmodifier

@pytest.mark.skipif(is_ironpython, reason="Requires Pandas Support")
def test_08B_import_materials_from_excel(self):
mats = self.aedtapp.materials.import_materials_from_excel(
os.path.join(local_path, "example_models", test_subfolder, "mats.xlsx")
)
assert len(mats) == 2
assert mats[0].conductivity.value == 5700000
assert mats[0].permittivity.value == 0.5
assert mats[0].name == "aluminum_2"
mats = self.aedtapp.materials.import_materials_from_excel(
os.path.join(local_path, "example_models", test_subfolder, "mats.csv")
)
assert len(mats) == 2

def test_09_non_linear_materials(self):
app = Maxwell3d(specified_version=desktop_version)
mat1 = app.materials.add_material("myMat")
Expand Down
3 changes: 3 additions & 0 deletions _unittest/test_28_Maxwell3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,3 +664,6 @@ def test_42_harmonic_forces(self):
start_frequency=1, stop_frequency=100, number_of_frequency=None
)
assert self.m3dtransient.export_element_based_harmonic_force(number_of_frequency=5)

def test_43_eddy_effect_transient(self):
assert self.m3dtransient.eddy_effects_on(["Rotor"], activate_eddy_effects=True)
7 changes: 6 additions & 1 deletion pyaedt/application/Analysis3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def plot(
plot_air_objects=True,
force_opacity_value=None,
clean_files=False,
view="isometric",
):
"""Plot the model or a subset of objects.
Expand All @@ -206,6 +207,9 @@ def plot(
clean_files : bool, optional
Whether to clean created files after plot generation. The default is ``False``,
which means that the cache is maintained in the model object that is returned.
view : str, optional
View to export. Options are ``"isometric"``, ``"xy"``, ``"xz"``, ``"yz"``.
The default is ``"isometric"``.
Returns
-------
Expand All @@ -225,6 +229,7 @@ def plot(
plot_air_objects=plot_air_objects,
force_opacity_value=force_opacity_value,
clean_files=clean_files,
view=view,
)

@pyaedt_function_handler()
Expand All @@ -233,7 +238,7 @@ def export_mesh_stats(self, setup_name, variation_string="", mesh_path=None):
Parameters
----------
setup_name :str
setup_name : str
Setup name.
variation_string : str, optional
Variation list. The default is ``""``.
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/application/Analysis3DLayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def export_mesh_stats(self, setup_name, variation_string="", mesh_path=None):
Parameters
----------
setup_name :str
setup_name : str
Setup name.
variation_string : str, optional
Variation List.
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/application/Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -2487,7 +2487,7 @@ def dataset_exists(self, name, is_project_dataset=True):
Parameters
----------
name :str
name : str
Name of the dataset (without a prefix for a project dataset).
is_project_dataset : bool, optional
Whether it is a project data set. The default is ``True``.
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def get_source_pin_names(
----------
source_design_name : str
Name of the source design.
source_project_name :str, optional
source_project_name : str, optional
Name of the source project. The default is ``None``.
source_project_path : str, optional
Path to the source project if different than the existing path. The default is ``None``.
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ def copy_design(self, project_name=None, design_name=None, target_project=None):
Parameters
----------
project_name :str, optional
project_name : str, optional
Project name. The default is ``None``, in which case the active project
is used.
design_name : str, optional
Expand Down
6 changes: 6 additions & 0 deletions pyaedt/edb_core/EDB_Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2983,6 +2983,8 @@ def res_value(self):
componentProperty = self.edbcomponent.GetComponentProperty()
model = componentProperty.GetModel().Clone()
pinpairs = model.PinPairs
if not list(pinpairs):
return "0"
for pinpair in pinpairs:
pair = model.GetPinPairRlc(pinpair)
return pair.R.ToString()
Expand All @@ -3002,6 +3004,8 @@ def cap_value(self):
componentProperty = self.edbcomponent.GetComponentProperty()
model = componentProperty.GetModel().Clone()
pinpairs = model.PinPairs
if not list(pinpairs):
return "0"
for pinpair in pinpairs:
pair = model.GetPinPairRlc(pinpair)
return pair.C.ToString()
Expand All @@ -3021,6 +3025,8 @@ def ind_value(self):
componentProperty = self.edbcomponent.GetComponentProperty()
model = componentProperty.GetModel().Clone()
pinpairs = model.PinPairs
if not list(pinpairs):
return "0"
for pinpair in pinpairs:
pair = model.GetPinPairRlc(pinpair)
return pair.L.ToString()
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/edb_core/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ def get_pin_position(self, pin):
Parameters
----------
pin :str
pin : str
Name of the pin.
Returns
Expand Down
5 changes: 4 additions & 1 deletion pyaedt/generic/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,10 @@ def __init__(self):
self.gif_file = None
self._background_color = (255, 255, 255)
self.off_screen = False
self.windows_size = [1024, 768]
if self.is_notebook:
self.windows_size = [600, 600]
else:
self.windows_size = [1024, 768]
self.pv = None
self._orientation = ["xy", 0, 0, 0]
self.units = "meter"
Expand Down
7 changes: 4 additions & 3 deletions pyaedt/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ def create_spiral_lumped_port(self, start_object, end_object, port_width=None):
Parameters
----------
start_object : str or int or :class:`pyaedt.modeler.Object3d.Object3d`
end_object: str or int or :class:`pyaedt.modeler.Object3d.Object3d`
end_object : str or int or :class:`pyaedt.modeler.Object3d.Object3d`
Returns
-------
Expand Down Expand Up @@ -3918,12 +3918,13 @@ def thicken_port_sheets(self, inputlist, value, internalExtr=True, internalvalue
tol = 1e-6
ports_ID = {}
aedt_bounding_box = self.modeler.get_model_bounding_box()
aedt_bounding_dim = self.modeler.get_bounding_dimension()
directions = {}
for el in inputlist:
objID = self.modeler.oeditor.GetFaceIDs(el)
faceCenter = self.modeler.oeditor.GetFaceCenter(int(objID[0]))
directionfound = False
l = 10
l = min(aedt_bounding_dim) / 2
while not directionfound:
self.modeler.oeditor.ThickenSheet(
["NAME:Selections", "Selections:=", el, "NewPartsModelFlag:=", "Model"],
Expand All @@ -3948,7 +3949,7 @@ def thicken_port_sheets(self, inputlist, value, internalExtr=True, internalvalue
directions[el] = "Internal"
directionfound = True
else:
l = l + 10
l = l + min(aedt_bounding_dim) / 2
for el in inputlist:
objID = self.modeler.oeditor.GetFaceIDs(el)
maxarea = 0
Expand Down
72 changes: 47 additions & 25 deletions pyaedt/maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,30 +424,52 @@ def eddy_effects_on(self, object_list, activate_eddy_effects=True, activate_disp
if not activate_eddy_effects:
activate_displacement_current = False
for obj in solid_objects_names:
if obj in object_list:
EddyVector.append(
[
"NAME:Data",
"Object Name:=",
obj,
"Eddy Effect:=",
activate_eddy_effects,
"Displacement Current:=",
activate_displacement_current,
]
)
else:
EddyVector.append(
[
"NAME:Data",
"Object Name:=",
obj,
"Eddy Effect:=",
bool(self.oboundary.GetEddyEffect(obj)),
"Displacement Current:=",
bool(self.oboundary.GetDisplacementCurrent(obj)),
]
)
if self.solution_type == "EddyCurrent":
if obj in object_list:
EddyVector.append(
[
"NAME:Data",
"Object Name:=",
obj,
"Eddy Effect:=",
activate_eddy_effects,
"Displacement Current:=",
activate_displacement_current,
]
)
else:
EddyVector.append(
[
"NAME:Data",
"Object Name:=",
obj,
"Eddy Effect:=",
bool(self.oboundary.GetEddyEffect(obj)),
"Displacement Current:=",
bool(self.oboundary.GetDisplacementCurrent(obj)),
]
)
if self.solution_type == "Transient":
if obj in object_list:
EddyVector.append(
[
"NAME:Data",
"Object Name:=",
obj,
"Eddy Effect:=",
activate_eddy_effects,
]
)
else:
EddyVector.append(
[
"NAME:Data",
"Object Name:=",
obj,
"Eddy Effect:=",
bool(self.oboundary.GetEddyEffect(obj)),
]
)
else:
for obj in solid_objects_names:
if obj in object_list:
Expand Down Expand Up @@ -616,7 +638,7 @@ def assign_translate_motion(
Object container.
coordinate_system : str, optional
Coordinate system name. The default is ``"Global"``.
axis :str or int, optional
axis : str or int, optional
Coordinate system axis. The default is ``"Z"``.
It can be a ``pyaedt.generic.constants.AXIS`` enumerator value.
positive_movement : bool, optional
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/mechanical.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def assign_thermal_map(
Name of the design with the source mapping. The default is ``"IcepakDesign1"``.
setupname : str, optional
Name of the EM setup. The default is ``"Setup1"``.
sweepname :str, optional
sweepname : str, optional
Name of the EM sweep to use for the mapping. The default is ``"SteadyState"``.
source_project_name : str, optional
Name of the source project. The default is ``None``, in which case the
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/modeler/stackup_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class Layer3D(object):
Parameters
----------
stackup: :class:`pyaedt.modeler.stackup_3d.Stackup3D`
stackup : :class:`pyaedt.modeler.stackup_3d.Stackup3D`
The stackup where the layers will be added.
app : :class:`pyaedt.hfss.Hfss
HFSS design or project where the variable is to be created.
Expand Down
16 changes: 13 additions & 3 deletions pyaedt/modules/AdvancedPostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def plot_model_obj(
force_opacity_value=None,
clean_files=False,
array_coordinates=None,
view="isometric",
):
"""Plot the model or a substet of objects.
Expand All @@ -248,6 +249,9 @@ def plot_model_obj(
array_coordinates : list of list
List of array element centers. The modeler objects will be duplicated and translated.
List of [[x1,y1,z1], [x2,y2,z2]...].
view : str, optional
View to export. Options are ``"isometric"``, ``"xy"``, ``"xz"``, ``"yz"``.
The default is ``"isometric"``.
Returns
-------
Expand All @@ -264,6 +268,10 @@ def plot_model_obj(
)

model.off_screen = not show
if view != "isometric" and view in ["xy", "xz", "yz"]:
model.camera_position = view
else:
self.logger.warning("Wrong view setup. It has to be one of xy, xz, yz, isometric.")
if export_path:
model.plot(export_path)
elif show:
Expand Down Expand Up @@ -305,8 +313,7 @@ def plot_field_from_fieldplot(
``"png"``, ``"svg"``, and ``"webp"``. The default is
``"jpg"``.
view : str, optional
View to export. Options are ``isometric``, ``top``, ``front``,
``left``, ``all``.. The default is ``"iso"``. If ``"all"``, all views are exported.
View to export. Options are ``"isometric"``, ``"xy"``, ``"xz"``, ``"yz"``.
plot_label : str, optional
Type of the plot. The default is ``"Temperature"``.
plot_folder : str, optional
Expand Down Expand Up @@ -341,7 +348,10 @@ def plot_field_from_fieldplot(
if plot_label:
model.fields[0].label = plot_label

model.view = view
if view != "isometric" and view in ["xy", "xz", "yz"]:
model.camera_position = view
else:
self.logger.warning("Wrong view setup. It has to be one of xy, xz, yz, isometric.")

if scale_min and scale_max:
model.range_min = scale_min
Expand Down
Loading

0 comments on commit f44d785

Please sign in to comment.