Skip to content

Commit

Permalink
FEAT: Circuit current probe (#5352)
Browse files Browse the repository at this point in the history
Co-authored-by: Samuelopez-ansys <[email protected]>
  • Loading branch information
boyang2022 and Samuelopez-ansys authored Nov 12, 2024
1 parent 33278b9 commit 48f4e87
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 6 deletions.
73 changes: 68 additions & 5 deletions src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ def create_voltage_probe(self, name=None, location=None, angle=0, use_instance_i
Parameters
----------
name :
name : str, optional
Name of the voltage probe. The default is ``None``.
location : list of float, optional
Position on the X axis and Y axis. The default is ``None``.
Expand All @@ -830,24 +830,87 @@ def create_voltage_probe(self, name=None, location=None, angle=0, use_instance_i
References
----------
>>> oEditor.CreateComponent
Examples
--------
>>> from ansys.aedt.core import Circuit
>>> cir = Circuit()
>>> cir.modeler.components.create_voltage_probe(name="probe")
>>> cir.release_desktop(False, False)
"""
return self.__create_probe(
name=name,
probe_type="voltage",
location=location,
angle=angle,
use_instance_id_netlist=use_instance_id_netlist,
)

@pyaedt_function_handler()
def create_current_probe(self, name=None, location=None, angle=0, use_instance_id_netlist=False):
"""Create a current probe.
Parameters
----------
name : str, optional
Name of the current probe. The default is ``None``.
location : list of float, optional
Position on the X axis and Y axis. The default is ``None``.
angle : float, optional
Angle rotation in degrees. The default is ``0``.
use_instance_id_netlist : bool, optional
Whether to use the instance ID in the net list.
The default is ``False``.
Returns
-------
:class:`ansys.aedt.core.modeler.cad.object_3dcircuit.CircuitComponent`
Circuit Component Object.
References
----------
>>> oEditor.CreateComponent
Examples
--------
>>> from ansys.aedt.core import Circuit
>>> cir = Circuit()
>>> cir.modeler.components.create_current_probe(name="probe")
>>> cir.release_desktop(False, False)
"""
return self.__create_probe(
name=name,
probe_type="current",
location=location,
angle=angle,
use_instance_id_netlist=use_instance_id_netlist,
)

def __create_probe(self, name=None, probe_type="voltage", location=None, angle=0.0, use_instance_id_netlist=False):
if probe_type == "voltage":
component_name = "VPROBE"
elif probe_type == "current":
component_name = "IPROBE"
else: # pragma: no cover
self.logger.error("Wrong probe type assigned.")
return False

if location is None:
location = []
else:
location = [location[0] + 0.2 * 24.4 / 1000, location[1] + 0.2 * 24.4 / 1000]

cmpid = self.create_component(
None,
name,
component_library="Probes",
component_name="VPROBE",
component_name=component_name,
location=location,
angle=angle,
use_instance_id_netlist=use_instance_id_netlist,
)

cmpid.set_property("Name", name)
if name:
cmpid.set_property("InstanceName", name)
return cmpid

@pyaedt_function_handler(compname="name")
Expand Down
9 changes: 8 additions & 1 deletion tests/system/general/test_21_Circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def test_35_netlist_data_block(self):
assert self.aedtapp.analyze()

def test_36_create_voltage_probe(self):
myprobe = self.aedtapp.modeler.components.create_voltage_probe(name="test_probe", location=[0.4, 0.2])
myprobe = self.aedtapp.modeler.components.create_voltage_probe(name="voltage_probe")
assert type(myprobe.id) is int

def test_37_draw_graphical_primitives(self):
Expand Down Expand Up @@ -988,3 +988,10 @@ def test_51_import_asc(self):
self.aedtapp.insert_design("ASC")
asc_file = os.path.join(TESTS_GENERAL_PATH, "example_models", test_subfolder, "butter.asc")
assert self.aedtapp.create_schematic_from_asc_file(asc_file)

def test_52_create_current_probe(self):
iprobe = self.aedtapp.modeler.schematic.create_current_probe(name="test_probe", location=[0.4, 0.2])
assert type(iprobe.id) is int
assert iprobe.InstanceName == "test_probe"
iprobe2 = self.aedtapp.modeler.schematic.create_current_probe(location=[0.8, 0.2])
assert type(iprobe2.id) is int

0 comments on commit 48f4e87

Please sign in to comment.