diff --git a/_unittest/test_12_PostProcessing.py b/_unittest/test_12_PostProcessing.py index 7ec1a8ab760..b1b8d486224 100644 --- a/_unittest/test_12_PostProcessing.py +++ b/_unittest/test_12_PostProcessing.py @@ -808,12 +808,21 @@ def test_75_plot_field_line_traces(self, m2dtest): plot.surfaces_indexes.append(8) assert not plot.update() + def test_98_get_variations(self, field_test): + vars = field_test.available_variations.get_variation_strings() + assert vars + variations = field_test.available_variations.variations() + assert type(variations) is list + assert type(variations[0]) is list + vars_dict = field_test.available_variations.variations(output_as_dict=True) + assert type(vars_dict) is list + assert type(vars_dict[0]) is dict + def test_z99_delete_variations(self, q3dtest): assert q3dtest.cleanup_solution() def test_z99_delete_variations_B(self, field_test): vars = field_test.available_variations.get_variation_strings() - assert field_test.available_variations.variations() assert field_test.cleanup_solution(vars, entire_solution=False) assert field_test.cleanup_solution(vars, entire_solution=True) diff --git a/_unittest/test_27_Maxwell2D.py b/_unittest/test_27_Maxwell2D.py index 364985e22f9..bd15edf44cc 100644 --- a/_unittest/test_27_Maxwell2D.py +++ b/_unittest/test_27_Maxwell2D.py @@ -151,6 +151,21 @@ def test_14a_model_depth(self): self.aedtapp.model_depth = 2.0 assert self.aedtapp.change_design_settings({"ModelDepth": "3mm"}) + def test_14b_skew_model(self): + self.aedtapp.set_active_design("Basis_Model_For_Test") + assert self.aedtapp.apply_skew() + assert not self.aedtapp.apply_skew(skew_type="Invalid") + assert not self.aedtapp.apply_skew(skew_part="Invalid") + assert not self.aedtapp.apply_skew( + skew_type="Continuous", skew_part="Stator", skew_angle="0.5", skew_angle_unit="Invalid" + ) + assert not self.aedtapp.apply_skew( + skew_type="User Defined", number_of_slices="4", custom_slices_skew_angles=["1", "2", "3"] + ) + assert self.aedtapp.apply_skew( + skew_type="User Defined", number_of_slices="4", custom_slices_skew_angles=["1", "2", "3", "4"] + ) + def test_15_assign_movement(self): self.aedtapp.set_active_design("Y_Connections") self.aedtapp.insert_design("Motion") diff --git a/doc/source/Resources/PyAEDTInstallerFromDesktop.py b/doc/source/Resources/PyAEDTInstallerFromDesktop.py index 706cabed594..1ed1eefd86e 100644 --- a/doc/source/Resources/PyAEDTInstallerFromDesktop.py +++ b/doc/source/Resources/PyAEDTInstallerFromDesktop.py @@ -42,15 +42,37 @@ def run_pyinstaller_from_c_python(oDesktop): return_code = run_command(" ".join(command)) err_msg = "There was an error while installing PyAEDT. Refer to the Terminal window where AEDT was launched " \ "from." - - if version >= "232": - oDesktop.RefreshToolkitUI() - + if is_windows: + venv_dir = os.path.join(os.environ["APPDATA"], "pyaedt_env_ide", "v" + version) + python_exe = os.path.join(venv_dir, "Scripts", "python.exe") + else: + venv_dir = os.path.join(os.environ["HOME"], "pyaedt_env_ide", "v" + version) + python_exe = os.path.join(venv_dir, "bin", "python") if str(return_code) != "0": oDesktop.AddMessage("", "", 2, err_msg) return + else: + oDesktop.AddMessage("", "", 0, "PyAEDT setup complete.") + - msg = "PyAEDT setup complete." + import tempfile + python_script = os.path.join(tempfile.gettempdir(), "configure_pyaedt.py") + with open(python_script, "w") as f: + # enable in debu mode + #f.write("import sys\n") + #f.write('sys.path.insert(0, r"c:\\ansysdev\\git\\repos\\pyaedt")\n') + f.write("from pyaedt.misc.aedtlib_personalib_install import add_pyaedt_to_aedt\n") + f.write('add_pyaedt_to_aedt(aedt_version="{}", is_student_version={}, use_sys_lib=False, new_desktop_session=False, pers_dir=r"{}")\n'.format(oDesktop.GetVersion()[:6], is_student_version(oDesktop), oDesktop.GetPersonalLibDirectory())) + + command = r'"{}" "{}"'.format(python_exe, python_script) + oDesktop.AddMessage("", "", 0, command) + ret_code = os.system(command) + if ret_code != 0: + oDesktop.AddMessage("", "", 2, "Error configuring the configuration Tab.") + return + if version >= "232": + oDesktop.RefreshToolkitUI() + msg = "PyAEDT configuration complete." if is_linux: msg += " Please ensure Ansys Electronics Desktop is launched in gRPC mode (i.e. launch ansysedt with -grpcsrv" \ " argument) to take advantage of the new toolkits." @@ -152,19 +174,19 @@ def install_pyaedt(): else: run_command('"{}" --default-timeout=1000 install pyaedt[full]'.format(pip_exe)) - if is_windows: - pyaedt_setup_script = "{}/Lib/site-packages/pyaedt/misc/aedtlib_personalib_install.py".format(venv_dir) - else: - pyaedt_setup_script = "{}/lib/python{}/site-packages/pyaedt/misc/aedtlib_personalib_install.py".format( - venv_dir, args.python_version) - - if not os.path.isfile(pyaedt_setup_script): - sys.exit("[ERROR] PyAEDT was not setup properly since {} file does not exist.".format(pyaedt_setup_script)) - - command = '"{}" "{}" --version={}'.format(python_exe, pyaedt_setup_script, args.version) - if args.student: - command += " --student" - run_command(command) + # if is_windows: + # pyaedt_setup_script = "{}/Lib/site-packages/pyaedt/misc/aedtlib_personalib_install.py".format(venv_dir) + # else: + # pyaedt_setup_script = "{}/lib/python{}/site-packages/pyaedt/misc/aedtlib_personalib_install.py".format( + # venv_dir, args.python_version) + # + # if not os.path.isfile(pyaedt_setup_script): + # sys.exit("[ERROR] PyAEDT was not setup properly since {} file does not exist.".format(pyaedt_setup_script)) + # + # command = '"{}" "{}" --version={}'.format(python_exe, pyaedt_setup_script, args.version) + # if args.student: + # command += " --student" + # run_command(command) sys.exit(0) diff --git a/pyaedt/application/Analysis.py b/pyaedt/application/Analysis.py index e9d912874b9..d14eb27f56c 100644 --- a/pyaedt/application/Analysis.py +++ b/pyaedt/application/Analysis.py @@ -9,6 +9,7 @@ from collections import OrderedDict import os +import re import shutil import tempfile import time @@ -919,20 +920,22 @@ def variables(self): list of str List of names of independent variables. """ - return [i for i in self._app.variable_manager.independent_variables] + return self._app.variable_manager.independent_variable_names @pyaedt_function_handler() - def variations(self, setup_sweep=None): + def variations(self, setup_sweep=None, output_as_dict=False): """Variations. Parameters ---------- setup_sweep : str, optional Setup name with the sweep to search for variations on. The default is ``None``. + output_as_dict : bool, optional + Whether to output the variations as a dict. The default is ``False``. Returns ------- - list of lists + list of lists, List of dicts List of variation families. References @@ -940,20 +943,36 @@ def variations(self, setup_sweep=None): >>> oModule.GetAvailableVariations """ - vs = self.get_variation_strings(setup_sweep) + variations_string = self.get_variation_strings(setup_sweep) + variables = [k for k, v in self._app.variable_manager.variables.items() if not v.post_processing] families = [] - if vs: - for v in vs: - variations = v.split(" ") - family = [] - for el in self.variables: - family.append(el + ":=") - i = 0 - while i < len(variations): - if variations[i][0 : len(el)] == el: - family.append([variations[i][len(el) + 2 : -1]]) - i += 1 - families.append(family) + if variations_string: + for vs in variations_string: + vsplit = vs.split(" ") + variation = [] + for v in vsplit: + m = re.search(r"(.+?)='(.+?)'", v) + if m and len(m.groups()) == 2: + variation.append([m.group(1), m.group(2)]) + else: # pragma: no cover + raise Exception("Error in splitting the variation variable.") + family_list = [] + family_dict = {} + count = 0 + for var in variables: + family_list.append(var + ":=") + for v in variation: + if var == v[0]: + family_list.append([v[1]]) + family_dict[v[0]] = v[1] + count += 1 + break + if count != len(variation): # pragma: no cover + raise IndexError("Not all variations were found in variables.") + if output_as_dict: + families.append(family_dict) + else: + families.append(family_list) return families @pyaedt_function_handler() diff --git a/pyaedt/application/Analysis3D.py b/pyaedt/application/Analysis3D.py index 509fd70b765..f2b08efd4e2 100644 --- a/pyaedt/application/Analysis3D.py +++ b/pyaedt/application/Analysis3D.py @@ -38,7 +38,7 @@ class FieldAnalysis3D(Analysis, object): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. non_graphical : bool, optional diff --git a/pyaedt/application/Analysis3DLayout.py b/pyaedt/application/Analysis3DLayout.py index f25ed1bcf00..ad5530635b9 100644 --- a/pyaedt/application/Analysis3DLayout.py +++ b/pyaedt/application/Analysis3DLayout.py @@ -33,7 +33,7 @@ class FieldAnalysis3DLayout(Analysis): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. NG : bool, optional diff --git a/pyaedt/application/AnalysisMaxwellCircuit.py b/pyaedt/application/AnalysisMaxwellCircuit.py index 3257f8efac4..b3b2ff48fb5 100644 --- a/pyaedt/application/AnalysisMaxwellCircuit.py +++ b/pyaedt/application/AnalysisMaxwellCircuit.py @@ -18,7 +18,7 @@ class AnalysisMaxwellCircuit(Analysis): Name of the design to select. The default is ``None``, in which case an attempt is made to get an active design. If no designs are present, an empty design is created. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``. If ``None``, the active setup is used or the latest installed version is used. diff --git a/pyaedt/application/Design.py b/pyaedt/application/Design.py index eee790bb19e..37fa7b178c7 100644 --- a/pyaedt/application/Design.py +++ b/pyaedt/application/Design.py @@ -82,7 +82,7 @@ class Design(AedtObjects): solution_type : str, optional Solution type to apply to the design. The default is ``None``, in which case the default type is applied. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. non_graphical : bool, optional @@ -2828,9 +2828,16 @@ def change_design_settings(self, settings): bool """ arg = ["NAME:Design Settings Data"] - for k, v in settings.items(): - arg.append(k + ":=") - arg.append(v) + for key, value in settings.items(): + if "SkewSliceTable" not in key: + arg.append(key + ":=") + arg.append(value) + else: + arg_skew = [key] + if isinstance(value, list): + for v in value: + arg_skew.append(v) + arg.append(arg_skew) self.odesign.SetDesignSettings(arg) return True diff --git a/pyaedt/circuit.py b/pyaedt/circuit.py index 1693e369e86..a9b87a0d922 100644 --- a/pyaedt/circuit.py +++ b/pyaedt/circuit.py @@ -48,10 +48,11 @@ class Circuit(FieldAnalysisCircuit, object): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. This parameter is ignored when Script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non_graphical : bool, optional Whether to run AEDT in non-graphical mode. The default is ``False``, in which case AEDT is launched in graphical mode. @@ -104,15 +105,15 @@ class Circuit(FieldAnalysisCircuit, object): >>> aedtapp = Circuit("myfile.aedt") - Create an instance of Circuit using the 2021 R1 version and + Create an instance of Circuit using the 2023 R2 version and open the specified project, which is ``"myfile.aedt"``. - >>> aedtapp = Circuit(specified_version="2021.2", projectname="myfile.aedt") + >>> aedtapp = Circuit(specified_version=2023.2, projectname="myfile.aedt") - Create an instance of Circuit using the 2021 R2 student version and open + Create an instance of Circuit using the 2023 R2 student version and open the specified project, which is named ``"myfile.aedt"``. - >>> hfss = Circuit(specified_version="2021.2", projectname="myfile.aedt", student_version=True) + >>> hfss = Circuit(specified_version="2023.2", projectname="myfile.aedt", student_version=True) """ diff --git a/pyaedt/desktop.py b/pyaedt/desktop.py index 980e081be2a..30aca77ef6d 100644 --- a/pyaedt/desktop.py +++ b/pyaedt/desktop.py @@ -42,6 +42,7 @@ from pyaedt.generic.desktop_sessions import _desktop_sessions from pyaedt.generic.general_methods import active_sessions from pyaedt.generic.general_methods import com_active_sessions +from pyaedt.generic.general_methods import get_string_version from pyaedt.generic.general_methods import grpc_active_sessions from pyaedt.generic.general_methods import inside_desktop from pyaedt.generic.general_methods import is_ironpython @@ -383,9 +384,10 @@ class Desktop(object): Parameters ---------- - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active setup or latest installed version is used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non_graphical : bool, optional Whether to launch AEDT in non-graphical mode. The default is ``False``, in which case AEDT is launched in graphical mode. @@ -416,19 +418,19 @@ class Desktop(object): Examples -------- - Launch AEDT 2021 R1 in non-graphical mode and initialize HFSS. + Launch AEDT 2023 R1 in non-graphical mode and initialize HFSS. >>> import pyaedt - >>> desktop = pyaedt.Desktop(specified_version="2021.2", non_graphical=True) + >>> desktop = pyaedt.Desktop(specified_version="2023.2", non_graphical=True) PyAEDT INFO: pyaedt v... PyAEDT INFO: Python version ... >>> hfss = pyaedt.Hfss(designname="HFSSDesign1") PyAEDT INFO: Project... PyAEDT INFO: Added design 'HFSSDesign1' of type HFSS. - Launch AEDT 2021 R1 in graphical mode and initialize HFSS. + Launch AEDT 2023 R2 in graphical mode and initialize HFSS. - >>> desktop = Desktop("2021.2") + >>> desktop = Desktop(232) PyAEDT INFO: pyaedt v... PyAEDT INFO: Python version ... >>> hfss = pyaedt.Hfss(designname="HFSSDesign1") @@ -474,11 +476,12 @@ def __init__( port=0, aedt_process_id=None, ): + if aedt_process_id: # pragma no cover + aedt_process_id = int(aedt_process_id) if getattr(self, "_initialized", None) is not None and self._initialized: return else: self._initialized = True - self._initialized_from_design = True if Desktop._invoked_from_design else False Desktop._invoked_from_design = False @@ -551,6 +554,7 @@ def __init__( sessions = active_sessions( version=specified_version, student_version=student_version_flag, non_graphical=non_graphical ) + self.logger.info(sessions) if aedt_process_id in sessions: if sessions[aedt_process_id] != -1: self.port = sessions[aedt_process_id] @@ -749,6 +753,7 @@ def _assert_version(self, specified_version, student_version): self.logger.warning("Only AEDT Student Version found on the system. Using Student Version.") elif student_version: specified_version += "SV" + specified_version = get_string_version(specified_version) if float(specified_version[0:6]) < 2019: raise ValueError("PyAEDT supports AEDT version 2021 R1 and later. Recommended version is 2022 R2 or later.") diff --git a/pyaedt/edb.py b/pyaedt/edb.py index 738f0fcc52d..ee574182512 100644 --- a/pyaedt/edb.py +++ b/pyaedt/edb.py @@ -47,6 +47,7 @@ from pyaedt.generic.constants import AEDT_UNITS from pyaedt.generic.constants import SolverType from pyaedt.generic.general_methods import generate_unique_name +from pyaedt.generic.general_methods import get_string_version from pyaedt.generic.general_methods import inside_desktop from pyaedt.generic.general_methods import is_ironpython from pyaedt.generic.general_methods import is_linux @@ -79,8 +80,9 @@ class Edb(Database): isreadonly : bool, optional Whether to open EBD in read-only mode when it is owned by HFSS 3D Layout. The default is ``False``. - edbversion : str, optional - Version of EDB to use. The default is ``"2021.2"``. + edbversion : str, int, float, optional + Version of EDB to use. The default is ``None``. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. isaedtowned : bool, optional Whether to launch EDB from HFSS 3D Layout. The default is ``False``. @@ -138,6 +140,8 @@ def __init__( use_ppe=False, technology_file=None, ): + edbversion = get_string_version(edbversion) + self._clean_variables() Database.__init__(self, edbversion=edbversion, student_version=student_version) self.standalone = True diff --git a/pyaedt/emit.py b/pyaedt/emit.py index 77e886806e8..7301b9c0453 100644 --- a/pyaedt/emit.py +++ b/pyaedt/emit.py @@ -34,10 +34,11 @@ class Emit(Design, object): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active setup is used or the latest installed version is used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non_graphical : bool, optional Whether to launch AEDT in non-graphical mode. The default is ``False``, in which case AEDT is launched in graphical mode. @@ -73,7 +74,7 @@ class Emit(Design, object): Typically, it is desirable to specify a project name, design name, and other parameters. - >>> aedtapp = Emit(projectname, designame) + >>> aedtapp = Emit(projectname, designame, specified_version=232) Once an ``Emit`` instance is initialized, you can edit the schematic: diff --git a/pyaedt/generic/design_types.py b/pyaedt/generic/design_types.py index ce17101fd37..8b9028e36fb 100644 --- a/pyaedt/generic/design_types.py +++ b/pyaedt/generic/design_types.py @@ -19,9 +19,95 @@ def Circuit( ): """Circuit Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which + case an attempt is made to get an active project. If no + projects are present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is + ``None``, in which case the default type is applied. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or + nothing is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which case + the active version or latest installed version is used. + This parameter is ignored when Script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to run AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. This parameter is ignored when + a script is launched within AEDT. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. The default is ``False``. + This parameter is ignored when Script is launched within AEDT. + machine : str, optional + Machine name to which connect the oDesktop Session. Works only in 2022 R2 + or later. The remote server must be up and running with the command + `"ansysedt.exe -grpcsrv portnum"`. If a machine is `"localhost"`, the + server also starts if not present. + port : int, optional + Port number on which to start the oDesktop communication on an already existing server. + This parameter is ignored when creating a new server. It works only in 2022 R2 or + later. The remote server must be up and running with the command + `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- :class:`pyaedt.circuit.Circuit` + + Examples + -------- + Create an instance of Circuit and connect to an existing HFSS + design or create a new HFSS design if one does not exist. + + >>> from pyaedt import Circuit + >>> aedtapp = Circuit() + + Create an instance of Circuit and link to a project named + ``"projectname"``. If this project does not exist, create one with + this name. + + >>> aedtapp = Circuit(projectname) + + Create an instance of Circuit and link to a design named + ``"designname"`` in a project named ``"projectname"``. + + >>> aedtapp = Circuit(projectname,designame) + + Create an instance of Circuit and open the specified project, + which is ``"myfie.aedt"``. + + >>> aedtapp = Circuit("myfile.aedt") + + Create an instance of Circuit using the 2023 R2 version and + open the specified project, which is ``"myfile.aedt"``. + + >>> aedtapp = Circuit(specified_version=2023.2, projectname="myfile.aedt") + + Create an instance of Circuit using the 2023 R2 student version and open + the specified project, which is named ``"myfile.aedt"``. + + >>> hfss = Circuit(specified_version="2023.2", projectname="myfile.aedt", student_version=True) + """ from pyaedt.circuit import Circuit as app @@ -57,9 +143,115 @@ def Hfss( ): """Return an instance of the Hfss Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which + case an attempt is made to get an active project. If no + projects are present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is + ``None``, in which case the default type is applied. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or + nothing is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which case + the active version or latest installed version is used. + This parameter is ignored when a script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to run AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``False``. This parameter is ignored when + a script is launched within AEDT. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. The default is + ``False``. This parameter is ignored when a script is launched + within AEDT. + machine : str, optional + Machine name to connect the oDesktop session to. This parameter works only on + 2022 R2 or later. The remote Server must be up and running with the command + `"ansysedt.exe -grpcsrv portnum"`. If the machine is `"localhost"`, the server + starts if it is not present. + port : int, optional + Port number on which to start the oDesktop communication on an already existing server. + This parameter is ignored when creating a new server. It works only in 2022 R2 or later. + The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- :class:`pyaedt.hfss.Hfss` + + Examples + -------- + Create an instance of HFSS and connect to an existing HFSS + design or create a new HFSS design if one does not exist. + + >>> from pyaedt import Hfss + >>> hfss = Hfss() + PyAEDT INFO: No project is defined... + PyAEDT INFO: Active design is set to... + + + Create an instance of HFSS and link to a project named + ``HfssProject``. If this project does not exist, create one with + this name. + + >>> hfss = Hfss("HfssProject") + PyAEDT INFO: Project HfssProject has been created. + PyAEDT INFO: No design is present. Inserting a new design. + PyAEDT INFO: Added design ... + + + Create an instance of HFSS and link to a design named + ``HfssDesign1`` in a project named ``HfssProject``. + + >>> hfss = Hfss("HfssProject","HfssDesign1") + PyAEDT INFO: Added design 'HfssDesign1' of type HFSS. + + + Create an instance of HFSS and open the specified project, + which is named ``"myfile.aedt"``. + + >>> hfss = Hfss("myfile.aedt") + PyAEDT INFO: Project myfile has been created. + PyAEDT INFO: No design is present. Inserting a new design. + PyAEDT INFO: Added design... + + + Create an instance of HFSS using the 2023 R2 release and open + the specified project, which is named ``"myfile2.aedt"``. + + >>> hfss = Hfss(specified_version=232, projectname="myfile2.aedt") + PyAEDT INFO: Project myfile2 has been created. + PyAEDT INFO: No design is present. Inserting a new design. + PyAEDT INFO: Added design... + + + Create an instance of HFSS using the 2023 R2 student version and open + the specified project, which is named ``"myfile3.aedt"``. + + >>> hfss = Hfss(specified_version="2023.2", projectname="myfile3.aedt", student_version=True) + PyAEDT INFO: Project myfile3 has been created. + PyAEDT INFO: No design is present. Inserting a new design. + PyAEDT INFO: Added design... + """ from pyaedt.hfss import Hfss as app @@ -95,9 +287,99 @@ def Icepak( ): """Icepak Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which + case an attempt is made to get an active project. If no + projects are present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is + ``None``, in which case the default type is applied. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or + nothing is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which case + the active version or latest installed version is used. + This parameter is ignored when Script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non-graphical : bool, optional + Whether to launch AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. The default is ``False``. + This parameter is ignored when a script is launched within AEDT. + machine : str, optional + Machine name to connect the oDesktop session to. This works only in 2022 R2 or later. + The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + If the machine is `"localhost"`, the server also starts if not present. + port : int, optional + Port number of which to start the oDesktop communication on an already existing server. + This parameter is ignored when creating a new server. It works only in 2022 R2 or later. + The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- - :class:`pyaedt.icepak.Icepak`""" + :class:`pyaedt.icepak.Icepak` + + Examples + -------- + + Create an instance of Icepak and connect to an existing Icepak + design or create a new Icepak design if one does not exist. + + >>> from pyaedt import Icepak + >>> icepak = Icepak() + PyAEDT INFO: No project is defined. Project ... + PyAEDT INFO: Active design is set to ... + + Create an instance of Icepak and link to a project named + ``IcepakProject``. If this project does not exist, create one with + this name. + + >>> icepak = Icepak("IcepakProject") + PyAEDT INFO: Project ... + PyAEDT INFO: Added design ... + + Create an instance of Icepak and link to a design named + ``IcepakDesign1`` in a project named ``IcepakProject``. + + >>> icepak = Icepak("IcepakProject", "IcepakDesign1") + PyAEDT INFO: Added design 'IcepakDesign1' of type Icepak. + + Create an instance of Icepak and open the specified project, + which is ``myipk.aedt``. + + >>> icepak = Icepak("myipk.aedt") + PyAEDT INFO: Project myipk has been created. + PyAEDT INFO: No design is present. Inserting a new design. + PyAEDT INFO: Added design ... + + Create an instance of Icepak using the 2023 R2 release and + open the specified project, which is ``myipk2.aedt``. + + >>> icepak = Icepak(specified_version=2023.2, projectname="myipk2.aedt") + PyAEDT INFO: Project... + PyAEDT INFO: No design is present. Inserting a new design. + PyAEDT INFO: Added design... + """ from pyaedt.icepak import Icepak as app return app( @@ -132,9 +414,97 @@ def Emit( ): """Emit Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which case + an attempt is made to get an active project. If no projects are + present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in which case + an attempt is made to get an active design. If no designs are + present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is ``None``, in which + case the default type is applied. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or + nothing is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which case + the active setup is used or the latest installed version is + used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to launch AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to start the AEDT student version. The default is ``False``. + port : int, optional + Port number on which to start the oDesktop communication on an already existing server. + This parameter is ignored when creating a server. This parameter works only in 2022 R2 or later. + The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + The default is ``0``. + machine : str, optional + Machine name that the Desktop session is to connect to. This + parameter works only in 2022 R2 and later. The remote server must be + up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + If the machine is `"localhost"`, the server starts if it is not present. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- - :class:`pyaedt.emit.Emit`""" + :class:`pyaedt.emit.Emit` + + Examples + -------- + Create an ``Emit`` instance. You can also choose to define parameters for this instance here. + + >>> from pyaedt import Emit + >>> aedtapp = Emit() + + Typically, it is desirable to specify a project name, design name, and other parameters. + + >>> aedtapp = Emit(projectname, designame, specified_version=232) + + Once an ``Emit`` instance is initialized, you can edit the schematic: + + >>> rad1 = aedtapp.modeler.components.create_component("Bluetooth") + >>> ant1 = aedtapp.modeler.components.create_component("Antenna") + >>> if rad1 and ant1: + >>> ant1.move_and_connect_to(rad1) + + Once the schematic is generated, the ``Emit`` object can be analyzed to generate + a revision. Each revision is added as an element of the ``Emit`` object member's + revisions_list. + + >>> aedtapp.analyze() + + A revision within PyAEDT is analogous to a revision in AEDT. An interaction domain must + be defined and then used as the input to the run command used on that revision. + + >>> domain = aedtapp.interaction_domain() + >>> domain.rx_radio_name = "UE - HandHeld" + >>> interaction = aedtapp.revisions_list[0].run(domain) + + The output of the run command is an ``interaction`` object. This object summarizes the interaction data + that is defined in the interaction domain. + + >>> instance = interaction.worst_instance(ResultType.SENSITIVITY) + >>> val = instance.value(ResultType.SENSITIVITY) + >>> print("Worst-case sensitivity for Rx '{}' is {}dB.".format(domain.rx_radio_name, val)) + """ from pyaedt.emit import Emit as app return app( @@ -169,9 +539,95 @@ def Hfss3dLayout( ): """Hfss3dLayout Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open or the path to the ``aedb`` folder or + ``edb.def`` file. The default is ``None``, in which case an + attempt is made to get an active project. If no projects are present, + an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is + ``None``, in which case the default type is applied. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or + nothing is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which case + the active version or latest installed version is used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to launch AEDT in non-graphical mode. The default + is ``False```, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. The default is ``False``. + machine : str, optional + Machine name to connect the oDesktop session to. This works only in 2022 R2 or later. + The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + If the machine is `"localhost"`. the server also starts if not present. + port : int, optional + Port number on which to start the oDesktop communication on an already existing server. + This parameter is ignored when creating a new server. It works only in 2022 R2 or later. + The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- - :class:`pyaedt.hfss3dlayout.Hfss3dLayout`""" + :class:`pyaedt.hfss3dlayout.Hfss3dLayout` + + Examples + -------- + Create an ``Hfss3dLayout`` object and connect to an existing HFSS + design or create a new HFSS design if one does not exist. + + >>> from pyaedt import Hfss3dLayout + >>> aedtapp = Hfss3dLayout() + + Create an ``Hfss3dLayout`` object and link to a project named + ``projectname``. If this project does not exist, create one with + this name. + + >>> aedtapp = Hfss3dLayout(projectname) + + Create an ``Hfss3dLayout`` object and link to a design named + ``designname`` in a project named ``projectname``. + + >>> aedtapp = Hfss3dLayout(projectname,designame) + + Create an ``Hfss3dLayout`` object and open the specified project. + + >>> aedtapp = Hfss3dLayout("myfile.aedt") + + Create an AEDT 2023 R1 object and then create a + ``Hfss3dLayout`` object and open the specified project. + + >>> aedtapp = Hfss3dLayout(specified_version="2023.1", projectname="myfile.aedt") + + Create an instance of ``Hfss3dLayout`` from an ``Edb`` + + >>> import pyaedt + >>> edb_path = "/path/to/edbfile.aedb" + >>> edb = pyaedt.Edb(edb_path, edbversion=231) + >>> edb.import_stackup("stackup.xml") # Import stackup. Manipulate edb, ... + >>> edb.save_edb() + >>> edb.close_edb() + >>> aedtapp = pyaedt.Hfss3dLayout(specified_version=231, projectname=edb_path) + """ from pyaedt.hfss3dlayout import Hfss3dLayout as app return app( @@ -206,6 +662,56 @@ def Maxwell2d( ): """Maxwell2d Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which + case an attempt is made to get an active project. If no + projects are present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is + ``None``, in which case the default type is applied. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or + nothing is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which case + the active version or latest installed version is used. + This parameter is ignored when a script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to launch AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. This parameter is ignored when + a script is launched within AEDT. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. The default is ``False``. + This parameter is ignored when a script is launched within AEDT. + machine : str, optional + Machine name to connect the oDesktop session to. This works only in 2022 R2 + or later. The remote server must be up and running with the command + `"ansysedt.exe -grpcsrv portnum"`. If the machine is `"localhost"`, + the server also starts if not present. + port : int, optional + Port number of which to start the oDesktop communication on an already existing + server. This parameter is ignored when creating a new server. It works only in 2022 + R2 or later. The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- :class:`pyaedt.maxwell.Maxwell2d`""" @@ -243,9 +749,77 @@ def Maxwell3d( ): """Maxwell3d Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which + case an attempt is made to get an active project. If no + projects are present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is + ``None``, in which case the default type is applied. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or + nothing is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which case + the active version or latest installed version is used. This + parameter is ignored when a script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to launch AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical + mode. This parameter is ignored when a script is launched within + AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. This parameter is ignored + when a script is launched within AEDT. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. The default is + ``False``. This parameter is ignored when a script is launched + within AEDT. + machine : str, optional + Machine name to connect the oDesktop session to. This works only in 2022 R2 + or later. The remote server must be up and running with the command + `"ansysedt.exe -grpcsrv portnum"`. If the machine is `"localhost"`, the + server also starts if not present. + port : int, optional + Port number on which to start the oDesktop communication on an already existing server. + This parameter is ignored when a new server is created. It works only in 2022 R2 or later. + The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- - :class:`pyaedt.maxwell.Maxwell3d`""" + :class:`pyaedt.maxwell.Maxwell3d` + + Examples + -------- + Create an instance of Maxwell 3D and open the specified + project, which is named ``mymaxwell.aedt``. + + >>> from pyaedt import Maxwell3d + >>> aedtapp = Maxwell3d("mymaxwell.aedt") + PyAEDT INFO: Added design ... + + Create an instance of Maxwell 3D using the 2023 R2 release and open + the specified project, which is named ``mymaxwell2.aedt``. + + >>> aedtapp = Maxwell3d(specified_version="2023.2", projectname="mymaxwell2.aedt") + PyAEDT INFO: Added design ... + """ from pyaedt.maxwell import Maxwell3d as app return app( @@ -279,6 +853,47 @@ def MaxwellCircuit( ): """MaxwellCircuit Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which + case an attempt is made to get an active project. If no + projects are present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``. If ``None``, + the active setup is used or the latest installed version is + used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non-graphical : bool, optional + Whether to launch AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. The default is ``False``. + machine : str, optional + Machine name to connect the oDesktop session to. This works only in 2022 R2 + and later. The remote server must be up and running with the command + `"ansysedt.exe -grpcsrv portnum"`. If the machine is `"localhost"`, the server + is also started if not present. + port : int, optional + Port number on which to start the oDesktop communication on an already existing server. + This parameter is ignored when creating a new server. It works only in 2022 R2 or + later. The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- :class:`pyaedt.maxwellcircuit.MaxwellCircuit`""" @@ -315,9 +930,90 @@ def Mechanical( ): """Mechanical Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which + case an attempt is made to get an active project. If no + projects are present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is + ``None``, in which case the default type is applied. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or + nothing is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which case + the active version or latest installed version is used. + This parameter is ignored when a script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to launch AEDT in the non-graphical mode. The default + is ``False``, in which case AEDT is launched in the graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. This parameter is ignored when + a script is launched within AEDT. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. The default is ``False``. + This parameter is ignored when a script is launched within AEDT. + machine : str, optional + Machine name to connect the oDesktop session to. Works only in 2022R2 and + later. The remote server must be up and running with the command + `"ansysedt.exe -grpcsrv portnum"`. If the machine is `"localhost"`, + the server also starts if not present. + port : int, optional + Port number on which to start the oDesktop communication on an already existing server. + This parameter is ignored when creating a new server. It works only in 2022 R2 or + later. The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- - :class:`pyaedt.mechanical.Mechanical`""" + :class:`pyaedt.mechanical.Mechanical` + + Examples + -------- + Create an instance of Mechanical and connect to an existing + HFSS design or create a new HFSS design if one does not exist. + + >>> from pyaedt import Mechanical + >>> aedtapp = Mechanical() + + Create an instance of Mechanical and link to a project named + ``"projectname"``. If this project does not exist, create one with + this name. + + >>> aedtapp = Mechanical(projectname) + + Create an instance of Mechanical and link to a design named + ``"designname"`` in a project named ``"projectname"``. + + >>> aedtapp = Mechanical(projectname,designame) + + Create an instance of Mechanical and open the specified + project, which is named ``"myfile.aedt"``. + + >>> aedtapp = Mechanical("myfile.aedt") + + Create a ``Desktop on 2023 R2`` object and then create an + ``Mechanical`` object and open the specified project, which is + named ``"myfile.aedt"``. + + >>> aedtapp = Mechanical(specified_version=23.2, projectname="myfile.aedt") + """ from pyaedt.mechanical import Mechanical as app return app( @@ -352,6 +1048,56 @@ def Q2d( ): """Q2D Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which + case an attempt is made to get an active project. If no + projects are present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is + ``None``, in which case the default type is applied. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or + nothing is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which case + the active version or latest installed version is used. This + parameter is ignored when a script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to launch AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. This parameter is ignored + when a script is launched within AEDT. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. This parameter is + ignored when a script is launched within AEDT. + machine : str, optional + Machine name to connect the oDesktop session to. This works only in 2022 R2 + and later. The remote server must be up and running with the command + `"ansysedt.exe -grpcsrv portnum"`. If the machine is `"localhost"`, + the server also starts if not present. + port : int, optional + Port number on which to start the oDesktop communication on an already existing server. + This parameter is ignored when creating a new server. It works only in 2022 R2 or later. + The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- :class:`pyaedt.q3d.Q2d`""" @@ -389,6 +1135,57 @@ def Q3d( ): """Q3D Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which + case an attempt is made to get an active project. If no + projects are present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is + ``None``, in which case the default type is applied. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or nothing + is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which case + the active version or latest installed version is used. + This parameter is ignored when Script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to launch AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. This parameter is ignored when + a script is launched within AEDT. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. The default is ``False``. + This parameter is ignored when a script is launched within AEDT. + machine : str, optional + Machine name to connect the oDesktop session to. This works only in + 2022 R2 and later. The remote server must be up and running with the + command `"ansysedt.exe -grpcsrv portnum"`. If the machine is `"localhost"`, + the server also starts if not present. + port : int, optional + Port number on which to start the oDesktop communication on an already + existing server. This parameter is ignored when a new server is created. + It works only in 2022 R2 and later. The remote server must be up and + running with the command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- :class:`pyaedt.q3d.Q3d`""" @@ -426,6 +1223,56 @@ def Rmxprt( ): """Rmxprt Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which + case an attempt is made to get an active project. If no + projects are present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is + ``None``, in which case the default type is applied. + model_units : str, optional + Model units. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or + nothing is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which case + the active setup is used or the latest installed version is + used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to launch AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. The default is ``False``. + machine : str, optional + Machine name to connect the oDesktop session to. This works only in 2022 R2 or + later. The remote server must be up and running with the command + `"ansysedt.exe -grpcsrv portnum"`. If the machine is `"localhost"`, the + server also starts if not present. + port : int, optional + Port number on which to start the oDesktop communication on an already existing server. + This parameter is ignored when creating a new server. It works only in 2022 R2 or later. + The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- :class:`pyaedt.rmxprt.Rmxprt`""" @@ -463,6 +1310,54 @@ def TwinBuilder( ): """TwinBuilder Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which + case an attempt is made to get an active project. If no + projects are present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is + ``None``, in which case the default type is applied. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or + nothing is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which + case the active setup or latest installed version is + used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to launch AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. The default is ``False``. + machine : str, optional + Machine name to connect the oDesktop session to. This works only in 2022 R2 + or later. The remote server must be up and running with the command + `"ansysedt.exe -grpcsrv portnum"`. If the machine is `"localhost"`, + the server also starts if not present. + port : int, optional + Port number on which to start the oDesktop communication on an already existing server. + This parameter is ignored when creating a new server. It works only in 2022 R2 or later. + The remote server must be up and running with command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- :class:`pyaedt.twinbuilder.TwinBuilder`""" @@ -500,6 +1395,54 @@ def Simplorer( ): """Simplorer Class. + Parameters + ---------- + projectname : str, optional + Name of the project to select or the full path to the project + or AEDTZ archive to open. The default is ``None``, in which + case an attempt is made to get an active project. If no + projects are present, an empty project is created. + designname : str, optional + Name of the design to select. The default is ``None``, in + which case an attempt is made to get an active design. If no + designs are present, an empty design is created. + solution_type : str, optional + Solution type to apply to the design. The default is + ``None``, in which case the default type is applied. + setup_name : str, optional + Name of the setup to use as the nominal. The default is + ``None``, in which case the active setup is used or + nothing is used. + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which + case the active setup or latest installed version is + used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to launch AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the + machine. The default is ``True``. + close_on_exit : bool, optional + Whether to release AEDT on exit. The default is ``False``. + student_version : bool, optional + Whether to open the AEDT student version. The default is ``False``. + machine : str, optional + Machine name to connect the oDesktop session to. This works only in 2022 R2 + or later. The remote server must be up and running with the command + `"ansysedt.exe -grpcsrv portnum"`. If the machine is `"localhost"`, + the server also starts if not present. + port : int, optional + Port number on which to start the oDesktop communication on an already existing server. + This parameter is ignored when creating a new server. It works only in 2022 R2 or later. + The remote server must be up and running with command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. + Returns ------- :class:`pyaedt.twinbuilder.TwinBuilder`""" @@ -532,10 +1475,64 @@ def Desktop( aedt_process_id=None, ): """Desktop Class. + Parameters + ---------- + specified_version : str, int, float, optional + Version of AEDT to use. The default is ``None``, in which case the + active setup or latest installed version is used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. + non_graphical : bool, optional + Whether to launch AEDT in non-graphical mode. The default + is ``False``, in which case AEDT is launched in graphical mode. + This parameter is ignored when a script is launched within AEDT. + new_desktop_session : bool, optional + Whether to launch an instance of AEDT in a new thread, even if + another instance of the ``specified_version`` is active on the machine. + The default is ``True``. + close_on_exit : bool, optional + Whether to close AEDT on exit. The default is ``True``. + This option is used only when Desktop is used in a context manager (``with`` statement). + If Desktop is used outside a context manager, see the ``release_desktop`` arguments. + student_version : bool, optional + Whether to open the AEDT student version. The default is + ``False``. + machine : str, optional + Machine name to connect the oDesktop session to. This parameter works only in 2022 R2 + and later. The remote server must be up and running with the command + `"ansysedt.exe -grpcsrv portnum"`. If the machine is `"localhost"`, the server also + starts if not present. + port : int, optional + Port number on which to start the oDesktop communication on the already existing server. + This parameter is ignored when creating a new server. It works only in 2022 R2 and + later. The remote server must be up and running with the command `"ansysedt.exe -grpcsrv portnum"`. + aedt_process_id : int, optional + Process ID for the instance of AEDT to point PyAEDT at. The default is + ``None``. This parameter is only used when ``new_desktop_session = False``. Returns ------- - :class:`pyaedt.desktop.Desktop`""" + :class:`pyaedt.desktop.Desktop` + + Examples + -------- + Launch AEDT 2023 R1 in non-graphical mode and initialize HFSS. + + >>> import pyaedt + >>> desktop = pyaedt.Desktop(specified_version="2023.2", non_graphical=True) + PyAEDT INFO: pyaedt v... + PyAEDT INFO: Python version ... + >>> hfss = pyaedt.Hfss(designname="HFSSDesign1") + PyAEDT INFO: Project... + PyAEDT INFO: Added design 'HFSSDesign1' of type HFSS. + + Launch AEDT 2023 R2 in graphical mode and initialize HFSS. + + >>> desktop = Desktop(232) + PyAEDT INFO: pyaedt v... + PyAEDT INFO: Python version ... + >>> hfss = pyaedt.Hfss(designname="HFSSDesign1") + PyAEDT INFO: No project is defined. Project... + """ from pyaedt.desktop import Desktop as app return app( @@ -564,7 +1561,7 @@ def launch_desktop( Parameters ---------- - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active setup or latest installed version is used. non_graphical : bool, optional @@ -648,7 +1645,7 @@ def Edb( Parameters ---------- - edbpath : str, optional + edbpath : str, int, float optional Full path to the ``aedb`` folder. The variable can also contain the path to a layout to import. Allowed formats are BRD, XML (IPC2581), GDS, and DXF. The default is ``None``. diff --git a/pyaedt/generic/general_methods.py b/pyaedt/generic/general_methods.py index 4bb8e34f522..5e179296a86 100644 --- a/pyaedt/generic/general_methods.py +++ b/pyaedt/generic/general_methods.py @@ -435,6 +435,24 @@ def get_version_and_release(input_version): return (version, release) +@pyaedt_function_handler() +def get_string_version(input_version): + output_version = input_version + if isinstance(input_version, float): + output_version = str(input_version) + if len(output_version) == 4: + output_version = "20" + output_version + elif isinstance(input_version, int): + output_version = str(input_version) + output_version = "20{}.{}".format(output_version[:2], output_version[-1]) + elif isinstance(input_version, str): + if len(input_version) == 3: + output_version = "20{}.{}".format(input_version[:2], input_version[-1]) + elif len(input_version) == 4: + output_version = "20" + input_version + return output_version + + @pyaedt_function_handler() def env_path(input_version): """Get the path of the version environment variable for an AEDT version. diff --git a/pyaedt/hfss.py b/pyaedt/hfss.py index cdcc85a5cb8..5f85ef4b332 100644 --- a/pyaedt/hfss.py +++ b/pyaedt/hfss.py @@ -52,10 +52,11 @@ class Hfss(FieldAnalysis3D, object): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. This parameter is ignored when a script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non_graphical : bool, optional Whether to run AEDT in non-graphical mode. The default is ``False``, in which case AEDT is launched in graphical mode. @@ -121,19 +122,19 @@ class Hfss(FieldAnalysis3D, object): PyAEDT INFO: Added design... - Create an instance of HFSS using the 2021 R1 release and open + Create an instance of HFSS using the 2023 R2 release and open the specified project, which is named ``"myfile2.aedt"``. - >>> hfss = Hfss(specified_version="2021.2", projectname="myfile2.aedt") + >>> hfss = Hfss(specified_version=232, projectname="myfile2.aedt") PyAEDT INFO: Project myfile2 has been created. PyAEDT INFO: No design is present. Inserting a new design. PyAEDT INFO: Added design... - Create an instance of HFSS using the 2021 R2 student version and open + Create an instance of HFSS using the 2023 R2 student version and open the specified project, which is named ``"myfile3.aedt"``. - >>> hfss = Hfss(specified_version="2021.2", projectname="myfile3.aedt", student_version=True) + >>> hfss = Hfss(specified_version="2023.2", projectname="myfile3.aedt", student_version=True) PyAEDT INFO: Project myfile3 has been created. PyAEDT INFO: No design is present. Inserting a new design. PyAEDT INFO: Added design... diff --git a/pyaedt/hfss3dlayout.py b/pyaedt/hfss3dlayout.py index 833ecd0f67d..b0180cf5781 100644 --- a/pyaedt/hfss3dlayout.py +++ b/pyaedt/hfss3dlayout.py @@ -45,9 +45,10 @@ class Hfss3dLayout(FieldAnalysis3DLayout): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non_graphical : bool, optional Whether to launch AEDT in non-graphical mode. The default is ``False```, in which case AEDT is launched in graphical mode. @@ -95,7 +96,7 @@ class Hfss3dLayout(FieldAnalysis3DLayout): >>> aedtapp = Hfss3dLayout("myfile.aedt") - Create an AEDT 2021 R1 object and then create a + Create an AEDT 2023 R1 object and then create a ``Hfss3dLayout`` object and open the specified project. >>> aedtapp = Hfss3dLayout(specified_version="2023.1", projectname="myfile.aedt") @@ -104,12 +105,11 @@ class Hfss3dLayout(FieldAnalysis3DLayout): >>> import pyaedt >>> edb_path = "/path/to/edbfile.aedb" - >>> specified_version = "2023.1" - >>> edb = pyaedt.Edb(edb_path) + >>> edb = pyaedt.Edb(edb_path, edbversion=231) >>> edb.import_stackup("stackup.xml") # Import stackup. Manipulate edb, ... >>> edb.save_edb() >>> edb.close_edb() - >>> aedtapp = pyaedt.Hfss3dLayout(specified_version="2021.2", projectname=edb_path) + >>> aedtapp = pyaedt.Hfss3dLayout(specified_version=231, projectname=edb_path) """ diff --git a/pyaedt/icepak.py b/pyaedt/icepak.py index e9f8a67cd84..edb850fabb9 100644 --- a/pyaedt/icepak.py +++ b/pyaedt/icepak.py @@ -59,10 +59,11 @@ class Icepak(FieldAnalysis3D): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. This parameter is ignored when Script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non-graphical : bool, optional Whether to launch AEDT in non-graphical mode. The default is ``False``, in which case AEDT is launched in graphical mode. @@ -121,10 +122,10 @@ class Icepak(FieldAnalysis3D): PyAEDT INFO: No design is present. Inserting a new design. PyAEDT INFO: Added design ... - Create an instance of Icepak using the 2021 R1 release and + Create an instance of Icepak using the 2023 R2 release and open the specified project, which is ``myipk2.aedt``. - >>> icepak = Icepak(specified_version="2021.2", projectname="myipk2.aedt") + >>> icepak = Icepak(specified_version=2023.2, projectname="myipk2.aedt") PyAEDT INFO: Project... PyAEDT INFO: No design is present. Inserting a new design. PyAEDT INFO: Added design... diff --git a/pyaedt/maxwell.py b/pyaedt/maxwell.py index 9309d0519f2..199fdb6e1a1 100644 --- a/pyaedt/maxwell.py +++ b/pyaedt/maxwell.py @@ -9,6 +9,7 @@ import re from pyaedt.application.Analysis3D import FieldAnalysis3D +from pyaedt.application.Variables import decompose_variable_value from pyaedt.generic.DataHandlers import float_units from pyaedt.generic.constants import SOLUTIONS from pyaedt.generic.general_methods import generate_unique_name @@ -104,6 +105,90 @@ def change_inductance_computation(self, compute_transient_inductance=True, incre {"ComputeTransientInductance": compute_transient_inductance, "ComputeIncrementalMatrix": incremental_matrix} ) + @pyaedt_function_handler + def apply_skew( + self, + skew_type="Continuous", + skew_part="Rotor", + skew_angle="1", + skew_angle_unit="deg", + number_of_slices=2, + custom_slices_skew_angles=None, + ): + """Apply skew to 2D model. + + Parameters + ---------- + skew_type : str, optional + Skew type. + Possible choices are ``Continuous``, ``Step``, ``V-Shape``, ``User Defined``. + The default value is ``Continuous``. + skew_part : str, optional + Part to skew. + Possible choices are ``Rotor`` or ``Stator``. + The default value is ``Rotor``. + skew_angle : str, optional + Skew angle. + The default value is ``1``. + skew_angle_unit : str, optional + Skew angle unit. + Possible choices are ``deg``, ``rad``, ``degsec``, ``degmin``. + The default value is ``deg``. + number_of_slices : str, optional + Number of slices to split the selected part into. + The default value is ``2``. + custom_slices_skew_angles : list, optional + List of custom angles to apply to slices. + Only available if skew_type is ``User Defined``. + The length of this list must be equal to number_of_slices. + The default value is ``None``. + Returns + ------- + bool + ``True`` when successful, ``False`` when failed. + """ + if skew_type not in ["Continuous", "Step", "V-Shape", "User Defined"]: + self.logger.error("Invalid skew type.") + return False + if skew_part not in ["Rotor", "Stator"]: + self.logger.error("Invalid skew part.") + return False + if skew_angle_unit not in ["deg", "rad", "degsec", "degmin"]: + self.logger.error("Invalid skew angle unit.") + return False + if skew_type != "User Defined": + arg = { + "UseSkewModel": True, + "SkewType": skew_type, + "SkewPart": skew_part, + "SkewAngle": "{}{}".format(skew_angle, skew_angle_unit), + "NumberOfSlices": number_of_slices, + } + return self.change_design_settings(arg) + else: + if not custom_slices_skew_angles or len(custom_slices_skew_angles) != int(number_of_slices): + self.logger.error("Please provide skew angles for each slice.") + return False + arg_slice_table = {"NAME:SkewSliceTable": []} + slice_length = decompose_variable_value(self.design_properties["ModelDepth"])[0] / int(number_of_slices) + for i in range(int(number_of_slices)): + arg_slice_info = [] + arg_slice_info.append("NAME:OneSliceInfo") + arg_slice_info.append("SkewAngle:=") + arg_slice_info.append(str(custom_slices_skew_angles[i])) + arg_slice_info.append("SliceLength:=") + arg_slice_info.append(str(slice_length)) + arg_slice_table["NAME:SkewSliceTable"].append(arg_slice_info) + props = { + "UseSkewModel": True, + "SkewType": skew_type, + "SkewPart": skew_part, + "SkewAngleUnit": skew_angle_unit, + "NumberOfSlices": number_of_slices, + } + props.update(arg_slice_table) + return self.change_design_settings(props) + @pyaedt_function_handler() def set_core_losses(self, objects, value=False): """Whether to enable core losses for a set of objects. @@ -1857,10 +1942,11 @@ class Maxwell3d(Maxwell, FieldAnalysis3D, object): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. This parameter is ignored when a script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non_graphical : bool, optional Whether to launch AEDT in non-graphical mode. The default is ``False``, in which case AEDT is launched in graphical @@ -1899,10 +1985,10 @@ class Maxwell3d(Maxwell, FieldAnalysis3D, object): >>> aedtapp = Maxwell3d("mymaxwell.aedt") PyAEDT INFO: Added design ... - Create an instance of Maxwell 3D using the 2021 R1 release and open + Create an instance of Maxwell 3D using the 2023 R2 release and open the specified project, which is named ``mymaxwell2.aedt``. - >>> aedtapp = Maxwell3d(specified_version="2021.2", projectname="mymaxwell2.aedt") + >>> aedtapp = Maxwell3d(specified_version="2023.2", projectname="mymaxwell2.aedt") PyAEDT INFO: Added design ... """ @@ -2595,10 +2681,11 @@ class Maxwell2d(Maxwell, FieldAnalysis3D, object): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. This parameter is ignored when a script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non_graphical : bool, optional Whether to launch AEDT in non-graphical mode. The default is ``False``, in which case AEDT is launched in graphical mode. diff --git a/pyaedt/maxwellcircuit.py b/pyaedt/maxwellcircuit.py index 8f6ad91d177..e60477c51cd 100644 --- a/pyaedt/maxwellcircuit.py +++ b/pyaedt/maxwellcircuit.py @@ -23,10 +23,11 @@ class MaxwellCircuit(AnalysisMaxwellCircuit, object): Name of the design to select. The default is ``None``, in which case an attempt is made to get an active design. If no designs are present, an empty design is created. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``. If ``None``, the active setup is used or the latest installed version is used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non-graphical : bool, optional Whether to launch AEDT in non-graphical mode. The default is ``False``, in which case AEDT is launched in graphical mode. diff --git a/pyaedt/mechanical.py b/pyaedt/mechanical.py index b7692ae164d..ad48c9e511a 100644 --- a/pyaedt/mechanical.py +++ b/pyaedt/mechanical.py @@ -31,10 +31,11 @@ class Mechanical(FieldAnalysis3D, object): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. This parameter is ignored when a script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non_graphical : bool, optional Whether to launch AEDT in the non-graphical mode. The default is ``False``, in which case AEDT is launched in the graphical mode. @@ -86,11 +87,11 @@ class Mechanical(FieldAnalysis3D, object): >>> aedtapp = Mechanical("myfile.aedt") - Create a ``Desktop on 2021R2`` object and then create an + Create a ``Desktop on 2023 R2`` object and then create an ``Mechanical`` object and open the specified project, which is named ``"myfile.aedt"``. - >>> aedtapp = Mechanical(specified_version="2021.2", projectname="myfile.aedt") + >>> aedtapp = Mechanical(specified_version=23.2, projectname="myfile.aedt") """ diff --git a/pyaedt/misc/Run_PyAEDT_Toolkit_Script.py_build b/pyaedt/misc/Run_PyAEDT_Toolkit_Script.py_build index c203856005b..aaac748a78b 100644 --- a/pyaedt/misc/Run_PyAEDT_Toolkit_Script.py_build +++ b/pyaedt/misc/Run_PyAEDT_Toolkit_Script.py_build @@ -30,6 +30,7 @@ else: def main(): try: + oDesktop.AddMessage("", "", 0, "Toolkit launched. Please wait.") # launch file version = oDesktop.GetVersion()[2:6].replace(".", "") python_exe = r"##PYTHON_EXE##" % version diff --git a/pyaedt/misc/aedtlib_personalib_install.py b/pyaedt/misc/aedtlib_personalib_install.py index 2cbc5905b14..e1f3bda7fa8 100644 --- a/pyaedt/misc/aedtlib_personalib_install.py +++ b/pyaedt/misc/aedtlib_personalib_install.py @@ -55,70 +55,84 @@ def process_arguments(args, parser): return args -def add_pyaedt_to_aedt(aedt_version, is_student_version=False, use_sys_lib=False, new_desktop_session=False): - from pyaedt import Desktop - from pyaedt.generic.general_methods import grpc_active_sessions - - sessions = grpc_active_sessions(aedt_version, is_student_version) - if not sessions: - if not new_desktop_session: - print("Launching a new AEDT desktop session.") - new_desktop_session = True - with Desktop( - specified_version=aedt_version, - non_graphical=new_desktop_session, - new_desktop_session=new_desktop_session, - student_version=is_student_version, - ) as d: - desktop = sys.modules["__main__"].oDesktop - pers1 = os.path.join(desktop.GetPersonalLibDirectory(), "pyaedt") - pid = desktop.GetProcessID() - # Linking pyaedt in PersonalLib for IronPython compatibility. - if os.path.exists(pers1): - d.logger.info("PersonalLib already mapped.") +def add_pyaedt_to_aedt( + aedt_version, is_student_version=False, use_sys_lib=False, new_desktop_session=False, sys_dir="", pers_dir="" +): + if not (sys_dir or pers_dir): + from pyaedt import Desktop + from pyaedt import settings + from pyaedt.generic.general_methods import grpc_active_sessions + + sessions = grpc_active_sessions(aedt_version, is_student_version) + close_on_exit = True + if not sessions: + if not new_desktop_session: + print("Launching a new AEDT desktop session.") + new_desktop_session = True else: - if is_windows: - os.system('mklink /D "{}" "{}"'.format(pers1, pyaedt_path)) + close_on_exit = False + settings.use_grpc_api = True + with Desktop( + specified_version=aedt_version, + non_graphical=new_desktop_session, + new_desktop_session=new_desktop_session, + student_version=is_student_version, + close_on_exit=close_on_exit, + ) as d: + desktop = sys.modules["__main__"].oDesktop + pers1 = os.path.join(desktop.GetPersonalLibDirectory(), "pyaedt") + pid = desktop.GetProcessID() + # Linking pyaedt in PersonalLib for IronPython compatibility. + if os.path.exists(pers1): + d.logger.info("PersonalLib already mapped.") else: - os.system('ln -s "{}" "{}"'.format(pyaedt_path, pers1)) - - toolkits = ["Project"] - # Bug on Linux 23.1 and before where Project level toolkits don't show up. Thus copying to individual design - # toolkits. - if is_linux and aedt_version <= "2023.1": - toolkits = [ - "2DExtractor", - "CircuitDesign", - "HFSS", - "HFSS-IE", - "HFSS3DLayoutDesign", - "Icepak", - "Maxwell2D", - "Maxwell3D", - "Q3DExtractor", - "Mechanical", - ] - - for product in toolkits: - if use_sys_lib: - try: - sys_dir = os.path.join(d.syslib, "Toolkits") - install_toolkit(sys_dir, product, aedt_version) - d.logger.info("Installed toolkit for {} in sys lib.".format(product)) - - except IOError: - pers_dir = os.path.join(d.personallib, "Toolkits") - install_toolkit(pers_dir, product, aedt_version) - d.logger.info("Installed toolkit for {} in personal lib.".format(product)) - else: - pers_dir = os.path.join(d.personallib, "Toolkits") + if is_windows: + os.system('mklink /D "{}" "{}"'.format(pers1, pyaedt_path)) + else: + os.system('ln -s "{}" "{}"'.format(pyaedt_path, pers1)) + sys_dir = d.syslib + pers_dir = d.personallib + if pid and new_desktop_session: + try: + os.kill(pid, 9) + except: + pass + + toolkits = ["Project"] + # Bug on Linux 23.1 and before where Project level toolkits don't show up. Thus copying to individual design + # toolkits. + if is_linux and aedt_version <= "2023.1": + toolkits = [ + "2DExtractor", + "CircuitDesign", + "HFSS", + "HFSS-IE", + "HFSS3DLayoutDesign", + "Icepak", + "Maxwell2D", + "Maxwell3D", + "Q3DExtractor", + "Mechanical", + ] + + for product in toolkits: + if use_sys_lib: + try: + sys_dir = os.path.join(sys_dir, "Toolkits") + install_toolkit(sys_dir, product, aedt_version) + print("Installed toolkit for {} in sys lib.".format(product)) + # d.logger.info("Installed toolkit for {} in sys lib.".format(product)) + + except IOError: + pers_dir = os.path.join(pers_dir, "Toolkits") install_toolkit(pers_dir, product, aedt_version) - d.logger.info("Installed toolkit for {} in personal lib.".format(product)) - if pid and new_desktop_session: - try: - os.kill(pid, 9) - except: - pass + print("Installed toolkit for {} in sys lib.".format(product)) + # d.logger.info("Installed toolkit for {} in personal lib.".format(product)) + else: + pers_dir = os.path.join(pers_dir, "Toolkits") + install_toolkit(pers_dir, product, aedt_version) + print("Installed toolkit for {} in sys lib.".format(product)) + # d.logger.info("Installed toolkit for {} in personal lib.".format(product)) def install_toolkit(toolkit_dir, product, aedt_version): diff --git a/pyaedt/misc/install_extra_toolkits.py b/pyaedt/misc/install_extra_toolkits.py index b6778764736..8d97f8c5425 100644 --- a/pyaedt/misc/install_extra_toolkits.py +++ b/pyaedt/misc/install_extra_toolkits.py @@ -11,9 +11,9 @@ "AntennaWizard": { "pip": "git+https://github.com/ansys/pyaedt-antenna-toolkit.git", "image": "pyansys.png", - "toolkit_script": "ansys/aedt/toolkits/antennas/run_toolkit.py", + "toolkit_script": "ansys/aedt/toolkits/antenna/run_toolkit.py", "installation_path": "HFSS", - "package_name": "ansys.aedt.toolkits.antennas", + "package_name": "ansys.aedt.toolkits.antenna", }, "ChokeWizard": { "pip": "git+https://github.com/ansys/pyaedt-choke-toolkit.git", diff --git a/pyaedt/modules/MeshIcepak.py b/pyaedt/modules/MeshIcepak.py index a77129098fa..e864e3ffd6b 100644 --- a/pyaedt/modules/MeshIcepak.py +++ b/pyaedt/modules/MeshIcepak.py @@ -589,7 +589,7 @@ def add_priority(self, entity_type, obj_list=None, comp_name=None, priority=3): non_user_defined_component_parts = self._app.modeler.oeditor.GetChildNames() new_obj_list = [] for comp in obj_list: - if comp != "Region" and comp in non_user_defined_component_parts and self._app.modeler[comp].is3d: + if comp != "Region" and comp in non_user_defined_component_parts: new_obj_list.append(comp) objects = ", ".join(new_obj_list) diff --git a/pyaedt/q3d.py b/pyaedt/q3d.py index 5706d5eae32..a239b4b840c 100644 --- a/pyaedt/q3d.py +++ b/pyaedt/q3d.py @@ -1219,10 +1219,11 @@ class Q3d(QExtractor, object): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. This parameter is ignored when Script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non_graphical : bool, optional Whether to launch AEDT in non-graphical mode. The default is ``False``, in which case AEDT is launched in graphical mode. @@ -2025,10 +2026,11 @@ class Q2d(QExtractor, object): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. This parameter is ignored when a script is launched within AEDT. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non_graphical : bool, optional Whether to launch AEDT in non-graphical mode. The default is ``False``, in which case AEDT is launched in graphical mode. diff --git a/pyaedt/rmxprt.py b/pyaedt/rmxprt.py index 29cd1fa2004..241feae7670 100644 --- a/pyaedt/rmxprt.py +++ b/pyaedt/rmxprt.py @@ -141,10 +141,11 @@ class Rmxprt(FieldAnalysisRMxprt): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active setup is used or the latest installed version is used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non_graphical : bool, optional Whether to launch AEDT in non-graphical mode. The default is ``False``, in which case AEDT is launched in graphical mode. diff --git a/pyaedt/rpc/rpyc_services.py b/pyaedt/rpc/rpyc_services.py index be2c0f8af95..d578e56806a 100644 --- a/pyaedt/rpc/rpyc_services.py +++ b/pyaedt/rpc/rpyc_services.py @@ -359,7 +359,7 @@ def exposed_hfss( Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. non_graphical : bool, optional @@ -414,7 +414,7 @@ def exposed_hfss3dlayout( Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. non_graphical : bool, optional @@ -469,7 +469,7 @@ def exposed_maxwell3d( Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. non_graphical : bool, optional @@ -524,7 +524,7 @@ def exposed_maxwell2d( Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. non_graphical : bool, optional @@ -579,7 +579,7 @@ def exposed_icepak( Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. non_graphical : bool, optional @@ -634,7 +634,7 @@ def exposed_circuit( Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. non_graphical : bool, optional @@ -689,7 +689,7 @@ def exposed_mechanical( Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. non_graphical : bool, optional @@ -744,7 +744,7 @@ def exposed_q3d( Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. non_graphical : bool, optional @@ -799,7 +799,7 @@ def exposed_q2d( Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active version or latest installed version is used. non_graphical : bool, optional diff --git a/pyaedt/siwave.py b/pyaedt/siwave.py index 048264c9939..038239c9aa8 100644 --- a/pyaedt/siwave.py +++ b/pyaedt/siwave.py @@ -25,7 +25,7 @@ class Siwave(object): Parameters ---------- - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active setup is used or the latest installed version is used. diff --git a/pyaedt/twinbuilder.py b/pyaedt/twinbuilder.py index cc85b5cd876..2a2b2aaf7cd 100644 --- a/pyaedt/twinbuilder.py +++ b/pyaedt/twinbuilder.py @@ -30,10 +30,11 @@ class TwinBuilder(AnalysisTwinBuilder, object): Name of the setup to use as the nominal. The default is ``None``, in which case the active setup is used or nothing is used. - specified_version : str, optional + specified_version : str, int, float, optional Version of AEDT to use. The default is ``None``, in which case the active setup or latest installed version is used. + Examples of input values are ``232``, ``23.2``,``2023.2``,``"2023.2"``. non_graphical : bool, optional Whether to launch AEDT in non-graphical mode. The default is ``False``, in which case AEDT is launched in graphical mode. diff --git a/pyproject.toml b/pyproject.toml index bb6f7e67a46..ae63db4172f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ tests = [ "openpyxl==3.1.2", "osmnx", "pandas==1.3.5; python_version <= '3.7'", - "pandas==2.0.3; python_version > '3.7'", + "pandas==2.1.0; python_version > '3.7'", "pytest==7.4.0", "pytest-cov==4.1.0", "pytest-xdist==3.3.1", @@ -78,7 +78,7 @@ doc = [ "recommonmark==0.7.1", "scikit-learn==1.3.0", "Sphinx==7.1.2; python_version <= '3.9'", - "Sphinx==7.2.4; python_version >= '3.9'", + "Sphinx==7.2.5; python_version >= '3.9'", "sphinx-autobuild==2021.3.14", "sphinx-autodoc-typehints==1.24.0", "sphinx-copybutton==0.5.2", @@ -98,7 +98,7 @@ full = [ "numpy==1.21.6; python_version <= '3.9'", "numpy==1.25.2; python_version > '3.9'", "pandas==1.3.5; python_version <= '3.7'", - "pandas==2.0.3; python_version > '3.7'", + "pandas==2.1.0; python_version > '3.7'", "osmnx", "pyvista==0.41.1; python_version > '3.7'", "pyvista==0.38.0; python_version <= '3.7'", @@ -114,7 +114,7 @@ all = [ "numpy==1.21.6; python_version <= '3.9'", "numpy==1.25.2; python_version > '3.9'", "pandas==1.3.5; python_version <= '3.7'", - "pandas==2.0.3; python_version > '3.7'", + "pandas==2.1.0; python_version > '3.7'", "osmnx", "pyvista==0.41.1; python_version > '3.7'", "pyvista==0.38.0; python_version <= '3.7'",