-
Couldn't load subscription status.
- Fork 87
Description
Hi, I have a question about a User definition device with non-linear properties
I want to define a specific current source with a specific variable factor.
ex ) when I define that I_current_source is 1.6e-19 * (4e+14) * (V_n1 - V_n2 - 1.12)*((F_MAX)(3/2))*mp.exp(-(3.1e+7)/F_MAX), this I_current_source has specific variable factor "F_MAX = abs(-Root_2 *((((float(V_n3 - V_n4))1.6e-195e+19)/8.854e-14)(1/2)))".
(V_n is node voltage when the circuit is running)
Also, because my circuit has a time transient voltage source, node voltages (=V_n1,2,3,4) vary according to time. so, transient analysis must be implemented.
This is my defined device code. But it doesn't work.
n1 = cir.add_node('n1')
n2 = cir.add_node('n2')
n3 = cir.add_node('n3')
n4 = cir.add_node('n4')
class I_current_source(ahkab.devices.Component):
def __init__(self, part_id, n1, n2, n3, n4):
self.part_id = part_id
self.n1 = n1
self.n2 = n2
self.n3 = n3
self.n4 = n4
self.ports = ((self.n1, self.n2),(self.n3, self.n4),)
self.is_nonlinear = True
self.is_symbolic = False
def get_ports(self):
return ((n1,n2,n3))
def get_output_ports(self):
return ((self.n1, self.n2),)
def get_drive_ports(self, op):
if not op == 0:
raise ValueError('C_dep %s has no output port %d' %
(self.part_id, op))
return self.ports
def g(self, op_index, v, port_index, time=0):
return 0
def i(self, op_index, ports_v, time=0):
F_MAX = abs(-Root_2 *((((float(ports_v[0][1]))*q*N_BL_D)/epsilon_si)**(1/2)))
IGIDL = q * (4e+14) * (float(ports_v[0][0]) - 1.12)*((F_MAX)**(3/2))*mp.exp(-(3.1e+7)/F_MAX)
return IGIDL
def get_op_info(self, ports_v):
vn1n2 = float(ports_v[0][0])
In1n2 = float(self.i(0))
op_keys = ['Part ID', "V(n1-n2) [V]", "I [A]"]
op_info = [self.part_id.upper(), vn1n2, In1n2 ]
return op_keys, op_info
def get_netlist_elem_line(self, nodes_dict):
return "%s %s %s %s %s" % (self.part_id, nodes_dict[self.n1],
nodes_dict[self.n2], nodes_dict[self.n3],nodes_dict[self.n4])
element=I_current_source('I_current_source', n1 = n1 , n2 = n2, n3 = n3, n4 = n4)
mycir.append(element)
-----n1---I_current_source---n2----- (n1,n2 is output ports)
so, If you know what my problem is, I would appreciate it if you could give me feedback.