-
Notifications
You must be signed in to change notification settings - Fork 0
/
runSimulation.m
84 lines (72 loc) · 3.25 KB
/
runSimulation.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
% Make sure you have added the folder 'asn', including its subdiretories
close all;
clear;
tic
%% Set the seed for PRNGs for reproducibility:
rng(42)
s = rng;
%% Simulation general options:
SimulationOptions.seed = s; % save
SimulationOptions.dt = 1e-3; % (sec)
SimulationOptions.T = 10 ; % (sec) duration of simulation
SimulationOptions.TimeVector = (SimulationOptions.dt:SimulationOptions.dt:SimulationOptions.T)';
SimulationOptions.NumberOfIterations = length(SimulationOptions.TimeVector);
%% Simulation recording options:
SimulationOptions.ContactMode = 'preSet'; % 'farthest' \ 'specifiedDistance' \ 'random' (the only one relevant for 'randAdjMat' (no spatial meaning)) \ 'preSet'
SimulationOptions.electrodes = [73,30];
SimulationOptions.numOfElectrodes = length(SimulationOptions.electrodes);
%% Generate Connectivity:
Connectivity.WhichMatrix = 'nanoWires'; % 'nanoWires' \ 'randAdjMat'
switch Connectivity.WhichMatrix
case 'nanoWires'
Connectivity.filename = '2016-09-08-155153_asn_nw_00100_nj_00261_seed_042_avl_100.00_disp_10.00.mat';
% Connectivity.filename = '2016-09-08-155044_asn_nw_00700_nj_14533_seed_042_avl_100.00_disp_10.00.mat';
case 'randAdjMat'
Connectivity.NumberOfNodes = 30;
Connectivity.AverageDegree = 10;
end
Connectivity = getConnectivity(Connectivity);
%% Choose contacts:
if strcmp(SimulationOptions.ContactMode, 'specifiedDistance')
SimulationOptions.BiProbeDistance = 1500; % (um)
end
%% Initialize dynamic components:
Components.ComponentType = 'atomicSwitch'; % 'atomicSwitch' \ 'memristor' \ 'resistor'
Components = initializeComponents(Connectivity.NumberOfEdges,Components);
%% Initialize stimulus:
Signals = cell(SimulationOptions.numOfElectrodes,1);
% Stimulus1.BiasType = 'SinglePulse'; % 'DC' \ 'AC' \ 'DCandWait' \ 'Ramp'
% Stimulus1.OnTime = 0;
% Stimulus1.OffTime = 100;
% Stimulus1.AmplitudeOn = 0.3;
% Stimulus1.AmplitudeOff = 0.005;
% Signals{1,1} = getStimulus(Stimulus1, SimulationOptions);
Stimulus1.BiasType = 'DC'; % 'DC' \ 'AC' \ 'DCandWait' \ 'Ramp'
Stimulus1.Amplitude = 1.1;
Stimulus1.AmplitudeOff = 0.005;
Signals{1,1} = getStimulus(Stimulus1, SimulationOptions);
Stimulus2.BiasType = 'Drain'; % 'DC' \ 'AC' \ 'DCandWait' \ 'Ramp'
Signals{2,1} = getStimulus(Stimulus2, SimulationOptions);
% Stimulus2.BiasType = 'SinglePulse';
% Stimulus2.OnTime = 2.0;
% Stimulus2.OffTime = 3.0;
% Stimulus2.AmplitudeOn = -1.4;
% Stimulus2.AmplitudeOff = -0.005;
% Signals{2,1} = getStimulus(Stimulus2, SimulationOptions);
%
% Stimulus3.BiasType = 'SinglePulse'; % 'DC' \ 'AC' \ 'DCandWait' \ 'Ramp'
% Stimulus3.OnTime = 0.0;
% Stimulus3.OffTime = 1.0;
% Stimulus3.AmplitudeOn = 1.4;
% Stimulus3.AmplitudeOff = 0.005;
% Signals{3,1} = getStimulus(Stimulus3, SimulationOptions);
%
% Stimulus4.BiasType = 'Drain'; % 'DC' \ 'AC' \ 'DCandWait' \ 'Ramp'
% Signals{4,1} = getStimulus(Stimulus4, SimulationOptions);
%% Simulate:
fprintf('Running simulation ...')
[Output, SimulationOptions, snapshots] = simulateNetworkLite(Connectivity, Components, Signals, SimulationOptions); % (Ohm)
fprintf('\n')
% run DataExport.m
toc
%run ShowMe.m