Skip to content

Commit

Permalink
Merge branch 'main' into release/0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys committed Sep 11, 2024
2 parents 562832f + ce3b625 commit e76149d
Show file tree
Hide file tree
Showing 107 changed files with 8,139 additions and 1,495 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ scratch_notebooks/

# Visual studio code local settings
.vscode/
*.code-workspace

# EDB temp and backup files
*.aedb.bak/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*** PyAEDT README
-->

[![PyAEDT logo](https://github.com/ansys/pyaedt/blob/main/doc/source/_static/logo.png)](https://aedt.docs.pyansys.com)
[![PyAEDT logo](https://raw.githubusercontent.com/ansys/pyaedt/blob/main/doc/source/_static/logo.png)](https://aedt.docs.pyansys.com)

<p style="text-align: center;">
<br> English | <a href="README_CN.md">中文</a>
Expand Down
5 changes: 3 additions & 2 deletions _unittest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ def desktop():
d = Desktop(desktop_version, NONGRAPHICAL, new_thread)
d.odesktop.SetTempDirectory(tempfile.gettempdir())
d.disable_autosave()
d.odesktop.SetDesktopConfiguration("All")
d.odesktop.SetSchematicEnvironment(0)
if desktop_version > "2022.2":
d.odesktop.SetDesktopConfiguration("All")
d.odesktop.SetSchematicEnvironment(0)
yield d
d.release_desktop(True, True)
time.sleep(1)
Expand Down
Binary file modified _unittest/example_models/T98/transient_fs.aedtz
Binary file not shown.
1 change: 1 addition & 0 deletions _unittest/test_01_3dlayout_edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,5 +415,6 @@ def test_23_dissolve_element(self):
assert self.aedtapp.create_ports_on_component_by_nets(comp.name, nets)
assert self.aedtapp.create_pec_on_component_by_nets(comp.name, "GND")

@pytest.mark.skipif(config["desktopVersion"] <= "2024.1", reason="Introduced in 2024R1")
def test_24_open_ic_mode_design(self):
assert self.ic_mode_design.ic_mode
2 changes: 1 addition & 1 deletion _unittest/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def test_33_aedt_object(self):

def test_34_force_project_path_disable(self):
settings.force_error_on_missing_project = True
assert settings.force_error_on_missing_project == True
assert settings.force_error_on_missing_project
e = None
exception_raised = False
try:
Expand Down
25 changes: 24 additions & 1 deletion _unittest/test_02_2D_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_03_objects(self):
assert self.aedtapp.modeler._odefinition_manager
assert self.aedtapp.modeler._omaterial_manager

def test_04_create_rectangle(self):
def test_04a_create_rectangle(self):
test_color = (220, 90, 0)
rect1 = self.aedtapp.modeler.create_rectangle([0, -2, -2], [3, 8])
rect2 = self.aedtapp.modeler.create_rectangle(
Expand All @@ -88,6 +88,29 @@ def test_04_create_rectangle(self):
list_of_pos = [ver.position for ver in rect2.vertices]
assert sorted(list_of_pos) == [[10.0, -2.0, -2.0], [10.0, 8.0, -2.0], [13.0, -2.0, -2.0], [13.0, 8.0, -2.0]]

def test_04b_create_rectangle(self):
materials = ["copper", "steel_1008"]
material_array = []
for m in materials:
material_array.append('"' + m + '"')
s = ", ".join(material_array)
self.aedtapp["Materials"] = "[{}]".format(s)
material_index = 1
rect1 = self.aedtapp.modeler.create_rectangle(
origin=[0, 0, 0], sizes=[6, 12], name="rect1", material=f"Materials[{material_index}]"
)
assert rect1.material_name == materials[material_index]
rect2 = self.aedtapp.modeler.create_rectangle(origin=[0, 0, 0], sizes=[6, 12], name="rect2", material="test[0]")
assert rect2.material_name == "vacuum"
self.aedtapp["disp"] = 0
rect3 = self.aedtapp.modeler.create_rectangle(
origin=[0, 0, 0],
sizes=[6, 12],
name="rect3",
material="Materials[if(disp<={} && {}<=disp+{}-1,0,1)]".format(2, 2, 10),
)
assert rect3.material_name == materials[0]

def test_05_create_rectangle_rz(self):
self.aedtapp.solution_type = "MagnetostaticZ"
rect1 = self.aedtapp.modeler.create_rectangle([1, 0, -2], [8, 3])
Expand Down
15 changes: 12 additions & 3 deletions _unittest/test_02_3D_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ def test_18_chamfer(self):
o1 = self.aedtapp.modeler["box_to_split"]
assert abs(o1.volume - 4000.0) / 4000.0 < small_number
assert o1.top_edge_x.chamfer(1)
assert abs(o1.volume - 3990.0) / 3990.0 < small_number # Volume decreased
if config["desktopVersion"] == "2022.2":
assert abs(o1.volume - 3995.0) / 3995.0 < small_number # Volume decreased
else:
assert abs(o1.volume - 3990.0) / 3990.0 < small_number # Volume decreased

def test_19_clone(self):
self.restore_model()
Expand Down Expand Up @@ -521,7 +524,10 @@ def test_40b_create_object_coordinate_system(self):
assert cs
assert cs.name == "obj_cs"
assert cs.entity_id == box.id
assert cs.ref_cs == "Global"
if config["desktopVersion"] == "2022.2":
assert not cs.ref_cs
else:
assert cs.ref_cs == "Global"
cs.props["MoveToEnd"] = False
assert not cs.props["MoveToEnd"]
cs.props["yAxis"]["xDirection"] = 1
Expand All @@ -535,7 +541,10 @@ def test_40b_create_object_coordinate_system(self):
assert cs
assert cs.name == "obj_cs"
assert cs.entity_id == box.id
assert cs.ref_cs == "Global"
if config["desktopVersion"] == "2022.2":
assert not cs.ref_cs
else:
assert cs.ref_cs == "Global"
cs.props["MoveToEnd"] = False
assert not cs.props["MoveToEnd"]
cs.props["xAxis"]["xDirection"] = 1
Expand Down
22 changes: 22 additions & 0 deletions _unittest/test_04_SBR.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,28 @@ def test_12_import_map(self):
for part in parts_dict["parts"]:
assert os.path.exists(parts_dict["parts"][part]["file_name"])

def test_13_create_custom_array(self, aedtapp, local_scratch):
output_file1 = aedtapp.create_sbr_custom_array()
assert os.path.isfile(output_file1)

output_file2 = aedtapp.create_sbr_custom_array(
frequencies=[1.0, 2.0, 5.0],
element_number=4,
state_number=2,
position=[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 1.0, 1.0]],
x_axis=[[1.0, 0.0, 0.0]] * 4,
y_axis=[[0.0, 1.0, 0.0]] * 4,
weight=[
[complex(1.0, 0.0), complex(1.0, 0.0), complex(1.1, 0.0), complex(1.0, 0.0)],
[complex(1.0, 0.0), complex(1.0, 0.0), complex(1.0, 0.0), complex(1.0, 0.0)],
[complex(1.0, 0.0), complex(1.0, 0.0), complex(1.0, 1.0), complex(1.0, 0.0)],
[complex(1.0, 0.0), complex(1.0, 0.0), complex(1.0, 0.0), complex(1.0, 0.0)],
[complex(1.0, 0.0), complex(1.0, 0.0), complex(1.0, 0.0), complex(1.0, 0.0)],
[complex(1.0, 0.0), complex(1.0, 0.0), complex(1.0, 0.0), complex(1.0, 0.0)],
],
)
assert os.path.isfile(output_file2)

@pytest.mark.skipif(is_linux, reason="feature supported in Cpython")
def test_16_read_hdm(self):
self.aedtapp.insert_design("hdm")
Expand Down
1 change: 0 additions & 1 deletion _unittest/test_08_Primitives3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ def test_24_create_cone(self):
assert o.object_type == "Solid"
assert o.is3d is True
assert not self.aedtapp.modeler.create_cone(axis, [1, 1], 20, 10, 5, name="MyCone", material="Copper")
assert not self.aedtapp.modeler.create_cone(axis, udp, 20, 20, 5, name="MyCone", material="Copper")
assert not self.aedtapp.modeler.create_cone(axis, udp, -20, 20, 5, name="MyCone", material="Copper")
assert not self.aedtapp.modeler.create_cone(axis, udp, 20, -20, 5, name="MyCone", material="Copper")
assert not self.aedtapp.modeler.create_cone(axis, udp, 20, 20, -5, name="MyCone", material="Copper")
Expand Down
34 changes: 34 additions & 0 deletions _unittest/test_11_Setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,40 @@ def test_01_create_hfss_setup(self):
setup1.disable()
setup1.enable()

assert setup1.use_matrix_convergence(
entry_selection=0,
ignore_phase_when_mag_is_less_than=0.015,
all_diagonal_entries=True,
max_delta=0.03,
max_delta_phase=8,
custom_entries=None,
)
assert setup1.use_matrix_convergence(
entry_selection=1,
ignore_phase_when_mag_is_less_than=0.025,
all_diagonal_entries=True,
max_delta=0.023,
max_delta_phase=18,
custom_entries=None,
all_offdiagonal_entries=False,
)
assert setup1.use_matrix_convergence(
entry_selection=1,
ignore_phase_when_mag_is_less_than=0.025,
all_diagonal_entries=True,
max_delta=0.023,
max_delta_phase=18,
custom_entries=None,
)
assert setup1.use_matrix_convergence(
entry_selection=2,
ignore_phase_when_mag_is_less_than=0.01,
all_diagonal_entries=True,
max_delta=0.01,
max_delta_phase=8,
custom_entries=[["1", "2", 0.03, 4]],
)

def test_01b_create_hfss_sweep(self):
self.aedtapp.save_project()
setup1 = self.aedtapp.get_setup("My_HFSS_Setup")
Expand Down
89 changes: 89 additions & 0 deletions _unittest/test_12_1_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,95 @@ def test_14B_Field_Ploton_Vector(self):
image_format="jpg",
)
assert os.path.exists(plot_obj.image_file)
assert plot_obj.range_min is None
assert plot_obj.range_max is None
plot_obj_1 = self.aedtapp.post.plot_field(
"Vector_E",
cutlist,
"CutPlane",
setup=setup_name,
intrinsics=intrinsic,
mesh_on_fields=False,
view="isometric",
show=False,
export_path=self.local_scratch.path,
image_format="jpg",
log_scale=False,
)
assert os.path.exists(plot_obj_1.image_file)
assert plot_obj_1.range_min is None
assert plot_obj_1.range_max is None
plot_obj_2 = self.aedtapp.post.plot_field(
"Vector_E",
cutlist,
"CutPlane",
setup=setup_name,
intrinsics=intrinsic,
mesh_on_fields=False,
view="isometric",
show=False,
export_path=self.local_scratch.path,
image_format="jpg",
log_scale=False,
scale_min=0,
scale_max=10e6,
)
assert os.path.exists(plot_obj_2.image_file)
assert plot_obj_2.range_min == 0
assert plot_obj_2.range_max == 10e6
plot_obj_3 = self.aedtapp.post.plot_field(
"Vector_E",
cutlist,
"CutPlane",
setup=setup_name,
intrinsics=intrinsic,
mesh_on_fields=False,
view="isometric",
show=False,
export_path=self.local_scratch.path,
image_format="jpg",
log_scale=True,
scale_min=0,
scale_max=10e6,
)
assert os.path.exists(plot_obj_3.image_file)
assert plot_obj_3.range_min is None
assert plot_obj_3.range_max is None
plot_obj_4 = self.aedtapp.post.plot_field(
"Vector_E",
cutlist,
"CutPlane",
setup=setup_name,
intrinsics=intrinsic,
mesh_on_fields=False,
view="isometric",
show=False,
export_path=self.local_scratch.path,
image_format="jpg",
log_scale=True,
scale_min=10e6,
scale_max=0,
)
assert os.path.exists(plot_obj_4.image_file)
assert plot_obj_4.range_min is None
assert plot_obj_4.range_max is None
plot_obj_5 = self.aedtapp.post.plot_field(
"Vector_E",
cutlist,
"CutPlane",
setup=setup_name,
intrinsics=intrinsic,
mesh_on_fields=False,
view="isometric",
show=False,
export_path=self.local_scratch.path,
image_format="jpg",
log_scale=False,
scale_min=0,
)
assert os.path.exists(plot_obj_5.image_file)
assert plot_obj_5.range_min is None
assert plot_obj_5.range_max is None

@pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="Not running in ironpython")
def test_15_export_plot(self):
Expand Down
3 changes: 1 addition & 2 deletions _unittest/test_27_Maxwell2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from collections import OrderedDict
import os
import shutil

Expand Down Expand Up @@ -286,7 +285,7 @@ def test_19_matrix(self):
group_sources=group_sources,
)
assert L.props["MatrixGroup"]["MatrixGroup"]
group_sources = OrderedDict()
group_sources = {}
group_sources["Group1_Test"] = ["Current1", "Current3"]
group_sources["Group2_Test"] = ["Current2", "Current4"]
L = self.aedtapp.assign_matrix(
Expand Down
4 changes: 4 additions & 0 deletions _unittest/test_29_Mechanical.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ def test_05_assign_load(self, add_app):
assert self.aedtapp.assign_em_losses(hfss.design_name, hfss.setups[0].name, "LastAdaptive", freq)

def test_06a_create_setup(self):
assert not self.aedtapp.assign_2way_coupling()
mysetup = self.aedtapp.create_setup()
mysetup.props["Solver"] = "Direct"
assert mysetup.update()

def test_06b_two_way(self):
assert self.aedtapp.assign_2way_coupling()

@pytest.mark.skipif(config["desktopVersion"] < "2021.2", reason="Skipped on versions lower than 2021.2")
def test_07_assign_thermal_loss(self, add_app):
ipk = add_app(application=Icepak, solution_type=self.aedtapp.SOLUTIONS.Icepak.SteadyTemperatureAndFlow)
Expand Down
33 changes: 33 additions & 0 deletions _unittest/test_41_3dlayout_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,39 @@ def test_15_edit_setup(self):
setup2.props["AdvancedSettings"]["OrderBasis"] = 2
setup2.props["PercentRefinementPerPass"] = 17
assert setup2.update()
assert setup2.use_matrix_convergence(
entry_selection=0,
ignore_phase_when_mag_is_less_than=0.015,
all_diagonal_entries=True,
max_delta=0.03,
max_delta_phase=8,
custom_entries=None,
)
assert setup2.use_matrix_convergence(
entry_selection=1,
ignore_phase_when_mag_is_less_than=0.025,
all_diagonal_entries=True,
max_delta=0.023,
max_delta_phase=18,
custom_entries=None,
all_offdiagonal_entries=False,
)
assert setup2.use_matrix_convergence(
entry_selection=1,
ignore_phase_when_mag_is_less_than=0.025,
all_diagonal_entries=True,
max_delta=0.023,
max_delta_phase=18,
custom_entries=None,
)
assert setup2.use_matrix_convergence(
entry_selection=2,
ignore_phase_when_mag_is_less_than=0.01,
all_diagonal_entries=True,
max_delta=0.01,
max_delta_phase=8,
custom_entries=[["1", "2", 0.03, 4]],
)

def test_16_disable_enable_setup(self):
setup_name = "RFBoardSetup3"
Expand Down
1 change: 1 addition & 0 deletions _unittest/test_45_FilterSolutions/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
# SOFTWARE.

from .resources import read_resource_file
from .resources import resource_path
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*
V1 1 0 AC 1 PULSE 0 1 0 1.592E-13 0
R0 1 2 50
C1 2 0 2.296E-12
L2 2 3 1.688E-08
C3 3 0 4.517E-12
L4 3 4 1.688E-08
C5 4 0 2.296E-12
R6 4 0 50
*
.AC DEC 200 2E+08 5E+09
.PLOT AC VDB(4) -90 0
.PLOT AC VP(4) -200 200
.PLOT AC VG(4) 0 1.2E-09
.TRAN 5E-11 1E-08 0
.PLOT TRAN V(4) 0 0.6
.END
Loading

0 comments on commit e76149d

Please sign in to comment.