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

Fixes to component creation #944

Merged
merged 5 commits into from
Mar 11, 2022
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
15 changes: 12 additions & 3 deletions _unittest/test_21_Circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
except ImportError:
import _unittest_ironpython.conf_unittest as pytest # noqa: F401


original_project_name = "Galileo_t21"
test_project_name = "Galileo_t21"
netlist1 = "netlist_small.cir"
Expand All @@ -40,7 +39,7 @@ def setup_class(self):
def teardown_class(self):
BasisTest.my_teardown(self)

def test_01_create_inductor(self):
def test_01a_create_inductor(self):
myind = self.aedtapp.modeler.schematic.create_inductor(value=1e-9, location=[0.2, 0.2])
assert type(myind.id) is int
assert myind.parameters["L"] == "1e-09"
Expand All @@ -64,13 +63,23 @@ def test_04_getpin_names(self):
assert type(pinnames) is list
assert len(pinnames) == 2

def test_05_getpin_location(self):
def test_05a_getpin_location(self):
for el in self.aedtapp.modeler.schematic.components:
pinnames = self.aedtapp.modeler.schematic.get_pins(el)
for pinname in pinnames:
pinlocation = self.aedtapp.modeler.schematic.get_pin_location(el, pinname)
assert len(pinlocation) == 2

def test_05b_add_pin_iport(self):
mycap3 = self.aedtapp.modeler.schematic.create_capacitor(value=1e-12)
assert self.aedtapp.modeler.schematic.add_pin_iports(mycap3.name, mycap3.id)

def test_05c_create_component(self):
assert self.aedtapp.modeler.schematic.create_new_component_from_symbol("Test", ["1", "2"])
assert self.aedtapp.modeler.schematic.create_new_component_from_symbol(
"Test1", [1, 2], parameter_list=["Author:=", "NumTerminals:="], parameter_value=["pyaedt", 2]
)

def test_06_add_3dlayout_component(self):
myedb = self.aedtapp.modeler.schematic.add_subcircuit_3dlayout("Galileo_G87173_204")
assert type(myedb.id) is int
Expand Down
166 changes: 27 additions & 139 deletions pyaedt/modeler/PrimitivesCircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,33 @@ def create_wire(self, points_array):
)
return True

@pyaedt_function_handler()
def add_pin_iports(self, name, id_num):
"""Add ports on pins.

Parameters
----------
name : str
Name of the component.
id_num : int
ID of circuit component.

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

References
----------

>>> oeditor.AddPinIPorts
"""
comp_id = "CompInst@" + name + ";" + str(id_num) + ";395"
arg1 = ["Name:Selections", "Selections:=", [comp_id]]
self._oeditor.AddPinIPorts(arg1)

return True

@pyaedt_function_handler()
def create_iport(self, name, posx=0.1, posy=0.1, angle=0):
"""Create an interface port.
Expand Down Expand Up @@ -883,145 +910,6 @@ def create_symbol(self, symbol_name, pin_lists):
oDefinitionEditor.CloseEditor()
return True

@pyaedt_function_handler()
def create_new_component_from_symbol(
self, symbol_name, pin_lists, Refbase="U", parameter_list=[], parameter_value=[]
):
"""Create a component from a symbol.

Parameters
----------
symbol_name : str
Name of the symbol.
pin_lists : list
List of the pins.
Refbase : str, optional
Reference base. The default is ``"U"``.
parameter_list : list, optional
List of the parameters. The default is ``[]``.
parameter_value : list, optional
List of the parameter values. The default is ``[]``.

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

References
----------

