{ "cells": [ { "cell_type": "markdown", "metadata": { "toc": true }, "source": [ "

Table of Contents

\n", "
" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING: KICAD_SYMBOL_DIR environment variable is missing, so the default KiCad symbol libraries won't be searched.\n" ] } ], "source": [ "from skidl.pyspice import *\n", "from PySpice.Spice.Netlist import Circuit" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Checking tool" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def netlist_comp_check(skidl_netlist, pyspice_netlist):\n", " \"\"\"\n", " Simple dumb check tool to compare the netlist from skidl and pyspice \n", " \n", " Args:\n", " skidl_netlist (PySpice.Spice.Netlist.Circuit): resulting netlist obj from\n", " skidl using skidl's `generate_netlist` utlity to compare to pyspice direct\n", " creation\n", " \n", " pyspice_netlist (PySpice.Spice.Netlist.Circuit): circuit obj created directly in pyspice via\n", " `PySpice.Spice.Netlist.Circuit` to compare it's netlist to skidl produced one\n", " \n", " Returns:\n", " if skidl_netlist is longer then pyspice_netlist will return string statment saying: 'skidl_netlist is longer then pyspice_netlist'\n", " \n", " if skidl_netlist is shorter then pyspice_netlist will return string statment saying: 'skidl_netlist is shorter then pyspice_netlist'\n", " \n", " if skidl_netlist and pyspice_netlist are equall and but there are diffrances then will print\n", " message of thoes difrances(|1 indexed) and return a list of indexs where the skidl netlist is differs from the pyspice one\n", " \n", " if skidl_netlist == pyspice_netlist then will return the word: 'Match'\n", " \n", " TODO: Where should I start\n", " \"\"\"\n", " #only care about the final netlist string\n", " skidl_netlist=skidl_netlist.str()\n", " pyspice_netlist=pyspice_netlist.str()\n", " \n", " #check the lengths\n", " if len(skidl_netlist)>len(pyspice_netlist):\n", " return('skidl_netlist is longer then pyspice_netlist')\n", " elif len(skidl_netlist) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## C | Capacitor \n", "PySpice/PySpice/Spice/BasicElement.py; class Capacitor(DipoleElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"C\"\n", "\n", "ngspice 3.2.5 Capacitors: \n", "\n", "CXXXXXXX n| n- \n", " \n", "### Notes" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "C1 N1 N2 5 dtemp=5 ic=5 m=5 scale=5 temp=5\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_C=C(ref='1', value=5, scale=5, temp=5, dtemp=5, ic=5, m=5)\n", "skidl_C['p', 'n']+=net_1, net_2\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "C1 N1 N2 5 dtemp=5 ic=5 m=5 scale=5 temp=5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.C('1', 'N1', 'N2', 5, scale=5, temp=5, dtemp=5, ic=5, m=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## D | Diode \n", "PySpice/PySpice/Spice/BasicElement.py; class Diode(FixedPinElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"D\"\n", "\n", "ngspice 7.1 Junction Diodes: \n", "\n", "DXXXXXXX n| n- mname \n", " \n", "### Notes\n", "- `ic`: did not work in eather skidl or pyspice" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "ERROR: Unknown SPICE model: 5\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "D1 N1 N2 5 area=5 dtemp=5 m=5 off pj=5 temp=5\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "0 warnings found during netlist generation.\n", "1 errors found during netlist generation.\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_D=D(ref='1',model=5, area=5, m=5, pj=5, off=5, temp=5, dtemp=5)\n", "skidl_D['p', 'n']+=net_1, net_2\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "D1 N1 N2 5 area=5 dtemp=5 m=5 off pj=5 temp=5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.D('1', 'N1', 'N2', model=5, area=5, m=5, pj=5, off=5, temp=5, dtemp=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## E | Voltage-controlled voltage source (VCVS)\n", "PySpice/PySpice/Spice/BasicElement.py; class VoltageControlledVoltageSource(TwoPortElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"E\"\n", "\n", "ngspice 4.2.2 Exxxx: Linear Voltage-Controlled Voltage Sources (VCVS): \n", "\n", "EXXXXXXX N| N- NC| NC- VALUE\n", " \n", "### Notes" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "E1 N3 N4 N1 N2 5\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2'); net_3=Net('N3'); net_4=Net('N4')\n", "skidl_E=E(ref='1', voltage_gain=5)\n", "skidl_E['ip', 'in']+=net_1, net_2; skidl_E['op', 'on']+=net_3, net_4\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "E1 N3 N4 N1 N2 5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.VoltageControlledVoltageSource('1', 'N3', 'N4', 'N1', 'N2', voltage_gain=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## F | Current-controlled current source (CCCs) \n", "PySpice/PySpice/Spice/BasicElement.py; class CurrentControlledCurrentSource(DipoleElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"F\"\n", "\n", "ngspice 4.2.3 Fxxxx: Linear Current-Controlled Current Sources (CCCS): \n", "\n", "FXXXXXXX N| N- VNAM VALUE \n", "### Notes" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "F1 N1 N2 V1 5 m=5\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_F=F(ref='1', control='V1', current_gain=5, m=5)\n", "skidl_F['p', 'n']+=net_1, net_2;\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "F1 N1 N2 V1 5 m=5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.CurrentControlledCurrentSource('1', 'N1', 'N2', 'V1', current_gain=5, m=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## G | Voltage-controlled current source (VCCS)\n", "PySpice/PySpice/Spice/BasicElement.py; class VoltageControlledCurrentSource(TwoPortElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"G\"\n", "\n", "ngspice 4.2.1 Gxxxx: Linear Voltage-Controlled Current Sources (VCCS):\n", "\n", "GXXXXXXX N| N- NC| NC- VALUE \n", "\n", "### Notes\n", "- 'transconductance' did not work in skidl; but `gain` did as did `current_gain`" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "G1 N3 N4 N1 N2 5 m=5\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2'); net_3=Net('N3'); net_4=Net('N4')\n", "skidl_G=G(ref='1', current_gain=5, m=5)\n", "skidl_G['ip', 'in']+=net_1, net_2; skidl_G['op', 'on']+=net_3, net_4\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "G1 N3 N4 N1 N2 5 m=5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.VoltageControlledCurrentSource('1', 'N3', 'N4', 'N1', 'N2', transconductance=5, m=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## H | Current-controlled voltage source (CCVS)\n", "PySpice/PySpice/Spice/BasicElement.py; class CurrentControlledVoltageSource(DipoleElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"H\"\n", "\n", "ngspice 4.2.4 Hxxxx: Linear Current-Controlled Voltage Sources (CCVS): \n", "\n", "HXXXXXXX n| n- vnam val\n", " \n", "### Notes" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "H1 N1 N2 V1 5\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_H=H(ref='1', control='V1', transresistance=5)\n", "skidl_H['p', 'n']+=net_1, net_2;\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "H1 N1 N2 V1 5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.CurrentControlledVoltageSource('1', 'N1', 'N2', 'V1', transresistance=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I | Current source \n", "\n", "PySpice/PySpice/Spice/BasicElement.py; class CurrentSource(DipoleElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"I\"\n", "\n", "ngspice 4.1 Independent Sources for Voltage or Current: \n", "\n", "IYYYYYYY N| N- < \n", " \n", "### Notes\n", "- a reduced version of ngspices IYYYYYYY only generating the arguement for < DC/TRAN VALUE >" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "I1 N1 N2 5\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_I=I(ref='1', dc_value=5)\n", "skidl_I['p', 'n']+=net_1, net_2\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "I1 N1 N2 5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.I('1', 'N1', 'N2', dc_value=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## J | Junction field effect transistor (JFET) \n", "PySpice/PySpice/Spice/BasicElement.py; class JunctionFieldEffectTransistor(JfetElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"J\"\n", "\n", "ngspice 9.1 Junction Field-Effect Transistors (JFETs): \n", "\n", "JXXXXXXX nd ng ns mname \n", " \n", "### Notes\n", "- `ic`: did not work in eather skidl or pyspice" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "ERROR: Unknown SPICE model: 5\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "J1 N1 N2 N3 5 area=5 m=5 off temp=5\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "0 warnings found during netlist generation.\n", "1 errors found during netlist generation.\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2'); net_3=Net('N3')\n", "skidl_J=J(ref='1',model=5, area=5, m=5, off=5, temp=5)\n", "skidl_J['d', 'g', 's']+=net_1, net_2, net_3\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "J1 N1 N2 N3 5 area=5 m=5 off temp=5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.J('1', 'N1', 'N2', 'N3', model=5, area=5, m=5, off=5, temp=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## K | Coupled (Mutual) Inductors \n", "\n", "PySpice/PySpice/Spice/BasicElement.py; class CoupledInductor(AnyPinElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"K\"\n", "\n", "ngspice 3.2.11 Coupled (Mutual) Inductors: \n", "\n", "KXXXXXXX LYYYYYYY LZZZZZZZ value\n", "\n", "### Notes\n", "- need to get daves help on using K inside skidl\n", "- the inductors must already exsist for pyspice to work" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "L1 N1 N2 5 dtemp=5 ic=5 m=5 temp=5\n", "L2 N1 N2 5 dtemp=5 ic=5 m=5 temp=5\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_L1=L(ref='1', value=5, m=5, temp=5, dtemp=5, ic=5)\n", "skidl_L1['p', 'n']+=net_1, net_2\n", "\n", "skidl_L2=L(ref='2', value=5, m=5, temp=5, dtemp=5, ic=5)\n", "skidl_L2['p', 'n']+=net_1, net_2\n", "\n", "#need to find out how to use this\n", "#skidl_K=K()\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "L1 N1 N2 5 dtemp=5 ic=5 m=5 temp=5\n", "L2 N1 N2 5 dtemp=5 ic=5 m=5 temp=5\n", "K1 L1 L2 5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "#inductors need to exsist to then be coupled\n", "pyspice_circ.L('1', 'N1', 'N2', 5, m=5, temp=5, dtemp=5, ic=5)\n", "pyspice_circ.L('2', 'N1', 'N2', 5, m=5, temp=5, dtemp=5, ic=5)\n", "pyspice_circ.K('1', 'L1', 'L2', coupling_factor=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'skidl_netlist is shorter then pyspice_netlist'" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## L | Inductor \n", "\n", "PySpice/PySpice/Spice/BasicElement.py; class Inductor(DipoleElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"L\"\n", "\n", "ngspice 3.2.9 Inductors: \n", "\n", "LYYYYYYY n| n- \n", " \n", "### Notes" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "L1 N1 N2 5 dtemp=5 ic=5 m=5 temp=5\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_L=L(ref='1', value=5, m=5, temp=5, dtemp=5, ic=5)\n", "skidl_L['p', 'n']+=net_1, net_2\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "L1 N1 N2 5 dtemp=5 ic=5 m=5 temp=5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.L('1', 'N1', 'N2', 5, m=5, temp=5, dtemp=5, ic=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## M | Metal oxide field effect transistor (MOSFET)\n", "PySpice/PySpice/Spice/BasicElement.py; class Mosfet(FixedPinElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"M\"\n", "\n", "ngspice 11.1 MOSFET devices: \n", "\n", "MXXXXXXX nd ng ns nb mname \n", " \n", "### Notes\n", "- `ic`: did not work in eather skidl or pyspice" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "ERROR: Unknown SPICE model: 5\n", "\n", "0 warnings found during netlist generation.\n", "1 errors found during netlist generation.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "M1 N1 N2 N3 N4 5 ad=5 nrd=5 pd=5 l=5 m=5 off as=5 nrs=5 ps=5 temp=5 w=5\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2'); net_3=Net('N3'); net_4=Net('N4')\n", "skidl_M=M(ref='1', model=5, m=5, l=5, w=5, \n", " drain_area=5, source_area=5, drain_perimeter=5, source_perimeter=5, \n", " drain_number_square=5, source_number_square=5,\n", " off=5, temp=5)\n", "\n", "skidl_M['d', 'g', 's', 'b']+=net_1, net_2, net_3, net_4\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "M1 N1 N2 N3 N4 5 ad=5 nrd=5 pd=5 l=5 m=5 off as=5 nrs=5 ps=5 temp=5 w=5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.M('1', 'N1', 'N2', 'N3', 'N4', model=5, m=5, l=5, w=5, \n", " drain_area=5, source_area=5, drain_perimeter=5, source_perimeter=5, \n", " drain_number_square=5, source_number_square=5,\n", " off=5, temp=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| N | Numerical device for GSS |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| O | Lossy transmission line |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| P | Coupled multiconductor line (CPL) |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Q | Bipolar junction transistor (BJT) \n", "PySpice/PySpice/Spice/BasicElement.py; class BipolarJunctionTransistor(FixedPinElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"Q\"\n", "\n", "ngspice 8.1 Bipolar Junction Transistors (BJTs): \n", "\n", "QXXXXXXX nc nb ne mname \n", " \n", "### Notes\n", "- could not get the substrate connection working in pyspice but it worked fine with skidl\n", "- `ic`: did not work in eather skidl or pyspice" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "ERROR: Unknown SPICE model: 5\n", "\n", "0 warnings found during netlist generation.\n", "1 errors found during netlist generation.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "Q1 N1 N2 N3 5 area=5 areab=5 areac=5 dtemp=5 m=5 off temp=5\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2'); net_3=Net('N3'); net_4=Net('N4')\n", "skidl_Q=Q(ref='1',model=5, \n", " area=5, areab=5, areac=5,\n", " m=5, off=5, temp=5, dtemp=5)\n", "skidl_Q['c', 'b', 'e']+=net_1, net_2, net_3\n", "\n", "#skidl will make the substrate connection fine but could not get pyspice to do so\n", "#therefore skiping for the time being\n", "#skidl_Q['s']+=net_4\n", "\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "Q1 N1 N2 N3 5 area=5 areab=5 areac=5 dtemp=5 m=5 off temp=5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.Q('1', 'N1', 'N2', 'N3', model=5, area=5, areab=5, areac=5,\n", " m=5, off=5, temp=5, dtemp=5, \n", " #could not get the substrate connection working in pyspice\n", " #ns='N4'\n", " )\n", " \n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## R | Resistor \n", "\n", "PySpice/PySpice/Spice/BasicElement.py; class Resistor(DipoleElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"R\"\n", "\n", "ngspice 3.2.1 Resistors: \n", "\n", "RXXXXXXX n| n- value \n", " \n", "### Notes" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "R1 N1 N2 5 ac=5 dtemp=5 m=5 noisy=1 scale=5 temp=5\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_R=R(ref='1', value=5, ac=5, m=5, scale=5, temp=5, dtemp=5, noisy=1)\n", "skidl_R['p', 'n']+=net_1, net_2\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "R1 N1 N2 5 ac=5 dtemp=5 m=5 noisy=1 scale=5 temp=5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.R('1', 'N1', 'N2', 5, ac=5, m=5, scale=5, temp=5, dtemp=5, noisy=1)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| S | Switch (voltage-controlled) |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| T | Lossless transmission line |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| U | Uniformly distributed RC line |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## V | Voltage source \n", "\n", "PySpice/PySpice/Spice/BasicElement.py; class VoltageSource(DipoleElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"V\"\n", "\n", "ngspice 4.1 Independent Sources for Voltage or Current: \n", "\n", "VXXXXXXX N| N- < DC/TRAN VALUE >\n", " \n", "### Notes\n", "- a reduced version of ngspices VXXXXXXX only generating the arguement for < DC/TRAN VALUE >" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "V1 N1 N2 5\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_V=V(ref='1', dc_value=5)\n", "skidl_V['p', 'n']+=net_1, net_2\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "V1 N1 N2 5\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.V('1', 'N1', 'N2', dc_value=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| W | Switch (current-controlled) |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| X | Subcircuit |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| Y | Single lossy transmission line (TXL) |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "| Z | Metal semiconductor field effect transistor (MESFET) |" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Z | Metal semiconductor field effect transistor (MESFET)\n", "PySpice/PySpice/Spice/BasicElement.py; class Mesfet(JfetElement)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"Z\"\n", "\n", "ngspice 10.1 MESFETs: \n", "\n", "ZXXXXXXX ND NG NS MNAME \n", " \n", "### Notes\n", "- `ic`: did not work in eather skidl or pyspice" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "ERROR: Unknown SPICE model: 5\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "Z1 N1 N2 N3 5 area=5 m=5 off\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "0 warnings found during netlist generation.\n", "1 errors found during netlist generation.\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2'); net_3=Net('N3')\n", "skidl_Z=Z(ref='1',model=5, area=5, m=5, off=5)\n", "skidl_Z['d', 'g', 's']+=net_1, net_2, net_3\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "Z1 N1 N2 N3 5 area=5 m=5 off\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.Z('1', 'N1', 'N2', 'N3', model=5, area=5, m=5, off=5)\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Highlevel Elements `SinusoidalMixin` Based\n", "\n", "## Note in Armour's fort added as_phase \n", "\n", "SinusoidalMixin is the base translation class for sinusoid wave waveform sources, in other words even thou ngspice compines most sinusoid source as just argument extations to exsisting DC source to create AC souces through pyspice to ngspice these elements must be used\n", "\n", "## `SinusoidalMixin` args:\n", "\n", "\n", "| Name | Parameter | Default Value | Units |\n", "|------|----------------|---------------|-------|\n", "| Vo | offset | | V, A |\n", "|------|----------------|---------------|-------|\n", "| Va | amplitude | | V, A |\n", "|------|----------------|---------------|-------|\n", "| f | frequency | 1 / TStop | Hz |\n", "|------|----------------|---------------|-------|\n", "| Td | delay | 0.0 | sec |\n", "|------|----------------|---------------|-------|\n", "| Df | damping factor | 0.01 | 1/sec |\n", "|------|----------------|---------------|-------|\n", "\n", "so for a AC SIN voltage sours it's output should be equilint to the following:\n", "\n", "$$V(t) = \\begin{cases}\n", " V_o & \\text{if}\\ 0 \\leq t < T_d, \\\\\n", " V_o + V_a e^{-D_f(t-T_d)} \\sin\\left(2\\pi f (t-T_d)\\right) & \\text{if}\\ T_d \\leq t < T_{stop}.\n", " \\end{cases}$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## SinusoidalVoltageSource (AC)\n", " \n", "\n", "PySpice/PySpice/Spice/HighLevelElement.py; class SinusoidalVoltageSource(VoltageSource, VoltageSourceMixinAbc, SinusoidalMixin)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"SINEV\"\n", "\n", "ngspice 4.1 Independent Sources for Voltage or Current & 4.1.2 Sinusoidal: \n", "\n", "VXXXXXXX N+ N- < DC/TRAN VALUE > >> >> >> \n", " \n", "SIN(VO VA FREQ TD THETA PHASE)\n", " \n", "### Notes\n", "- a amalgumation of ngspice's Independent Sources for Voltage & Sinusoidal statment for transint simulations" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "V1 N1 N2 DC 5V AC 5V SIN(5V 5V 5Hz 5s 5Hz)\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_SINV=SINEV(ref='1', \n", " #transit sim statments\n", " offset=5,amplitude=5, frequency=5 , delay=5, damping_factor=5,\n", " #ac sim statments\n", " ac_magnitude=5, dc_offset=5)\n", "\n", "skidl_SINV['p', 'n']+=net_1, net_2\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "V1 N1 N2 DC 5V AC 5V SIN(5V 5V 5Hz 5s 5Hz)\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.SinusoidalVoltageSource('1', 'N1', 'N2', \n", " #transit sim statments\n", " offset=5,amplitude=5, frequency=5 , delay=5, damping_factor=5,\n", " #ac sim statments\n", " ac_magnitude=5, dc_offset=5\n", " \n", " )\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## SinusoidalCurrentSource (AC)\n", " \n", "\n", "PySpice/PySpice/Spice/HighLevelElement.py; class class SinusoidalCurrentSource(CurrentSource, CurrentSourceMixinAbc, SinusoidalMixin):\n", "\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"SINEI\"\n", "\n", "ngspice 4.1 Independent Sources for Voltage or Current & 4.1.2 Sinusoidal: \n", "\n", "IYYYYYYY N+ N- < DC/TRAN VALUE > >> >> >> \n", " \n", "SIN(VO VA FREQ TD THETA PHASE)\n", " \n", "### Notes\n", "- a amalgumation of ngspice's Independent Sources for Voltage & Sinusoidal statment for transint simulations" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "I1 N1 N2 DC 5A AC 5A SIN(5A 5A 5Hz 5s 5Hz)\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_SINI=SINEI(ref='1', \n", " #transit sim statments\n", " offset=5,amplitude=5, frequency=5 , delay=5, damping_factor=5,\n", " #ac sim statments\n", " ac_magnitude=5, dc_offset=5)\n", "\n", "skidl_SINI['p', 'n']+=net_1, net_2\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "I1 N1 N2 DC 5A AC 5A SIN(5A 5A 5Hz 5s 5Hz)\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.SinusoidalCurrentSource('1', 'N1', 'N2', \n", " #transit sim statments\n", " offset=5,amplitude=5, frequency=5 , delay=5, damping_factor=5,\n", " #ac sim statments\n", " ac_magnitude=5, dc_offset=5\n", " \n", " )\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## AcLine(SinusoidalVoltageSource)\n", "PySpice/PySpice/Spice/HighLevelElement.py; class AcLine(SinusoidalVoltageSource)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; NOT IMPLIMENTED\n", "\n", "ngspice 4.1 Independent Sources for Voltage or Current: \n", "\n", "VXXXXXXX N+ N- < DC/TRAN VALUE > >> >> >> \n", " \n", "\n", "\n", "### Notes\n", "- it's a pyspice only wraper around pyspices `SinusoidalVoltageSource` that makes a pure for transisint simulation only SIN voltage source with the only arguments being `rms_voltage` and `frequency`\n", "- pyspice does the rms to amplitute conversion internaly\n", "- pyspice does not have a `offset` arg\n", "- pyspice does not have a `delay` arg\n", "- pyspice does not have a `damping_factor` arg\n", "- pyspice does not have a `ac_magnitude` arg\n", "- pyspice does not have a `dc_offset` arg\n", "- pspice still gives a AC output of the default 1V; this needs to be changed to be equal to `amplitude` internal value or else will give aid in producing incorect results with **ac** simulations" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "# Skidle does not impliment an AcLine equivlent at this time\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "V1 N1 N2 DC 0V AC 1V SIN(0V 11.313708498984761V 5Hz 0s 0Hz)\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.AcLine('1', 'N1', 'N2', \n", " #transit sim statments\n", " rms_voltage=8, frequency=5 \n", " \n", " )\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'skidl_netlist is shorter then pyspice_netlist'" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Highlevel Elements `PulseMixin` Based" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Highlevel Elements `ExponentialMixin` Based\n", "\n", "ExponentialMixin is the base translation class for exponential shped sources used for transisint simulations. Typicly used for simulating responce to charing and discharing events from capcitor/inductor networks. Pyspice does not include ac arguements that are technicly allowed by ngspice\n", "\n", "## `ExponentialMixin` args:\n", "\n", "\n", "\n", "| Name | Parameter | Default Value | Units |\n", "|------|--------------------|---------------|-------|\n", "| V1 | Initial value | | V, A |\n", "|------|--------------------|---------------|-------|\n", "| V2 | pulsed value | | V, A |\n", "|------|--------------------|---------------|-------|\n", "| Td1 | rise delay time | 0.0 | sec |\n", "|------|--------------------|---------------|-------|\n", "| tau1 | rise time constant | Tstep | sec |\n", "|------|--------------------|---------------|-------|\n", "| Td2 | fall delay time | Td1|Tstep | sec |\n", "|------|--------------------|---------------|-------|\n", "| tau2 | fall time constant | Tstep | sec |\n", "|------|--------------------|---------------|-------|\n", "\n", "so for a expoential based voltage source it's output should be equilint to the following:\n", "\n", "$$V(t) = \\begin{cases}\n", " V_1 & \\text{if}\\ 0 \\leq t < T_{d1}, \\\\\n", " V_1 + V_{21} ( 1 − e^{-\\frac{t-T_{d1}}{\\tau_1}} )\n", " & \\text{if}\\ T_{d1} \\leq t < T_{d2}, \\\\\n", " V_1 + V_{21} ( 1 − e^{-\\frac{t-T_{d1}}{\\tau_1}} ) + V_{12} ( 1 − e^{-\\frac{t-T_{d2}}{\\tau_2}} )\n", " & \\text{if}\\ T_{d2} \\leq t < T_{stop}\n", " \\end{cases}$$\n", "\n", "where $V_{21} = V_2 - V_1$ and $V_{12} = V_1 - V_2$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ExponentialVoltageSource \n", " \n", "\n", "PySpice/PySpice/Spice/HighLevelElement.py; class ExponentialVoltageSource(VoltageSource, VoltageSourceMixinAbc, ExponentialMixin)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"EXPV\"\n", "\n", "ngspice 4.1 Independent Sources for Voltage or Current & 4.1.3 Exponential: \n", "\n", "VXXXXXXX N+ N- \n", " \n", "EXP(V1 V2 TD1 TAU1 TD2 TAU2)\n", " \n", "### Notes\n", "- should technicly also alow dc and ac values from ngspice Independent voltage source statment" ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "V1 N1 N2 EXP(5V 5V 5s 5s 5s 5s)\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_EXPV=EXPV(ref='1', \n", " #transit sim statments\n", " initial_value=5,pulsed_value=5, rise_delay_time=5 , rise_time_constant=5, fall_delay_time=5, fall_time_constant=5,\n", " )\n", "\n", "skidl_EXPV['p', 'n']+=net_1, net_2\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "V1 N1 N2 EXP(5V 5V 5s 5s 5s 5s)\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.ExponentialVoltageSource('1', 'N1', 'N2', \n", " #transit sim statments\n", " initial_value=5,pulsed_value=5, rise_delay_time=5 , rise_time_constant=5, fall_delay_time=5, fall_time_constant=5,\n", " \n", " )\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ExponentialCurrentSource \n", " \n", "\n", "PySpice/PySpice/Spice/HighLevelElement.py; class ExponentialCurrentSource(VoltageSource, VoltageSourceMixinAbc, ExponentialMixin)\n", "\n", "skidl/skidl/libs/pyspice_sklib.py; name=\"EXPI\"\n", "\n", "ngspice 4.1 Independent Sources for Voltage or Current & 4.1.3 Exponential: \n", "\n", "IXXXXXXX N+ N- \n", " \n", "EXP(I1 I2 TD1 TAU1 TD2 TAU2)\n", " \n", "### Notes\n", "- should technicly also alow dc and ac values from ngspice Independent voltage source statment" ] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "I1 N1 N2 EXP(5A 5A 5s 5s 5s 5s)\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "No errors or warnings found during netlist generation.\n", "\n" ] } ], "source": [ "reset()\n", "net_1=Net('N1'); net_2=Net('N2')\n", "skidl_EXPI=EXPI(ref='1', \n", " #transit sim statments\n", " initial_value=5,pulsed_value=5, rise_delay_time=5 , rise_time_constant=5, fall_delay_time=5, fall_time_constant=5,\n", " )\n", "\n", "skidl_EXPI['p', 'n']+=net_1, net_2\n", "skidl_circ=generate_netlist()\n", "print(skidl_circ)" ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".title \n", "I1 N1 N2 EXP(5A 5A 5s 5s 5s 5s)\n", "\n" ] } ], "source": [ "pyspice_circ=Circuit('')\n", "pyspice_circ.ExponentialCurrentSource('1', 'N1', 'N2', \n", " #transit sim statments\n", " initial_value=5,pulsed_value=5, rise_delay_time=5 , rise_time_constant=5, fall_delay_time=5, fall_time_constant=5,\n", " \n", " )\n", "print(pyspice_circ)" ] }, { "cell_type": "code", "execution_count": 62, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Match'" ] }, "execution_count": 62, "metadata": {}, "output_type": "execute_result" } ], "source": [ "netlist_comp_check(skidl_circ, pyspice_circ)" ] }, { "cell_type": "markdown", "metadata": { "heading_collapsed": true }, "source": [ "# Highlevel Elements `PieceWiseLinearMixin` Based" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Highlevel Elements `SingleFrequencyFMMixin` Based" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Highlevel Elements `AmplitudeModulatedMixin` Based" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Highlevel Elements `RandomMixin` Based" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.6" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": true, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }