Exemplo n.º 1
0
                kmc.electrodes[cf.Q] = Q[k] * V_high
                kmc.update_V()
                kmc.simulate_discrete(prehops=500, hops=5000)
                output[k] = kmc.current[cf.output]
            outputArray[i, j] = output
            fitness += cf.Fitness(output, cf.target)

        genePool.fitness[j] = fitness / avg
        fitnessArray[i, j] = genePool.fitness[j]
    # Status print
    print("Generation nr. " + str(i + 1) + " completed")
    print("Highest fitness: " + str(max(genePool.fitness)))

    # Evolve to the next generation
    genePool.NextGen()

# Save experiment
filepath = SaveLib.createSaveDirectory(cf.filepath, cf.name)
SaveLib.saveExperiment(filepath,
                       geneArray=geneArray,
                       fitnessArray=fitnessArray,
                       outputArray=outputArray,
                       target=cf.target,
                       P=P,
                       Q=Q)

domain = kmc_dn_utils.visualize_basic(kmc)
plt.figure()
plt.plot(output)
plt.show()
Exemplo n.º 2
0
w = cf.InputGen()[3]  # Weight array
target = cf.TargetGen()[1]  # Target signal

# np arrays to save genePools, outputs and fitness
geneArray = np.zeros((cf.generations, cf.genomes, cf.genes))
outputArray = np.zeros((cf.generations, cf.genomes, len(x[0])))
fitnessArray = np.zeros((cf.generations, cf.genomes))

# Temporary arrays, overwritten each generation
fitnessTemp = np.zeros((cf.genomes, cf.fitnessavg))
outputAvg = np.zeros((cf.fitnessavg, len(x[0])))
outputTemp = np.zeros((cf.genomes, len(x[0])))
controlVoltages = np.zeros(cf.genes)

# Initialize save directory
saveDirectory = SaveLib.createSaveDirectory(cf.filepath, cf.name)

# Initialize main figure
mainFig = PlotBuilder.initMainFigEvolution(cf.genes, cf.generations, cf.genelabels, cf.generange)

# Initialize instruments
ivvi = InstrumentImporter.IVVIrack.initInstrument()

# Initialize genepool
genePool = Evolution.GenePool(cf)

#%% Measurement loop

for i in range(cf.generations):
    for j in range(cf.genomes):
        # Set the DAC voltages
Exemplo n.º 3
0
w = cf.InputGen()[3]  # Weight array
target = cf.TargetGen()[1]  # Target signal

# np arrays to save genePools, outputs and fitness
geneArray = np.zeros((cf.generations, cf.genomes, cf.genes))
outputArray = np.zeros((cf.generations, cf.genomes, len(x[0])))
fitnessArray = np.zeros((cf.generations, cf.genomes))

# Temporary arrays, overwritten each generation
fitnessTemp = np.zeros((cf.genomes, cf.fitnessavg))
outputAvg = np.zeros((cf.fitnessavg, len(x[0])))
outputTemp = np.zeros((cf.genomes, len(x[0])))
controlVoltages = np.zeros(cf.genes)

# Initialize save directory
saveDirectory = SaveLib.createSaveDirectory(cf.filepath, cf.name)

# Initialize main figure
mainFig = PlotBuilder.initMainFigEvolution(cf.genes, cf.generations,
                                           cf.genelabels, cf.generange)

# Initialize NN
main_dir = r'../../test/NN_test/data4nn/Data_for_testing/'
dtype = torch.cuda.FloatTensor
net = staNNet(main_dir + 'TEST_NN.pt')

# Initialize genepool
genePool = Evolution.GenePool(cf)

#%% Measurement loop
Exemplo n.º 4
0
# Update constant quantities that depend on I_0 and ab
kmc.calc_E_constant()
kmc.calc_transitions_constant()

# Define input signals
P = [0, 1, 0, 1]
Q = [0, 0, 1, 1]
w = [1, 1, 1, 1]
kmc.electrodes[cf.output, 3] = 0

