def read_single_S_list(filen, i, j):
    filen_i = filen+".%i.%i" % (i,j)
    print "reading file: "+filen_i
    try:
        data = scat.read_S(data_direc, filen_i)
        return data
    except Exception:
        if 'problems' in globals():
            problems.append(filen_i) 
        print "WARNING: problem reading "+filen_i
        return np.zeros((1, 3*nfreq, 2*nin_max, 2*nin_max), dtype='complex')
Example #2
0
def read_single_S_list(filen, i, j):
    filen_i = filen + ".%i.%i" % (i, j)
    print "reading file: " + filen_i
    try:
        data = scat.read_S(data_direc, filen_i)
        return data
    except Exception:
        if 'problems' in globals():
            problems.append(filen_i)
        print "WARNING: problem reading " + filen_i
        return np.zeros((1, nfreq, 2 * nin_max, 2 * nin_max), dtype='complex')
Example #3
0
plot_direc = "../../VSC2/AverageDwellTime-20130618/" + filen + "/"

try:
    obstacles = np.loadtxt(plot_direc + 'potential.dat', usecols=(1, ))
    obst_mask = abs(obstacles) == 0
    obst_ratio = float(np.shape(obstacles[obst_mask])[0]) / float(
        np.shape(obstacles)[0])
    print "filling factor of obstacles: %5f" % (1.0 - obst_ratio)
except:
    obst_ratio = 0.94
    print "WARNING: automatically assuming filling fraction to be 0.06"

# Weyl estimate for dwell time: A / 2Pi = W * L * (1-fill) / 2Pi
Weyl = [10 * L * 10 * obst_ratio / (2 * Pi)] * nfreq

energs = scat.read_S(data_direc, filen + ".0.0")[2]
if (len(energs) == 0):
    kmin = 3.1 * np.pi / 10.
    kmax = 4.9 * np.pi / 10.
    dk = 0.5 * (kmin + kmax) * 10**(-7)
else:
    kvals = np.sqrt(2 * energs)
    dk = (kvals[-1] - kvals[-3]) / 2.0

dims = np.take(
    scat.read_S(data_direc, filen + ".0.0")[1] / 2, np.arange(1, 3 * nfreq, 3))
nin_max = np.max(dims)


def read_single_S_list(filen, i, j):
    filen_i = filen + ".%i.%i" % (i, j)
#!/usr/bin/env python

import numpy as np
import scipy as sp
import scipy.optimize as spopt
import matplotlib.pyplot as plt
import sys
from math import pi as Pi

from Utils import utils as ut
from Scattering import scattering2D as scat

filen = str(sys.argv[1]) # namestring of calculation
n     = int(sys.argv[2]) # number of calculation
dims  = int(sys.argv[3]) # number of open modes in left lead

data_direc = "../../VSC2/AverageDwellTime-20130618/" + filen + "/scatterdata/"

energs = scat.read_S(data_direc, filen+".%i.0"%n)[2]
kvals = np.sqrt(2*energs)
dk = (kvals[-1] - kvals[-2]) / 1.0

filen_i = filen+".%i.%i" % (n,0)
print "reading file: "+filen_i
S = scat.read_S(data_direc, filen_i)[0]
q_mean = np.trace(scat.calc_Q(S,dk)[0]) /(2*dims)

print q_mean.real
Example #5
0
#!/usr/bin/env python

import numpy as np
from Scattering import scattering2D as scat
from Utils_green import utils as ut
import matplotlib.pyplot as plt

filen = "sp18"
file_path = "/home/lv70071/ambichl/greens_code/calculations/Spiral-20141105/" + filen + "/"

d = 1.0
pphwl = 10
L_lead = 15.0 * d

S, dims, energs = scat.read_S(file_path, filen, old_ver=0)
nin = dims/2
Nw = np.shape(dims)[0]
modes_max = np.sqrt(2.0 * energs[-1]) * d / np.pi
# hier z.B. kleine numerische Ungenauigkeiten!
nyout = np.floor(modes_max * pphwl)
dx = d / (nyout + 1.0)
L_lead += dx

