Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lorentz actuator example #125

Merged
merged 21 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
65a91ca
Lorentz actuator example
IreneWoyna May 17, 2024
76a5b22
Merge branch 'refs/heads/main' into add/Maxwell_lorentz_actuator
anur7 Aug 29, 2024
63767e9
Merge branch 'refs/heads/main' into add/Maxwell_lorentz_actuator
anur7 Aug 29, 2024
1d5fd1b
adding in example list, adding the file in the right folder
anur7 Aug 29, 2024
4747018
adding in example list, adding the file in the right folder, cleaning…
anur7 Aug 29, 2024
7d5295b
adding in example list, adding the file in the right folder, cleaning…
anur7 Aug 29, 2024
6ac085a
Merge branch 'refs/heads/main' into add/Maxwell_lorentz_actuator
anur7 Aug 29, 2024
b8081da
Merge branch 'refs/heads/main' into add/Maxwell_lorentz_actuator
anur7 Aug 30, 2024
b079eed
Merge branch 'main' into add/Maxwell_lorentz_actuator
gmalinve Aug 30, 2024
6f5f746
Merge remote-tracking branch 'origin/add/Maxwell_lorentz_actuator' in…
anur7 Aug 30, 2024
1b36e15
some minor correction on the reviewed parts
anur7 Aug 30, 2024
116076d
Merge branch 'refs/heads/main' into add/Maxwell_lorentz_actuator
anur7 Sep 2, 2024
9ad72b2
some minor correction on the reviewed parts
anur7 Sep 2, 2024
add91f2
update latest pyaedt changes
gmalinve Sep 9, 2024
499ccac
update args
gmalinve Sep 9, 2024
41df802
comment
gmalinve Sep 9, 2024
8c4ae74
comments
gmalinve Sep 9, 2024
e33455f
comments
gmalinve Sep 9, 2024
10249b7
Merge branch 'refs/heads/main' into add/Maxwell_lorentz_actuator
gmalinve Sep 10, 2024
63faaaf
fix merge mistakes and move actuator example
gmalinve Sep 10, 2024
2f1e33f
fix merge mistakes and move actuator example
gmalinve Sep 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/04-low_frequency/magnetic/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ These examples use PyAEDT to show some magnetics examples
choke.py
magneto_motive_contour.py
magneto_motive_line.py
lorentz_actuator.py
324 changes: 324 additions & 0 deletions examples/04-low_frequency/magnetic/lorentz_actuator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
# # Lorentz actuator
#
# This example uses PyAEDT to set up a Lorentz actuator
# and solve it using the Maxwell 2D transient solver.
#
# Keywords: **Maxwell2D**, **Transient**, **translational motion**, **mechanical transient**

# ## 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")

# ## Initialize dictionaries
#
# Initialize electric and geometric parameters for the actuator.
# Initialize simulation specification.
# Initialize materials for the actuator component.

dimensions = {
"Core_outer_x": "100mm",
"Core_outer_y": "80mm",
"Core_thickness": "10mm",
"Magnet_thickness": "10mm",
"Coil_width": "30mm",
"Coil_thickness": "5mm",
"Coil_inner_diameter": "20mm",
"Coil_magnet_distance": "5mm",
"Coil_start_position": "3mm",
"Band_clearance": "1mm",
}

coil_specifications = {
"Winding_current": "5A",
"No_of_turns": "100",
"Coil_mass": "0.2kg",
}

simulation_specifications = {
"Mesh_bands": "0.5mm",
"Mesh_other_objects": "2mm",
"Stop_time": "10ms",
"Time_step": "0.5ms",
"Save_fields_interval": "1",
}

materials = {
"Coil_material": "copper",
"Core_material": "steel_1008",
"Magnet_material": "NdFe30",
}

