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

REFACTOR: Refacto args #4929

Merged
merged 13 commits into from
Jul 23, 2024
4 changes: 2 additions & 2 deletions _unittest/test_02_3D_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ def test_59a_region_property(self):
self.aedtapp.modeler.create_coordinate_system(
origin=[1, 1, 1], name=cs_name, mode="zxz", phi=10, theta=30, psi=50
)
assert self.aedtapp.modeler.change_region_coordinate_system(region_cs=cs_name)
assert self.aedtapp.modeler.change_region_coordinate_system(assignment=cs_name)
assert self.aedtapp.modeler.change_region_padding("10mm", padding_type="Absolute Offset", direction="-X")
assert self.aedtapp.modeler.change_region_padding(
["1mm", "-2mm", "3mm", "-4mm", "5mm", "-6mm"],
Expand All @@ -1052,7 +1052,7 @@ def test_59a_region_property(self):

def test_59b_region_property_failing(self):
self.aedtapp.modeler.create_air_region()
assert not self.aedtapp.modeler.change_region_coordinate_system(region_cs="NoCS")
assert not self.aedtapp.modeler.change_region_coordinate_system(assignment="NoCS")
assert not self.aedtapp.modeler.change_region_padding(
"10mm", padding_type="Absolute Offset", direction="-X", region_name="NoRegion"
)
Expand Down
20 changes: 15 additions & 5 deletions _unittest/test_07_Object3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ def test_10_chamfer(self):
assert test
test = initial_object.edges[4].chamfer(chamfer_type=4)
assert not test
self.aedtapp.modeler.delete(initial_object)
self.aedtapp.modeler.delete(
initial_object,
)
initial_object = self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 5], "ChamferTest2", "Copper")
assert initial_object.chamfer(edges=initial_object.faces[0].edges[0], chamfer_type=3)
initial_object = self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 5], "ChamferTest3", "Copper")
Expand All @@ -325,7 +327,9 @@ def test_11_fillet(self):
test = initial_object.edges[0].fillet(radius=0.2)
assert test
test = initial_object.edges[1].fillet(radius=0.2, setback=0.1)
self.aedtapp.modeler.delete(initial_object)
self.aedtapp.modeler.delete(
initial_object,
)

def test_object_length(self):
initial_object = self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 5], "FilletTest", "Copper")
Expand All @@ -338,7 +342,9 @@ def test_object_length(self):
for i in range(0, 3):
sum_sq += (end_point.position[i] - start_point.position[i]) ** 2
assert isclose(math.sqrt(sum_sq), test_edge.length)
self.aedtapp.modeler.delete(initial_object)
self.aedtapp.modeler.delete(
initial_object,
)

def test_12_set_color(self):
initial_object = self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 5], "ColorTest")
Expand All @@ -365,7 +371,9 @@ def test_12_set_color(self):
initial_object.color = (255, "Invalid", 0)
assert initial_object.color == (255, 0, 0)

self.aedtapp.modeler.delete("ColorTest")
self.aedtapp.modeler.delete(
"ColorTest",
)

def test_print_object(self):
o = self.create_copper_box()
Expand Down Expand Up @@ -576,7 +584,9 @@ def test_26_unclassified_object(self):

def test_26a_delete_unclassified_object(self):
unclassified = self.aedtapp.modeler.unclassified_objects
assert self.aedtapp.modeler.delete(unclassified)
assert self.aedtapp.modeler.delete(
unclassified,
)
assert len(self.aedtapp.modeler.unclassified_objects) != unclassified
assert len(self.aedtapp.modeler.unclassified_objects) == 0

Expand Down
47 changes: 21 additions & 26 deletions _unittest/test_08_Primitives3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,14 @@ def create_polylines(self, name=None):
test_points = [[0, 100, 0], [-100, 0, 0], [-50, -50, 0], [0, 0, 0]]

if self.aedtapp.modeler[name + "segmented"]:
self.aedtapp.modeler.delete(name + "segmented")
self.aedtapp.modeler.delete(
name + "segmented",
)

if self.aedtapp.modeler[name + "compound"]:
self.aedtapp.modeler.delete(name + "compound")
self.aedtapp.modeler.delete(
name + "compound",
)

