diff --git a/_unittest/example_models/T21/netlist_small.cir b/_unittest/example_models/T21/netlist_small.cir index 109e7254807..3b29b2f597e 100644 --- a/_unittest/example_models/T21/netlist_small.cir +++ b/_unittest/example_models/T21/netlist_small.cir @@ -14,6 +14,9 @@ L201 N1721592 BUS_P 643.0p V1 N1721592 BUS_N 12 V2 N1814870 0 PULSE(0 10 0 0.1u 0.1u 1.2u 5u) I1 N1763408 0 1e-3 +L4 N003 N004 110µ +L7 N018 N019 110µ +kcoupl L4 L7 0.9999 .param a=50V .PARAM definire=20 .param a1=50V diff --git a/pyaedt/circuit.py b/pyaedt/circuit.py index f641716cba9..f64cef9b08e 100644 --- a/pyaedt/circuit.py +++ b/pyaedt/circuit.py @@ -159,6 +159,7 @@ def __enter__(self): def _get_number_from_string(self, stringval): value = stringval[stringval.find("=") + 1 :].strip().replace("{", "").replace("}", "").replace(",", ".") + value = value.replace("µ", "u") try: float(value) return value @@ -206,8 +207,11 @@ def create_schematic_from_netlist(self, file_to_import): line = line.decode("utf-8") if ".param" in line[:7].lower(): try: - ppar = line[7:].split("=")[0] - pval = line[7:].split("=")[1] + param_line = " ".join(line[7:].split()) + param_re = re.split("[ =]", param_line) + + ppar = param_re[0] + pval = param_re[1] self[ppar] = pval xpos = 0.0254 except: @@ -371,7 +375,7 @@ def create_schematic_from_netlist(self, file_to_import): mycomp = self.modeler.schematic.create_voltage_pulse( name, value, [xpos, ypos], use_instance_id_netlist=use_instance ) - elif fields[0][0] == "K": + elif fields[0][0].lower() == "k": value = self._get_number_from_string(fields[3]) mycomp = self.modeler.schematic.create_coupling_inductors( name, fields[1], fields[2], value, [xpos, ypos], use_instance_id_netlist=use_instance @@ -388,6 +392,8 @@ def create_schematic_from_netlist(self, file_to_import): mycomp = self.modeler.schematic.create_current_pulse( name, value, [xpos, ypos], use_instance_id_netlist=use_instance ) + elif not any(word in line.lower() for word in [".param", ".model", ".lib"]): + self.logger.warning("%s could not be imported", line) if mycomp: id = 1 for pin in mycomp.pins: @@ -396,7 +402,12 @@ def create_schematic_from_netlist(self, file_to_import): angle = 0.0 else: angle = math.pi - self.modeler.schematic.create_page_port(fields[id], [pos[0], pos[1]], angle) + if fields[id] == "0": + gnd_pos = self.modeler.schematic._convert_point_to_units([0, -0.00254]) + new_pos = [i + j for i, j in zip(pos, gnd_pos)] + self.modeler.schematic.create_gnd([new_pos[0], new_pos[1]]) + else: + self.modeler.schematic.create_page_port(fields[id], [pos[0], pos[1]], angle) id += 1 ypos += delta if ypos > 0.254: