Skip to content

Commit

Permalink
Merge branch 'main' into release/0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcapodi78 authored and maxcapodi78 committed Dec 6, 2023
2 parents bad7c95 + 3664c1b commit 91f10ba
Show file tree
Hide file tree
Showing 31 changed files with 1,419 additions and 423 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ repos:

# validate GitHub workflow files
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.1
rev: 0.27.2
hooks:
- id: check-github-workflows

Expand Down
3 changes: 3 additions & 0 deletions _unittest/example_models/T21/netlist_small.cir
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ L201 N1721592 BUS_P 643.0p
V1 N1721592 BUS_N 12
V2 N1814870 0 PULSE(0 10 0 0.1u 0.1u 1.2u 5u)
I1 N1763408 0 1e-3
L4 N003 N004 110µ
L7 N018 N019 110µ
kcoupl L4 L7 0.9999
.param a=50V
.PARAM definire=20
.param a1=50V
Expand Down
18 changes: 18 additions & 0 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -2993,3 +2993,21 @@ def test_152_simconfig_built_custom_sballs_height(self):
assert round(edbapp.components["X1"].solder_ball_height, 6) == 0.00025
assert round(edbapp.components["U1"].solder_ball_height, 6) == 0.00035
edbapp.close_edb()

def test_153_update_padstacks_after_layer_name_changed(self):
source_path = os.path.join(local_path, "example_models", test_subfolder, "ANSYS-HSD_V1.aedb")
target_path = os.path.join(self.local_scratch.path, "test_padstack_def_update", "ANSYS-HSD_V1.aedb")
self.local_scratch.copyfolder(source_path, target_path)

edbapp = Edb(target_path, edbversion=desktop_version)
signal_layer_list = [layer for layer in list(edbapp.stackup.stackup_layers.values()) if layer.type == "signal"]
old_layers = []
for n_layer, layer in enumerate(signal_layer_list):
new_name = f"new_signal_name_{n_layer}"
old_layers.append(layer.name)
layer.name = new_name
for layer_name in list(edbapp.stackup.stackup_layers.keys()):
print(f"New layer name is {layer_name}")
for padstack_inst in list(edbapp.padstacks.instances.values()):
assert not [lay for lay in padstack_inst.layer_range_names if lay in old_layers]
edbapp.close_edb()
23 changes: 23 additions & 0 deletions _unittest/test_01_configuration_files.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# standard imports
import json
import os
import time

Expand Down Expand Up @@ -208,6 +209,28 @@ def test_04a_icepak(self, icepak_a, aedtapp, add_app):
out = app.configurations.import_config(conf_file)
assert isinstance(out, dict)
assert app.configurations.results.global_import_success
# backward compatibility
with open(conf_file, "r") as f:
old_dict_format = json.load(f)
old_dict_format["monitor"] = old_dict_format.pop("monitors")
old_mon_dict = {}
for mon in old_dict_format["monitor"]:
old_mon_dict[mon["Name"]] = mon
old_mon_dict[mon["Name"]].pop("Name")
old_dict_format["monitor"] = old_mon_dict
old_dataset_dict = {}
for dat in old_dict_format["datasets"]:
old_dataset_dict[dat["Name"]] = dat
old_dataset_dict[dat["Name"]].pop("Name")
old_dict_format["datasets"] = old_dataset_dict
old_conf_file = conf_file + ".old.json"
with open(old_conf_file, "w") as f:
json.dump(old_dict_format, f)
app = add_app(application=Icepak, project_name="new_proj_Ipk_a_test2", just_open=True)
app.modeler.import_3d_cad(file_path)
out = app.configurations.import_config(old_conf_file)
assert isinstance(out, dict)
assert app.configurations.results.global_import_success
app.close_project(save_project=False)