# ## Launch AEDT and Maxwell 2D
#
# Launch AEDT and Maxwell 2D after first setting up the project name.
# The following code also creates an instance of the
# ``Maxwell2d`` class named ``m2d`` by providing
# the project name, the design name, the solver, the version and the graphical mode.

project_name = os.path.join(temp_folder.name, "Lorentz_actuator.aedt")
m2d = ansys.aedt.core.Maxwell2d(
project=project_name,
design="1 transient 2D",
solution_type="TransientXY",
version=AEDT_VERSION,
non_graphical=NG_MODE,
)

# ## Define variables from dictionaries
#
# Define design variables from the created dictionaries.

m2d.variable_manager.set_variable(name="Dimensions")
for k, v in dimensions.items():
m2d[k] = v

m2d.variable_manager.set_variable(name="Winding data")
for k, v in coil_specifications.items():
m2d[k] = v

m2d.variable_manager.set_variable(name="Simulation data")
for k, v in simulation_specifications.items():
m2d[k] = v

# Materials.

m2d.variable_manager.set_variable(name="Material data")
m2d.logger.clear_messages()
for i, key in enumerate(materials.keys()):
if key == "Coil_material":
coil_mat_index = i
elif key == "Core_material":
core_mat_index = i
elif key == "Magnet_material":
magnet_mat_index = i
material_array = []
for k, v in materials.items():
material_array.append('"' + v + '"')
s = ", ".join(material_array)
m2d["Materials"] = "[{}]".format(s)

# ## Create geometry
#
# Create magnetic core, coils, and magnets. Assign materials and create a new coordinate system to
# define the magnet orientation.

core_id = m2d.modeler.create_rectangle(
origin=[0, 0, 0],
sizes=["Core_outer_x", "Core_outer_y"],
name="Core",
material="Materials[" + str(core_mat_index) + "]",
)

hole_id = m2d.modeler.create_rectangle(
origin=["Core_thickness", "Core_thickness", 0],
sizes=["Core_outer_x-2*Core_thickness", "Core_outer_y-2*Core_thickness"],
name="hole",
)
m2d.modeler.subtract(blank_list=[core_id], tool_list=[hole_id])

magnet_n_id = m2d.modeler.create_rectangle(
origin=["Core_thickness", "Core_outer_y-2*Core_thickness", 0],
sizes=["Core_outer_x-2*Core_thickness", "Magnet_thickness"],
name="magnet_n",
material="Materials[" + str(magnet_mat_index) + "]",
)
magnet_s_id = m2d.modeler.create_rectangle(
origin=["Core_thickness", "Core_thickness", 0],
sizes=["Core_outer_x-2*Core_thickness", "Magnet_thickness"],
name="magnet_s",
material="Materials[" + str(magnet_mat_index) + "]",
)

m2d.modeler.create_coordinate_system(
origin=[0, 0, 0], x_pointing=[0, 1, 0], y_pointing=[1, 0, 0], name="cs_x_positive"
)
m2d.modeler.create_coordinate_system(
origin=[0, 0, 0], x_pointing=[0, -1, 0], y_pointing=[1, 0, 0], name="cs_x_negative"
)
magnet_s_id.part_coordinate_system = "cs_x_positive"
magnet_n_id.part_coordinate_system = "cs_x_negative"
m2d.modeler.set_working_coordinate_system("Global")

# ## Assign current
#
# Create coil terminals with 100 turns and winding with 5A current.

coil_in_id = m2d.modeler.create_rectangle(
origin=[
"Core_thickness+Coil_start_position",
"Core_thickness+Magnet_thickness+Coil_magnet_distance",
0,
],
sizes=["Coil_width", "Coil_thickness"],
name="coil_in",
material="Materials[" + str(coil_mat_index) + "]",
)
coil_out_id = m2d.modeler.create_rectangle(
origin=[
"Core_thickness+Coil_start_position",
"Core_thickness+Magnet_thickness+Coil_magnet_distance+Coil_inner_diameter+Coil_thickness",
0,
],
sizes=["Coil_width", "Coil_thickness"],
name="coil_out",
material="Materials[" + str(coil_mat_index) + "]",
)

