forked from SMuscimol/multiDchaos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind-meanfield-solution-iteratively.jl
75 lines (56 loc) · 1.48 KB
/
find-meanfield-solution-iteratively.jl
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
using JLD
using RateNet
using AdaptiveNet
using MyTools
netType = ARGS[1]
gamma = parse(Float64,ARGS[2])
b = parse(Float64, ARGS[3])
gFactor = parse(Float64, ARGS[4])
inpFreq = parse(Float64, ARGS[5])
inpAmp = parse(Float64, ARGS[6])
dataDir = ARGS[7]
if netType == "standard"
g = gFactor
elseif netType == "adapt"
g = gFactor.*getcriticalg(gamma,b)
end
inpArea = 0.25.*(inpAmp).^2
gF(x) = piecewiseLinearGain.(x)
tauA = 1
try
tauA = 1./gamma
end
iterations = 200
shift = true
dFreq = 0.001
maxFreq = 2.0
dIntSigmaFactor = 200
if shift
freqRange = -maxFreq:dFreq:maxFreq
else
freqRange = vcat( 0.:dFreq:maxFreq, -(maxFreq-dFreq):dFreq:-dFreq)
end
inpS = zeros(size(freqRange))
inpS[find(x->abs.(x)==inpFreq, freqRange)] = inpArea./dFreq
S0 = ones(size(freqRange))
SR = AdaptiveNet.iterativemethod(iterations, freqRange,S0, g, gF, AdaptiveNet.PWLnonlinearpass;
externalInput=true, saveAll=false, externalSpectrum=inpS, dFreq=dFreq, maxFreq=maxFreq, netType=netType, tauA = tauA, beta=b, tauX=1., stopAtConvergence=false, dIntSigmaFactor=200)
toName = Dict(
"netType"=>netType,
"gFactor"=>gFactor,
"beta"=>b,
"gamma"=>gamma,
"inpFreq"=>inpFreq,
"inpAmp"=>inpAmp,
"iterations"=>iterations
)
randomSignature = string(round(rand(),4))
filename = getfilename(string(dataDir,"spectrum_iterative_driven_PWL"),toName,randomSignature,".jld")
try
close(f)
end
f = jldopen(filename,"w")
f["freqRange"] = freqRange
f["SR"] = SR
f["inpS"] = inpS
close(f)