@pytest.mark.skipif(
Expand Down
16 changes: 15 additions & 1 deletion _unittest/test_11_Setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,20 @@ def test_01b_create_hfss_sweep(self):
assert self.aedtapp.get_sweeps("My_HFSS_Setup")
sweep2 = setup1.add_sweep(sweepname="test_sweeptype", sweeptype="invalid")
assert sweep2.props["Type"] == "Interpolating"
setup1.create_frequency_sweep(freqstart=1, freqstop="500MHz")
sweep3 = setup1.create_frequency_sweep(freqstart=1, freqstop="500MHz")
assert sweep3.props["Type"] == "Discrete"
sweep4 = setup1.create_frequency_sweep("GHz", 23, 25, 401, sweep_type="Fast")
assert sweep4.props["Type"] == "Fast"

def test_01c_create_hfss_setup_auto_open(self):
self.aedtapp.duplicate_design("auto_open")
for setup in self.aedtapp.get_setups():
self.aedtapp.delete_setup(setup)
self.aedtapp.set_auto_open()
setup1 = self.aedtapp.get_setup("Auto1")
setup1.enable_adaptive_setup_multifrequency([1.9, 2.4], 0.02)
assert setup1.update({"MaximumPasses": 20})
assert setup1.props["SolveType"] == "MultiFrequency"

def test_02_create_circuit_setup(self):
circuit = Circuit(specified_version=desktop_version)
Expand All @@ -74,6 +87,7 @@ def test_02_create_circuit_setup(self):
setup1.enable()

def test_03_non_valid_setup(self):
self.aedtapp.set_active_design("HFSSDesign")
self.aedtapp.duplicate_design("non_valid")
setup1 = self.aedtapp.create_setup("My_HFSS_Setup2", self.aedtapp.SETUPS.HFSSDrivenAuto)
assert not setup1.enable_adaptive_setup_multifrequency([1, 2, 3])
Expand Down
17 changes: 17 additions & 0 deletions _unittest/test_20_HFSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -1613,3 +1613,20 @@ def test_65_component_array(self, add_app):

array.delete()
assert not hfss_array.component_array

def test_66_assign_febi(self, add_app):
aedtapp = add_app(project_name="test_66")
udp = aedtapp.modeler.Position(0, 0, 0)
coax_dimension = 200
aedtapp.modeler.create_cylinder(aedtapp.AXIS.X, udp, 3, coax_dimension, 0, "inner")
aedtapp.modeler.create_cylinder(aedtapp.AXIS.X, udp, 10, coax_dimension, 0, "outer")
aedtapp.hybrid = True
assert aedtapp.assign_febi(["inner"])
assert len(aedtapp.boundaries) == 1
aedtapp.close_project(save_project=False)

def test_67_transient_composite(self, add_app):
aedtapp = add_app(project_name="test_66")
aedtapp.solution_type = "Transient Composite"
assert aedtapp.solution_type == "Transient Composite"
aedtapp.close_project(save_project=False)
5 changes: 4 additions & 1 deletion _unittest/test_28_Maxwell3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,14 +819,17 @@ def test_50_objects_segmentation(self, cyl_gap):
assert isinstance(sheets[0][object_name], list)
assert len(sheets[0][object_name]) == segments_number - 1
segments_number = 4
mesh_sheets_number = 3
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
magnet_id, segments_number=segments_number, apply_mesh_sheets=True, mesh_sheets_number=mesh_sheets_number
)
assert isinstance(sheets, tuple)
assert isinstance(sheets[0][object_name], list)
assert len(sheets[0][object_name]) == segments_number - 1
assert isinstance(sheets[1][object_name], list)
assert len(sheets[1][object_name]) == mesh_sheets_number
segmentation_thickness = 1
object_name = "PM_O1"
magnet = [obj for obj in cyl_gap.modeler.object_list if obj.name == object_name][0]
Expand Down
62 changes: 62 additions & 0 deletions _unittest/test_98_Icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,16 @@ def test_54_assign_stationary_wall(self):
ht_correlation_value_type="Average Values",
ht_correlation_free_stream_velocity=1,
)
self.aedtapp.create_dataset("ds1", [1, 2, 3], [2, 3, 4], is_project_dataset=False)
assert self.aedtapp.assign_stationary_wall_with_htc(
"surf1",
name=None,
thickness="0mm",
material="Al-Extruded",
htc_dataset="ds1",
ref_temperature="AmbientTemp",
ht_correlation=False,
)
assert self.aedtapp.assign_stationary_wall_with_temperature(
"surf1",
name=None,
Expand Down Expand Up @@ -931,6 +941,17 @@ def test_54_assign_stationary_wall(self):
ext_surf_rad_ref_temp=0,
ext_surf_rad_view_factor=0.5,
)
self.aedtapp.solution_type = "Transient"
assert self.aedtapp.assign_stationary_wall_with_temperature(
"surf1",
name=None,
temperature={"Type": "Transient", "Function": "Sinusoidal", "Values": ["20cel", 1, 1, "1s"]},
thickness="0mm",
material="Al-Extruded",
radiate=False,
radiate_surf_mat="Steel-oxidised-surface",
shell_conduction=False,
)