p1 = self.aedtapp.modeler.create_polyline(points=test_points, name=name + "segmented")
p2 = self.aedtapp.modeler.create_polyline(
Expand Down Expand Up @@ -590,7 +594,9 @@ def test_30_get_faces_from_position(self):
def test_31_delete_object(self):
self.create_rectangle(name="MyRectangle")
assert "MyRectangle" in self.aedtapp.modeler.object_names
deleted = self.aedtapp.modeler.delete("MyRectangle")
deleted = self.aedtapp.modeler.delete(
"MyRectangle",
)
assert deleted
assert "MyRectangle" not in self.aedtapp.modeler.object_names

Expand Down Expand Up @@ -1215,38 +1221,35 @@ def test_64_create_3dcomponent(self):
mr1 = self.aedtapp.mesh.assign_length_mesh([box1.name, box2.name])
assert self.aedtapp.modeler.create_3dcomponent(
self.component3d_file,
object_list=["Solid", new_obj[1][0], box1.name, box2.name],
boundaries_list=[rad.name],
excitation_list=[exc.name],
included_cs="Global",
variables_to_include=["test_variable"],
assignment=["Solid", new_obj[1][0], box1.name, box2.name],
boundaries=[rad.name],
excitations=[exc.name],
coordinate_systems="Global",
)
assert os.path.exists(self.component3d_file)

def test_64_create_3d_component_encrypted(self):
assert self.aedtapp.modeler.create_3dcomponent(
self.component3d_file,
included_cs="Global",
is_encrypted=True,
password="password_test",
self.component3d_file, coordinate_systems="Global", is_encrypted=True, password="password_test"
)
assert self.aedtapp.modeler.create_3dcomponent(
self.component3d_file,
included_cs="Global",
coordinate_systems="Global",
is_encrypted=True,
password="password_test",
hide_contents=["Solid"],
)
assert not self.aedtapp.modeler.create_3dcomponent(
self.component3d_file,
included_cs="Global",
coordinate_systems="Global",
is_encrypted=True,
password="password_test",
password_type="Invalid",
)
assert not self.aedtapp.modeler.create_3dcomponent(
self.component3d_file,
included_cs="Global",
coordinate_systems="Global",
is_encrypted=True,
password="password_test",
component_outline="Invalid",
Expand Down Expand Up @@ -1799,15 +1802,11 @@ def test_84_replace_3d_component(self):
box2 = self.aedtapp.modeler.create_box([0, 0, 0], ["test_variable", 100, 30])
mr1 = self.aedtapp.mesh.assign_length_mesh([box1.name, box2.name])
obj_3dcomp = self.aedtapp.modeler.replace_3dcomponent(
object_list=[box1.name],
variables_to_include=["test_variable"],
variables_to_include=["test_variable"], assignment=[box1.name]
)
assert isinstance(obj_3dcomp, UserDefinedComponent)

self.aedtapp.modeler.replace_3dcomponent(
component_name="new_comp",
object_list=[box2.name],
)
self.aedtapp.modeler.replace_3dcomponent(name="new_comp", assignment=[box2.name])
assert len(self.aedtapp.modeler.user_defined_components) == 2

@pytest.mark.skipif(config["desktopVersion"] < "2023.1", reason="Method available in beta from 2023.1")
Expand Down Expand Up @@ -1853,13 +1852,9 @@ def test_85_insert_layout_component(self):
def test_87_set_mesh_fusion_settings(self):
self.aedtapp.insert_design("MeshFusionSettings")
box1 = self.aedtapp.modeler.create_box([0, 0, 0], [10, 20, 30])
obj_3dcomp = self.aedtapp.modeler.replace_3dcomponent(
object_list=[box1.name],
)
obj_3dcomp = self.aedtapp.modeler.replace_3dcomponent(assignment=[box1.name])
box2 = self.aedtapp.modeler.create_box([0, 0, 0], [100, 20, 30])
obj2_3dcomp = self.aedtapp.modeler.replace_3dcomponent(
object_list=[box2.name],
)
obj2_3dcomp = self.aedtapp.modeler.replace_3dcomponent(assignment=[box2.name])
assert self.aedtapp.set_mesh_fusion_settings(assignment=obj2_3dcomp.name, volume_padding=None, priority=None)

assert self.aedtapp.set_mesh_fusion_settings(
Expand Down
12 changes: 9 additions & 3 deletions _unittest/test_09_Primitives2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ def test_fillet_vertex(self):

def test_06_create_region(self):
if self.aedtapp.modeler["Region"]:
self.aedtapp.modeler.delete("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], "Absolute Offset")
self.aedtapp.modeler["Region"].delete()
Expand All @@ -126,7 +128,9 @@ def test_06_create_region(self):

def test_06_a_create_region_Z(self):
if self.axisymmetrical.modeler["Region"]:
self.axisymmetrical.modeler.delete("Region")
self.axisymmetrical.modeler.delete(
"Region",
)
assert "Region" not in self.axisymmetrical.modeler.object_names
assert not self.axisymmetrical.modeler.create_region(["100%", "50%", "20%"])
assert self.axisymmetrical.modeler.create_region([100, 50, 20])
Expand Down Expand Up @@ -154,7 +158,9 @@ def test_07_assign_material(self, material="steel_stainless"):

def test_08_region(self, q2d_app):
if q2d_app.modeler["Region"]:
q2d_app.modeler.delete("Region")
q2d_app.modeler.delete(
"Region",
)
assert "Region" not in q2d_app.modeler.object_names
assert not q2d_app.modeler.create_region(["100%", "50%", "20%", "10%"])
assert q2d_app.modeler.create_region([100, 50, 20, 20])
Expand Down
14 changes: 7 additions & 7 deletions _unittest/test_11_Setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def test_27_create_doe(self):
setup2 = self.aedtapp.optimizations.add(
calculation,
ranges={"Freq": "2.5GHz"},
optim_type="DXDOE",
optimization_type="DXDOE",
solution="{} : {}".format(new_setup.name, sweep.name),
)
assert setup2.add_variation("w1", 0.1, 10)
Expand All @@ -279,15 +279,15 @@ def test_28A_create_optislang(self):
calculation=None,
ranges=None,
variables=None,
optim_type="optiSLang",
optimization_type="optiSLang",
solution="{} : {}".format(new_setup.name, sweep.name),
)
assert setup1.add_variation("w1", 1, 10, 51)
setup2 = self.aedtapp.optimizations.add(
calculation=None,
ranges=None,
variables={"w1": "1mm", "w2": "2mm"},
optim_type="optiSLang",
optimization_type="optiSLang",
solution="{} : {}".format(new_setup.name, sweep.name),
)
assert setup2.add_variation("a1", 1, 10, 51)
Expand All @@ -305,15 +305,15 @@ def test_28B_create_dx(self):
None,
ranges=None,
variables=None,
optim_type="DesignExplorer",
optimization_type="DesignExplorer",
solution="{} : {}".format(new_setup.name, sweep.name),
)
assert setup1.add_variation("w1", 5, 10, 51)
setup2 = self.aedtapp.optimizations.add(
None,
ranges=None,
variables={"w1": "1mm", "w2": "2mm"},
optim_type="DesignExplorer",
optimization_type="DesignExplorer",
solution="{} : {}".format(new_setup.name, sweep.name),
)
assert setup2.add_variation("a1", 1, 10, 51)
Expand All @@ -330,7 +330,7 @@ def test_29_create_sensitivity(self):
setup2 = self.aedtapp.optimizations.add(
calculation,
ranges={"Freq": "2.5GHz"},
optim_type="Sensitivity",
optimization_type="Sensitivity",
solution="{} : {}".format(new_setup.name, sweep.name),
)
assert setup2.add_variation("w1", 0.1, 10, 3.2)
Expand All @@ -347,7 +347,7 @@ def test_29_create_statistical(self):
setup2 = self.aedtapp.optimizations.add(
calculation,
ranges={"Freq": "2.5GHz"},
optim_type="Statistical",
optimization_type="Statistical",
solution="{} : {}".format(new_setup.name, sweep.name),
)
assert setup2.add_variation("w1", 0.1, 10, 0.3)
Expand Down
8 changes: 4 additions & 4 deletions _unittest/test_28_Maxwell3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ def test_50_objects_segmentation(self, cyl_gap):
segments_number = 5
object_name = "PM_I1"
sheets = cyl_gap.modeler.objects_segmentation(
object_name, segments_number=segments_number, apply_mesh_sheets=True
assignment=object_name, segments=segments_number, apply_mesh_sheets=True
)
assert isinstance(sheets, tuple)
assert isinstance(sheets[0], dict)
Expand All @@ -934,7 +934,7 @@ def test_50_objects_segmentation(self, cyl_gap):
object_name = "PM_I1_1"
magnet_id = [obj.id for obj in cyl_gap.modeler.object_list if obj.name == object_name][0]
sheets = cyl_gap.modeler.objects_segmentation(
magnet_id, segments_number=segments_number, apply_mesh_sheets=True, mesh_sheets_number=mesh_sheets_number
magnet_id, segments=segments_number, apply_mesh_sheets=True, mesh_sheets=mesh_sheets_number
)
assert isinstance(sheets, tuple)
assert isinstance(sheets[0][object_name], list)
Expand All @@ -953,11 +953,11 @@ def test_50_objects_segmentation(self, cyl_gap):
assert len(sheets[0][object_name]) == segments_number - 1
assert not cyl_gap.modeler.objects_segmentation(object_name)
assert not cyl_gap.modeler.objects_segmentation(
object_name, segments_number=segments_number, segmentation_thickness=segmentation_thickness
object_name, segmentation_thickness=segmentation_thickness, segments=segments_number
)
object_name = "PM_O1_1"
segments_number = 10
sheets = cyl_gap.modeler.objects_segmentation(object_name, segments_number=segments_number)
sheets = cyl_gap.modeler.objects_segmentation(object_name, segments=segments_number)
assert isinstance(sheets, dict)
assert isinstance(sheets[object_name], list)
assert len(sheets[object_name]) == segments_number - 1
Expand Down
22 changes: 11 additions & 11 deletions _unittest/test_98_Icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,9 +851,9 @@ def test_50_advanced3dcomp_export(self):
)
assert self.aedtapp.modeler.create_3dcomponent(
os.path.join(file_path, file_name),
component_name="board_assembly",
included_cs=["Global"],
auxiliary_dict=True,
name="board_assembly",
coordinate_systems=["Global"],
export_auxiliary=True,
)
self.aedtapp.create_dataset(
"test_ignore",
Expand All @@ -873,10 +873,10 @@ def test_50_advanced3dcomp_export(self):
self.aedtapp.modeler.create_coordinate_system()
assert self.aedtapp.modeler.create_3dcomponent(
os.path.join(file_path, file_name),
component_name="board_assembly",
included_cs=cs_list,
auxiliary_dict=True,
reference_cs="CS1",
name="board_assembly",
coordinate_systems=cs_list,
reference_coordinate_systems="CS1",
export_auxiliary=True,
monitor_objects=mon_list,
datasets=["test_dataset"],
)
Expand Down Expand Up @@ -950,10 +950,10 @@ def test_51_advanced3dcomp_import(self):
self.aedtapp.modeler.create_coordinate_system()
assert self.aedtapp.modeler.create_3dcomponent(
os.path.join(file_path, file_name),
component_name="board_assembly",
included_cs=cs_list,
auxiliary_dict=True,
reference_cs="CS1",
name="board_assembly",
coordinate_systems=cs_list,
reference_coordinate_systems="CS1",
export_auxiliary=True,
monitor_objects=mon_list,
datasets=["test_dataset"],
)
Expand Down
15 changes: 6 additions & 9 deletions examples/01-Modeling-Setup/Optimetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create an optimetrics sensitivity analysis with output calculations.

sweep2 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="Sensitivity")
sweep2 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optimization_type="Sensitivity")
sweep2.add_variation("w1", 0.1, 3, 0.5)
sweep2.add_calculation(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})

