Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Circuit current probe #5352

Merged
merged 9 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

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 @@

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(

Check warning on line 842 in src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py#L842

Added line #L842 was not covered by tests
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``.
Samuelopez-ansys marked this conversation as resolved.
Show resolved Hide resolved
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(

Check warning on line 882 in src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py#L882

Added line #L882 was not covered by tests
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"

Check warning on line 894 in src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py#L891-L894

Added lines #L891 - L894 were not covered by tests
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)

Check warning on line 913 in src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_nexxim.py#L912-L913

Added lines #L912 - L913 were not covered by tests
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
Loading