t = []
for w in range(Nw):
    #t.append(S[w][:nin[w],nin[w]:])
    t.append(S[w][nin[w]:,:nin[w]])    

flux_factors = []
t_perf = []
for e in energs:
data_direc = "../../VSC2/AverageDwellTime-20130618/" + filen + "/scatterdata/"
plot_direc = "../../VSC2/AverageDwellTime-20130618/" + filen + "/"

try:
    obstacles = np.loadtxt(plot_direc + 'potential.dat', usecols=(1,))
    obst_mask = abs(obstacles) == 0
    obst_ratio = float(np.shape(obstacles[obst_mask])[0]) / float(np.shape(obstacles)[0])
    print "filling factor of obstacles: %5f" % (1.0-obst_ratio)
except:
    obst_ratio = 0.94
    print "WARNING: automatically assuming filling fraction to be 0.06"

# Weyl estimate for dwell time: A / 2Pi = W * L * (1-fill) / 2Pi
Weyl = [10*L*10 * obst_ratio / (2*Pi)]*nfreq

energs = scat.read_S(data_direc, filen+".0.0")[2]
if (len(energs)==0):
    kmin = 3.1 * np.pi / 10.
    kmax = 4.9 * np.pi / 10.
    dk = 0.5 * (kmin+kmax) * 10**(-7)
else:
    kvals = np.sqrt(2*energs)
    dk = (kvals[-1] - kvals[-3]) / 2.0

dims = np.take(scat.read_S(data_direc, filen+".0.0")[1]/2, np.arange(1,3*nfreq,3))
nin_max = np.max(dims)

def read_single_S_list(filen, i, j):
    filen_i = filen+".%i.%i" % (i,j)
    print "reading file: "+filen_i
    try:
from Calc import transmission as trans
from Calc import localization as local


if (len(sys.argv)!=6):
    sys.exit("ABORT: parameters filen, # of radius variations, # of configurations,  # of frequency variations, length of system [W] needed")

filen = str(sys.argv[1]) # namestring of calculation
nr    = int(sys.argv[2]) # number of radius variations
nconf = int(sys.argv[3]) # number of configurations to be averaged over
nfreq = int(sys.argv[4]) # number of frequency steps scanned over
L = float(sys.argv[5]) # length of system in units of width

data_direc = "../../VSC2/AverageDwellTime-20130618/" + filen + "/scatterdata/"

energs = scat.read_S(data_direc, filen+".0.0")[2]
if (len(energs)==0):
    kmin = 3.1 * np.pi / 10.
    kmax = 4.9 * np.pi / 10.
    dk = 0.5 * (kmin+kmax) * 10**(-7)
else:
    kvals = np.sqrt(2*energs)
    dk = (kvals[-1] - kvals[-3]) / 2.0

dims = scat.read_S(data_direc, filen+".0.0")[1]/2
nin_max = np.max(dims)

def read_single_S_list(filen, i, j):
    filen_i = filen+".%i.%i" % (i,j)
    print "reading file: "+filen_i
    try:
Example #8
0
else:
    print "specify machine (VSC: 1, VSC2: 2)"

if machine == 1:
    pic_direc = ("/home/ambichl/Universitaet/Scattering-Data/"
                  "VSC/Fibres-20130819/" + pic_filen + "/")
elif machine == 2:
    pic_direc = ("/home/ambichl/Universitaet/Scattering-Data/"
                  "VSC2/Fibres-20130802/" + pic_filen + "/")

plot_direc = data_direc

fullout = False


S, dims = scat.read_S(data_direc, filen, old_ver=1)
modes = int(max(dims)/2)

if (len(dims)%3 == 0):
    Nk = len(dims)/3
else:
    sys.exit("ABORT: # of S matrices not divisible by 3")

if (refmodes > int(min(dims)/2)):
    print ("WARNING: # of modes under consideration (%i)"
           "> # minimum number of modes (%i)") % (refmodes,int(min(dims)/2))


