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: VSin, ISin Sources added to Maxwell Circuit Primitives #5283

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5aac760
VSin, ISin Sources added to Maxwell Circuit Primitives
DaveTwyman Oct 11, 2024
f8699a5
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Oct 11, 2024
8552947
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 11, 2024
93375bd
VSin, ISin Sources added to Maxwell Circuit Primitives
DaveTwyman Oct 11, 2024
955bcf7
Merge remote-tracking branch 'origin/5282-Add-Missing-Circuit-Element…
DaveTwyman Oct 11, 2024
cf6153e
VSin, ISin Sources added to Maxwell Circuit Primitives
DaveTwyman Oct 11, 2024
eb4c79e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 11, 2024
a07645f
vsin, isin Sources added to Maxwell Circuit Primitives
DaveTwyman Oct 14, 2024
84e4f7a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 14, 2024
d7945da
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Oct 14, 2024
a3a2340
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Oct 14, 2024
46152e2
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Oct 15, 2024
bf84832
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Oct 16, 2024
0c4d246
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
SMoraisAnsys Oct 17, 2024
d180ad8
Unit Tests added for vsin and isin
DaveTwyman Oct 17, 2024
5a95e4e
Replaced id with comp_name
DaveTwyman Oct 18, 2024
4b7d09f
Delete unused function handler from create_page
DaveTwyman Oct 18, 2024
f00f682
Use component instead of comp_name
DaveTwyman Oct 18, 2024
359f752
Added support for Name=None case which previously created error messa…
DaveTwyman Oct 18, 2024
fdf3786
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Oct 18, 2024
4ef9e9f
Added method 'get_num_pages' as well as unit tests 52_create_page and…
DaveTwyman Oct 30, 2024
d44fd5d
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Oct 30, 2024
0a98ed1
Update src/ansys/aedt/core/modeler/circuits/primitives_circuit.py
DaveTwyman Nov 5, 2024
a4dd34f
Update src/ansys/aedt/core/modeler/circuits/primitives_circuit.py
DaveTwyman Nov 5, 2024
7aa718d
Update src/ansys/aedt/core/modeler/circuits/primitives_circuit.py
DaveTwyman Nov 5, 2024
bd322c4
Update src/ansys/aedt/core/modeler/circuits/primitives_circuit.py
DaveTwyman Nov 5, 2024
44827f3
Update src/ansys/aedt/core/modeler/circuits/primitives_circuit.py
DaveTwyman Nov 5, 2024
29eeb97
-Moved create_page and get_num_pages into maxwellcircuit.py, they sho…
DaveTwyman Nov 12, 2024
3f56946
Merge branch 'main' of https://github.com/ansys/pyaedt into 5282-Add-…
DaveTwyman Nov 12, 2024
e053aab
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Nov 12, 2024
8cefb93
CHORE: Auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 12, 2024
44c9258
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Nov 12, 2024
8b94bd1
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Nov 12, 2024
0291fd4
Added property to get number of pages in schematic instead of a method.
DaveTwyman Nov 19, 2024
9496014
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Nov 19, 2024
8a765fb
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Nov 20, 2024
e8bfc8f
Changed from using a method called 'get_num_pages' to a property call…
DaveTwyman Nov 20, 2024
9f129ad
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Nov 20, 2024
8efe72b
Moved nb_pages and create_page methods to schematic.py instead of bei…
DaveTwyman Dec 4, 2024
161773c
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Dec 4, 2024
e8431c4
Corrected test_11_create_page
DaveTwyman Dec 4, 2024
70600ea
Merge branch 'main' into 5282-Add-Missing-Circuit-Elements
DaveTwyman Dec 11, 2024
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
157 changes: 128 additions & 29 deletions src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@

Parameters
----------
name : str, optional
Name of the resistor. The default is ``None``.
name : str, int, float or optional
Name of the resistor. The default is ``None`` which adds a resistor without a name.
DaveTwyman marked this conversation as resolved.
Show resolved Hide resolved
value : float, optional
Value for the resistor. The default is ``50``.
location : list of float, optional
Expand All @@ -109,27 +109,27 @@
if location == None:
location = []