@pytest.mark.skipif(config["desktopVersion"] < "2023.1" and config["use_grpc"], reason="Not working in 2022.2 GRPC")
def test_55_native_components_history(self):
Expand Down Expand Up @@ -1362,3 +1383,44 @@ def test_71_assign_adiabatic_plate(self):
ad_plate = self.aedtapp.assign_adiabatic_plate(rectangle.name)
assert ad_plate
assert ad_plate.update()

def test_72_assign_resistance(self):
box = self.aedtapp.modeler.create_box([5, 5, 5], [1, 2, 3], "ResistanceBox", "copper")
assert self.aedtapp.assign_device_resistance(
box.name,
boundary_name=None,
total_power="0W",
fluid="air",
laminar=False,
linear_loss=["1m_per_sec", "2m_per_sec", 3],
quadratic_loss=[1, "1", 1],
linear_loss_free_area_ratio=[1, "0.1", 1],
quadratic_loss_free_area_ratio=[1, 0.1, 1],
)
assert self.aedtapp.assign_loss_curve_resistance(
box.name,
boundary_name=None,
total_power="0W",
fluid="air",
laminar=False,
loss_curves_x=[[0, 1, 2, 3, 4], [0, 1, 2, 3, 5]],
loss_curves_y=[[0, 1, 2, 3, 4], [0, 1, 2, 3, 5]],
loss_curves_z=[[0, 1, 2, 3, 4], [0, 1, 2, 3, 5]],
loss_curve_flow_unit="m_per_sec",
loss_curve_pressure_unit="n_per_meter_sq",
)
assert not self.aedtapp.assign_power_law_resistance(
box.name,
boundary_name="TestNameResistance",
total_power={"Function": "Linear", "Values": ["0.01W", "1W"]},
power_law_constant=1.5,
power_law_exponent="3",
)
self.aedtapp.solution_type = "Transient"
assert self.aedtapp.assign_power_law_resistance(
box.name,
boundary_name="TestNameResistance",
total_power={"Function": "Linear", "Values": ["0.01W", "1W"]},
power_law_constant=1.5,
power_law_exponent="3",
)
90 changes: 90 additions & 0 deletions _unittest_solvers/test_26_emit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Import required modules
import os
import sys
import time

from _unittest_solvers.conftest import config
import pytest
Expand Down Expand Up @@ -1170,3 +1171,92 @@ def test_result_categories(self, add_app):
with pytest.raises(RuntimeError) as e:
instance.get_largest_emi_problem_type()
assert "An EMI value is not available so the largest EMI problem type is undefined." in str(e)

@pytest.mark.skipif(
config["desktopVersion"] < "2024.2", reason="Skipped on versions earlier than 2024 R2."
)
def test_license_session(self, add_app):
self.aedtapp = add_app(project_name="interference", application=Emit, subfolder=test_subfolder)

# Generate a revision
results = self.aedtapp.results
revision = self.aedtapp.results.analyze()

receivers = revision.get_receiver_names()
modeRx = TxRxMode.RX
modeTx = TxRxMode.TX
modeEmi = ResultType.EMI
self.aedtapp.set_units("Frequency", "GHz")

def get_best_rx_channel(results, receiver):
domain = results.interaction_domain()
rev = results.current_revision
# get interferers
interferers = rev.get_interferer_names()
best_emi = 300.0
best_band = None
best_freq = None

combinations_run = 0

domain.set_receiver(receiver)
interaction = rev.run(domain)