t , t_q = trans.calc_t(S, dims, refmodes)
#trans.write_teigvals(t_q, refmodes)
q = []
   lead_width = float(par['lead_width'])
   nyout = int(par['nyout'])
   modes_min = float(par['modes_min'])
   modes_max = float(par['modes_max'])
   nin = int(par['refmodes']) # nin = refmodes
   ptc = int(par['ptc'])
except KeyError:
    raw_input("WARNING: parameter missing in pinput.dat")

kmean = 0.5 * (modes_max + modes_min) * np.pi / lead_width
dk =  kmean * 10**(-8)
nin_Max = int(0.5 * (modes_max + modes_min)) # nin_Max = n_open_modes
dy = lead_width / (nyout + 1)
yrange = np.arange(1,nyout+1)*dy

S, dims, energs = scat.read_S('./', filen)

t = []
t_q = []
for i in range(3):
    m = dims[i]/2
    n = min(m, nin)
    t.append( S[i][m:,0:m] )      # full t-matrix
    t_q.append( S[i][m:m+n,0:n] ) # considered part of t-matrix 

def calc_modes(n):
   '''
   calculate normalized n-th lead mode

   In Flo's code y-axis points downwards, y=0 is upper egde of lead;
   modes are chosen such that most upper point is real and positive.
Example #10
0
from Calc import localization as local

if (len(sys.argv) != 6):
    sys.exit(
        "ABORT: parameters filen, # of radius variations, # of configurations,  # of frequency variations, length of system [W] needed"
    )

filen = str(sys.argv[1])  # namestring of calculation
nr = int(sys.argv[2])  # number of radius variations
nconf = int(sys.argv[3])  # number of configurations to be averaged over
nfreq = int(sys.argv[4])  # number of frequency steps scanned over
L = float(sys.argv[5])  # length of system in units of width

data_direc = "../../VSC2/AverageDwellTime-20130618/" + filen + "/scatterdata/"

energs = scat.read_S(data_direc, filen + ".0.0")[2]
if (len(energs) == 0):
    kmin = 3.1 * np.pi / 10.
    kmax = 4.9 * np.pi / 10.
    dk = 0.5 * (kmin + kmax) * 10**(-7)
else:
    kvals = np.sqrt(2 * energs)
    dk = (kvals[-1] - kvals[-3]) / 2.0

dims = scat.read_S(data_direc, filen + ".0.0")[1] / 2
nin_max = np.max(dims)


def read_single_S_list(filen, i, j):
    filen_i = filen + ".%i.%i" % (i, j)
    print "reading file: " + filen_i
Example #11
0
   modes_min = float(par['modes_min'])
   modes_max = float(par['modes_max'])
   refmodes = int(par['refmodes']) # number of modes to be considered
   W = float(par['W'])
   pphwl = float(par['points_per_hwl'])
except KeyError:
    raw_input("WARNING: parameter missing in Abmessung.xml")


# read in scattering matrices
data_direc = ("/home/ambichl/Universitaet/Scattering-Data/"
              "VSC2/Fibres-20130802/" + filen + "/")

print "Reading scattering matrices"
if (not os.path.exists("scatter."+filen+".dat.npy")):
   S, dims, energs = scat.read_S(data_direc, filen, old_ver=0)
   np.save("scatter."+filen+".dat", (S, dims, energs))
else:
   S, dims, energs = np.load("scatter."+filen+".dat.npy")


# other parameters
pixel = True # whether system is transformed to y-eigenbasis
#pixel = False # whether system is transformed to y-eigenbasis
Nav = 1 # number of random noise configurations to be averaged
#phase_only = False # whether optimization w.r.t. phase only
phase_only = True # whether optimization w.r.t. phase only
#ds0 = 5.0 # step size for gradient in optimization
ds0 = 1e-2
#ds0 = 0.001
proj_list = np.zeros((refmodes,), dtype="complex")
Example #12
0
        'file']  # namestring of calculation where scatter data is stored
    modes_min = float(par['modes_min'])
    modes_max = float(par['modes_max'])
    refmodes = int(par['refmodes'])  # number of modes to be considered
    W = float(par['W'])
    pphwl = float(par['points_per_hwl'])
except KeyError:
    raw_input("WARNING: parameter missing in Abmessung.xml")

# read in scattering matrices
data_direc = ("/home/ambichl/Universitaet/Scattering-Data/"
              "VSC2/Fibres-20130802/" + filen + "/")

print "Reading scattering matrices"
if (not os.path.exists("scatter." + filen + ".dat.npy")):
    S, dims, energs = scat.read_S(data_direc, filen, old_ver=0)
    np.save("scatter." + filen + ".dat", (S, dims, energs))
else:
    S, dims, energs = np.load("scatter." + filen + ".dat.npy")

# other parameters
pixel = True  # whether system is transformed to y-eigenbasis
#pixel = False # whether system is transformed to y-eigenbasis
Nav = 1  # number of random noise configurations to be averaged
#phase_only = False # whether optimization w.r.t. phase only
phase_only = True  # whether optimization w.r.t. phase only
#ds0 = 5.0 # step size for gradient in optimization
ds0 = 1e-2
#ds0 = 0.001
proj_list = np.zeros((refmodes, ), dtype="complex")
proj_list[:10] = 1.0
Example #13
0
def read_single_S_list(filen, i, j):
    filen_i = filen+".%i.%i" % (i,j)
    return scat.read_S(data_direc, filen_i)
Example #14
0
par = ut.read_input(data_direc)
try:
    nr = int(par['nr']) # number of radius variations
    nconf = int(par['nconf']) # number of configurations to be averaged over
    nfreq = int(par['nfreq']) # number of frequency steps scanned over
    lead_width = float(par['lead_width'])
    nyout = int(par['nyout'])
except KeyError:
    raw_input("WARNING: parameter missing in pinput.dat")

#energs = scat.read_S(data_direc, filen+".0.0")[2]
#kvals = np.sqrt(2*energs)
#dk = (kvals[-1] - kvals[-3]) / 2.0

dims = np.take(scat.read_S(data_direc + "/scatterdata/", filen + ".0.0")[1]/2, np.arange(1,3*nfreq,3))
nin_max = np.max(dims)

def read_state(filen, i, j, w, m):
    filen_i = filen + ".%i.%i.%04i.%04i" % (i,j,w,m)
    print "reading state: "+filen_i
    try:
        data = np.loadtxt(data_direc + "/states/" + "state." + filen_i + ".streu.dat",
                          dtype ='float', skiprows=1, usecols=(1,2), unpack=True)
        state = data[0] + imag_i * data[1]
        return state
    except Exception:
        print "WARNING: problem reading state "+filen_i
        return np.array(0.)

def read_refind(filen, i, j):
Example #15
0
Nfile = filemax - filemin + 1

data_direc = ("/home/ambichl/Universitaet/Scattering-Data/"
              "VSC2/Fibres-20130802/" + filen + "/")

Slist = []

for i in np.arange(filemin, filemax+1):

   file_i = "fi%i" % i
   scatter_direc = ("/home/ambichl/Universitaet/Scattering-Data/"
                 "VSC2/Fibres-20130802/fi%i/" % i)

   print "Reading scattering matrices fi%i" % i
   if (not os.path.exists("scatter."+file_i+".dat.npy")):
      S, dims, energs = scat.read_S(scatter_direc, file_i, old_ver=0)
      np.save(data_direc + "scatter." + file_i + ".dat", (S, dims, energs))
   else:
      S, dims, energs = np.load(data_direc + "scatter." + file_i + ".dat.npy")
   
   Slist.append(S)


for i in range(max(0,Nseg-Nfile)):
   el = np.random.randint(low=0, high=len(Slist))
   Slist.append(Slist[el]) # if Nseg > Nfile append randomly chosen S-matrices


Slist = np.array(Slist)
Nw = len(dims)
dw = np.sqrt(2.0*energs[2]) - np.sqrt(2.0*energs[1])
Example #16
0

#ppwhl = 10

#W = 1.
#L = 10.*W

#kmin  = modes_min * Pi / W
#kmax  = modes_max * Pi / W
#kmean = 0.5*(kmax+kmin)
#dk = kmean * 10**-8
#Nk = 7

dk = 0.00023626

S, dims = scat.read_S(direc, filen)
modes = int(max(dims)/2)

if (refmodes > int(min(dims)/2):
        sys.exit("ABORT: # of modes under consideration ($i) > # number of modes (%i)" % (refmodes,modes))

exit

t = []
t_q = []
for i in range(3*Nk):
    m = dimlist[i]/2
    n = min(m, refmodes)
    t.append( S[i][m:,0:m] )      # full t-matrix
    t_q.append( S[i][m:m+n,0:n] ) # considered part of t-matrix 
Example #17
0
#!/usr/bin/env python

import numpy as np

from Scattering import scattering2D as scat
from Utils import utils as ut
import sys

if (len(sys.argv)!=2):
    sys.exit("ABORT: filen needed")

filen = str(sys.argv[1]) # namestring of calculation

S_dis, dims, energs = scat.read_S('./', filen+'.dis')
S_clean, dims, energs = scat.read_S('./', filen+'.clean')

dk = np.sqrt(2.0*energs[-1]) - np.sqrt(2.0*energs[-2])

t_dis = []
t_clean = []
for i in range(3):
    nin = dims[i]/2
    t_dis.append( S_dis[i][nin:,0:nin] )
    t_clean.append( S_clean[i][nin:,0:nin] )

Q = scat.calc_Q(S_clean,dk)[0]
Q11 = Q[0:nin,0:nin]
Q11EigVec = ut.sort_eig(Q11)[1]

TransStates = np.dot( np.linalg.inv(t_dis[1]), np.dot( t_clean[1], Q11EigVec ))
Example #18
0
if machine == 1:
    data_direc = ("/home/ambichl/Universitaet/Scattering-Data/"
                  "VSC/Fibres-20130819/" + filen + "/")
    pic_direc = ("/home/ambichl/Universitaet/Scattering-Data/"
                 "VSC/Fibres-20130819/" + pic_filen + "/")
elif machine ==2:
    data_direc = ("/home/ambichl/Universitaet/Scattering-Data/"
                  "VSC2/Fibres-20130802/" + filen + "/")
    pic_direc = ("/home/ambichl/Universitaet/Scattering-Data/"
                 "VSC2/Fibres-20130802/" + pic_filen + "/")
else:
    print "specify machine (VSC: 1, VSC2: 2)"
plot_direc = data_direc


S, dims = scat.read_S(data_direc, filen+".1E-%i"%expo, old_ver=1)
modes = int(max(dims)/2)


t , t_q = trans.calc_t(S, dims, refmodes)

tp = (t[2] - t[0]) / (2*dk)

ShiftPhase = -I * (t[1]/np.absolute(t[1])).conj() * (t[2]/np.absolute(t[2]) - t[0]/np.absolute(t[0])) / (2*dk)

#ShiftPhase = 0.001*np.ones((3,3), dtype="complex")

ShiftFacsP = np.exp( I * ShiftPhase * dk)
ShiftFacsM = np.exp(-I * ShiftPhase * dk)

#print np.absolute(ShiftFacsM)
#!/usr/bin/env python

import numpy as np
import scipy as sp
import scipy.optimize as spopt
import matplotlib.pyplot as plt
import sys
from math import pi as Pi

from Utils import utils as ut
from Scattering import scattering2D as scat

filen = str(sys.argv[1])  # namestring of calculation
n = int(sys.argv[2])  # number of calculation
dims = int(sys.argv[3])  # number of open modes in left lead

data_direc = "../../VSC2/AverageDwellTime-20130618/" + filen + "/scatterdata/"

energs = scat.read_S(data_direc, filen + ".%i.0" % n)[2]
kvals = np.sqrt(2 * energs)
dk = (kvals[-1] - kvals[-2]) / 1.0

filen_i = filen + ".%i.%i" % (n, 0)
print "reading file: " + filen_i
S = scat.read_S(data_direc, filen_i)[0]
q_mean = np.trace(scat.calc_Q(S, dk)[0]) / (2 * dims)

print q_mean.real