id = self.create_component(
component = self.create_component(

Check warning on line 112 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L112

Added line #L112 was not covered by tests
name,
component_library="Passive Elements",
component_name="Res",
location=location,
angle=angle,
use_instance_id_netlist=use_instance_id_netlist,
)

id.set_property("R", value)
id.set_property("Name", name)
return id
component.set_property("R", value)
DaveTwyman marked this conversation as resolved.
Show resolved Hide resolved
if isinstance(name, (str, int, float)):
DaveTwyman marked this conversation as resolved.
Show resolved Hide resolved
component.parameters["Name"] = name
return component

Check warning on line 123 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L120-L123

Added lines #L120 - L123 were not covered by tests

@pyaedt_function_handler(compname="name")
def create_inductor(self, name=None, value=50, location=None, angle=0, use_instance_id_netlist=False):
"""Create an inductor.

Parameters
----------
name : str, optional
Name of the inductor. The default is ``None``.
name : str, int, float or optional
Name of the inductor. The default is ``None`` which adds an inductor without a name.
value : float, optional
Value for the inductor. The default is ``50``.
location : list of float, optional
Expand All @@ -152,7 +152,7 @@
if location == None:
location = []

id = self.create_component(
component = self.create_component(

Check warning on line 155 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L155

Added line #L155 was not covered by tests
name,
component_library="Passive Elements",
component_name="Ind",
Expand All @@ -161,18 +161,19 @@
use_instance_id_netlist=use_instance_id_netlist,
)

id.set_property("L", value)
id.set_property("Name", name)
return id
component.set_property("L", value)
DaveTwyman marked this conversation as resolved.
Show resolved Hide resolved
if isinstance(name, (str, int, float)):
component.parameters["Name"] = name
return component

Check warning on line 167 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L164-L167

Added lines #L164 - L167 were not covered by tests

@pyaedt_function_handler(compname="name")
def create_capacitor(self, name=None, value=50, location=None, angle=0, use_instance_id_netlist=False):
"""Create a capacitor.

Parameters
----------
name : str, optional
Name of the capacitor. The default is ``None``.
name : str, int, float or optional
Name of the capacitor. The default is ``None`` which adds a capacitor without a name.
value : float, optional
Value for the capacitor. The default is ``50``.
location : list of float, optional
Expand All @@ -194,7 +195,7 @@
"""
if location is None:
location = []
id = self.create_component(
component = self.create_component(

Check warning on line 198 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L198

Added line #L198 was not covered by tests
name,
component_library="Passive Elements",
component_name="Cap",
Expand All @@ -203,18 +204,19 @@
use_instance_id_netlist=use_instance_id_netlist,
)

id.set_property("C", value)
id.set_property("Name", name)
return id
component.set_property("C", value)
DaveTwyman marked this conversation as resolved.
Show resolved Hide resolved
if isinstance(name, (str, int, float)):
component.parameters["Name"] = name
return component

Check warning on line 210 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L207-L210

Added lines #L207 - L210 were not covered by tests

@pyaedt_function_handler(compname="name")
def create_diode(self, name=None, location=None, angle=0, use_instance_id_netlist=False):
"""Create a diode.

Parameters
----------
name : str, optional
Name of the diode. The default is ``None``.
name : str, int, float or optional
Name of the diode. The default is ``None`` which adds a diode without a name.
location : list of float, optional
Position on the X axis and Y axis. The default is ``None``.
angle : float, optional
Expand All @@ -235,7 +237,7 @@
if location is None:
location = []

id = self.create_component(
component = self.create_component(

Check warning on line 240 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L240

Added line #L240 was not covered by tests
name,
component_library="Passive Elements",
component_name="DIODE",
Expand All @@ -244,17 +246,18 @@
use_instance_id_netlist=use_instance_id_netlist,
)

id.set_property("Name", name)
return id
if isinstance(name, (str, int, float)):
DaveTwyman marked this conversation as resolved.
Show resolved Hide resolved
component.parameters["Name"] = name
return component

Check warning on line 251 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L249-L251

Added lines #L249 - L251 were not covered by tests

@pyaedt_function_handler(compname="name")
def create_winding(self, name=None, location=None, angle=0, use_instance_id_netlist=False):
"""Create a winding linked to a Maxwell design.

Parameters
----------
name : str, optional
Name of the winding. The default is ``None``.
name : str, int, float or optional
Name of the winding. The default is ``None`` which adds a winding without a name.
location : list of float, optional
Position on the X axis and Y axis.
angle : float, optional
Expand All @@ -274,13 +277,109 @@
"""
if location is None:
location = []
id = self.create_component(
component = self.create_component(

Check warning on line 280 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L280

Added line #L280 was not covered by tests
name,
component_library="Dedicated Elements",
component_name="Winding",
location=location,
angle=angle,
use_instance_id_netlist=use_instance_id_netlist,
)
id.set_property("Name", name)
return id
if isinstance(name, (str, int, float)):
DaveTwyman marked this conversation as resolved.
Show resolved Hide resolved
component.parameters["Name"] = name
return component

Check warning on line 290 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L288-L290

Added lines #L288 - L290 were not covered by tests

@pyaedt_function_handler()
def create_i_sin(self, name=None, value=1, location=None, angle=0, use_instance_id_netlist=False):
DaveTwyman marked this conversation as resolved.
Show resolved Hide resolved
"""Create a sinusoidal current source.

Parameters
----------
name : str, int, float or optional
Name of the current source. The default is ``None`` which adds a current source without a name.
value : float, optional
Value for the amplitude of current. The default is ``1``.
location : list of float, optional
Position on the X axis and Y axis.
angle : float, optional
Angle of rotation in degrees. The default is ``0``.
use_instance_id_netlist : bool, optional
Whether to use the instance ID in the net list or not. 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 MaxwellCircuit
>>>app=MaxwellCircuit()
>>>component=app.modeler.schematic.create_i_sin(name="new_current_source", value = 100)
"""
if location is None:
DaveTwyman marked this conversation as resolved.
Show resolved Hide resolved
location = []
component = self.create_component(

Check warning on line 326 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L324-L326

Added lines #L324 - L326 were not covered by tests
name,
component_library="Sources",
component_name="ISin",
location=location,
angle=angle,
use_instance_id_netlist=use_instance_id_netlist,
)
component.parameters["Ia"] = value
if isinstance(name, (str, int, float)):
component.parameters["Name"] = name
return component

Check warning on line 337 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L334-L337

Added lines #L334 - L337 were not covered by tests

@pyaedt_function_handler()
def create_v_sin(self, name=None, value=1, location=None, angle=0, use_instance_id_netlist=False):
"""Create a sinusoidal voltage source.

Parameters
----------
name : str, int, float or optional
Name of the voltage source. The default is ``None`` which adds a voltage source without a name.
value : float, optional
Value for the amplitude of voltage. The default is ``1``.
location : list of float, optional
Position on the X axis and Y axis.
angle : float, optional
Angle of rotation in degrees. The default is ``0``.
use_instance_id_netlist : bool, optional
Whether to use the instance ID in the net list or not. 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 MaxwellCircuit
>>>app=MaxwellCircuit()
>>>component=app.modeler.schematic.create_v_sin(name="new_voltage_source", value = 240)
"""
if location is None:
location = []
component = self.create_component(

Check warning on line 374 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L372-L374

Added lines #L372 - L374 were not covered by tests
name,
component_library="Sources",
component_name="VSin",
location=location,
angle=angle,
use_instance_id_netlist=use_instance_id_netlist,
)
component.parameters["Va"] = value
if isinstance(name, (str, int, float)):
component.parameters["Name"] = name
return component

Check warning on line 385 in src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/primitives_maxwell_circuit.py#L382-L385

Added lines #L382 - L385 were not covered by tests
36 changes: 36 additions & 0 deletions src/ansys/aedt/core/modeler/schematic.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,42 @@
val = f"{value}{units}"
return val

@pyaedt_function_handler()
def create_page(self, name):
"""Add a new circuit schematic page.

Parameters
----------
name : str, int or float
Name to be used when creating the new circuit schematic.

Returns
-------
bool
``True`` when successful, ``False`` when failed.

References
----------
>>> oEditor.CreatePage()

Examples
--------
>>>from ansys.aedt.core import MaxwellCircuit
>>>app=MaxwellCircuit ()
>>>component=app.modeler.schematic.create_page(name=page_name)

"""
if not isinstance(name, (str, int, float)):
self.logger.error("Wrong type for argument ``name``.")
return False
self.oeditor.CreatePage(name)
return True

Check warning on line 509 in src/ansys/aedt/core/modeler/schematic.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/schematic.py#L505-L509

Added lines #L505 - L509 were not covered by tests

@property
def nb_pages(self):
"""Number of circuit schematic pages."""
return self.oeditor.GetNumPages()

Check warning on line 514 in src/ansys/aedt/core/modeler/schematic.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/schematic.py#L514

Added line #L514 was not covered by tests


class ModelerNexxim(ModelerCircuit):
"""ModelerNexxim class.
Expand Down
6 changes: 3 additions & 3 deletions tests/system/general/test_21_Circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ def test_25_import_model(self):

def test_25_zoom_to_fit(self):
self.aedtapp.insert_design("zoom_test")
myind = self.aedtapp.modeler.schematic.create_inductor("L100", 1e-9)
myres = self.aedtapp.modeler.components.create_resistor("R100", 50)
mycap = self.aedtapp.modeler.components.create_capacitor("C100", 1e-12)
self.aedtapp.modeler.schematic.create_inductor("L100", 1e-9)
self.aedtapp.modeler.components.create_resistor("R100", 50)
self.aedtapp.modeler.components.create_capacitor("C100", 1e-12)
self.aedtapp.modeler.zoom_to_fit()

def test_26_component_catalog(self):
Expand Down
23 changes: 23 additions & 0 deletions tests/system/general/test_35_MaxwellCircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,26 @@ def test_08_import_netlist(self):
self.aedtapp.insert_design("SchematicImport")
self.aedtapp.modeler.schematic.limits_mils = 5000
assert self.aedtapp.create_schematic_from_netlist(self.netlist_file1)

def test_09_create_voltage_source(self):
name_type = ["voltage_source", 123, 1.23]
for item in name_type:
component = self.aedtapp.modeler.schematic.create_v_sin(name=item, value=3.14, angle=90)
assert component.parameters["Name"] == item
assert component.parameters["Va"] == 3.14

def test_10_create_current_source(self):
name_type = ["current_source", 456, 4.56]
for item in name_type:
component = self.aedtapp.modeler.schematic.create_i_sin(name=item, value=2.72, angle=90)
assert component.parameters["Name"] == item
assert component.parameters["Ia"] == 2.72

def test_11_create_page(self):
assert self.aedtapp.modeler.create_page("string_test")
assert self.aedtapp.modeler.nb_pages == 2
assert self.aedtapp.modeler.create_page(123)
assert self.aedtapp.modeler.nb_pages == 3
assert self.aedtapp.modeler.create_page(3.14)
assert self.aedtapp.modeler.nb_pages == 4
assert not self.aedtapp.modeler.create_page(["create_page_test"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaveTwyman is there any reason why are you testing create_page giving as argument different type of data types? I think the code lines 134 and 140 are enough to test create_page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anur7 , The other lines are there to test that passing other data types works correctly. As there is no AEDT documentation on page name data types, we've restricted it to String, Integer and Float and just test these types.

Loading