# Initialize arrays to save experiment
geneArray = np.zeros((cf.generations, cf.genomes, cf.genes))
currentArray = np.zeros((cf.generations, cf.genomes, 8, 4 * cf.avg))
voltageArray = np.zeros((cf.generations, cf.genomes, 8, 4 * cf.avg))
fitnessArray = np.zeros((cf.generations, cf.genomes))
filepath = SaveLib.createSaveDirectory(cf.filepath, cf.name)
# Save experiment (also copies files)
SaveLib.saveExperiment(filepath,
                       geneArray=geneArray,
                       fitnessArray=fitnessArray,
                       currentArray=currentArray,
                       voltageArray=voltageArray,
                       target=cf.target,
                       P=P,
                       Q=Q)

for i in range(cf.generations):
    geneArray[i] = genePool.pool
    for j in range(cf.genomes):
        if (i == 0 and j == 1):
            tic = time.time()
Exemplo n.º 5
0
import sys

# Initialize config object
cf = config.experiment_config()

# Construct configuration array
voltages = grid(cf.electrodes, cf.voltageGrid)
voltages = voltages[:, ::-1]
print('First two indices are inputs, rest CV. Fastest CV has the last index!')

# Init data container
data = np.zeros((voltages.shape[0], voltages.shape[1] + cf.samples))
data[:, :voltages.shape[1]] = voltages

# initialize save directory
saveDirectory = SaveLib.createSaveDirectory(cf.filepath, cf.name)

# Initialize instruments
ivvi = InstrumentImporter.IVVIrack.initInstrument(dac_step=500,
                                                  dac_delay=0.001)

