HFSS-Mechanical Multiphysics Analysis

This example shows how to use Pyaedt to create a multiphysics workflow that includes Circuit, Hfss and Mechanical.

Import packages

Import needed packages.

import tempfile
import os
import shutil

from pyaedt import examples, generate_unique_name
from pyaedt import Hfss, Circuit, Mechanical

Open Project

Download Project, opens it and save to TEMP Folder.

Out:

'C:\\Users\\ansys\\AppData\\Local\\Temp\\Example_IDQU4C\\via_wizard.aedt'

Starts HFSS

Starts Hfss and initialize the Pyaedt object.

version = "2021.2"
hfss = Hfss(project_temp_name, specified_version=version)
pin_names = hfss.modeler.get_excitations_name()

Out:

Launching PyAEDT outside Electronics Desktop with CPython and Pythonnet
Launching AEDT installation C:\Program Files\AnsysEM\AnsysEM21.2\Win64
===================================================================================
pyaedt info: Launching AEDT with module Pythonnet.
pyaedt info: Ansoft.ElectronicsDesktop.2021.2 Started with process ID 5208.
pyaedt info: Logger Started on C:\Users\ansys\Documents\Ansoft\pyaedt20220120_155023.log
pyaedt info: pyaedt v0.5.dev1
pyaedt info: Python version 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
pyaedt info: Project via_wizard has been opened.
pyaedt info: Active design is set to HFSSDesign1
pyaedt.generic.LoadAEDTFile._read_aedt_file: 0.015555999999999999s
pyaedt info: AEDT Load time 0.09376168251037598
pyaedt info: Design Loaded
pyaedt info: Successfully loaded project materials !
pyaedt info: Materials Loaded

Starts Circuit

Starts Circuit and add Hfss dynamic link component to it.

circuit = Circuit()
hfss_comp = circuit.modeler.schematic.add_subcircuit_hfss_link("MyHfss", pin_names, hfss.project_file, hfss.design_name)

Out:

pyaedt info: No project is defined. Project via_wizard exists and has been read.
pyaedt info: No consistent unique design is present. Inserting a new design.
pyaedt.generic.LoadAEDTFile._read_aedt_file: 0.015621s
pyaedt info: AEDT Load time 0.09383010864257812
pyaedt info: Design Loaded
pyaedt info: Successfully loaded project materials !
pyaedt info: Materials Loaded

Create Ports and Excitations

Find Component pins locations adnd place interface port on it. Defines Voltage source on input port.

circuit.modeler.schematic.create_interface_port(
    "Excitation_1", [hfss_comp.pins[0].location[0], hfss_comp.pins[0].location[1]]
)
circuit.modeler.schematic.create_interface_port(
    "Excitation_2", [hfss_comp.pins[1].location[0], hfss_comp.pins[1].location[1]]
)
circuit.modeler.schematic.create_interface_port(
    "Port_1", [hfss_comp.pins[2].location[0], hfss_comp.pins[2].location[1]]
)
circuit.modeler.schematic.create_interface_port(
    "Port_2", [hfss_comp.pins[3].location[0], hfss_comp.pins[3].location[1]]
)

voltage = 1
phase = 0
excitation_settings = [str(voltage) + " V", str(phase) + " deg", "0V", "0V", "0V", "1GHz", "0s", "0", "0deg", "0Hz"]
ports_list = ["Excitation_1", "Excitation_2"]
circuit.assign_voltage_sinusoidal_excitation_to_ports(ports_list, excitation_settings)

Out:

pyaedt info: Voltage Source updated correctly.

True

Setup

Define Simulation Setup

setup_name = "MySetup"
LNA_setup = circuit.create_setup(setupname=setup_name)
bw_start = 4.3
bw_stop = 4.4
n_points = 1001
unit = "GHz"
sweep_list = ["LINC", str(bw_start) + unit, str(bw_stop) + unit, str(n_points)]
LNA_setup.props["SweepDefinition"]["Data"] = " ".join(sweep_list)
LNA_setup.update()

Out:

True

Solve and Push Excitation

Solve Circuit and Push Excitations to Hfss model to get right value of losses.

circuit.analyze_nominal()

circuit.push_excitations(instance_name="S1", setup_name=setup_name)

Out:

pyaedt info: Solving design setup MySetup
pyaedt info: Design setup MySetup solved correctly

True

Starts Mechanical

Starts Mechanical and copy bodies from Hfss Project.

mech = Mechanical()
mech.copy_solid_bodies_from(hfss)

Out:

pyaedt info: No project is defined. Project via_wizard exists and has been read.
pyaedt info: No consistent unique design is present. Inserting a new design.
pyaedt.generic.LoadAEDTFile._read_aedt_file: 0.015552s
pyaedt info: AEDT Load time 0.09368228912353516
pyaedt info: Design Loaded
pyaedt info: Successfully loaded project materials !
pyaedt info: Materials Loaded

True

Boundaries and Excitations

Get losses from Hfss and assign Convection to Mechanical.

mech.assign_em_losses(
    hfss.design_name,
    hfss.setups[0].name,
    "LastAdaptive",
    hfss.setups[0].props["Frequency"],
    surface_objects=hfss.get_all_conductors_names(),
)
diels = ["1_pd", "2_pd", "3_pd", "4_pd", "5_pd"]
for el in diels:
    mech.assign_uniform_convection(
        [mech.modeler.primitives[el].top_face_y, mech.modeler.primitives[el].bottom_face_y], 3
    )

Out:

pyaedt info: Mapping HFSS EM Lossess
pyaedt info: EM losses mapped from design HFSSDesign1.

Plot the model

mech.plot(show=False, export_path=os.path.join(mech.working_directory, "Mech.jpg"), plot_air_objects=False)
Hfss Mechanical

Out:

<pyaedt.modules.AdvancedPostProcessing.ModelPlotter object at 0x000001D051F0EBE0>

Solution

Solve and Plot Thermal results

mech.create_setup()
mech.save_project()
mech.analyze_nominal()
surfaces = []
for name in mech.get_all_conductors_names():
    surfaces.extend(mech.modeler.primitives.get_object_faces(name))
mech.post.create_fieldplot_surface(surfaces, "Temperature")

Out:

pyaedt info: Saving via_wizard Project
pyaedt info: Solving design setup MySetupAuto
pyaedt info: Design setup MySetupAuto solved correctly

<pyaedt.modules.PostProcessor.FieldPlot object at 0x000001D05E6FC3D0>

Exit

Release Desktop and Exit.

mech.release_desktop(True, True)

Out:

True

Total running time of the script: ( 3 minutes 5.513 seconds)

Gallery generated by Sphinx-Gallery