for interferer in interferers:
for tx_band in rev.get_band_names(interferer, modeTx):
for tx_freq in rev.get_active_frequencies(interferer, tx_band, modeTx):
domain.set_interferer(interferer, tx_band, tx_freq)
rx_band = rev.get_band_names(receiver, modeRx)[0]
for rx_freq in rev.get_active_frequencies(receiver, rx_band, modeRx):

domain.set_receiver(receiver, rx_band, rx_freq)

if best_band == None:
best_band = rx_band
if best_freq == None:
best_freq = rx_freq

try:
instance = interaction.get_instance(domain)
if instance.has_valid_values():
emi = instance.get_value(modeEmi)
if emi < best_emi:
best_emi = emi
best_band = rx_band
best_freq = rx_freq
else:
assert(f'No valid values found')
except:
assert("No results between " + interferer + ": " + tx_band +
": " + str(tx_freq) + " and " + receiver + ": " +
rx_band + ": " + str(rx_freq))

combinations_run += 1

if combinations_run >= 20:
return [best_band, best_freq]
return [best_band, best_freq]

# Warmup in case something isn't solved
best_case_rx_ch = {}
for rx in [receivers[0]]:
best_case_rx_ch[rx] = get_best_rx_channel(results, rx)

# Get the time without the license session
start = time.perf_counter()
best_case_rx_ch = {}
for rx in [receivers[0]]:
best_case_rx_ch[rx] = get_best_rx_channel(results, rx)
end = time.perf_counter()
noLicenseSessionTime = end - start

# Get the time using the license session
start = time.perf_counter()
best_case_rx_ch = {}
with revision.get_license_session():
for rx in [receivers[0]]:
best_case_rx_ch[rx] = get_best_rx_channel(results, rx)
end = time.perf_counter()
licenseSessionTime = end - start

assert (licenseSessionTime*2) < noLicenseSessionTime
2 changes: 2 additions & 0 deletions doc/styles/Vocab/ANSYS/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ EDB
EDT
efields
EMIT
FEBI
FE-BI
getters
globals
[Gg]gRPC
Expand Down
4 changes: 2 additions & 2 deletions pyaedt/application/Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2203,7 +2203,7 @@ def value_with_units(
Some common examples are:
"in": inches
"cm": centimeter
"um": micron
"um": micron
"mm": millimeter
"meter": meters
"mil": 0.001 inches (mils)
Expand All @@ -2217,7 +2217,7 @@ def value_with_units(
str
String that combines the value and the units (e.g. "1.2mm").
"""
if not units:
if units is None:
if unit_system == "Length":
units = self.modeler.model_units
else:
Expand Down
5 changes: 5 additions & 0 deletions pyaedt/application/Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ def boundaries(self):
bb = list(self.oboundary.GetBoundaries())
elif "Boundaries" in self.get_oo_name(self.odesign):
bb = self.get_oo_name(self.odesign, "Boundaries")
if "GetHybridRegions" in self.oboundary.__dir__():
hybrid_regions = self.oboundary.GetHybridRegions()
for region in hybrid_regions:
bb.append(region)
bb.append("FE-BI")

# Parameters and Motion definitions
if self.design_type in ["Maxwell 3D", "Maxwell 2D"]:
Expand Down
13 changes: 12 additions & 1 deletion pyaedt/application/design_solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,14 @@
"default_adaptive": "Transient",
"intrinsics": ["Time"],
},
"Transient Composite": {
"name": "Transient Composite",
"options": None,
"report_type": "Terminal Solution Data",
"default_setup": 3,
"default_adaptive": "Transient",
"intrinsics": ["Time"],
},
"Transient": {
"name": "Transient",
"options": None,
Expand Down Expand Up @@ -681,9 +689,12 @@ def solution_type(self, value):
else:
self._solution_type = solutions_defaults[self._design_type]
elif value and value in self._solution_options and self._solution_options[value]["name"]:
if value == "Transient":
if value == "Transient" or value == "Transient Network":
value = "Transient Network"
self._solution_type = "Transient Network"
elif value == "Transient Composite":
value = "Transient Composite"
self._solution_type = "Transient Composite"
elif "Modal" in value:
value = "Modal"
self._solution_type = "Modal"
Expand Down
Loading

0 comments on commit 91f10ba

Please sign in to comment.