Skip to content

Commit

Permalink
REFACTOR: Refactor application init arguments (#4777)
Browse files Browse the repository at this point in the history
Co-authored-by: maxcapodi78 <Shark78>
Co-authored-by: Samuelopez-ansys <[email protected]>
  • Loading branch information
maxcapodi78 and Samuelopez-ansys authored Jun 13, 2024
1 parent d3aa856 commit 3539828
Show file tree
Hide file tree
Showing 144 changed files with 1,121 additions and 2,444 deletions.
6 changes: 3 additions & 3 deletions _unittest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ def _method(
if not application:
application = Hfss
return application(
projectname=test_project,
designname=design_name,
project=test_project,
design=design_name,
solution_type=solution_type,
specified_version=desktop_version,
version=desktop_version,
non_graphical=NONGRAPHICAL,
)

Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_01_3dlayout_edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import pytest

from pyaedt import Hfss3dLayout
from pyaedt import is_linux
from pyaedt.generic.settings import is_linux

test_subfolder = "T40"
original_project_name = "ANSYS-HSD_V1"
Expand Down
6 changes: 3 additions & 3 deletions _unittest/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def test_34_force_project_path_disable(self):
e = None
exception_raised = False
try:
h = Hfss("c:/dummy/test.aedt", specified_version=desktop_version)
h = Hfss("c:/dummy/test.aedt", version=desktop_version)
except Exception as e:
exception_raised = True
assert e.args[0] == "Project doesn't exist. Check it and retry."
Expand Down Expand Up @@ -426,15 +426,15 @@ def test_36_test_load(self, add_app):
with open(file_name2_lock, "w") as f:
f.write(" ")
try:
hfss = Hfss(projectname=file_name2, specified_version=desktop_version)
hfss = Hfss(project=file_name2, version=desktop_version)
except Exception:
assert True
try:
os.makedirs(os.path.join(self.local_scratch.path, "test_36_2.aedb"))
file_name3 = os.path.join(self.local_scratch.path, "test_36_2.aedb", "edb.def")
with open(file_name3, "w") as f:
f.write(" ")
hfss = Hfss3dLayout(projectname=file_name3, specified_version=desktop_version)
hfss = Hfss3dLayout(project=file_name3, version=desktop_version)
except Exception:
assert True

Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_01_downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import pytest

from pyaedt import downloads
from pyaedt import is_linux
from pyaedt.generic.general_methods import generate_unique_name
from pyaedt.generic.settings import is_linux


@pytest.fixture(scope="module", autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_04_SBR.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from _unittest.conftest import desktop_version
from _unittest.conftest import local_path

from pyaedt import is_linux
from pyaedt.generic.settings import is_linux

if desktop_version > "2022.2":
test_project_name = "Cassegrain_231"
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_08_Primitives3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
from pyaedt import Icepak
from pyaedt import Q2d
from pyaedt import generate_unique_name
from pyaedt import is_linux
from pyaedt.generic.constants import AXIS
from pyaedt.generic.settings import is_linux
from pyaedt.modeler.cad.Primitives import PolylineSegment
from pyaedt.modeler.cad.components_3d import UserDefinedComponent
from pyaedt.modeler.cad.object3d import Object3d
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_09_VariableManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def test_15_arrays(self):
assert self.aedtapp.variable_manager["getvalue2"].numeric_value == 1.0

def test_16_maxwell_circuit_variables(self):
mc = MaxwellCircuit(specified_version=desktop_version)
mc = MaxwellCircuit(version=desktop_version)
mc["var2"] = "10mm"
assert mc["var2"] == "10mm"
v_circuit = mc.variable_manager
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_11_Setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_01c_create_hfss_setup_auto_open(self):
assert setup1.props["SolveType"] == "MultiFrequency"

def test_02_create_circuit_setup(self):
circuit = Circuit(specified_version=desktop_version)
circuit = Circuit(version=desktop_version)
setup1 = circuit.create_setup("circuit", self.aedtapp.SETUPS.NexximLNA)
assert setup1.name == "circuit"
setup1.props["SweepDefinition"]["Data"] = "LINC 0GHz 4GHz 501"
Expand Down
8 changes: 4 additions & 4 deletions _unittest/test_14_AedtLogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ def test_log_when_accessing_non_existing_object(self, caplog):
from pyaedt import Hfss

app = Hfss(
projectname="log_project",
designname="log_design",
specified_version=desktop_version,
new_desktop_session=True,
project="log_project",
design="log_design",
version=desktop_version,
new_desktop=True,
)
with pytest.raises(AttributeError):
app.get_object_material_properties("MS1", "conductivity")
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_21_Circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import pytest

from pyaedt import Circuit
from pyaedt import is_linux
from pyaedt.generic.settings import is_linux

test_subfolder = "T21"

Expand Down
4 changes: 2 additions & 2 deletions _unittest/test_22_Circuit_DynamicLink.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
from pyaedt import Circuit
from pyaedt import Q2d
from pyaedt import Q3d
from pyaedt import is_ironpython
from pyaedt import is_linux
from pyaedt.generic.general_methods import is_ironpython
from pyaedt.generic.settings import is_linux

test_subfloder = "T22"
test_project_name = "Dynamic_Link"
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

import pytest

from pyaedt import settings
from pyaedt.generic.general_methods import pyaedt_function_handler
from pyaedt.generic.settings import settings

SETTINGS_RELEASE_ON_EXCEPTION = settings.release_on_exception
SETTINGS_ENABLE_ERROR_HANDLER = settings.enable_error_handler
Expand Down
6 changes: 3 additions & 3 deletions _unittest_solvers/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ def _method(
if not application:
application = Hfss
return application(
projectname=test_project,
designname=design_name,
project=test_project,
design=design_name,
solution_type=solution_type,
specified_version=desktop_version,
version=desktop_version,
)

return _method
Expand Down
2 changes: 1 addition & 1 deletion _unittest_solvers/test_00_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from pathlib import Path

from pyaedt import is_linux
from pyaedt.generic.settings import is_linux
from pyaedt import Icepak
from pyaedt import Hfss3dLayout
from pyaedt import Circuit, Maxwell3d
Expand Down
2 changes: 1 addition & 1 deletion _unittest_solvers/test_45_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import shutil

import pyaedt
from pyaedt import is_linux
from pyaedt.generic.settings import is_linux
from _unittest.conftest import local_path
from _unittest_solvers.conftest import local_path as solver_local_path

Expand Down
2 changes: 1 addition & 1 deletion examples/01-HFSS3DLayout/Dcir_in_3DLayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
# Analysis DCIR in AEDT
# ~~~~~~~~~~~~~~~~~~~~~
# Launch AEDT and import the configured EDB and analysis DCIR
desktop = pyaedt.Desktop(aedt_version, non_graphical=False, new_desktop_session=True)
desktop = pyaedt.Desktop(aedt_version, non_graphical=False, new_desktop=True)
hfss3dl = pyaedt.Hfss3dLayout(local_path)
hfss3dl.analyze()
hfss3dl.save_project()
Expand Down
2 changes: 1 addition & 1 deletion examples/01-HFSS3DLayout/HFSS3DLayout_Via.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# ~~~~~~~~~~~
# Launch AEDT 2023 R2 in graphical mode.

h3d = pyaedt.Hfss3dLayout(specified_version=aedt_version, new_desktop_session=True, non_graphical=non_graphical)
h3d = pyaedt.Hfss3dLayout(version=aedt_version, new_desktop=True, non_graphical=non_graphical)

###############################################################################
# Set up variables
Expand Down
2 changes: 1 addition & 1 deletion examples/01-HFSS3DLayout/Hfss3DComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# ~~~~~~~~~~~
# Launch HFSS application

hfss = pyaedt.Hfss(new_desktop_session=True, specified_version=aedt_version, non_graphical=non_graphical)
hfss = pyaedt.Hfss(new_desktop=True, version=aedt_version, non_graphical=non_graphical)

hfss.solution_type = "Terminal"

Expand Down
6 changes: 3 additions & 3 deletions examples/01-Modeling-Setup/Configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@

project_full_name = pyaedt.downloads.download_icepak(pyaedt.generate_unique_folder_name(folder_name="Graphic_Card"))

ipk = pyaedt.Icepak(projectname=project_full_name, specified_version=aedt_version,
new_desktop_session=True, non_graphical=non_graphical)
ipk = pyaedt.Icepak(project=project_full_name, version=aedt_version,
new_desktop=True, non_graphical=non_graphical)
ipk.autosave_disable()

###############################################################################
Expand Down Expand Up @@ -115,7 +115,7 @@
# ~~~~~~~~~~~~~~
# Create an Icepak project and import the step.

app = pyaedt.Icepak(projectname="new_proj_Ipk")
app = pyaedt.Icepak(project="new_proj_Ipk")
app.modeler.import_3d_cad(file_path)

###############################################################################
Expand Down
4 changes: 2 additions & 2 deletions examples/01-Modeling-Setup/HFSS_CoordinateSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Launch AEDT 2023 R2 in graphical mode.

d = pyaedt.launch_desktop(specified_version=aedt_version, non_graphical=non_graphical, new_desktop_session=True)
d = pyaedt.launch_desktop(version=aedt_version, non_graphical=non_graphical, new_desktop=True)

###############################################################################
# Insert HFSS design
# ~~~~~~~~~~~~~~~~~~
# Insert an HFSS design with the default name.

hfss = pyaedt.Hfss(projectname=pyaedt.generate_unique_project_name(folder_name="CoordSysDemo"))
hfss = pyaedt.Hfss(project=pyaedt.generate_unique_project_name(folder_name="CoordSysDemo"))

###############################################################################
# Create coordinate system
Expand Down
2 changes: 1 addition & 1 deletion examples/01-Modeling-Setup/Optimetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# Initialize the ``Hfss`` object and create two needed design variables,
# ``w1`` and ``w2``.

hfss = pyaedt.Hfss(specified_version=aedt_version, new_desktop_session=True, non_graphical=non_graphical)
hfss = pyaedt.Hfss(version=aedt_version, new_desktop=True, non_graphical=non_graphical)
hfss["w1"] = "1mm"
hfss["w2"] = "100mm"

Expand Down
4 changes: 2 additions & 2 deletions examples/01-Modeling-Setup/Polyline_Primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~
# Create a :class:`pyaedt.maxwell.Maxwell3d` object and set the unit type to ``"mm"``.

M3D = pyaedt.Maxwell3d(solution_type="Transient", designname="test_polyline_3D", specified_version=aedt_version,
new_desktop_session=True, non_graphical=non_graphical, )
M3D = pyaedt.Maxwell3d(solution_type="Transient", design="test_polyline_3D", version=aedt_version,
new_desktop=True, non_graphical=non_graphical, )
M3D.modeler.model_units = "mm"
prim3D = M3D.modeler

Expand Down
8 changes: 4 additions & 4 deletions examples/02-HFSS/Array.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Launch HFSS and save the project.
project_name = pyaedt.generate_unique_project_name(project_name="array")
hfss = pyaedt.Hfss(projectname=project_name,
specified_version=aedt_version,
designname="Array_Simple",
hfss = pyaedt.Hfss(project=project_name,
version=aedt_version,
design="Array_Simple",
non_graphical=non_graphical,
new_desktop_session=True)
new_desktop=True)

print("Project name " + project_name)

Expand Down
4 changes: 2 additions & 2 deletions examples/02-HFSS/Create_3d_Component_and_use_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# PyAEDT can initialize a new session of Electronics Desktop or connect to an existing one.
# Once Desktop is connected, a new HFSS session is started and a design is created.

hfss = Hfss(specified_version=aedt_version, new_desktop_session=True, close_on_exit=True)
hfss = Hfss(version=aedt_version, new_desktop=True, close_on_exit=True)

##########################################################
# Variables
Expand Down Expand Up @@ -100,7 +100,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
# PyAEDT allows to control multiple projects, design and solution type at the same time.

hfss2 = Hfss(projectname="new_project", designname="new_design")
hfss2 = Hfss(project="new_project", design="new_design")

##########################################################
# Insert of 3d component
Expand Down
4 changes: 2 additions & 2 deletions examples/02-HFSS/Flex_CPWG.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
# ~~~~~~~~~~~
# Launch AEDT 2023 R2 in graphical mode.

hfss = pyaedt.Hfss(specified_version=aedt_version,
hfss = pyaedt.Hfss(version=aedt_version,
solution_type="DrivenTerminal",
new_desktop_session=True,
new_desktop=True,
non_graphical=non_graphical)
hfss.change_material_override(True)
hfss.change_automatically_use_causal_materials(True)
Expand Down
6 changes: 3 additions & 3 deletions examples/02-HFSS/HFSS_Choke.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
# ~~~~~~~~~~~
# Launches HFSS 2023 R2 in graphical mode.

hfss = pyaedt.Hfss(projectname=project_name,
specified_version=aedt_version,
hfss = pyaedt.Hfss(project=project_name,
version=aedt_version,
non_graphical=non_graphical,
new_desktop_session=True,
new_desktop=True,
solution_type="Terminal")

###############################################################################
Expand Down
4 changes: 2 additions & 2 deletions examples/02-HFSS/HFSS_Dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
# ~~~~~~~~~~~
# Launch AEDT 2023 R2 in graphical mode.

d = pyaedt.launch_desktop(aedt_version, non_graphical=non_graphical, new_desktop_session=True)
d = pyaedt.launch_desktop(aedt_version, non_graphical=non_graphical, new_desktop=True)

###############################################################################
# Launch HFSS
# ~~~~~~~~~~~
# Launch HFSS 2023 R2 in graphical mode.

hfss = pyaedt.Hfss(projectname=project_name, solution_type="Modal")
hfss = pyaedt.Hfss(project=project_name, solution_type="Modal")

###############################################################################
# Define variable
Expand Down
4 changes: 2 additions & 2 deletions examples/02-HFSS/HFSS_FSS_unitcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
# ~~~~~~~~~~~
# Launch AEDT 2023 R2 in graphical mode.

d = pyaedt.launch_desktop(aedt_version, non_graphical=non_graphical, new_desktop_session=True)
d = pyaedt.launch_desktop(aedt_version, non_graphical=non_graphical, new_desktop=True)

###############################################################################
# Launch HFSS
# ~~~~~~~~~~~
# Launch HFSS 2023 R2 in graphical mode.

hfss = pyaedt.Hfss(projectname=project_name, solution_type="Modal")
hfss = pyaedt.Hfss(project=project_name, solution_type="Modal")

###############################################################################
# Define variable
Expand Down
4 changes: 2 additions & 2 deletions examples/02-HFSS/HFSS_Spiral.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
# Launch HFSS 2023 R2 in non-graphical mode and change the
# units to microns.

hfss = pyaedt.Hfss(specified_version=aedt_version, non_graphical=non_graphical, designname="A1",
new_desktop_session=True)
hfss = pyaedt.Hfss(version=aedt_version, non_graphical=non_graphical, design="A1",
new_desktop=True)
hfss.solution_type = "Modal"
hfss.modeler.model_units = "um"
p = hfss.modeler
Expand Down
4 changes: 2 additions & 2 deletions examples/02-HFSS/HFSS_eigenmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@
# ~~~~~~~~~~~
# Launch AEDT 2023 R2 in graphical mode.

d = pyaedt.launch_desktop(aedt_version, non_graphical=non_graphical, new_desktop_session=True)
d = pyaedt.launch_desktop(aedt_version, non_graphical=non_graphical, new_desktop=True)

###############################################################################
# Launch HFSS
# ~~~~~~~~~~~
# Launch HFSS 2023 R2 in graphical mode.

hfss = pyaedt.Hfss(projectname=project_path, non_graphical=non_graphical)
hfss = pyaedt.Hfss(project=project_path, non_graphical=non_graphical)

###############################################################################
# Input parameters for eigenmode solver
Expand Down
8 changes: 4 additions & 4 deletions examples/02-HFSS/Probe_Fed_Patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
# -----------
#

hfss = pyaedt.Hfss(projectname=proj_name,
hfss = pyaedt.Hfss(project=proj_name,
solution_type="Terminal",
designname="patch",
design="patch",
non_graphical=non_graphical,
new_desktop_session=True,
specified_version=aedt_version)
new_desktop=True,
version=aedt_version)

hfss.modeler.model_units = length_units

Expand Down
Loading

0 comments on commit 3539828

Please sign in to comment.