|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. |
| 4 | +# SPDX-License-Identifier: MIT |
| 5 | +# |
| 6 | +# |
| 7 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | +# of this software and associated documentation files (the "Software"), to deal |
| 9 | +# in the Software without restriction, including without limitation the rights |
| 10 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | +# copies of the Software, and to permit persons to whom the Software is |
| 12 | +# furnished to do so, subject to the following conditions: |
| 13 | +# |
| 14 | +# The above copyright notice and this permission notice shall be included in all |
| 15 | +# copies or substantial portions of the Software. |
| 16 | +# |
| 17 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | +# SOFTWARE. |
| 24 | + |
| 25 | +from ansys.aedt.core import Circuit |
| 26 | +from ansys.aedt.core import Hfss |
| 27 | +from ansys.aedt.core import Hfss3dLayout |
| 28 | +from ansys.aedt.core.generic.settings import is_linux |
| 29 | +import pytest |
| 30 | + |
| 31 | +from tests.system.solvers.conftest import config |
| 32 | + |
| 33 | + |
| 34 | +@pytest.mark.skipif(is_linux, reason="FilterSolutions API is not supported on Linux.") |
| 35 | +@pytest.mark.skipif(config["desktopVersion"] < "2025.2", reason="Skipped on versions earlier than 2025.1") |
| 36 | +class TestClass: |
| 37 | + def test_lumped_exported_desktop(self, lumped_design): |
| 38 | + schem_name = lumped_design.export_to_aedt.schematic_name |
| 39 | + schem_name_length = len(schem_name) |
| 40 | + circuit = lumped_design.export_to_aedt.export_design() |
| 41 | + assert isinstance(circuit, Circuit) |
| 42 | + assert circuit.project_name.split()[0][:schem_name_length] == schem_name |
| 43 | + assert circuit.design_name == schem_name |
| 44 | + assert next(iter(circuit.setup_sweeps_names)) == "FS_Advanced Setup" |
| 45 | + variables = circuit.variable_manager.variables |
| 46 | + assert variables["C1"].value == pytest.approx(1.967e-12) |
| 47 | + assert variables["L2"].value == pytest.approx(1.288e-8) |
| 48 | + assert variables["C3"].value == pytest.approx(6.366e-12) |
| 49 | + |
| 50 | + def test_distributed_circuit_exported_desktop(self, distributed_design): |
| 51 | + schem_name = distributed_design.export_to_aedt.schematic_name |
| 52 | + schem_name_length = len(schem_name) |
| 53 | + distributed_design.export_to_aedt.insert_circuit_design = True |
| 54 | + circuit = distributed_design.export_to_aedt.export_design() |
| 55 | + assert isinstance(circuit, Circuit) |
| 56 | + assert circuit.project_name.split()[0][:schem_name_length] == schem_name |
| 57 | + assert circuit.design_name == schem_name |
| 58 | + assert next(iter(circuit.setup_sweeps_names)) == "FS_Advanced Setup" |
| 59 | + variables = circuit.variable_manager.variables |
| 60 | + assert variables["W1"].value == pytest.approx(5.08e-3) |
| 61 | + assert variables["W2"].value == pytest.approx(3.175e-4) |
| 62 | + assert variables["W3"].value == pytest.approx(5.08e-3) |
| 63 | + assert variables["S1"].value == pytest.approx(3.362e-3) |
| 64 | + assert variables["S2"].value == pytest.approx(2.172e-2) |
| 65 | + assert variables["S3"].value == pytest.approx(1.008e-2) |
| 66 | + |
| 67 | + def test_distributed_hfss3dl_exported_desktop(self, distributed_design): |
| 68 | + schem_name = distributed_design.export_to_aedt.schematic_name |
| 69 | + schem_name_length = len(schem_name) |
| 70 | + distributed_design.export_to_aedt.insert_hfss_3dl_design = True |
| 71 | + hfss3dl = distributed_design.export_to_aedt.export_design() |
| 72 | + assert isinstance(hfss3dl, Hfss3dLayout) |
| 73 | + assert hfss3dl.project_name.split()[0][:schem_name_length] == schem_name |
| 74 | + assert hfss3dl.design_name == schem_name |
| 75 | + assert next(iter(hfss3dl.setup_sweeps_names)) == "FS_Advanced Setup" |
| 76 | + variables = hfss3dl.variable_manager.variables |
| 77 | + assert variables["Win"].value == pytest.approx(1.234e-3) |
| 78 | + assert variables["W1"].value == pytest.approx(5.08e-3) |
| 79 | + assert variables["W2"].value == pytest.approx(3.175e-4) |
| 80 | + assert variables["W3"].value == pytest.approx(5.08e-3) |
| 81 | + assert variables["S1"].value == pytest.approx(3.36225452227e-3) |
| 82 | + assert variables["S2"].value == pytest.approx(2.17231965814e-2) |
| 83 | + assert variables["S3"].value == pytest.approx(1.00773795179e-2) |
| 84 | + |
| 85 | + def test_distributed_hfss_exported_desktop(self, distributed_design): |
| 86 | + schem_name = distributed_design.export_to_aedt.schematic_name |
| 87 | + schem_name_length = len(schem_name) |
| 88 | + distributed_design.export_to_aedt.insert_hfss_design = True |
| 89 | + hfss = distributed_design.export_to_aedt.export_design() |
| 90 | + assert isinstance(hfss, Hfss) |
| 91 | + assert hfss.project_name.split()[0][:schem_name_length] == schem_name |
| 92 | + assert hfss.design_name == schem_name |
| 93 | + assert next(iter(hfss.setup_sweeps_names)) == "FS_Advanced_Setup" |
| 94 | + variables = hfss.variable_manager.variables |
| 95 | + assert variables["Win"].value == pytest.approx(1.234e-3) |
| 96 | + assert variables["W1"].value == pytest.approx(5.08e-3) |
| 97 | + assert variables["W2"].value == pytest.approx(3.175e-4) |
| 98 | + assert variables["W3"].value == pytest.approx(5.08e-3) |
| 99 | + assert variables["S1"].value == pytest.approx(3.36225452227e-3) |
| 100 | + assert variables["S2"].value == pytest.approx(2.17231965814e-2) |
| 101 | + assert variables["S3"].value == pytest.approx(1.00773795179e-2) |
0 commit comments