Esempio n. 1
0
def generate_network(mem_pars, net_pars):
    if net_pars['type'] == graph_type[1]:
        G = nx.watts_strogatz_graph(net_pars['N'], net_pars['k'],
                                    net_pars['p'])
    elif net_pars['type'] == graph_type[2]:
        G = nx.random_regular_graph(net_pars['degree'], net_pars['N'])

    cir = Circuit('Memristor network test')

    # assign dictionary with terminals and memristors
    memdict = {}

    w = mem_pars['w']
    D = mem_pars['D']
    Roff = mem_pars['Roff']
    Ron = mem_pars['Ron']
    mu = mem_pars['mu']
    Tao = mem_pars['Tao']

    for e in G.edges_iter():
        rval = round(Roff + 0.01 * Roff * (random.random() - 0.5), 2)
        key = 'R' + str(e[0]) + str(e[1])
        [v1, v2] = [e[0], e[1]]
        memdict[key] = [
            v1, v2, memristor.memristor(w, D, Roff, Ron, mu, Tao, 0.0)
        ]  # we set v=0.0 value in the beginning
        cir.add_resistor(key, 'n' + str(v1), 'n' + str(v2), rval)
        G[e[0]][e[1]]['weight'] = rval
        # edge_labels[e]=rval;

    for n in G.nodes_iter():
        G.node[n]['number'] = n

    # Add random ground and voltage terminal nodes
    [v1, gnd] = random.sample(xrange(0, len(G.nodes())), 2)
    lastnode = len(G.nodes())
    G.add_edge(v1, lastnode)
    G.node[lastnode]['number'] = 'V1'
    lastnode += 1
    G.add_edge(gnd, lastnode)
    G.node[lastnode]['number'] = 'gnd'

    plot_graph(G)

    export_graph(
        G,
        '/Users/nfrik/CloudStation/Research/LaBean/ESN/FalstadSPICE/test.txt')

    cir.add_resistor("RG", 'n' + str(gnd), cir.gnd, 0.001)
    cir.add_vsource("V1", 'n' + str(v1), cir.gnd, 1000)
    opa = new_op()

    # netdict contains setup graph and circuit
    networkdict = {}
    networkdict['Graph'] = G
    networkdict['Circuit'] = cir
    networkdict['Memristors'] = memdict
    networkdict['Opa'] = opa

    return networkdict
Esempio n. 2
0
def generate_network(mem_pars, net_pars):
    if net_pars['type']==graph_type[1]:
        G = nx.watts_strogatz_graph(net_pars['N'],net_pars['k'],net_pars['p'])
    elif net_pars['type']==graph_type[2]:
        G = nx.random_regular_graph(net_pars['degree'], net_pars['N'])

    cir = Circuit('Memristor network test')

    # assign dictionary with terminals and memristors
    memdict = {}

    w = mem_pars['w']
    D = mem_pars['D']
    Roff = mem_pars['Roff']
    Ron = mem_pars['Ron']
    mu = mem_pars['mu']
    Tao = mem_pars['Tao']

    for e in G.edges_iter():
        rval = round(Roff + 0.01 * Roff * (random.random() - 0.5), 2)
        key = 'R' + str(e[0]) + str(e[1])
        [v1, v2] = [e[0], e[1]]
        memdict[key] = [v1, v2,
                        memristor.memristor(w, D, Roff, Ron, mu, Tao, 0.0)]  # we set v=0.0 value in the beginning
        cir.add_resistor(key, 'n' + str(v1), 'n' + str(v2), rval)
        G[e[0]][e[1]]['weight'] = rval
        # edge_labels[e]=rval;

    for n in G.nodes_iter():
        G.node[n]['number'] = n

    # Add random ground and voltage terminal nodes
    [v1, gnd] = random.sample(xrange(0, len(G.nodes())), 2)
    lastnode = len(G.nodes())
    G.add_edge(v1, lastnode)
    G.node[lastnode]['number'] = 'V1'
    lastnode += 1
    G.add_edge(gnd, lastnode)
    G.node[lastnode]['number'] = 'gnd'

    plot_graph(G)

    export_graph(G,'/Users/nfrik/CloudStation/Research/LaBean/ESN/FalstadSPICE/test.txt')

    cir.add_resistor("RG", 'n' + str(gnd), cir.gnd, 0.001)
    cir.add_vsource("V1", 'n' + str(v1), cir.gnd, 1000)
    opa = new_op()

    # netdict contains setup graph and circuit
    networkdict = {}
    networkdict['Graph'] = G
    networkdict['Circuit'] = cir
    networkdict['Memristors'] = memdict
    networkdict['Opa']=opa

    return networkdict
Esempio n. 3
0
        yw.append(mem1.getW())
        yi.append(mem1.getI())
        yr.append(mem1.getR())
        xv.append(mem1.getV())
        mem.updateW()
        mem.setV(wave(a0, f0, i))

    return [yw, yr, yi, xv]


#(w, D, Roff, Ron, v, mu, Tao):
# mem1 = memristor(0.1,1.0,10000.0,10.0,10.0,0.1,100.1)
mem1 = memristor(w=25e-9,
                 D=50e-9,
                 Roff=16e3,
                 Ron=100.0,
                 mu=1e-14,
                 Tao=0.001,
                 v=1.0)
mem2 = memristor(w=25e-9,
                 D=50e-9,
                 Roff=16e3,
                 Ron=100.0,
                 mu=1e-14,
                 Tao=0.001,
                 v=1.0)
# mem2 = memristor(0.1,1.0,10000.0,10.0,10.0,0.1,100.1)

fig, (ax1, ax2, ax3) = plt.subplots(3, 1)
plt.subplots_adjust(left=0.25, bottom=0.25)