Skip to content

Commit

Permalink
New Microwave example
Browse files Browse the repository at this point in the history
Fix to MRI Example
  • Loading branch information
maxcapodi78 committed Jan 29, 2025
1 parent 64769c6 commit 19e0729
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
38 changes: 26 additions & 12 deletions examples/high_frequency/multiphysics/microwave_oven.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@
# +
working_dir = tempfile.TemporaryDirectory(suffix=".ansys")

#parasolid_path = ansys.aedt.core.downloads.download_file(
# source="oven", name="gingerbread.x_t", destination=working_dir.name
#)
#oven_path = ansys.aedt.core.downloads.download_file(
# source="oven", name="microwave_oven.aedt", destination=working_dir.name
#)
parasolid_path = ansys.aedt.core.downloads.download_file(
source="oven", name="gingerbread.x_t", destination=working_dir.name
)
oven_path = ansys.aedt.core.downloads.download_file(
source="oven", name="microwave_oven.aedt", destination=working_dir.name
)


parasolid_path = r'C:\ansysdev\repos\example-data\pyaedt\oven\gingerbread.x_t'
oven_path = r'C:\ansysdev\repos\example-data\pyaedt\oven\microwave_oven.aedt'


# -


# ## Launch HFSS
# Open AEDT and initialize the microwave oven project.
#
# After the project is opened, we save it in our working directory.

hfss = ansys.aedt.core.Hfss(version=AEDT_VERSION,
project=oven_path,
Expand All @@ -55,6 +55,7 @@
# ### Assign material
# This phase is fundamental because we need to assign correct material properties both, electrical and thermal.
#
# PyAEDT makes easy the creation and editing of a material using getter and setters. In this example we edit 5 parameters with their floating values.

ginger_material = hfss.materials.add_material(name="ginger_material")
ginger_material.permittivity = 41
Expand All @@ -65,7 +66,10 @@

# ### Import Gingerbread and assign material to it
# Once object is imported all its properties can be edited.
# In the example below the transparency and material name is changed.
#
# We are gonna move the gingerbread at the center of the plate and assign material to it.
#
# Finally, we are gonna change the transparency of the glass bowl.

hfss.modeler.import_3d_cad(input_file=parasolid_path)
ginger_biscuit = hfss.modeler["plateauPainEpices_Unnamed_5"]
Expand All @@ -74,10 +78,14 @@
hfss.modeler["glassBowl"].transparency = 0.75

# ### Export model picture for pdf report
# At the end of this example we will generate a pdf containing multiple info about all the workflow.
#
# Here we save the model picture as a png file.

hfss.post.export_model_picture(full_name=os.path.join(working_dir.name,'gingerbiscuit.png'))

# ## Launch Icepak
# In order to run a multiphysics analysis we need to create an Icepak project that will be coupled to HFSS and will get EM Losses from it.


ipk = ansys.aedt.core.Icepak(solution_type="Transient Thermal")
Expand All @@ -94,6 +102,9 @@
)

# ### Icepak boundaries
# Main thermal boundaries will be free opening of the microwave oven.
#
# In this example we will set 2 different types of openings on the two faces of the oven.

ipk.modeler["ovenCavity"].transparency = 1
ipk.assign_free_opening(assignment=ipk.modeler["ovenCavity"].top_face_y.id,
Expand All @@ -104,6 +115,7 @@


# #### Icepak MRF
# MRF assumes a mesh rotation of a solid block. In this example is useful to assume the rotation of the oven plate and the biscuit for a better cooking time.

rot_cyl= ipk.modeler.create_cylinder(orientation="Z",
origin=[158.75 ,228.6 ,0],
Expand All @@ -118,6 +130,7 @@
block.props["Is Cylinder MRF"]=True

# ### Icepak Mesh settings
# Mesh settings are important in Icepak to optimize the simulation time vs accuracy.

ipk.mesh.global_mesh_region.manual_settings = True
ipk.mesh.global_mesh_region.settings["MaxElementSizeX"] = "15mm"
Expand All @@ -128,6 +141,7 @@
ipk.mesh.global_mesh_region.update()

# ### Icepak Setup
# In this example we are limiting the number of steps to a maximum of 5 steps to make the example quick to run. Ideally this number has to be increased to improve the simulation accuracy and obtain more precise results.

setup = ipk.create_setup()
setup.props["SaveFieldsType"] = "Every N Steps"
Expand Down Expand Up @@ -295,6 +309,7 @@ def generate_temps(stop):


# ## Loop to determine transient time
# This is the core of our optimization process. We will increase the Icepak stop time by steps of 5 seconds until the mean temperature of the gingerbread reaches the 50 degrees. We could also have used an optimizer (Optislang) or run a longer time and plot the average temperature over time.

while not solved:
stop_time = stop_time + 5
Expand All @@ -319,6 +334,7 @@ def generate_temps(stop):
ipk.save_project()

# ## Generate PDF
# PyAEDT offers the possibility generate advanced pdf reports using a class called AnsysReport.

report.add_toc()
report.save_pdf(working_dir.name, "Gingerbread_ansys_recipe.pdf")
Expand All @@ -329,8 +345,6 @@ def generate_temps(stop):

ipk.save_project()
hfss.release_desktop()

# Wait 3 seconds to allow AEDT to shut down before cleaning the temporary directory.
time.sleep(3)

# ### Clean up
Expand Down
2 changes: 1 addition & 1 deletion examples/high_frequency/multiphysics/mri.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@
mesh_box.model = False
mesh_region = ipk.mesh.assign_mesh_region([mesh_box.name])
mesh_region.UserSpecifiedSettings = False
mesh_region.Level = 4
mesh_region.update()
mesh_region.properties["Mesh Resolution"] = 4

# ## Create point monitor
#
Expand Down

0 comments on commit 19e0729

Please sign in to comment.