nr_blocks = len(cf.input1) * len(cf.input2)
blockSize = int(len(voltages) / nr_blocks)
assert len(
    voltages
) == blockSize * nr_blocks, 'Nr of gridpoints not divisible by nr_blocks!!'
#main acquisition loop
for j in range(nr_blocks):
    print('Getting Data for block ' + str(j) + '...')
    start_block = time.time()
    InstrumentImporter.IVVIrack.setControlVoltages(ivvi,
Exemplo n.º 6
0
import SkyNEt.modules.Evolution as Evolution
import SkyNEt.modules.SaveLib as SaveLib
import kmc_dopant_networks as kmc_dn
import kmc_dopant_networks_utils as kmc_dn_utils
import numpy as np
import matplotlib.pyplot as plt
import config_single_shot as config
import time

cf = config.experiment_config()

saveDirectory = SaveLib.createSaveDirectory(cf.filepath, cf.name)

#%% System setup
xdim = 1
ydim = 1

# Load layouts
acceptor_layouts = np.load('acceptor_layouts.npy')
donor_layouts = np.load('donor_layouts.npy')

# Define 8 electrodes
electrodes = np.zeros((8, 4))
electrodes[0] = [0, ydim / 4, 0, 0]
electrodes[1] = [0, 3 * ydim / 4, 0, 0]
electrodes[2] = [xdim, ydim / 4, 0, 10]
electrodes[3] = [xdim, 3 * ydim / 4, 0, 0]
electrodes[4] = [xdim / 4, 0, 0, 0]
electrodes[5] = [3 * xdim / 4, 0, 0, 0]
electrodes[6] = [xdim / 4, ydim, 0, 0]
electrodes[7] = [3 * xdim / 4, ydim, 0, 0]
Exemplo n.º 7
0
import SkyNEt.modules.Evolution as Evolution
import SkyNEt.modules.SaveLib as SaveLib
import kmc_dopant_networks as kmc_dn
import kmc_dopant_networks_utils as kmc_dn_utils
import numpy as np
import matplotlib.pyplot as plt
import config_temperature_dependence as config
import time

cf = config.experiment_config()

saveDirectory = SaveLib.createSaveDirectory(cf.filepath, cf.name)

#%% System setup
xdim = 1
ydim = 1

# Load layouts
acceptor_layouts = np.load('acceptor_layouts.npy')
donor_layouts = np.load('donor_layouts.npy')

# Define 8 electrodes
electrodes = np.zeros((2, 4))
electrodes[0] = [0, ydim / 2, 0, 0]
electrodes[1] = [1, ydim / 2, 0, 0]

kmc = kmc_dn.kmc_dn(1, 0, xdim, ydim, 0, electrodes=electrodes)
kmc.load_acceptors(acceptor_layouts[cf.layout])
kmc.load_donors(donor_layouts[cf.layout])

# Set parameters
Exemplo n.º 8
0
import SkyNEt.modules.SaveLib as SaveLib
import matplotlib.pyplot as plt
from SkyNEt.instruments import InstrumentImporter
import numpy as np
import os
import config_IV as config

# Load the information from the config class.
config = config.experiment_config()

# Initialize save directory.
saveDirectory = SaveLib.createSaveDirectory(config.filepath, config.name)

# Define the device input using the function in the config class.
Input = config.Sweepgen(config.v_high, config.v_low, config.n_points,
                        config.direction)

# Measure using the device specified in the config class.
if config.device == 'nidaq':
    Output = InstrumentImporter.nidaqIO.IO(Input, config.fs)
elif config.device == 'adwin':
    adwin = InstrumentImporter.adwinIO.InitInstrument()
    Output = InstrumentImporter.adwinIO.IO(adwin, Input, config.fs)
else:
    print('specify measurement device')

# Save the Input and Output
SaveLib.saveExperiment(saveDirectory, input=Input, output=Output)

# Plot the IV curve.
plt.figure()
Exemplo n.º 9
0
import SkyNEt.modules.Evolution as Evolution
import SkyNEt.modules.SaveLib as SaveLib
import kmc_dopant_networks as kmc_dn
import kmc_dopant_networks_utils as kmc_dn_utils
import numpy as np
import matplotlib.pyplot as plt
import config_IV as config

cf = config.experiment_config()

saveDirectory = SaveLib.createSaveDirectory(cf.filepath, cf.name)

#%% System setup
xdim = 1
ydim = 1
layout = 0

# Load layouts
acceptor_layouts = np.load('acceptor_layouts.npy')
donor_layouts = np.load('donor_layouts.npy')

# Define 8 electrodes
electrodes = np.zeros((8, 4))
electrodes[0] = [0, ydim / 4, 0, 0]
electrodes[1] = [0, 3 * ydim / 4, 0, 0]
electrodes[2] = [xdim, ydim / 4, 0, 10]
electrodes[3] = [xdim, 3 * ydim / 4, 0, 0]
electrodes[4] = [xdim / 4, 0, 0, 0]
electrodes[5] = [3 * xdim / 4, 0, 0, 0]
electrodes[6] = [xdim / 4, ydim, 0, 0]
electrodes[7] = [3 * xdim / 4, ydim, 0, 0]
Exemplo n.º 10
0
import SkyNEt.modules.Evolution as Evolution
import SkyNEt.modules.SaveLib as SaveLib
import kmc_dopant_networks as kmc_dn
import kmc_dopant_networks_utils as kmc_dn_utils
import numpy as np
import matplotlib.pyplot as plt
import config_single_shot as config
import time as timelib

cf = config.experiment_config()

saveDirectory = SaveLib.createSaveDirectory(cf.filepath, cf.name)

#%% System setup
xdim = 1
ydim = 1
layout = 0

# Load layouts
acceptor_layouts = np.load('acceptor_layouts.npy')
donor_layouts = np.load('donor_layouts.npy')

# Define 8 electrodes
electrodes = np.zeros((8, 4))
electrodes[0] = [0, ydim / 4, 0, 0]
electrodes[1] = [0, 3 * ydim / 4, 0, 0]
electrodes[2] = [xdim, ydim / 4, 0, 10]
electrodes[3] = [xdim, 3 * ydim / 4, 0, 0]
electrodes[4] = [xdim / 4, 0, 0, 0]
electrodes[5] = [3 * xdim / 4, 0, 0, 0]
electrodes[6] = [xdim / 4, ydim, 0, 0]
Exemplo n.º 11
0
input1 = [-900, 0, 900]
voltageGrid = [*controlVoltages, input2, input1]
electrodes = len(voltageGrid)  #amount of electrodes
acqTime = 0.01
samples = 50

#construct configuration array
voltages = grid(electrodes, voltageGrid)
voltages = voltages[:, ::-1]
print('First two indices are inputs, rest CV. Fastest CV has the last index!')
# init data container
data = np.zeros((voltages.shape[0], voltages.shape[1] + samples))
data[:, :voltages.shape[1]] = voltages

# initialize save directory
saveDirectory = SaveLib.createSaveDirectory(filepath, name)
# initialize instruments
ivvi = IVVIrack.initInstrument(dac_step=500, dac_delay=0.001)

nr_blocks = len(input1) * len(input2)
blockSize = int(len(voltages) / nr_blocks)
assert len(
    voltages
) == blockSize * nr_blocks, 'Nr of gridpoints not divisible by nr_blocks!!'
#main acquisition loop
for j in range(nr_blocks):
    print('Getting Data for block ' + str(j) + '...')
    start_block = time.time()
    IVVIrack.setControlVoltages(ivvi, voltages[j * blockSize, :])
    time.sleep(1)  #extra delay to account for changing the input voltages
    for i in range(blockSize):
Exemplo n.º 12
0
# Initialize data array
outputs = np.zeros((len(cf.layouts), len(cf.voltagelist)))

# Load layouts and target
acceptor_layouts = np.load('acceptor_layouts.npy')
donor_layouts = np.load('donor_layouts.npy')
voltagelist = cf.voltagelist

# Define 2 electrodes
electrodes = np.zeros((2, 4))
electrodes[0] = [0, ydim / 2, 0, 0]
electrodes[1] = [1, ydim / 2, 0, 0]

# Initialize arrays to save experiment
filepath = SaveLib.createSaveDirectory(cf.filepath, cf.name)
os.makedirs(filepath + '/kmc_objects')

for ii in range(len(cf.layouts)):
    layout = cf.layouts[ii]
    # Initialize kmc
    if (cf.use_random_layout):
        kmc = kmc_dn.kmc_dn(cf.layoutsize,
                            cf.layoutsize // 10,
                            xdim,
                            ydim,
                            0,
                            electrodes=electrodes)
    else:
        kmc = kmc_dn.kmc_dn(1, 0, xdim, ydim, 0, electrodes=electrodes)
        kmc.load_acceptors(acceptor_layouts[layout])
Exemplo n.º 13
0
# Initialize kmc
kmc = kmc_dn.kmc_dn(1, 0, xdim, ydim, 0, electrodes=electrodes)
kmc.load_acceptors(acceptor_layouts[layout])
kmc.load_donors(donor_layouts[layout])

# Parameters
kT = cf.kT
prehops = cf.prehops
hops = cf.hops
kmc.kT = kT

# Initialize arrays to save experiment
geneArray = np.zeros((cf.generations, cf.genomes, cf.genes))
outputArray = np.zeros((cf.generations, cf.genomes, len(voltagelist)))
fitnessArray = np.zeros((cf.generations, cf.genomes))
filepath = SaveLib.createSaveDirectory(cf.filepath, cf.name)

# Save experiment (also copies files)
SaveLib.saveExperiment(
    filepath,
    geneArray=geneArray,
    fitnessArray=fitnessArray,
    outputArray=outputArray,
    voltagelist=voltagelist,
    target=target,
)

for i in range(cf.generations):
    geneArray[i] = genePool.pool
    for j in range(cf.genomes):
        # Time estimation