Replies: 2 comments
-
Hi @ZiadHatab, You can use the method "add_mesh_link". |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks @Samuelopez-ansys for the answer. mesh link works well when I do it manually through the GUI, but when I do it through scripting I get a different mesh (I compare the meshes of the two solutions in the mesh statistic window) Here is my code: import pyaedt
import numpy as np
import matplotlib.pyplot as plt
if __name__ == '__main__':
#aedt_version = "2024.2"
project_name = pyaedt.generate_unique_project_name(project_name='transmission_line')
print("Project name " + project_name)
hfss = pyaedt.Hfss(project=project_name,
#version=aedt_version,
design='microstrip',
non_graphical=False,
new_desktop=True,
solution_type='Modal',
close_on_exit=True,
)
hfss.change_material_override(True)
hfss.change_automatically_use_causal_materials(False)
hfss.modeler.model_units = 'meter'
hfss.mesh.assign_initial_mesh_from_slider(applycurvilinear=True)
# create material
isola_tachyon = hfss.materials.add_material('isola_tachyon')
isola_tachyon.conductivity = '0'
isola_tachyon.permittivity = '3'
isola_tachyon.permeability = '1'
isola_tachyon.dielectric_loss_tangent = '0.002'
isola_tachyon.material_appearance = [64,128,128,0]
isola_tachyon.update()
# parameters
line_length = 1e-3
sub_height = 0.1e-3
trace_thickness = 0.02e-3
sig_width = 0.24e-3
sub_width = 4e-3
port_height = 8*sub_height
# draw the substrate
sub = hfss.modeler.create_box(origin=[-sub_width/2,0,0],
sizes=[sub_width,sub_height,line_length],
material='isola_tachyon',
name='SUB')
sub.transparency = 0
# draw the signal line
sig = hfss.modeler.create_box(origin=[-sig_width/2,sub_height,0],
sizes=[sig_width,trace_thickness,line_length],
material='copper',
name='SIG')
# draw the ground plane
gnd = hfss.modeler.create_box(origin=[-sub_width/2,0,0],
sizes=[sub_width,-trace_thickness,line_length],
material='copper',
name='GND')
# draw the port and assign wave-port
port = hfss.modeler.create_polyline(points=[(-sub_width/2,0,0), (sub_width/2,0,0)],
name='PORT').sweep_along_vector(sweep_vector=[0,port_height,0])
P1 = hfss.wave_port(port, integration_line=[(0,sub_height,0),(0,0,0)],
modes=1, renormalize=False, deembed=0,
name='P1')
P1['Modes/Mode1/CharImp'] = 'Zpi' # define characteristic impedance type
# create air region
air = hfss.modeler.create_region(pad_value=[0,0,100,0,0,0], pad_type='Percentage Offset',
name='AIRBOX')
hfss.assign_radiation_boundary_to_objects(air, name='Radiation')
# define simulation setup
# first setup which we want to copy its mesh
setup1 = hfss.create_setup('setup1')
setup1.enable_adaptive_setup_single(freq='80GHz', max_passes=30)
setup1.props['SolveType'] = 'PortsOnly'
setup1.props['PortAccuracy'] = 0.01
setup1.analyze(cores=4, gpus=1)
# second setup "mesh-linked" to setup1
setup2 = hfss.create_setup('setup2')
setup2.enable_adaptive_setup_single(freq='80GHz')
setup2.props['SolveType'] = 'PortsOnly'
setup2.props['PortAccuracy'] = 0.01
setup2.props['DoLambdaRefine'] = False
setup2.add_mesh_link(design = hfss.design_name)
setup2.props['MeshLink']['Soln'] = 'setup1 : PortOnly'
# discrete sweep using sweep2
f = np.arange(2, 110.1, 2)*1e9
freq = f.tolist()
sweep = setup2.create_single_point_sweep(unit='Hz', freq=freq,
save_single_field=False, save_fields=False, name='Single')
setup2.analyze(cores=4, gpus=1)
sol = setup2.get_solution_data(expressions='Gamma(P1)', domain='Sweep',
primary_sweep_variable='Freq', sweep='Single')
gamma = np.array([complex(x,y) for x,y in zip(sol.data_real(expression='Gamma(P1)'), sol.data_imag(expression='Gamma(P1)'))])
plt.figure()
plt.plot(f*1e-9, gamma.real, lw=2)
plt.xlabel('Frequency (GHz)')
plt.ylabel('Alpha')
plt.show()
'''
hfss.close_project()
hfss.delete_project()
hfss.close_desktop()
''' These are mesh statistic result I get with script above. When I do the mesh link manually in the GUI and run the simulation, both mesh statistic agree. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, how can I reuse the same mesh from a solution in HFSS? The geometry is the same, I will only change the material.
Beta Was this translation helpful? Give feedback.
All reactions