Skip to content

Commit a7e1cba

Browse files
authored
FIX: Add Quantity class methods to perform unit conversion (#403)
1 parent 6212551 commit a7e1cba

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

examples/low_frequency/general/field_export.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,16 @@
142142
# Fields data is exported to the temporary folder as an AEDTPLT file.
143143

144144
for time_step in time_steps:
145-
t = ansys.aedt.core.generic.constants.unit_converter(
146-
time_step,
147-
unit_system="Time",
148-
input_units=data.units_sweeps["Time"],
149-
output_units="ms",
150-
)
145+
time_step = time_step.to("ms")
146+
151147
m3d.post.create_fieldplot_surface(
152148
assignment=m3d.modeler.objects_by_name["Coil_A2"],
153149
quantity=quantity[0],
154-
plot_name="J_{}_ms".format(t),
155-
intrinsics={"Time": "{}ms".format(t)},
150+
plot_name="J_{}_ms".format(time_step.value),
151+
intrinsics={"Time": time_step.expression},
156152
)
157153
mean_j_field_export = m3d.post.export_field_plot(
158-
plot_name="J_{}_ms".format(t),
154+
plot_name="J_{}_ms".format(time_step.value),
159155
output_dir=temp_folder.name,
160156
file_format="aedtplt",
161157
)
@@ -164,11 +160,11 @@
164160
o for o in m3d.modeler.solid_objects if o.material_name == "copper"
165161
],
166162
quantity="Mag_J",
167-
plot_name="Mag_J_Coils_{}_ms".format(t),
168-
intrinsics={"Time": "{}ms".format(t)},
163+
plot_name="Mag_J_Coils_{}_ms".format(time_step.value),
164+
intrinsics={"Time": time_step.expression},
169165
)
170166
mag_j_field_export = m3d.post.export_field_plot(
171-
plot_name="Mag_J_Coils_{}_ms".format(t),
167+
plot_name="Mag_J_Coils_{}_ms".format(time_step.value),
172168
output_dir=temp_folder.name,
173169
file_format="aedtplt",
174170
)

0 commit comments

Comments
 (0)