>>> oComponentManager.Add
"""
arg = [
"NAME:" + symbol_name,
"Info:=",
[
"Type:=",
0,
"NumTerminals:=",
5,
"DataSource:=",
"",
"ModifiedOn:=",
1591858313,
"Manufacturer:=",
"",
"Symbol:=",
symbol_name,
"ModelNames:=",
"",
"Footprint:=",
"",
"Description:=",
"",
"InfoTopic:=",
"",
"InfoHelpFile:=",
"",
"IconFile:=",
"",
"Library:=",
"",
"OriginalLocation:=",
"Project",
"IEEE:=",
"",
"Author:=",
"",
"OriginalAuthor:=",
"",
"CreationDate:=",
1591858278,
"ExampleFile:=",
"",
"HiddenComponent:=",
0,
"CircuitEnv:=",
0,
"GroupID:=",
0,
],
"CircuitEnv:=",
0,
"Refbase:=",
Refbase,
"NumParts:=",
1,
"ModSinceLib:=",
True,
]

for pin in pin_lists:
arg.append("Terminal:=")
arg.append([pin, pin, "A", False, 0, 1, "", "Electrical", "0"])
arg.append("CompExtID:=")
arg.append(1)
arg2 = ["NAME:Parameters"]
for el, val in zip(parameter_list, parameter_value):
if isinstance(val, str):
arg2.append("TextValueProp:=")
arg2.append([el, "D", "", val])
else:
arg2.append("ValueProp:=")
arg2.append([el, "D", "", val, False, ""])
arg2.append("ButtonProp:=")
arg2.append(["CosimDefinition", "D", "", "Edit", "Edit", 40501, "ButtonPropClientData:=", []])
arg2.append("MenuProp:=")
arg2.append(["CoSimulator", "D", "", "DefaultNetlist", 0])

arg.append(arg2)
spicesintax = Refbase + "@ID "
id = 0
while id < (len(pin_lists) - 1):
spicesintax += "%" + str(id) + " "
id += 1
for el in parameter_list:
spicesintax += "@{} ".format(el)

arg3 = [
"NAME:CosimDefinitions",
[
"NAME:CosimDefinition",
"CosimulatorType:=",
4,
"CosimDefName:=",
"DefaultNetlist",
"IsDefinition:=",
True,
"Connect:=",
True,
"Data:=",
["Nexxim Circuit:=", spicesintax],
"GRef:=",
["Nexxim Circuit:=", ""],
],
"DefaultCosim:=",
"DefaultNetlist",
]
arg.append(arg3)
self.o_component_manager.Add(arg)
return True

@pyaedt_function_handler()
def enable_use_instance_name(self, component_library="Resistors", component_name="RES_"):
"""Enable the use of the instance name.
Expand Down
39 changes: 29 additions & 10 deletions pyaedt/modeler/PrimitivesNexxim.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,15 @@ def create_pnp(self, compname=None, value=50, location=[], angle=0, use_instance

@pyaedt_function_handler()
def create_new_component_from_symbol(
self, symbol_name, pin_lists, Refbase="U", parameter_list=[], parameter_value=[]
self,
symbol_name,
pin_lists,
time_stamp=1591858313,
description="",
refbase="U",
parameter_list=[],
parameter_value=[],
gref="",
):
"""Create a component from a symbol.

Expand All @@ -933,12 +941,18 @@ def create_new_component_from_symbol(
Name of the symbol.
pin_lists : list
List of pin names.
Refbase : str, optional
time_stamp : int, optional
UTC time stamp.
description : str, optional
Component description.
refbase : str, optional
Reference base. The default is ``"U"``.
parameter_list : list
List of parameters. The default is ``[]``.
parameter_value : list
List of parameter values. The default is ``[]``.
gref : str, optional
Global Reference

Returns
-------
Expand All @@ -962,7 +976,7 @@ def create_new_component_from_symbol(
"DataSource:=",
"",
"ModifiedOn:=",
1591858313,
time_stamp,
"Manufacturer:=",
"",
"Symbol:=",
Expand All @@ -972,7 +986,7 @@ def create_new_component_from_symbol(
"Footprint:=",
"",
"Description:=",
"",
description,
"InfoTopic:=",
"",
"InfoHelpFile:=",
Expand All @@ -990,7 +1004,7 @@ def create_new_component_from_symbol(
"OriginalAuthor:=",
"",
"CreationDate:=",
1591858278,
time_stamp,
"ExampleFile:=",
"",
"HiddenComponent:=",
Expand All @@ -1003,7 +1017,7 @@ def create_new_component_from_symbol(
"CircuitEnv:=",
0,
"Refbase:=",
Refbase,
refbase,
"NumParts:=",
1,
"ModSinceLib:=",
Expand All @@ -1016,24 +1030,28 @@ def create_new_component_from_symbol(
arg.append("CompExtID:=")
arg.append(1)
arg2 = ["NAME:Parameters"]

for el, val in zip(parameter_list, parameter_value):
if type(val) is str:
if isinstance(val, str):
arg2.append("TextValueProp:=")
arg2.append([el, "D", "", val])

else:
arg2.append("ValueProp:=")
arg2.append([el, "D", "", val, False, ""])
arg2.append([el, "D", "", str(val), False, ""])

arg2.append("ButtonProp:=")
arg2.append(["CosimDefinition", "D", "", "Edit", "Edit", 40501, "ButtonPropClientData:=", []])
arg2.append("MenuProp:=")
arg2.append(["CoSimulator", "D", "", "DefaultNetlist", 0])

arg.append(arg2)
spicesintax = Refbase + "@ID "
spicesintax = refbase + "@ID "
id = 0
while id < len(pin_lists):
spicesintax += "%" + str(id) + " "
id += 1
spicesintax += symbol_name + " "
for el, val in zip(parameter_list, parameter_value):
if "MOD" in el:
spicesintax += "@{} ".format(el)
Expand All @@ -1055,12 +1073,13 @@ def create_new_component_from_symbol(
"Data:=",
["Nexxim Circuit:=", spicesintax],
"GRef:=",
["Nexxim Circuit:=", ""],
["Nexxim Circuit:=", gref],
],
"DefaultCosim:=",
"DefaultNetlist",
]
arg.append(arg3)
print(arg)
self.o_component_manager.Add(arg)
return True

Expand Down