diff --git a/src/ansys/aedt/core/generic/constants.py b/src/ansys/aedt/core/generic/constants.py index 4c9de014759..915c9d319aa 100644 --- a/src/ansys/aedt/core/generic/constants.py +++ b/src/ansys/aedt/core/generic/constants.py @@ -814,19 +814,11 @@ class Icepak(object): """Provides Icepak solution types.""" ( - SteadyTemperatureAndFlow, - SteadyTemperatureOnly, - SteadyFlowOnly, - TransientTemperatureAndFlow, - TransientTemperatureOnly, - TransientFlowOnly, + SteadyState, + Transient, ) = ( - "SteadyStateTemperatureAndFlow", - "SteadyStateTemperatureOnly", - "SteadyStateFlowOnly", - "TransientTemperatureAndFlow", - "TransientTemperatureOnly", - "TransientFlowOnly", + "SteadyState", + "Transient", ) class Circuit(object): @@ -887,9 +879,9 @@ class SETUPS(object): Electrostatic, ElectrostaticDC, ElectricTransient, - SteadyTemperatureAndFlow, - SteadyTemperatureOnly, - SteadyFlowOnly, + SteadyState, + SteadyState, + SteadyState, Matrix, NexximLNA, NexximDC, @@ -912,9 +904,9 @@ class SETUPS(object): MechModal, GRM, TR, - TransientTemperatureAndFlow, - TransientTemperatureOnly, - TransientFlowOnly, + Transient, + Transient, + Transient, DFIG, TPIM, SPIM, diff --git a/src/ansys/aedt/core/icepak.py b/src/ansys/aedt/core/icepak.py index 92f22dd1c6f..9a676d45a7f 100644 --- a/src/ansys/aedt/core/icepak.py +++ b/src/ansys/aedt/core/icepak.py @@ -33,9 +33,11 @@ import ansys.aedt.core from ansys.aedt.core.application.analysis_icepak import FieldAnalysisIcepak +from ansys.aedt.core.generic.constants import SOLUTIONS from ansys.aedt.core.generic.data_handlers import _arg2dict from ansys.aedt.core.generic.data_handlers import _dict2arg from ansys.aedt.core.generic.data_handlers import random_string +from ansys.aedt.core.generic.errors import AEDTRuntimeError from ansys.aedt.core.generic.errors import GrpcApiError from ansys.aedt.core.generic.general_methods import generate_unique_name from ansys.aedt.core.generic.general_methods import open_file @@ -386,11 +388,10 @@ def assign_2way_coupling( """ if not setup: - if self.setups: - setup = self.setups[0].name - else: - self.logger.error("No setup is defined.") - return False + if not self.setups: + raise AEDTRuntimeError("No setup is defined.") + setup = self.setups[0].name + self.oanalysis.AddTwoWayCoupling( setup, [ @@ -1053,35 +1054,25 @@ def assign_block_from_sherlock_file(self, csv_name): for el in component_header: component_data[el] = [i[k] for i in data] k += 1 + total_power = 0 - i = 0 all_objects = self.modeler.object_names - for power in component_data["Applied Power (W)"]: + for i, power in enumerate(component_data["Applied Power (W)"]): try: - float(power) if "COMP_" + component_data["Ref Des"][i] in all_objects: - status = self.create_source_block( - "COMP_" + component_data["Ref Des"][i], str(power) + "W", assign_material=False - ) - if not status: - self.logger.warning( - "Warning. Block %s skipped with %sW power.", component_data["Ref Des"][i], power - ) - else: - total_power += float(power) - elif component_data["Ref Des"][i] in all_objects: - status = self.create_source_block( - component_data["Ref Des"][i], str(power) + "W", assign_material=False + object_name = "COMP_" + component_data["Ref Des"][i] + else: + object_name = component_data["Ref Des"][i] + status = self.create_source_block(object_name, str(power) + "W", assign_material=False) + + if not status: + self.logger.warning( + "Warning. Block %s skipped with %sW power.", component_data["Ref Des"][i], power ) - if not status: - self.logger.warning( - "Warning. Block %s skipped with %sW power.", component_data["Ref Des"][i], power - ) - else: - total_power += float(power) + else: + total_power += float(power) except Exception: - pass - i += 1 + self.logger.debug(f"Failed to handle component data from Ref Des {i}") self.logger.info("Blocks inserted with total power %sW.", total_power) return total_power @@ -2045,6 +2036,8 @@ def export_summary( >>> oModule.EditFieldsSummarySetting >>> oModule.ExportFieldsSummary """ + if type not in ("Object", "Boundary"): + raise ValueError(("Entity type " + type + " not supported.")) if variation_list is None: variation_list = [] @@ -2057,9 +2050,7 @@ def export_summary( elif type == "Boundary": all_elements = [b.name for b in self.boundaries] self.logger.info("Boundary lists " + str(all_elements)) - else: - self.logger.error("Entity type " + type + " not supported.") - return False + arg = [] for el in all_elements: try: @@ -2923,19 +2914,19 @@ def generate_fluent_mesh( ansys_install_dir = os.environ.get(f"ANSYS{version}_DIR", "") if not ansys_install_dir: ansys_install_dir = os.environ.get(f"AWP_ROOT{version}", "") - assert ( - ansys_install_dir - ), f"Fluent {version} has to be installed to generate mesh. Please set ANSYS{version}_DIR" + + if not ansys_install_dir: + raise AEDTRuntimeError( + f"Fluent {version} has to be installed to generate mesh. Please set ANSYS{version}_DIR" + ) if not os.getenv(f"ANSYS{version}_DIR"): os.environ[f"ANSYS{version}_DIR"] = ansys_install_dir if not object_lists: object_lists = self.get_liquid_objects() - assert object_lists, "No Fluids objects found." + if not object_lists: + raise AEDTRuntimeError("No Fluids objects found.") if not min_size or not max_size: dims = [] - # try: - # dim = self.modeler["Region"].shortest_edge()[0].length - # except (AttributeError, KeyError, IndexError): for obj in object_lists: bb = self.modeler[obj].bounding_box dd = [abs(bb[3] - bb[0]), abs(bb[4] - bb[1]), abs(bb[5] - bb[2])] @@ -2960,7 +2951,10 @@ def generate_fluent_mesh( os.remove(fl_uscript_file_pointer) if os.path.exists(mesh_file_pointer + ".trn"): os.remove(mesh_file_pointer + ".trn") - assert self.export_3d_model(file_name, self.working_directory, ".sab", object_lists), "Failed to export .sab" + + export_success = self.export_3d_model(file_name, self.working_directory, ".sab", object_lists) + if not export_success: + raise AEDTRuntimeError("Failed to export SAB file") # Building Fluent journal script file *.jou fluent_script = open(fl_uscript_file_pointer, "w") @@ -3046,9 +3040,8 @@ def generate_fluent_mesh( if os.path.exists(mesh_file_pointer): self.logger.info("'" + mesh_file_pointer + "' has been created.") return self.mesh.assign_mesh_from_file(object_lists, mesh_file_pointer) - self.logger.error("Failed to create msh file") - return False + raise AEDTRuntimeError("Failed to create mesh file") @pyaedt_function_handler() def apply_icepak_settings( @@ -3135,9 +3128,8 @@ def assign_surface_material(self, obj, mat): ], ] ) - except Exception: - self.logger.warning("Warning. The material is not the database. Use add_surface_material.") - return False + except Exception as e: + raise AEDTRuntimeError(f"Failed to assign material {mat} to the provided object(s).") from e if mat.lower() not in self.materials.surface_material_keys: oo = self.get_oo_object(self.oproject, f"Surface Materials/{mat}") if oo: @@ -3998,7 +3990,7 @@ def create_setup(self, name=None, setup_type=None, **kwargs): >>> from ansys.aedt.core import Icepak >>> app = Icepak() - >>> app.create_setup(setup_type="TransientTemperatureOnly",name="Setup1",MaxIterations=20) + >>> app.create_setup(setup_type="Transient",name="Setup1",MaxIterations=20) """ if setup_type is None: @@ -4019,12 +4011,11 @@ def create_setup(self, name=None, setup_type=None, **kwargs): @pyaedt_function_handler() def _parse_variation_data(self, quantity, variation_type, variation_value, function): - if variation_type == "Transient" and self.solution_type == "SteadyState": - self.logger.error("A transient boundary condition cannot be assigned for a non-transient simulation.") - return None + if variation_type == "Transient" and self.solution_type == SOLUTIONS.Icepak.SteadyState: + raise AEDTRuntimeError("A transient boundary condition cannot be assigned for a non-transient simulation.") if variation_type == "Temp Dep" and function != "Piecewise Linear": - self.logger.error("Temperature dependent assignment support only piecewise linear function.") - return None + raise AEDTRuntimeError("Temperature dependent assignment support only piecewise linear function.") + out_dict = {"Variation Type": variation_type, "Variation Function": function} if function == "Piecewise Linear": if not isinstance(variation_value, list): @@ -4137,8 +4128,7 @@ def assign_source( if voltage_current_choice == quantity: if isinstance(voltage_current_value, (dict, BoundaryDictionary)): if voltage_current_value["Type"] == "Temp Dep": - self.logger.error("Voltage or Current assignment does not support temperature dependence.") - return None + raise AEDTRuntimeError("Voltage and Current assignment do not support temperature dependence.") voltage_current_value = self._parse_variation_data( quantity, voltage_current_value["Type"], @@ -4562,8 +4552,7 @@ def assign_free_opening( inflow=True, direction_vector=None, ): - """ - Assign free opening boundary condition. + """Assign free opening boundary condition. Parameters ---------- @@ -4688,9 +4677,9 @@ def assign_free_opening( ] for quantity, assignment in possible_transient_properties: if isinstance(assignment, (dict, BoundaryDictionary)): - if not self.solution_type == "Transient": - self.logger.error("Transient assignment is supported only in transient designs.") - return None + if self.solution_type != SOLUTIONS.Icepak.Transient: + raise AEDTRuntimeError("Transient assignment is supported only in transient designs.") + assignment = self._parse_variation_data( quantity, "Transient", @@ -5203,9 +5192,9 @@ def assign_resistance( } if isinstance(total_power, (dict, BoundaryDictionary)): - if not self.solution_type == "Transient": - self.logger.error("Transient assignment is supported only in transient designs.") - return None + if self.solution_type != SOLUTIONS.Icepak.Transient: + raise AEDTRuntimeError("Transient assignment is supported only in transient designs.") + assignment = self._parse_variation_data( "Thermal Power", "Transient", @@ -5546,9 +5535,9 @@ def assign_recirculation_opening( >>> flow_assignment="10kg_per_s_m2") """ - if not len(face_list) == 2: - self.logger.error("Recirculation boundary condition must be assigned to two faces.") - return False + if len(face_list) != 2: + raise ValueError("Recirculation boundary condition must be assigned to two faces.") + if conductance_external_temperature is not None and thermal_specification != "Conductance": self.logger.warning( "``conductance_external_temperature`` does not have any effect unless the ``thermal_specification`` " @@ -5559,9 +5548,9 @@ def assign_recirculation_opening( "``conductance_external_temperature`` must be specified when ``thermal_specification`` " 'is ``"Conductance"``. Setting ``conductance_external_temperature`` to ``"AmbientTemp"``.' ) - if (start_time is not None or end_time is not None) and not self.solution_type == "Transient": + if (start_time is not None or end_time is not None) and self.solution_type != SOLUTIONS.Icepak.Transient: self.logger.warning("``start_time`` and ``end_time`` only effect steady-state simulations.") - elif self.solution_type == "Transient" and not (start_time is not None and end_time is not None): + elif self.solution_type == SOLUTIONS.Icepak.Transient and not (start_time is not None and end_time is not None): self.logger.warning( '``start_time`` and ``end_time`` should be declared for transient simulations. Setting them to "0s".' ) @@ -5579,9 +5568,8 @@ def assign_recirculation_opening( props["ExtractFace"] = extract_face props["Thermal Condition"] = thermal_specification if isinstance(assignment_value, (dict, BoundaryDictionary)): - if not self.solution_type == "Transient": - self.logger.error("Transient assignment is supported only in transient designs.") - return None + if self.solution_type != SOLUTIONS.Icepak.Transient: + raise AEDTRuntimeError("Transient assignment is supported only in transient designs.") assignment = self._parse_variation_data( assignment_dict[thermal_specification], "Transient", @@ -5594,9 +5582,9 @@ def assign_recirculation_opening( if thermal_specification == "Conductance": props["External Temp"] = conductance_external_temperature if isinstance(flow_assignment, (dict, BoundaryDictionary)): - if not self.solution_type == "Transient": - self.logger.error("Transient assignment is supported only in transient designs.") - return None + if self.solution_type != SOLUTIONS.Icepak.Transient: + raise AEDTRuntimeError("Transient assignment is supported only in transient designs.") + assignment = self._parse_variation_data( flow_specification + " Rate", "Transient", @@ -5611,14 +5599,12 @@ def assign_recirculation_opening( else: props["Supply Flow Direction"] = "Specified" if not (isinstance(flow_direction, list)): - self.logger.error("``flow_direction`` can be only ``None`` or a list of strings or floats.") - return False + raise TypeError("``flow_direction`` can only be ``None`` or a list of strings or floats.") elif len(flow_direction) != 3: - self.logger.error("``flow_direction`` must have only three components.") - return False + raise ValueError("``flow_direction`` must have only three components.") for direction, val in zip(["X", "Y", "Z"], flow_direction): props[direction] = str(val) - if self.solution_type == "Transient": + if self.solution_type == SOLUTIONS.Icepak.Transient: props["Start"] = start_time props["End"] = end_time if not boundary_name: @@ -5815,8 +5801,8 @@ def _assign_blower( props["Blower Power"] = blower_power props["DimUnits"] = [fan_curve_flow_unit, fan_curve_pressure_unit] if len(fan_curve_flow) != len(fan_curve_pressure): - self.logger.error("``fan_curve_flow`` and ``fan_curve_pressure`` must have the same length.") - return False + raise ValueError("``fan_curve_flow`` and ``fan_curve_pressure`` must have the same length.") + props["X"] = [str(pt) for pt in fan_curve_flow] props["Y"] = [str(pt) for pt in fan_curve_pressure] if not boundary_name: @@ -6195,13 +6181,11 @@ def __create_dataset_assignment(self, type_assignment, ds_name, scale): ds = None try: if ds_name.startswith("$"): - self.logger.error("Only design datasets are supported.") - return False + raise ValueError("Only design datasets are supported.") else: ds = self.design_datasets[ds_name] except KeyError: - self.logger.error(f"Dataset {ds_name} not found.") - return False + raise AEDTRuntimeError(f"Dataset {ds_name} not found.") if not isinstance(scale, str): scale = str(scale) return PieceWiseLinearDictionary(type_assignment, ds, scale) @@ -6383,8 +6367,7 @@ def create_square_wave_transient_assignment(self, on_value, initial_time_off, on @pyaedt_function_handler() def clear_linked_data(self): - """ - Clear the linked data of all the solution setups. + """Clear the linked data of all the solution setups. Returns ------- @@ -6397,7 +6380,6 @@ def clear_linked_data(self): """ try: self.odesign.ClearLinkedData() - except: - return False - else: - return True + except Exception as e: + raise AEDTRuntimeError("Failed to clear linked data of all solution setups") from e + return True diff --git a/tests/system/general/test_29_Mechanical.py b/tests/system/general/test_29_Mechanical.py index deb786cff24..f1f5a69d3fb 100644 --- a/tests/system/general/test_29_Mechanical.py +++ b/tests/system/general/test_29_Mechanical.py @@ -91,7 +91,7 @@ def test_06b_two_way(self): @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) + ipk = add_app(application=Icepak, solution_type=self.aedtapp.SOLUTIONS.Icepak.SteadyState) udp = self.aedtapp.modeler.Position(0, 0, 0) coax_dimension = 30 ipk.modeler.create_cylinder(ipk.PLANE.XY, udp, 3, coax_dimension, 0, "MyCylinder", "brass") diff --git a/tests/system/general/test_98_Icepak.py b/tests/system/general/test_98_Icepak.py index a24a8c8cf0a..f59186fd4d5 100644 --- a/tests/system/general/test_98_Icepak.py +++ b/tests/system/general/test_98_Icepak.py @@ -23,8 +23,10 @@ # SOFTWARE. import os +import re from ansys.aedt.core import Icepak +from ansys.aedt.core.generic.errors import AEDTRuntimeError from ansys.aedt.core.generic.settings import settings from ansys.aedt.core.modules.boundary.icepak_boundary import NetworkObject from ansys.aedt.core.modules.boundary.layout_boundary import NativeComponentObject @@ -609,20 +611,26 @@ def test032__create_source(self, ipk): voltage_current_value="1A", ) ipk.solution_type = "SteadyState" - assert not ipk.assign_source( - ipk.modeler["boxSource"].top_face_x.id, - "Total Power", - assignment_value={"Type": "Temp Dep", "Function": "Piecewise Linear", "Values": ["1W", "Test_DataSet"]}, - voltage_current_choice="Current", - voltage_current_value={"Type": "Transient", "Function": "Sinusoidal", "Values": ["0A", 1, 1, "1s"]}, - ) - assert not ipk.assign_source( - ipk.modeler["boxSource"].top_face_x.id, - "Total Power", - assignment_value={"Type": "Temp Dep", "Function": "Sinusoidal", "Values": ["0W", 1, 1, "1K"]}, - voltage_current_choice="Current", - voltage_current_value={"Type": "Transient", "Function": "Sinusoidal", "Values": ["0A", 1, 1, "1s"]}, - ) + with pytest.raises( + AEDTRuntimeError, match="A transient boundary condition cannot be assigned for a non-transient simulation." + ): + ipk.assign_source( + ipk.modeler["boxSource"].top_face_x.id, + "Total Power", + assignment_value={"Type": "Temp Dep", "Function": "Piecewise Linear", "Values": ["1W", "Test_DataSet"]}, + voltage_current_choice="Current", + voltage_current_value={"Type": "Transient", "Function": "Sinusoidal", "Values": ["0A", 1, 1, "1s"]}, + ) + with pytest.raises( + AEDTRuntimeError, match="Temperature dependent assignment support only piecewise linear function." + ): + ipk.assign_source( + ipk.modeler["boxSource"].top_face_x.id, + "Total Power", + assignment_value={"Type": "Temp Dep", "Function": "Sinusoidal", "Values": ["0W", 1, 1, "1K"]}, + voltage_current_choice="Current", + voltage_current_value={"Type": "Transient", "Function": "Sinusoidal", "Values": ["0A", 1, 1, "1s"]}, + ) ipk.solution_type = "Transient" assert ipk.assign_source( ipk.modeler["boxSource"].top_face_x.id, @@ -1406,14 +1414,15 @@ def test061__assign_free_opening(self, ipk): velocity=[velocity_transient, 0, "0m_per_sec"], ) ipk.solution_type = "SteadyState" - assert not ipk.assign_velocity_free_opening( - ipk.modeler["Region"].faces[1].id, - boundary_name="Test", - temperature="AmbientTemp", - radiation_temperature="AmbientRadTemp", - pressure="AmbientPressure", - velocity=[velocity_transient, 0, "0m_per_sec"], - ) + with pytest.raises(AEDTRuntimeError, match="Transient assignment is supported only in transient designs."): + ipk.assign_velocity_free_opening( + ipk.modeler["Region"].faces[1].id, + boundary_name="Test", + temperature="AmbientTemp", + radiation_temperature="AmbientRadTemp", + pressure="AmbientPressure", + velocity=[velocity_transient, 0, "0m_per_sec"], + ) def test062__assign_symmetry_wall(self, ipk): ipk.modeler.create_rectangle(ipk.PLANE.XY, [0, 0, 0], [10, 20], name="surf1") @@ -1466,9 +1475,10 @@ def test065__mesh_priority_3d_comp(self, ipk): def test066__recirculation_boundary(self, ipk): box = ipk.modeler.create_box([5, 5, 5], [1, 2, 3], "BlockBoxEmpty", "copper") box.solve_inside = False - assert not ipk.assign_recirculation_opening( - [box.top_face_x, box.bottom_face_x, box.bottom_face_y], box.top_face_x, flow_assignment="10kg_per_s_m2" - ) + with pytest.raises(ValueError, match="Recirculation boundary condition must be assigned to two faces."): + ipk.assign_recirculation_opening( + [box.top_face_x, box.bottom_face_x, box.bottom_face_y], box.top_face_x, flow_assignment="10kg_per_s_m2" + ) assert ipk.assign_recirculation_opening( [box.top_face_x, box.bottom_face_x], box.top_face_x, conductance_external_temperature="25cel" ) @@ -1476,12 +1486,13 @@ def test066__recirculation_boundary(self, ipk): ipk.solution_type = "Transient" assert ipk.assign_recirculation_opening([box.top_face_x, box.bottom_face_x], box.top_face_x) assert ipk.assign_recirculation_opening([box.top_face_x.id, box.bottom_face_x.id], box.top_face_x.id) - assert not ipk.assign_recirculation_opening( - [box.top_face_x.id, box.bottom_face_x.id], - box.top_face_x.id, - thermal_specification="Conductance", - flow_direction=[1], - ) + with pytest.raises(ValueError, match=re.escape("``flow_direction`` must have only three components.")): + ipk.assign_recirculation_opening( + [box.top_face_x.id, box.bottom_face_x.id], + box.top_face_x.id, + thermal_specification="Conductance", + flow_direction=[1], + ) temp_dict = {"Function": "Square Wave", "Values": ["1cel", "0s", "1s", "0.5s", "0cel"]} flow_dict = {"Function": "Sinusoidal", "Values": ["0kg_per_s_m2", 1, 1, "1s"]} recirc = ipk.assign_recirculation_opening( @@ -1494,37 +1505,45 @@ def test066__recirculation_boundary(self, ipk): assert recirc assert recirc.update() ipk.solution_type = "SteadyState" - assert not ipk.assign_recirculation_opening( - [box.top_face_x.id, box.bottom_face_x.id], - box.top_face_x.id, - thermal_specification="Temperature", - assignment_value=temp_dict, - flow_assignment=flow_dict, - ) - assert not ipk.assign_recirculation_opening( - [box.top_face_x.id, box.bottom_face_x.id], - box.top_face_x.id, - thermal_specification="Temperature", - flow_direction="Side", - ) + with pytest.raises(AEDTRuntimeError, match="Transient assignment is supported only in transient designs."): + ipk.assign_recirculation_opening( + [box.top_face_x.id, box.bottom_face_x.id], + box.top_face_x.id, + thermal_specification="Temperature", + assignment_value=temp_dict, + flow_assignment=flow_dict, + ) + with pytest.raises( + TypeError, match=re.escape("``flow_direction`` can only be ``None`` or a list of strings or floats.") + ): + ipk.assign_recirculation_opening( + [box.top_face_x.id, box.bottom_face_x.id], + box.top_face_x.id, + thermal_specification="Temperature", + flow_direction="Side", + ) assert ipk.assign_recirculation_opening( [box.top_face_x.id, box.bottom_face_x.id], box.top_face_x.id, thermal_specification="Temperature", flow_direction=[0, 1, 0], ) - assert not ipk.assign_recirculation_opening( - [box.top_face_x.id, box.bottom_face_x.id], - box.top_face_x.id, - thermal_specification="Temperature", - flow_assignment=flow_dict, - ) + with pytest.raises(AEDTRuntimeError, match="Transient assignment is supported only in transient designs."): + ipk.assign_recirculation_opening( + [box.top_face_x.id, box.bottom_face_x.id], + box.top_face_x.id, + thermal_specification="Temperature", + flow_assignment=flow_dict, + ) def test067__blower_boundary(self, ipk): cylinder = ipk.modeler.create_cylinder(orientation="X", origin=[0, 0, 0], radius=10, height=1) curved_face = [f for f in cylinder.faces if not f.is_planar] planar_faces = [f for f in cylinder.faces if f.is_planar] - assert not ipk.assign_blower_type1(curved_face + planar_faces, planar_faces, [10, 5, 0], [0, 1, 2, 4]) + with pytest.raises( + ValueError, match=re.escape("``fan_curve_flow`` and ``fan_curve_pressure`` must have the same length.") + ): + ipk.assign_blower_type1(curved_face + planar_faces, planar_faces, [10, 5, 0], [0, 1, 2, 4]) blower = ipk.assign_blower_type1( [f.id for f in curved_face + planar_faces], [f.id for f in planar_faces], [10, 5, 0], [0, 2, 4] ) @@ -1568,13 +1587,14 @@ def test069__assign_resistance(self, ipk): loss_curve_flow_unit="m_per_sec", loss_curve_pressure_unit="n_per_meter_sq", ) - assert not ipk.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", - ) + with pytest.raises(AEDTRuntimeError, match="Transient assignment is supported only in transient designs."): + ipk.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", + ) ipk.solution_type = "Transient" assert ipk.assign_power_law_resistance( box.name, @@ -1665,8 +1685,10 @@ def test071__boundary_conditions_dictionaries(self, ipk): ds1_temp = ipk.create_dataset( "ds_temp3", [1, 2, 3], [3, 2, 1], is_project_dataset=True, x_unit="cel", y_unit="W" ) - assert not ipk.create_temp_dep_assignment(ds1_temp.name) - assert not ipk.create_temp_dep_assignment("nods") + with pytest.raises(ValueError, match="Only design datasets are supported."): + ipk.create_temp_dep_assignment(ds1_temp.name) + with pytest.raises(AEDTRuntimeError, match="Dataset nods not found."): + ipk.create_temp_dep_assignment("nods") @pytest.mark.parametrize("ipk", [native_import], indirect=True) def test072__native_component_load(self, ipk):