m2d.assign_coil(
assignment=[coil_in_id],
conductors_number="No_of_turns",
name="coil_terminal_in",
polarity="Negative",
)
m2d.assign_coil(
assignment=[coil_out_id],
conductors_number="No_of_turns",
name="coil_terminal_out",
polarity="Positive",
)
m2d.assign_winding(is_solid=False, current="Winding_current", name="Winding1")
m2d.add_winding_coils(
assignment="Winding1", coils=["coil_terminal_in", "coil_terminal_out"]
)

# ## Assign motion
#
# Create band objects: all the objects within the band move. Inner band ensures that the mesh is good,
# and additionally it is required when there more than 1 moving objects.
# Assign linear motion with mechanical transient.

band_id = m2d.modeler.create_rectangle(
origin=[
"Core_thickness + Band_clearance",
"Core_thickness+Magnet_thickness+Band_clearance",
0,
],
sizes=[
"Core_outer_x-2*(Core_thickness+Band_clearance)",
"Core_outer_y-2*(Core_thickness+Band_clearance+Magnet_thickness)",
],
name="Motion_band",
)
inner_band_id = m2d.modeler.create_rectangle(
origin=[
"Core_thickness+Coil_start_position-Band_clearance",
"Core_thickness+Magnet_thickness+Coil_magnet_distance-Band_clearance",
0,
],
sizes=[
"Coil_width + 2*Band_clearance",
"Coil_inner_diameter+2*(Coil_thickness+Band_clearance)",
],
name="Motion_band_inner",
)
motion_limit = "Core_outer_x-2*(Core_thickness+Band_clearance)-(Coil_width + 2*Band_clearance)-2*Band_clearance"
m2d.assign_translate_motion(
assignment="Motion_band",
axis="X",
periodic_translate=None,
mechanical_transient=True,
mass="Coil_mass",
start_position=0,
negative_limit=0,
positive_limit=motion_limit,
)

# ## Create simulation domain
#
# Create region and assign zero vector potential on the region edges.

region_id = m2d.modeler.create_region(pad_percent=2)
m2d.assign_vector_potential(assignment=region_id.edges, boundary="VectorPotential1")

# ## Assign mesh operations
#
# Transient solver does not have adaptive mesh refinement, so the mesh operations have to be assigned.

m2d.mesh.assign_length_mesh(
assignment=[band_id, inner_band_id],
maximum_length="Mesh_bands",
maximum_elements=None,
name="Bands",
)
m2d.mesh.assign_length_mesh(
assignment=[coil_in_id, coil_in_id, core_id, magnet_n_id, magnet_s_id, region_id],
maximum_length="Mesh_other_objects",
maximum_elements=None,
name="Coils_core_magnets",
)

# ## Turn on eddy effects
#
# Assign eddy effects to magnets.

m2d.eddy_effects_on(assignment=["magnet_n", "magnet_s"])

# ## Turn on core loss
#
# Enable core loss for core.

m2d.set_core_losses(assignment="Core")

# ## Create setup
#
# Create the simulation setup.

setup = m2d.create_setup(name="Setup1")
setup.props["StopTime"] = "Stop_time"
setup.props["TimeStep"] = "Time_step"
setup.props["SaveFieldsType"] = "Every N Steps"
setup.props["N Steps"] = "Save_fields_interval"
setup.props["Steps From"] = "0ms"
setup.props["Steps To"] = "Stop_time"

# ## Create report
#
# Create a XY-report with force on coil and the position of the coil on Y-axis, time on X-axis.

m2d.post.create_report(
expressions=["Moving1.Force_x", "Moving1.Position"],
plot_name="Force on Coil and Position of Coil",
primary_sweep_variable="Time",
)

# ## Analyze project
#
# Analyze the project.

