.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\01-Modeling-Setup\Configurations.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_01-Modeling-Setup_Configurations.py: General: configuration files ---------------------------- This example shows how you can use PyAEDT to export configuration files and re-use them to import in a new project. A configuration file is supported by these applications: * HFSS * 2D Extractor and Q3D Extractor * Maxwell * Icepak (in AEDT) * Mechanical (in AEDT) The following sections are covered: * Variables * Mesh operations (except Icepak) * Setup and optimetrics * Material properties * Object properties * Boundaries and excitations When a boundary is attached to a face, the tool tries to match it with a ``FaceByPosition`` on the same object name on the target design. If, for any reason, this face position has changed or the object name in the target design has changed, the boundary fails to apply. .. GENERATED FROM PYTHON SOURCE LINES 29-32 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports from PyAEDT. .. GENERATED FROM PYTHON SOURCE LINES 32-36 .. code-block:: Python import os import pyaedt .. GENERATED FROM PYTHON SOURCE LINES 37-40 Set AEDT version ~~~~~~~~~~~~~~~~ Set AEDT version. .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: Python aedt_version = "2024.1" .. GENERATED FROM PYTHON SOURCE LINES 44-48 Set non-graphical mode ~~~~~~~~~~~~~~~~~~~~~~ Set non-graphical mode. You can set ``non_graphical`` either to ``True`` or ``False``. .. GENERATED FROM PYTHON SOURCE LINES 48-51 .. code-block:: Python non_graphical = False .. GENERATED FROM PYTHON SOURCE LINES 52-55 Open project ~~~~~~~~~~~~ Download the project, open it, and save it to the temporary folder. .. GENERATED FROM PYTHON SOURCE LINES 55-62 .. code-block:: Python project_full_name = pyaedt.downloads.download_icepak(pyaedt.generate_unique_folder_name(folder_name="Graphic_Card")) ipk = pyaedt.Icepak(projectname=project_full_name, specified_version=aedt_version, new_desktop_session=True, non_graphical=non_graphical) ipk.autosave_disable() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 63-66 Create source blocks ~~~~~~~~~~~~~~~~~~~~ Create a source block on the CPU and memories. .. GENERATED FROM PYTHON SOURCE LINES 66-70 .. code-block:: Python ipk.create_source_block(object_name="CPU", input_power="25W") ipk.create_source_block(object_name=["MEMORY1", "MEMORY1_1"], input_power="5W") .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 71-74 Assign boundaries ~~~~~~~~~~~~~~~~~ Assign the opening and grille. .. GENERATED FROM PYTHON SOURCE LINES 74-79 .. code-block:: Python region = ipk.modeler["Region"] ipk.assign_openings(air_faces=region.bottom_face_x.id) ipk.assign_grille(air_faces=region.top_face_x.id, free_area_ratio=0.8) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 80-85 Create setup ~~~~~~~~~~~~ Create the setup. Properties can be set up from the ``setup`` object with getters and setters. They don't have to perfectly match the property syntax. .. GENERATED FROM PYTHON SOURCE LINES 85-93 .. code-block:: Python setup1 = ipk.create_setup() setup1["FlowRegime"] = "Turbulent" setup1["Max Iterations"] = 5 setup1["Solver Type Pressure"] = "flex" setup1["Solver Type Temperature"] = "flex" ipk.save_project(r"C:\temp\Graphic_card.aedt") .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 94-97 Export project to step file ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Export the current project to the step file. .. GENERATED FROM PYTHON SOURCE LINES 97-103 .. code-block:: Python filename = ipk.design_name file_path = os.path.join(ipk.working_directory, filename + ".step") ipk.export_3d_model(file_name=filename, file_path=ipk.working_directory, file_format=".step", object_list=[], removed_objects=[]) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 104-108 Export configuration files ~~~~~~~~~~~~~~~~~~~~~~~~~~ Export the configuration files. You can optionally disable the export and import sections. Supported formats are json and toml files .. GENERATED FROM PYTHON SOURCE LINES 108-113 .. code-block:: Python conf_file = ipk.configurations.export_config(os.path.join(ipk.working_directory, "config.toml")) ipk.close_project() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 114-117 Create project ~~~~~~~~~~~~~~ Create an Icepak project and import the step. .. GENERATED FROM PYTHON SOURCE LINES 117-121 .. code-block:: Python app = pyaedt.Icepak(projectname="new_proj_Ipk") app.modeler.import_3d_cad(file_path) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 122-126 Import and apply configuration file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Import and apply the configuration file. You can apply all or part of the JSON file that you import using options in the ``configurations`` object. .. GENERATED FROM PYTHON SOURCE LINES 126-130 .. code-block:: Python out = app.configurations.import_config(conf_file) app.configurations.results.global_import_success .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 131-134 Close project ~~~~~~~~~~~~~ Close the project. .. GENERATED FROM PYTHON SOURCE LINES 134-136 .. code-block:: Python app.release_desktop() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 16.029 seconds) .. _sphx_glr_download_examples_01-Modeling-Setup_Configurations.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Configurations.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Configurations.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_