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