setup.analyze(cores=NUM_CORES, use_auto_settings=False)

# ## Release AEDT

m2d.save_project()
m2d.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_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_folder.cleanup()
Binary file modified examples/06-AEDT/_static/aedt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/06-AEDT/emit/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ These examples use PyAEDT to show EMIT capabilities
../../03-high_frequency/antenna/interferences/hfss_emit.py
../../03-high_frequency/antenna/interferences/interference.py
../../03-high_frequency/antenna/interferences/interference_type.py
../../03-high_frequency/antenna/interferences/protection.py
../../03-high_frequency/antenna/interferences/protection.py
2 changes: 1 addition & 1 deletion examples/06-AEDT/hfss/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ These examples use PyAEDT to show HFSS capabilities
../../03-high_frequency/radiofrequency_mmwave/iris_filter.py
../../03-high_frequency/radiofrequency_mmwave/spiral.py
../../05-electrothermal/coaxial_hfss_icepak.py
../../05-electrothermal/icepak_circuit_hfss_coupling.py
../../05-electrothermal/icepak_circuit_hfss_coupling.py
2 changes: 1 addition & 1 deletion examples/06-AEDT/hfss_3d_layout/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ These examples use PyAEDT to show HFSS 3D Layout capabilities
../../03-high_frequency/layout/power_integrity/power_integrity.py
../../03-high_frequency/layout/signal_integrity/pre_layout.py
../../03-high_frequency/layout/signal_integrity/pre_layout_parametrized.py
../../03-high_frequency/layout/gui_manipulation.py
../../03-high_frequency/layout/gui_manipulation.py
3 changes: 2 additions & 1 deletion examples/06-AEDT/maxwell_2d/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ These examples use PyAEDT to show Maxwell 2D capabilities
../../04-low_frequency/magnetic/magneto_motive_contour.py
../../04-low_frequency/magnetic/magneto_motive_line.py
../../04-low_frequency/magnetic/transient_winding.py
../../04-low_frequency/magnetic/lorentz_actuator.py
../../04-low_frequency/motor/aedt_motor/pm_synchronous.py
../../04-low_frequency/motor/aedt_motor/rmxpert.py
../../04-low_frequency/motor/aedt_motor/transformer_inductance.py
../../04-low_frequency/motor/aedt_motor/transformer_inductance.py
3 changes: 1 addition & 2 deletions examples/06-AEDT/misc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ These examples use PyAEDT to show miscellaneous capabilities

../../02-aedt_general/report/touchstone_file.py
../../03-high_frequency/layout/signal_integrity/com_analysis.py
../../03-high_frequency/radiofrequency_mmwave/lumped_element.py

../../03-high_frequency/radiofrequency_mmwave/lumped_element.py
5 changes: 2 additions & 3 deletions examples/06-AEDT/q3d_q2d/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Circuit
Q2D-Q3D
~~~~~~~

These examples use PyAEDT to show Q3D and 2D Extractor capabilities
Expand All @@ -10,5 +10,4 @@ These examples use PyAEDT to show Q3D and 2D Extractor capabilities
../../03-high_frequency/layout/ac_q3d.py
../../03-high_frequency/layout/dcir_q3d.py
../../03-high_frequency/radiofrequency_mmwave/coplanar_waveguide.py
../../03-high_frequency/radiofrequency_mmwave/stripline.py

../../03-high_frequency/radiofrequency_mmwave/stripline.py
2 changes: 1 addition & 1 deletion examples/06-AEDT/twin_builder/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ These examples use PyAEDT to show Twin Builder capabilities
../../04-low_frequency/general/twin_builder/dynamic_rom.py
../../04-low_frequency/general/twin_builder/rc_circuit.py
../../04-low_frequency/general/twin_builder/rectifier.py
../../04-low_frequency/general/twin_builder/static_rom.py
../../04-low_frequency/general/twin_builder/static_rom.py
Loading