示例#1
0
 def __init__(self):
     self.__class__.locked = False
     
     import gnucap
     self.gnucap = gnucap
     
     gnucap.command("set lang=acs")
     self.runmode = gnucap.SET_RUN_MODE(gnucap.rBATCH)
示例#2
0
def eval(V_SUPPLY=2., LMIN=0.000001, INP_FREQ=850000000., WP=.007963, TEMP=25.):
	if np.isnan(V_SUPPLY):
		raise ValueError()

	command("param V_SUPPLY="+str(V_SUPPLY))
	command("transient 'INP_PERIOD/100' 'NO_PERIODS*INP_PERIOD' > x")

	command('measure ZP_SUPPLY0 rms(probe="I(VDD)" begin=tmeas_start end=tmeas_stop)>/dev/null')
	command("measure ZVHIGH1 at(probe='v(OUT)' at='TMEAS_2')>/dev/null")
	command("measure ZVLOW2  at(probe='v(OUT)' at='TMEAS_1')>/dev/null")

	zps = gnucap.eval("ZP_SUPPLY0")
	zvhigh = gnucap.eval("ZVHIGH1")
	zvlow = gnucap.eval("ZVLOW2")

	return zps, zvhigh, zvlow
示例#3
0
def eval(*args):
	for i,a in enumerate(args):
		if np.isnan(a):
			raise ValueError()
		command("param "+varnames[i]+"="+str(a))

	command("dc VIN -1 4 .1>/dev/null")
	command('measure DELTA rms(probe="V(CMP)")>/dev/null')

	delta = gnucap.eval("DELTA")

	return delta, 0
示例#4
0
"""
PSS analysis experiments

Currently the TRANSIENT analysis is subclassed and the accept method is
overloaded where the shooting newton iteration jacobian is formed using
the C matrix and the transient jacobian 

"""

import os
import numpy as np
import pylab

import gnucap

gnucap.command("set lang=acs")

## Set gnucap run mode
runmode = gnucap.SET_RUN_MODE(gnucap.rBATCH)

gnucap.command("get shooting.ckt")

class MyTransient(gnucap.TRANSIENT):
    def do_it(self, cmd, scope):
        n = gnucap.cvar.status.total_nodes
        self.Jshoot = np.eye(n)
        self.lastC = None

        ## Prepare AC analysis
        card_list = gnucap.cvar.CARD_LIST_card_list
        gnucap.cvar.SIM_jomega = 1j;
示例#5
0
class MyAC(gnucap.SIM):
	def do_it(self, cmd, scope):
		print("HELLOWORLD")
		stdout.flush()

ac = MyAC()
c1 = gnucap.install_command("myac", ac)
stdout.flush()

# test: "already installed"
c2 = gnucap.install_command("myac", ac)
stdout.flush()

print("running ac")
stdout.flush()
gnucap.command("ac 1 2 * 2")
stdout.flush()

print("running myac")
stdout.flush()
gnucap.command("myac 1 2 * 2")

try:
	c = gnucap.CARD()
	assert(False)
except RuntimeError:
	pass
except AttributeError:
	pass

示例#6
0
#import libgnucap

import gnucap

gnucap.command("print dc hidden(0)")
gnucap.command("print tran hidden(0)")
gnucap.command("dc trace=i")
gnucap.command("dc trace=i")
gnucap.command("ac")
gnucap.command("op")
gnucap.command("transient 0 1 1")
gnucap.command("error")  # BUG
gnucap.command("status notime")
示例#7
0
		self.HACK=[]

	def custom(self):
		return 42

	def clone(self):
		print("somelt clone")
		x = mytype(self)
		self.HACK.append(x)
		x.__class__ = mytype
		return x

s = mytype()
d1 = install_device("mytype", s)

command("set lang verilog")
parse("mytype #() a();")
parse("resistor #() r(0,0);")

cl = CARD_LIST().card_list_()
print("tst")
for a in cl:
	print(a.long_label(), "..")
	if(isinstance(a, mytype)):
		print(".. is mytype")
		assert(42==a.custom())
		assert(isinstance(a, ELEMENT))

	if(isinstance(a, ELEMENT)):
		print(".. is element")
		assert(isinstance(a, COMPONENT))
示例#8
0
def setup_circuit():
	command("get mosfit.sp")
	command("store dc v(cmp)")
	command("options reltol=.0001")
	command("options abstol=1e-14")
示例#9
0
"""
Create a new ac-analysis that always runs at a single frequency
"""

import os
import numpy as np
import pylab

import gnucap

gnucap.command("set lang=acs")

## Set gnucap run mode
runmode = gnucap.SET_RUN_MODE(gnucap.rBATCH)

gnucap.command("get example.ckt")

class MyAC(gnucap.SIMWrapper):
    def do_it(self, cmd, scope):
        self._scope = scope
        self.set_command_ac()

        self.init()

        self.alloc_vectors()

        acx =  gnucap.cvar.CKT_BASE_acx ## Static attributes must be accessed
                                        ## through cvar

        acx.reallocate()
