Skip to content

Commit 31f8dec

Browse files
Update SBR (#184)
Make consistent with template. Co-authored-by: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com>
1 parent 1f0336f commit 31f8dec

File tree

4 files changed

+65
-57
lines changed

4 files changed

+65
-57
lines changed

examples/02-SBR+/SBR_City_Import.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@
1818
# Set constant values
1919

2020
AEDT_VERSION = "2024.1"
21-
22-
# ## Set non-graphical mode
23-
#
24-
# Set non-graphical mode.
25-
# You can set ``non_graphical`` either to ``True`` or ``False``.
26-
27-
non_graphical = False
21+
NG_MODE = False # Open Electronics UI when the application is launched.
2822

2923
# ## Create temporary directory
3024

@@ -34,14 +28,14 @@
3428
#
3529
# Launch HFSS and open the project.
3630

37-
project_name = pyaedt.generate_unique_project_name(rootname=temp_dir.name, project_name="city")
31+
project_name = os.path.join(temp_dir.name, "city.aedt")
3832
app = pyaedt.Hfss(
3933
project=project_name,
4034
design="Ansys",
4135
solution_type="SBR+",
4236
version=AEDT_VERSION,
4337
new_desktop=True,
44-
non_graphical=non_graphical,
38+
non_graphical=NG_MODE,
4539
)
4640

4741
# ## Define Location to import
@@ -55,7 +49,11 @@
5549
# Assign boundaries.
5650

5751
app.modeler.import_from_openstreet_map(
58-
ansys_home, terrain_radius=250, road_step=3, plot_before_importing=False, import_in_aedt=True
52+
ansys_home,
53+
terrain_radius=250,
54+
road_step=3,
55+
plot_before_importing=False,
56+
import_in_aedt=True,
5957
)
6058

6159
# ## Plot model
@@ -76,6 +74,9 @@
7674

7775
app.release_desktop()
7876

79-
# ## Clean temporary directory
77+
# ## Cleanup
78+
#
79+
# All project files are saved in the folder ``temp_dir.name``. If you've run this example as a Jupyter notebook you
80+
# can retrieve those project files. The following cell removes all temporary files, including the project folder.
8081

8182
temp_dir.cleanup()

examples/02-SBR+/SBR_Doppler_Example.py

+35-23
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@
1717
# Set constant values
1818

1919
AEDT_VERSION = "2024.1"
20-
21-
# ## Set non-graphical mode
22-
#
23-
# Set non-graphical mode.
24-
# You can set ``non_graphical`` either to ``True`` or ``False``.
25-
26-
non_graphical = False
20+
NG_MODE = False # Open Electronics UI when the application is launched.
2721

2822
# ## Create temporary directory
2923

@@ -38,16 +32,19 @@
3832
#
3933
# Launch HFSS and open the project.
4034

41-
project_name = pyaedt.generate_unique_project_name(rootname=temp_dir.name, project_name="doppler")
35+
project_name = os.path.join(temp_dir.name, "doppler.aedt")
4236
app = pyaedt.Hfss(
4337
version=AEDT_VERSION,
4438
solution_type="SBR+",
4539
new_desktop=True,
4640
project=project_name,
4741
close_on_exit=True,
48-
non_graphical=non_graphical,
42+
non_graphical=NG_MODE,
4943
)
5044

45+
# Creation of the "actors" in the scene is comprised of many editing steps. Disabling the "autosave" option helps
46+
# avoids delays that occur while the project is being saved.
47+
5148
app.autosave_disable()
5249

5350
# ## Save project and rename design
@@ -60,7 +57,7 @@
6057

6158
# ## Set up library paths
6259
#
63-
# Set up library paths to 3D components.
60+
# Specify the location of 3D components used to create the scene.
6461

6562
actor_lib = os.path.join(library_path, "actor_library")
6663
env_lib = os.path.join(library_path, "environment_library")
@@ -75,7 +72,7 @@
7572
#
7673
# Define the background environment.
7774

78-
road1 = app.modeler.add_environment(env_folder=env_folder, environment_name="Bari")
75+
road1 = app.modeler.add_environment(input_dir=env_folder, name="Bari")
7976
prim = app.modeler
8077

8178
# ## Place actors
@@ -84,37 +81,45 @@
8481
# in the environment.
8582

8683
person1 = app.modeler.add_person(
87-
actor_folder=person_folder, speed=1.0, global_offset=[25, 1.5, 0], yaw=180, actor_name="Massimo"
84+
input_dir=person_folder,
85+
speed=1.0,
86+
global_offset=[25, 1.5, 0],
87+
yaw=180,
88+
name="Massimo",
8889
)
8990
person2 = app.modeler.add_person(
90-
actor_folder=person_folder, speed=1.0, global_offset=[25, 2.5, 0], yaw=180, actor_name="Devin"
91+
input_dir=person_folder,
92+
speed=1.0,
93+
global_offset=[25, 2.5, 0],
94+
yaw=180,
95+
name="Devin",
9196
)
9297
car1 = app.modeler.add_vehicle(
93-
actor_folder=car_folder, speed=8.7, global_offset=[3, -2.5, 0], actor_name="LuxuryCar"
98+
input_dir=car_folder, speed=8.7, global_offset=[3, -2.5, 0], name="LuxuryCar"
9499
)
95100
bike1 = app.modeler.add_vehicle(
96-
actor_folder=bike_folder,
101+
input_dir=bike_folder,
97102
speed=2.1,
98103
global_offset=[24, 3.6, 0],
99104
yaw=180,
100-
actor_name="Alberto_in_bike",
105+
name="Alberto_in_bike",
101106
)
102107
bird1 = app.modeler.add_bird(
103-
actor_folder=bird_folder,
108+
input_dir=bird_folder,
104109
speed=1.0,
105110
global_offset=[19, 4, 3],
106111
yaw=120,
107112
pitch=-5,
108113
flapping_rate=30,
109-
actor_name="Pigeon",
114+
name="Pigeon",
110115
)
111116
bird2 = app.modeler.add_bird(
112-
actor_folder=bird_folder,
117+
input_dir=bird_folder,
113118
speed=1.0,
114119
global_offset=[6, 2, 3],
115120
yaw=-60,
116121
pitch=10,
117-
actor_name="Eagle",
122+
name="Eagle",
118123
)
119124

120125
# ## Place radar
@@ -124,7 +129,7 @@
124129

125130
radar1 = app.create_sbr_radar_from_json(
126131
radar_file=radar_lib,
127-
radar_name="Example_1Tx_1Rx",
132+
name="Example_1Tx_1Rx",
128133
offset=[2.57, 0, 0.54],
129134
use_relative_cs=True,
130135
relative_cs_name=car1.cs_name,
@@ -145,22 +150,29 @@
145150
# Plot the model.
146151

147152
app.plot(
148-
show=False, export_path=os.path.join(app.working_directory, "Image.jpg"), plot_air_objects=True
153+
show=False,
154+
export_path=os.path.join(app.working_directory, "Image.jpg"),
155+
plot_air_objects=True,
149156
)
150157

151158
# ## Solve and release AEDT
152159
#
153160
# Solve and release AEDT. To solve, uncomment the ``app.analyze_setup`` command
154161
# to activate the simulation.
155162

163+
# +
156164
# app.analyze_setup(sweep.name)
165+
# -
157166

158167
# ## Release AEDT
159168
#
160169
# Release AEDT and close the example.
161170

162171
app.release_desktop()
163172

164-
# ## Clean temporary directory
173+
# ## Cleanup
174+
#
175+
# All project files are saved in the folder ``temp_dir.name``. If you've run this example as a Jupyter notebook you
176+
# can retrieve those project files. The following cell removes all temporary files, including the project folder.
165177

166178
temp_dir.cleanup()

examples/02-SBR+/SBR_Example.py

+11-14
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@
1919

2020
AEDT_VERSION = "2024.1"
2121
NUM_CORES = 4
22-
23-
# ## Set non-graphical mode
24-
#
25-
# Set non-graphical mode.
26-
# You can set ``non_graphical`` either to ``True`` or ``False``.
27-
28-
non_graphical = False
22+
NG_MODE = False # Open Electronics UI when the application is launched.
2923

3024
# ## Create temporary directory
3125

@@ -47,7 +41,7 @@
4741
solution_type="SBR+",
4842
version=AEDT_VERSION,
4943
new_desktop=True,
50-
non_graphical=non_graphical,
44+
non_graphical=NG_MODE,
5145
)
5246

5347
source = pyaedt.Hfss(
@@ -61,7 +55,9 @@
6155
#
6256
# Define a linked antenna. This is HFSS far field applied to HFSS SBR+.
6357

64-
target.create_sbr_linked_antenna(source, target_cs="feederPosition", fieldtype="farfield")
58+
target.create_sbr_linked_antenna(
59+
source, target_cs="feederPosition", fieldtype="farfield"
60+
)
6561

6662
# ## Assign boundaries
6763
#
@@ -98,9 +94,9 @@
9894
setup1["RangeStart"] = "10GHz"
9995
target.analyze(num_cores=NUM_CORES)
10096

101-
# ## Plot results
97+
# ## Post-processing
10298
#
103-
# Plot results.
99+
# Plot results in Electronics Desktop.
104100

105101
variations = target.available_variations.nominal_w_values_dict
106102
variations["Freq"] = ["10GHz"]
@@ -115,8 +111,6 @@
115111
report_category="Far Fields",
116112
)
117113

118-
# ## Plot results outside AEDT
119-
#
120114
# Plot results using Matplotlib.
121115

122116
solution = target.post.get_solution_data(
@@ -135,6 +129,9 @@
135129

136130
target.release_desktop()
137131

138-
# ## Clean temporary directory
132+
# ## Cleanup
133+
#
134+
# All project files are saved in the folder ``temp_dir.name``. If you've run this example as a Jupyter notebook you
135+
# can retrieve those project files. The following cell removes all temporary files, including the project folder.
139136

140137
temp_dir.cleanup()

examples/02-SBR+/SBR_Time_Plot.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,9 @@
1818

1919
AEDT_VERSION = "2024.1"
2020
NUM_CORES = 4
21+
NG_MODE = False # Open Electronics UI when the application is launched.
2122

2223

23-
# ## Set non-graphical mode
24-
#
25-
# Set non-graphical mode.
26-
# You can set ``non_graphical`` either to ``True`` or ``False``.
27-
28-
non_graphical = False
29-
3024
# ## Create temporary directory
3125

3226
temp_dir = tempfile.TemporaryDirectory(suffix="_ansys")
@@ -41,7 +35,7 @@
4135
hfss = Hfss(
4236
project=project_file,
4337
version=AEDT_VERSION,
44-
non_graphical=non_graphical,
38+
non_graphical=NG_MODE,
4539
new_desktop=True,
4640
)
4741

@@ -93,8 +87,12 @@
9387
#
9488
# Release AEDT and close the example.
9589

90+
hfss.save_project()
9691
hfss.release_desktop()
9792

98-
# ## Clean temporary directory
93+
# ## Cleanup
94+
#
95+
# All project files are saved in the folder ``temp_dir.name``. If you've run this example as a Jupyter notebook you
96+
# can retrieve those project files. The following cell removes all temporary files, including the project folder.
9997

10098
temp_dir.cleanup()

0 commit comments

Comments
 (0)