Skip to content

Commit b792aad

Browse files
authored
Implemented edit_sources in Hfss to support multiple Field Source edit at the same time (#1047)
Co-authored-by: maxcapodi78 <Shark78>
1 parent c7b9c2a commit b792aad

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

_unittest/test_20_HFSS.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,16 @@ def test_06z_validate_setup(self):
332332

333333
def test_07_set_power(self):
334334
assert self.aedtapp.edit_source("sheet1_Port" + ":1", "10W")
335+
assert self.aedtapp.edit_sources(
336+
{"sheet1_Port" + ":1": "10W", "sheet2_Port:1": ("20W", "20deg")},
337+
include_port_post_processing=True,
338+
max_available_power="40W",
339+
)
340+
assert self.aedtapp.edit_sources(
341+
{"sheet1_Port" + ":1": "10W", "sheet2_Port:1": ("20W", "0deg", True)},
342+
include_port_post_processing=True,
343+
use_incident_voltage=True,
344+
)
335345

336346
def test_08_create_circuit_port_from_edges(self):
337347
plane = self.aedtapp.PLANE.XY

pyaedt/hfss.py

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3595,9 +3595,81 @@ def create_circuit_port_from_edges(
35953595
edge_list, port_impedance, port_name, renormalize, deembed, renorm_impedance=renorm_impedance
35963596
)
35973597

3598+
@pyaedt_function_handler()
3599+
def edit_sources(
3600+
self, excitations, include_port_post_processing=True, max_available_power=None, use_incident_voltage=False
3601+
):
3602+
"""Set up the power loaded for Hfss Post-Processing in multiple sources simultaneously.
3603+
3604+
Parameters
3605+
----------
3606+
excitations : dict
3607+
Dictionary of input sources to modify module and phase.
3608+
Dictionary values can be:
3609+
- 1 Value to setup 0deg as default
3610+
- 2 values tuple or list (magnitude and phase) or
3611+
- 3 values (magnitude, phase and termination flag) for Terminal Solution in case of incident voltage usage.
3612+
3613+
Returns
3614+
-------
3615+
bool
3616+
3617+
Examples
3618+
--------
3619+
>>> sources = {"Port1:1": ("0W", "0deg"), "Port2:1": ("1W", "90deg")}
3620+
>>> hfss.edit_sources(sources, include_port_post_processing=True)
3621+
3622+
>>> sources = {"Box2_T1": ("0V", "0deg", True), "Box1_T1": ("1V", "90deg")}
3623+
>>> hfss.edit_sources(sources, max_available_power="2W", use_incident_voltage=True)
3624+
"""
3625+
data = {i: ("0W", "0deg", False) for i in self.excitations}
3626+
for key, value in excitations.items():
3627+
data[key] = value
3628+
setting = []
3629+
for key, vals in data.items():
3630+
if isinstance(vals, str):
3631+
power = vals
3632+
phase = "0deg"
3633+
else:
3634+
power = vals[0]
3635+
if len(vals) == 1:
3636+
phase = "0deg"
3637+
else:
3638+
phase = vals[1]
3639+
if isinstance(vals, (list, tuple)) and len(vals) == 3:
3640+
terminated = vals[2]
3641+
else:
3642+
terminated = False
3643+
if use_incident_voltage and self.solution_type == "Terminal":
3644+
setting.append(["Name:=", key, "Terminated:=", terminated, "Magnitude:=", power, "Phase:=", phase])
3645+
else:
3646+
setting.append(["Name:=", key, "Magnitude:=", power, "Phase:=", phase])
3647+
argument = []
3648+
if self.solution_type == "Terminal":
3649+
argument.extend(["UseIncidentVoltage:=", use_incident_voltage])
3650+
3651+
argument.extend(
3652+
[
3653+
"IncludePortPostProcessing:=",
3654+
include_port_post_processing,
3655+
"SpecifySystemPower:=",
3656+
True if max_available_power else False,
3657+
]
3658+
)
3659+
3660+
if max_available_power:
3661+
argument.append("Incident Power:=")
3662+
argument.append(max_available_power)
3663+
3664+
args = [argument]
3665+
args.extend(setting)
3666+
for arg in args:
3667+
self.osolution.EditSources(arg)
3668+
return True
3669+
35983670
@pyaedt_function_handler()
35993671
def edit_source(self, portandmode, powerin, phase="0deg"):
3600-
"""Set up the power loaded to the filter for thermal analysis.
3672+
"""Set up the power loaded for Hfss Post-Processing.
36013673
36023674
Parameters
36033675
----------

0 commit comments

Comments
 (0)