-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConfigurations.py
144 lines (115 loc) · 3.82 KB
/
Configurations.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# # General: configuration files
#
# This example shows how you can use PyAEDT to export configuration files and reuse
# 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.
# ## Preparation
# Import the required packages
# +
import os
import tempfile
import time
import pyaedt
from pyaedt.generic.general_methods import generate_unique_name
# -
# Define constants
AEDT_VERSION = "2024.1"
NG_MODE = False # Open Electronics UI when the application is launched.
# ## Create temporary directory
temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")
# ## Download project
project_full_name = pyaedt.downloads.download_icepak(destination=temp_dir.name)
# ## Open project
#
# Open the Icepak project from the project folder.
ipk = pyaedt.Icepak(
project=project_full_name,
version=AEDT_VERSION,
new_desktop=True,
non_graphical=NG_MODE,
)
ipk.autosave_disable()
# ## Create source blocks
#
# Create a source block on the CPU and memories.
ipk.create_source_block(object_name="CPU", input_power="25W")
ipk.create_source_block(object_name=["MEMORY1", "MEMORY1_1"], input_power="5W")
# ## Assign boundaries
#
# Assign the opening and grille.
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)
# ## 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.
setup1 = ipk.create_setup()
setup1["FlowRegime"] = "Turbulent"
setup1["Max Iterations"] = 5
setup1["Solver Type Pressure"] = "flex"
setup1["Solver Type Temperature"] = "flex"
ipk.save_project()
# ## Export project to step file
#
# Export the current project to the step file.
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",
assignment_to_export=[],
assignment_to_remove=[],
)
# ## Export configuration files
#
# Export the configuration files. You can optionally disable the export and
# import sections. Supported formats are json and toml files
conf_file = ipk.configurations.export_config(
os.path.join(ipk.working_directory, "config.toml")
)
ipk.close_project()
# ## Create project
#
# Create an Icepak project and import the step.
new_project = os.path.join(temp_dir.name, "example.aedt")
app = pyaedt.Icepak(project=new_project)
app.modeler.import_3d_cad(file_path)
# ## 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.
out = app.configurations.import_config(conf_file)
app.configurations.results.global_import_success
# ## Release AEDT
# Close the project and release AEDT.
app.release_desktop()
time.sleep(3) # Allow Electronics Desktop to shut down before cleaning the temporary project folder.
# ## Cleanup
#
# All project files are saved in the folder ``temp_dir.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_dir.cleanup()