示例#10
0
import os
import numpy as np
import pylab

import gnucap

## Load custom plot command
import loadplot

## Load example circuit and run an ac analysis
gnucap.command("get example.ckt")
gnucap.command("store ac vm(2)")
gnucap.command("ac oct 10 1k 100k")

## Now use the new command to plot vm(2)
gnucap.command("myplot vm(2)")

示例#11
0
# simoverride unit test
#
# Copyright 2018 Felix Salfelder
# Author: Felix Salfelder
#
# inspired by "custom_ac.py" 2009-2011 Henrik Johansson

from __future__ import print_function

import os
import numpy as np
import gnucap

gnucap.command("set trace")
gnucap.command("set lang=acs")

## Set gnucap run mode
runmode = gnucap.SET_RUN_MODE(gnucap.rBATCH)

gnucap.command("set lang=spice")
gnucap.parse("Vin 1 0 dc 0 ac 1.0")
gnucap.parse("R1 1 2 1e3")
gnucap.parse("C1 2 0 1e-8")
gnucap.command("list")


class MyAC(gnucap.SIM):
    def do_it(self, cmd, scope):
        self._scope = scope
        self._sim.set_command_ac()
        self._sim.init()
示例#12
0
"""
PSS analysis experiments

Currently the TRANSIENT analysis is subclassed and the accept method is
overloaded where the shooting newton iteration jacobian is formed using
the C matrix and the transient jacobian 

"""

import os
import numpy as np
import pylab

import gnucap

gnucap.command("set lang=acs")

## Set gnucap run mode
runmode = gnucap.SET_RUN_MODE(gnucap.rBATCH)

gnucap.command("get shooting.ckt")


class MyTransient(gnucap.TRANSIENT):
    def do_it(self, cmd, scope):
        n = gnucap.cvar.status.total_nodes
        self.Jshoot = np.eye(n)
        self.lastC = None

        ## Prepare AC analysis
        card_list = gnucap.cvar.CARD_LIST_card_list
示例#13
0
def setup_circuit():
	command("get inv.sp")
	command("store op v(nodes)")
	command("print op v(nodes)")
	command("store tran v(nodes) i(vdd)")
示例#14
0
import os
import numpy as np
import pylab

import gnucap

gnucap.command("set lang=acs")

## Set gnucap run mode
runmode = gnucap.SET_RUN_MODE(gnucap.rBATCH)

## Load custom plot command
import loadplot

## Load example circuit and run an ac analysis
gnucap.command("get example.ckt")
gnucap.command("store ac vm(2)")
gnucap.command("ac oct 10 1k 100k")

## Now use the new command to plot vm(2)
gnucap.command("myplot vm(2)")

示例#15
0
    def tr_iwant_matrix(self):
        pass

    def tr_probe_num(self, s):
        return 4.

    # uses default if not specified.
    # def clone(self):
    #	return __class__(self)


d4 = mytype4()
b2 = install_device("mytype4", d4)

command("set lang verilog")
parse("dummy #() d();")
parse("mytype #() a1();")
parse("mytype4 #() a4(0, 0);")
parse("resistor #() r(0,0);")

cl = CARD_LIST().card_list_()
for a in cl:
    print(a.long_label(), a.dev_type())

import sys
sys.stdout.flush()
command("list")
command("print op test(*)")
command("op")
示例#16
0
            ELEMENT.__init__(self)
        else:
            ELEMENT.__init__(self, other)

    def custom(self):
        return 42

    def dev_type(self):
        return "mytype0"

    def clone(self):
        s = mytype(self)
        return s


m = mytype()
a = install("mytype0|y", m)
b = install("y", m)

command("set lang verilog")
parse("mytype0 #() a0();")
parse("mytype1 #() a1();")
parse("mytype2 #() a2();")
parse("resistor #() r(0,0);")

cl = CARD_LIST().card_list_()
for a in cl:
    print(a.long_label(), a.dev_type())

command("simcmd")
示例#17
0
# (C) 2018 Felix Salfelder
# GPLv3
#
# this is part of gnucap-python

import gnucap, os, sys
from gnucap import command, parse

f=open("crash.sp", "w")
f.write("spice\n")
f.write(".subckt a 1 2 3\n")
f.write("r1 1 2 3\n")
f.write(".ends\n")
f.close()

command("get crash.sp")

os.remove("crash.sp")

parse("X1 1 3 4 a")

command("list")

print("end of crashtest")
示例#18
0
#!/usr/bin/env python

import gnucap

gnucap.command("print op hidden(0)")
gnucap.command("store op hidden(0)")
gnucap.command("op")
w = gnucap.CKT_BASE_find_wave("hidden(0)")

gnucap.command("param test=17")
gnucap.command("eval test")
gnucap.command("measure mm at(probe='hidden(0)')")

assert (17 == gnucap.eval("test"))
assert (0 == gnucap.eval("mm"))

for i in w:
    print(i)