From b5921f277b85eff68a8b8ab06ff74dbbe7d49847 Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Fri, 1 Dec 2023 18:43:04 +0300 Subject: [PATCH] Make BiasT available for SPICE #374 --- qucs/components/biast.cpp | 40 +++++++++++++++++++++---------- qucs/components/biast.h | 2 ++ qucs/components/potentiometer.cpp | 7 +++--- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/qucs/components/biast.cpp b/qucs/components/biast.cpp index 124b5eb2c..d34e72875 100644 --- a/qucs/components/biast.cpp +++ b/qucs/components/biast.cpp @@ -17,29 +17,30 @@ #include "biast.h" #include "extsimkernels/spicecompat.h" +#include "node.h" BiasT::BiasT() { Description = QObject::tr("bias t"); - Simulator = spicecompat::simQucsator; + Simulator = spicecompat::simAll; - Arcs.append(new qucs::Arc( -3, 2, 6, 6, 16*270, 16*180,QPen(Qt::darkBlue,1))); - Arcs.append(new qucs::Arc( -3, 8, 6, 6, 16*270, 16*180,QPen(Qt::darkBlue,1))); - Arcs.append(new qucs::Arc( -3, 14, 6, 6, 16*270, 16*180,QPen(Qt::darkBlue,1))); - Lines.append(new qucs::Line(-22,-10, 22,-10,QPen(Qt::darkBlue,1))); - Lines.append(new qucs::Line(-22,-10,-22, 22,QPen(Qt::darkBlue,1))); - Lines.append(new qucs::Line(-22, 22, 22, 22,QPen(Qt::darkBlue,1))); - Lines.append(new qucs::Line( 22,-10, 22, 22,QPen(Qt::darkBlue,1))); + Arcs.append(new qucs::Arc( -3, 2, 6, 6, 16*270, 16*180,QPen(Qt::darkBlue,2))); + Arcs.append(new qucs::Arc( -3, 8, 6, 6, 16*270, 16*180,QPen(Qt::darkBlue,2))); + Arcs.append(new qucs::Arc( -3, 14, 6, 6, 16*270, 16*180,QPen(Qt::darkBlue,2))); + Lines.append(new qucs::Line(-22,-10, 22,-10,QPen(Qt::darkBlue,2))); + Lines.append(new qucs::Line(-22,-10,-22, 22,QPen(Qt::darkBlue,2))); + Lines.append(new qucs::Line(-22, 22, 22, 22,QPen(Qt::darkBlue,2))); + Lines.append(new qucs::Line( 22,-10, 22, 22,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line(-13, -6,-13, 7,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -9, -6, -9, 7,QPen(Qt::darkBlue,2))); - Lines.append(new qucs::Line( -9, 0, 22, 0,QPen(Qt::darkBlue,1))); - Lines.append(new qucs::Line(-22, 0,-13, 0,QPen(Qt::darkBlue,1))); + Lines.append(new qucs::Line( -9, 0, 22, 0,QPen(Qt::darkBlue,2))); + Lines.append(new qucs::Line(-22, 0,-13, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line(-30, 0,-22, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 22, 0, 30, 0,QPen(Qt::darkBlue,2))); - Lines.append(new qucs::Line( 0, 0, 0, 2,QPen(Qt::darkBlue,1))); - Lines.append(new qucs::Line( 0, 20, 0, 22,QPen(Qt::darkBlue,1))); + Lines.append(new qucs::Line( 0, 0, 0, 2,QPen(Qt::darkBlue,2))); + Lines.append(new qucs::Line( 0, 20, 0, 22,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 0, 22, 0, 30,QPen(Qt::darkBlue,2))); Ports.append(new Port(-30, 0)); @@ -53,6 +54,7 @@ BiasT::BiasT() ty = y2+4; Model = "BiasT"; Name = "X"; + SpiceModel="L"; Props.append(new Property("L", "1 uH", false, QObject::tr("for transient simulation: inductance in Henry"))); @@ -77,3 +79,17 @@ Element* BiasT::info(QString& Name, char* &BitmapFile, bool getNewOne) if(getNewOne) return new BiasT(); return 0; } + +QString BiasT::spice_netlist(bool isXyce) +{ + Q_UNUSED(isXyce); + QString s; + QString L = spicecompat::normalize_value(getProperty("L")->Value); + QString C = spicecompat::normalize_value(getProperty("C")->Value); + QString pin1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); + QString pin2 = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); + QString pin3 = spicecompat::normalize_node_name(Ports.at(2)->Connection->Name); + s += QString("C_%1 %2 %3 %4\n").arg(Name).arg(pin1).arg(pin2).arg(C); + s += QString("L_%1 %2 %3 %4\n").arg(Name).arg(pin2).arg(pin3).arg(L); + return s; +} diff --git a/qucs/components/biast.h b/qucs/components/biast.h index 9ad3ceec2..45a97749c 100644 --- a/qucs/components/biast.h +++ b/qucs/components/biast.h @@ -27,6 +27,8 @@ class BiasT : public Component { ~BiasT(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); +protected: + QString spice_netlist(bool isXyce); }; #endif diff --git a/qucs/components/potentiometer.cpp b/qucs/components/potentiometer.cpp index 6a9ca1214..e6428dff8 100644 --- a/qucs/components/potentiometer.cpp +++ b/qucs/components/potentiometer.cpp @@ -113,13 +113,14 @@ void potentiometer::createSymbol() QString potentiometer::spice_netlist(bool isXyce) { + Q_UNUSED(isXyce); QString s; QString R = getProperty("R_pot")->Value; QString rot = getProperty("Rotation")->Value; QString max_rot = getProperty("Max_Rotation")->Value; - QString pin1 = Ports.at(0)->Connection->Name; - QString pin2 = Ports.at(1)->Connection->Name; - QString pin3 = Ports.at(2)->Connection->Name; + QString pin1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); + QString pin2 = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); + QString pin3 = spicecompat::normalize_node_name(Ports.at(2)->Connection->Name); s += QString("R%1_1 %2 %3 R='(%4)*(%5)/(%6)'\n").arg(Name).arg(pin1).arg(pin2).arg(R).arg(rot).arg(max_rot); s += QString("R%1_2 %2 %3 R='(%4)*(1.0-(%5)/(%6))'\n").arg(Name).arg(pin2).arg(pin3).arg(R).arg(rot).arg(max_rot); return s;