Expand All @@ -124,15 +124,15 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create a DX (DesignXplorer) optimization based on a goal and a calculation.

sweep4 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="DesignExplorer")
sweep4 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optimization_type="DesignExplorer")
sweep4.add_goal(calculation="dB(S(1,1))", ranges={"Freq": "2.6GHz"})

###############################################################################
# Create DOE based on a goal and calculation
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create a DOE (Design of Experiments) based on a goal and a calculation.

sweep5 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optim_type="DXDOE")
sweep5 = hfss.optimizations.add(calculation="dB(S(1,1))", ranges={"Freq": "2.5GHz"}, optimization_type="DXDOE")

###############################################################################
# Create DOE based on a goal and calculation
Expand All @@ -142,12 +142,9 @@
region = hfss.modeler.create_region()
hfss.assign_radiation_boundary_to_objects(region)
hfss.insert_infinite_sphere(name="Infinite_1")
sweep6 = hfss.optimizations.add(
calculation="RealizedGainTotal",
solution=hfss.nominal_adaptive,
ranges={"Freq": "5GHz", "Theta": ["0deg", "10deg", "20deg"], "Phi": "0deg"},
context="Infinite_1",
)
sweep6 = hfss.optimizations.add(calculation="RealizedGainTotal",
ranges={"Freq": "5GHz", "Theta": ["0deg", "10deg", "20deg"], "Phi": "0deg"},
solution=hfss.nominal_adaptive, context="Infinite_1")

###############################################################################
# Close AEDT
Expand Down
Loading
Loading