|
| 1 | +# # Short, Descriptive Title (do not specify the application name here, i.e.: Maxwell2D, Maxwell3D etc) |
| 2 | +# |
| 3 | +# Description: |
| 4 | +# |
| 5 | +# Most examples can be described as a series of steps that comprise a workflow. |
| 6 | +# 1. Import packages and instantiate the application. |
| 7 | +# 2. Do something useful and interesting. |
| 8 | +# 3. View the results. |
| 9 | +# |
| 10 | +# Keywords: **Template**, **Jupyter** |
| 11 | + |
| 12 | +# ## Perform required imports |
| 13 | +# |
| 14 | +# Perform required imports. |
| 15 | + |
| 16 | +import os |
| 17 | +import tempfile |
| 18 | +import time |
| 19 | + |
| 20 | +import ansys.aedt.core |
| 21 | + |
| 22 | +# ## Define constants |
| 23 | + |
| 24 | +AEDT_VERSION = "2024.2" |
| 25 | +NUM_CORES = 4 |
| 26 | +NG_MODE = False # Open Electronics UI when the application is launched. |
| 27 | + |
| 28 | +# ## Create temporary directory |
| 29 | +# |
| 30 | +# Create temporary directory. |
| 31 | +# If you'd like to retrieve the project data for subsequent use, |
| 32 | +# the temporary folder name is given by ``temp_folder.name``. |
| 33 | + |
| 34 | +temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") |
| 35 | + |
| 36 | +# ## Launch AEDT and application |
| 37 | +# |
| 38 | +# Create an instance of the application (i.e. ``Maxwell3d``,``Hfss`` etc) |
| 39 | +# class named (``m3d``,``hfss`` etc.) by providing |
| 40 | +# the project and design names, the solver, and the version. |
| 41 | + |
| 42 | +project_name = os.path.join(temp_folder.name, "my_project.aedt") |
| 43 | +m3d = ansys.aedt.core.Maxwell3d( |
| 44 | + project=project_name, |
| 45 | + design="my_design", |
| 46 | + solution_type="my_solver", |
| 47 | + version=AEDT_VERSION, |
| 48 | + non_graphical=NG_MODE, |
| 49 | + new_desktop=True, |
| 50 | +) |
| 51 | +m3d.modeler.model_units = "mm" |
| 52 | + |
| 53 | +# ## Pre-Processing |
| 54 | +# |
| 55 | +# Description of pre-processing task. |
| 56 | +# Add as many sections as needed for pre-processing tasks. |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +# ## Post-Processing |
| 61 | +# |
| 62 | +# Description of post-processing task. |
| 63 | +# Add as many sections as needed for post-processing tasks. |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | +# ## Release AEDT |
| 69 | + |
| 70 | +m3d.save_project() |
| 71 | +m3d.release_desktop() |
| 72 | +# Wait 3 seconds to allow Electronics Desktop to shut down before cleaning the temporary directory. |
| 73 | +time.sleep(3) |
| 74 | + |
| 75 | +# ## Cleanup |
| 76 | +# |
| 77 | +# All project files are saved in the folder ``temp_dir.name``. |
| 78 | +# If you've run this example as a Jupyter notebook you |
| 79 | +# can retrieve those project files. The following cell |
| 80 | +# removes all temporary files, including the project folder. |
| 81 | + |
| 82 | +temp_folder.cleanup() |
0 commit comments