repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
dmrgpy | dmrgpy-master/examples/entanglement_entropy/entropy_occupation_fermionic/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../../src')
import numpy as np
from dmrgpy import fermionchain
n = 4
# This example shows how compute the entropy between sites (0,1) and
# function computing the entropy
def get(c01):
"""Compute entropy"""
fc ... | 1,006 | 21.886364 | 78 | py |
dmrgpy | dmrgpy-master/examples/entanglement_entropy/entropy_dimer_random/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../../src')
import numpy as np
from dmrgpy import spinchain
n = 2
spins = ["S=1/2" for i in range(n)] # spin 1/2 heisenberg chain
sc = spinchain.Spin_Chain(spins) # create the spin chain
from dmrgpy import mps
for i i... | 439 | 17.333333 | 69 | py |
dmrgpy | dmrgpy-master/examples/entanglement_entropy/entropy_transverse_ising/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../../src')
import numpy as np
from dmrgpy import spinchain
def gets(b):
n = 30
spins = ["S=1/2" for i in range(n)] # spin 1/2 heisenberg chain
sc = spinchain.Spin_Chain(spins) # create the spin chain
h... | 668 | 18.676471 | 69 | py |
dmrgpy | dmrgpy-master/examples/entanglement_entropy/correlation_entropy/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../../src')
import numpy as np
from dmrgpy import fermionchain
def get(U):
n = 6 # number of spinful fermionic sites
fc = fermionchain.Fermionic_Chain(n) # create the chain
h = 0
for i in range(n-1): # ... | 845 | 19.142857 | 69 | py |
dmrgpy | dmrgpy-master/examples/entanglement_entropy/entropy_tetramer/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../../src')
import numpy as np
from dmrgpy import spinchain
n = 4
spins = ["S=1/2" for i in range(n)] # spin 1/2 heisenberg chain
# This example shows how compute the entropy between sites (0,1) and
# (2,3) of a spin c... | 1,319 | 24.882353 | 75 | py |
dmrgpy | dmrgpy-master/examples/entanglement_entropy/entropy_dimer/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../../src')
import numpy as np
from dmrgpy import spinchain
n = 2
spins = ["S=1/2" for i in range(n)] # spin 1/2 heisenberg chain
sc = spinchain.Spin_Chain(spins) # create the spin chain
# Heisenberg model
h = 0
h = h ... | 1,597 | 24.774194 | 79 | py |
dmrgpy | dmrgpy-master/examples/entanglement_entropy/entanglement_entropy_bond/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../../src')
import numpy as np
from dmrgpy import spinchain
n = 10
spins = ["S=1/2" for i in range(n)] # spin 1/2 heisenberg chain
sc = spinchain.Spin_Chain(spins) # create the spin chain
h = 0
for i in range(n-1):
... | 796 | 19.973684 | 69 | py |
dmrgpy | dmrgpy-master/examples/apply_inverse/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../src')
import numpy as np
from dmrgpy import spinchain
n = 6
spins = ["S=1/2" for i in range(n)] # spin 1/2 heisenberg chain
sc = spinchain.Spin_Chain(spins) # create the spin chain
h = 0
for i in range(n-1):
h = ... | 725 | 19.166667 | 66 | py |
dmrgpy | dmrgpy-master/examples/spinless_fermions_static_correlator/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../src')
import numpy as np
from dmrgpy import fermionchain
nf = 4 # number of different spinless fermionic orbitals
fc = fermionchain.Fermionic_Chain(nf) # create the object
C = fc.C # annihilation
Cdag = fc.Cdag # c... | 1,345 | 23.035714 | 77 | py |
dmrgpy | dmrgpy-master/examples/transverse_ising_model_map/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../src')
import numpy as np
from dmrgpy import spinchain
n = 40 # number of sites in your chain
spins = ["S=1/2" for i in range(n)] # create the sites
sc = spinchain.Spin_Chain(spins) # create the chain
# now define t... | 1,309 | 25.2 | 80 | py |
dmrgpy | dmrgpy-master/examples/finite_temperature_dynamical_correlator/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../src')
import numpy as np
from dmrgpy import spinchain
n = 6
# create a random spin chain
spins = [np.random.randint(2,5) for i in range(n)] # spin 1/2 heisenberg chain
spins = [2 for i in range(n)] # spin 1/2 heisenb... | 1,414 | 19.808824 | 78 | py |
dmrgpy | dmrgpy-master/examples/exponential_EV/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../src')
import numpy as np
from dmrgpy import spinchain
n = 4 # number of sites in your chain
spins = ["S=1/2" for i in range(n)] # create the sites
sc = spinchain.Spin_Chain(spins) # create the chain
Mz = sum(sc.Sz)... | 1,172 | 20.722222 | 66 | py |
dmrgpy | dmrgpy-master/examples/magnetization_distribution/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../src')
import numpy as np
from dmrgpy import spinchain
n = 10 # number of sites in your chain
spins = ["S=1/2" for i in range(n)] # create the sites
sc = spinchain.Spin_Chain(spins) # create the chain
#sc.itensor_ver... | 1,845 | 26.552239 | 85 | py |
dmrgpy | dmrgpy-master/examples/hubbard_fluctuations/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../src')
import numpy as np
from dmrgpy import fermionchain
n = 10 # number of spinful fermionic sites
def get_fc(u):
fc = fermionchain.Spinful_Fermionic_Chain(n) # create the chain
h = 0
for i in range(n-1):
... | 1,072 | 20.039216 | 70 | py |
dmrgpy | dmrgpy-master/examples/hubbard_fluctuations/plot.py | import numpy as np
import matplotlib.pyplot as plt
m = np.genfromtxt("D_VS_MU.OUT").transpose()
x,y = m[0],m[1]
from scipy.interpolate import interp1d
from scipy.signal import savgol_filter
xs = np.linspace(np.min(x),np.max(x),len(x)*10)
ys = interp1d(x,y,fill_value=0.0,bounds_error=False)(xs)
#ys = savgol_filter(y... | 428 | 21.578947 | 56 | py |
dmrgpy | dmrgpy-master/examples/mutual_information_long_chain/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../src')
import numpy as np
from dmrgpy import spinchain
n = 20
spins = ["S=1/2" for i in range(n)] # spin 1/2 heisenberg chain
# This example shows how to compute the mutual information
# Heisenberg model
sc = spinch... | 757 | 17.95 | 66 | py |
dmrgpy | dmrgpy-master/examples/multioperator_density/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../src')
import numpy as np
import matplotlib.pyplot as plt
from dmrgpy import fermionchain
from dmrgpy import multioperator
n = 6
fc = fermionchain.Fermionic_Chain(n,spinful=False) # create the chain
m = np.matrix(np.r... | 1,003 | 19.489796 | 69 | py |
dmrgpy | dmrgpy-master/examples/magnetization_VS_field_parallel/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../src')
import numpy as np
from dmrgpy import spinchain
# define the function that you want to parallelize
# the variables of this function should be internal, i.e.
# the variables inside the function have to be defi... | 1,355 | 26.673469 | 80 | py |
dmrgpy | dmrgpy-master/examples/heisenberg_12/main.py | # Add the root path of the dmrgpy library
import os ; import sys ; sys.path.append(os.getcwd()+'/../../src')
import numpy as np
from dmrgpy import spinchain
n = 30
spins = ["S=1/2" for i in range(n)] # spin 1/2 heisenberg chain
sc = spinchain.Spin_Chain(spins) # create the spin chain
h = 0
for i in range(n-1):
h =... | 509 | 17.888889 | 66 | py |
dmrgpy | dmrgpy-master/installtk/install3.py | import os
# compile Itensor library
path = os.path.dirname(os.path.realpath(__file__))+"/../" # main path
os.chdir(path+"/src/dmrgpy/mpscpp3/ITensor")
import platform
if platform.system()=="Linux": # Linux system
os.system("cp options.save options.mk")
print("Detected Linux system")
import cppversion
if cppver... | 1,154 | 30.216216 | 72 | py |
dmrgpy | dmrgpy-master/installtk/cppversion.py | import os
def cppversion(gpp="g++"):
"""
Return the C++ version
"""
os.system(gpp+" --version > /tmp/cpp.txt")
out = open("/tmp/cpp.txt").read()
out = out.split("\n")[0].split() # get the first line
out = out[-1] # last one
out = out.split(".")
out = [int(o) for o in out]
return... | 570 | 20.961538 | 57 | py |
dmrgpy | dmrgpy-master/installtk/install2.py | import os
def compile(gpp="g++",check_gpp=True):
# compile Itensor library
path = os.path.dirname(os.path.realpath(__file__))+"/../" # main path
os.chdir(path+"/src/dmrgpy/mpscpp2/ITensor")
import platform
if platform.system()=="Linux" or platform.system()=="Darwin": # System
os.system("cp o... | 2,426 | 38.786885 | 79 | py |
dmrgpy | dmrgpy-master/installtk/addpythonpath.py | import os
import sys
def addpath():
mpath = os.path.dirname(os.path.realpath(__file__))
def get_lp():
for p in sys.path:
if "/site-packages" in p: return p
print("Path to add the Python library not found")
exit()
p = get_lp()+"/dmrgpy" # get the path
os.system("rm -f... | 432 | 27.866667 | 77 | py |
dmrgpy | dmrgpy-master/installtk/autoinstallubuntu.py | import os
def install():
print("This script will install all the depencies for Ubuntu")
print("### It will ask for your sudo password ###")
os.system("sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y")
os.system("sudo apt-get update -y")
os.system("sudo sudo apt-get install g++-6 -y")
os.system("sudo... | 421 | 29.142857 | 69 | py |
dmrgpy | dmrgpy-master/installtk/addsystem.py | #!/usr/bin/python
from __future__ import print_function
import os
# different files for Linux and Mac
import platform
def addrc():
"""
Add program to the .bashrc
"""
shell = os.environ["SHELL"]
if "bash" in shell: shellrc = ".bashrc"
elif "zsh" in shell: shellrc = ".zshrc"
else:
... | 1,394 | 23.051724 | 74 | py |
dmrgpy | dmrgpy-master/installtk/__init__.py | 0 | 0 | 0 | py | |
dmrgpy | dmrgpy-master/src/__init__.py | 0 | 0 | 0 | py | |
dmrgpy | dmrgpy-master/src/dmrgpy/cpprun.py | from .manybodychain import dmrgpath
import os
def run(self):
if self.itensor_version in [2,"2","v2","C++","cpp","c","C"]:
mpscpp = dmrgpath+"/mpscpp2/mpscpp.x"
else: raise
self.execute(lambda : os.system(mpscpp+" > status.txt"))
| 251 | 24.2 | 64 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/inference.py | import numpy as np
def points2function(x,y,bounds=None):
"""Given a set of points for a holomorphic function,
derive the continuum function that fullfills the
analiticity condition"""
raise # this does not work yet
yr = y.real # real part
yi = y.imag # imaginary part
from scipy.signal impor... | 1,228 | 32.216216 | 93 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/taskdmrg.py | from __future__ import print_function
import numpy as np
def setup_task(self,mode="GS",task=dict()):
select_task(self,mode=mode)
for key in task: self.task[key] = task[key] # additional arguments
write_tasks(self) # write the tasks
def select_task(self,mode="GS"):
"""Setup the sweep parameters"""
task = ... | 2,621 | 30.214286 | 80 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/mps.py | from __future__ import print_function
from copy import deepcopy
import os
import numpy as np
from . import entropy
from . import multioperator
class MPS():
"""Object for an MPS"""
def __init__(self,MBO=None,name="psi_GS.mps"):
# self.sc = sc # many body object
# self.sc.wf0 = None # no wavefuncti... | 5,199 | 33.899329 | 79 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/kondochain.py | from manybodychain import Many_Body_Hamiltonian
class Kondo_Chain_Hamiltonian(Many_Body_Hamiltonian):
"""Class for fermionic Hamiltonians"""
def __init__(self,n):
sites = []
for i in range(n): # loop over sites
sites.append(1) # append a fermion
for i in range(n): # loop ov... | 495 | 28.176471 | 67 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/writemps.py | import numpy as np
from . import funtk
from . import ampotk
from . import multioperator
def write_hamiltonian(self):
self.execute(lambda: write_sites(self)) # write the different sites
if self.use_ampo_hamiltonian: # use Hamiltonian as an MPO
if self.hamiltonian is not None: # Hamiltonian object create... | 5,776 | 24.337719 | 73 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/multicorrelator.py | import numpy as np
import os
def multicorrelator(self,rs=None,es=np.linspace(0.0,4.0,100),**kwargs):
"""Compute the dynamical corraltor at different energies"""
if rs is None:
rs = [[i,0] for i in range(self.ns)] # initialize
rs = np.array(rs) # to array and transpose
ds = [] # empty list with total D... | 1,576 | 34.044444 | 79 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/simplechains.py | from . import spinchain
import numpy as np
from dmrgpy.pychain import rlc
from dmrgpy.pychain import dmrg as classicdmrg
# this is a wrapper to compute simple spin chains
class SSC():
def __init__(self,s=0.5,n=10,b=[0.,0.,0.],J=[1.,1.,1.]):
spins = [int(2*s)+1 for i in range(n)]
self.sc = spinchai... | 2,864 | 38.791667 | 79 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/manybodychain.py | from __future__ import print_function
import numpy as np
import os
from . import mps
from . import timedependent
from . import groundstate
from . import operatornames
from . import correlator
from . import densitymatrix
from . import taskdmrg
from . import dynamics
from . import funtk
from . import vev
from . import mp... | 18,970 | 36.715706 | 80 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/kpmdmrg.py | from __future__ import print_function
import numpy as np
from . import multioperator
from . import operatornames
from .algebra import kpm
def get_moments_dmrg(self,n=1000):
"""Get the moments with DMRG"""
self.setup_task("dos",task={"nkpm":str(n)})
self.write_hamiltonian() # write the Hamiltonian to a file
sel... | 7,067 | 34.34 | 86 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/funtk.py | # toolkit to deal with functions and matrices
import numpy as np
def fun2list(f,n):
"""
Transforma function into a list, where the first two entries
are the indexes and the next one is the coupling
"""
if f is None: return [] # empty list
out = [] # empty list
for i in range(n):
for ... | 776 | 20 | 64 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/effectivehamiltonian.py | import numpy as np
import scipy.linalg as lg
#def get_effective_hamiltonian(self,**kwargs):
# """Return an effective Hamiltonian"""
# n = self.ns # number of sites
# pairs = []
# for i in range(n): # loop
# for j in range(n): # loop
# pairs.append([i,j]) # store
# cs = self.get_correl... | 6,072 | 33.117978 | 80 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/dos.py | import numpy as np
from .algebra.kpm import generate_profile
# library to compute the DOS
def get_moments_dos_dmrg(self,delta=1e-1):
"""Get the moments with DMRG"""
task= { "dos":"true",
"kpmmaxm":str(self.kpmmaxm),
"kpm_scale":str(self.kpm_scale),
"kpm_n_sca... | 1,504 | 26.363636 | 72 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/densitymatrix.py | # routines to compute density matrices
from . import taskdmrg
import numpy as np
def reduced_dm(self,i=0):
"""
Compute the reduced density matrix
"""
self.get_gs() # compute ground state
task = {"density_matrix":"true",
"index_i_DM":str(i+1)
# "index_j_DM":str(j+1)
... | 2,644 | 36.253521 | 79 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/fidelity.py | import numpy as np
from .algebra import algebra
def get_fidelity(MBO,H0,H1,l=1.0,delta=1e-4,
dl = 1e-1,n=2,
fmode="derivative",**kwargs):
"""Given two Hamiltonians H0 and H1, compute the fidelity as a function
of lambda.
-fmode: mode of the calculation"""
MBO = MBO.copy() # copy the object
... | 3,050 | 40.22973 | 84 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/parafermionchain.py | from .manybodychain import Many_Body_Chain
import numpy as np
class Parafermionic_Chain(Many_Body_Chain):
"""Class for a parafermionic chain"""
def __init__(self,n,Z=3):
self.Z = Z # type of parafermion
self.N = [self.get_operator("N",i) for i in range(n)]
self.Sig = [self.get_operator... | 2,819 | 32.571429 | 72 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/fermionchain.py | from .manybodychain import Many_Body_Chain
import numpy as np
import scipy.linalg as lg
from .pyfermion import mbfermion
from .algebra import algebra
from .fermionchaintk import staticcorrelator
from .fermionchaintk import hamiltonian
from . import funtk
from . import gap
class Fermionic_Chain(Many_Body_Chain):
""... | 13,968 | 36.350267 | 80 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/fermiondos.py | import numpy as np
def get_dos(mbc,i=0,n=20,delta=0.1,window=5.):
"""Compute the DOS using the KPM"""
(x1,y1) = mbc.get_dynamical_correlator(i=i,j=i,name="cdc",
delta=delta,window=[0.0001,window])
(x2,y2) = mbc.get_dynamical_correlator(i=i,j=i,name="ccd",
delta=delta,window=[0.0001... | 2,599 | 37.235294 | 75 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/cvm.py | import numpy as np
from . import operatornames
from . import taskdmrg
from . import multioperator
def dynamical_correlator(self,es=np.linspace(0.,10.0,100),
delta=1e-1,name="XX",i=0,j=0):
"""
Compute the dynamical correlator using CVM method in DMRG
"""
if not self.computed_gs: self.get_gs() # ... | 3,740 | 30.974359 | 83 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/mode.py | import os
from . import taskdmrg
dmrgpath = os.path.dirname(os.path.realpath(__file__)) # path for the program
mpscpp = dmrgpath+"/mpscpp2/mpscpp.x" # C++ executable
def run(self,automatic=False):
"""
Run the DMRG calculation
"""
if get_mode(self)=="ED":
return # do nothing
# executable
... | 1,595 | 32.25 | 77 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/topology.py | import numpy as np
def berry_phase(f,nk=100):
"""Compute the Berry phase, requires a function
that returns a manybody Hamiltonian"""
ks = np.linspace(0.,1.,nk,endpoint=False) # kpoints
f(0).get_gs() # first iteration
wfs = [] # empty list
for k in ks:
sc = f(k) # get object
sc.... | 759 | 28.230769 | 65 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/randommps.py | import numpy as np
from . import taskdmrg
from .mps import MPS
def random_mps_dummy(self,normalize=True):
"""Generate a random MPS, beware of a complicated statistial
distribution"""
task = {"random_mps":"true",
}
self.task = task
self.execute( lambda : taskdmrg.write_tasks(self)) # wr... | 3,297 | 28.981818 | 77 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/analyticcontinuation.py | import numpy as np
def imag2real(zs,us,x=None):
"""Translate from imaginary axis to real axis"""
try:
from .padetk import bruteforcepade as pade
# from .padetk import taylorpade as pade
except:
print("Not functional yet")
exit()
p = pade.fit(zs,us)
if x is None: x ... | 1,030 | 26.864865 | 79 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/correlator.py | from . import operatornames
from . import writemps
import numpy as np
from . import taskdmrg
def get_correlator(self,pairs=[[]],name="SS",
apply_hamiltonian=False,**kwargs):
"""Compute a certain static correlator in the spin chain"""
if name=="SS":
def getop(i,j):
m = self.Sx[i]*s... | 2,237 | 35.688525 | 75 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/distribution.py | from .algebra.kpm import generate_profile
import numpy as np
def get_moments_distribution(self,X=None,num_p=None):
"""Get the mments with DMRG"""
# define the dictionary
self.gs_energy()
task = { "distribution": "true",
"kpmmaxm":str(self.kpmmaxm),
"kpm_scale":str(self.kp... | 2,528 | 30.222222 | 74 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/juliarun.py | # routines to run the code with Julia
import os
import subprocess
dmrgpath = os.path.dirname(os.path.realpath(__file__))
# check the system image
sysimage = os.environ["HOME"]+"/.julia/sysimages/sys_itensors.so"
if not os.path.isfile(sysimage):
print("No ITensors system image found, this may take some time")
... | 1,541 | 28.653846 | 93 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/mpsalgebra.py | from . import mps
import numpy as np
def exponential(self,h,wf,mode="DMRG",**kwargs):
"""Compute the exponential"""
if self.mode is not None: mode = self.mode # redefine
if mode=="DMRG":
if h.is_hermitian():
return exponential_dmrg(self,h,wf,dt=1.0,**kwargs)
elif h.is_antiherm... | 7,332 | 32.792627 | 97 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/spinfermionchain.py | from . import fermionchain
class Spin_Fermion_Hamiltonian(fermionchain.Spinful_Fermionic_Hamiltonian):
def __init__(self,sites):
"""Create the sites"""
super().__init__(len(sites)) # initialize the Hamiltonian
| 233 | 25 | 75 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/parallelslurm_old.py | # this is a special library to launch parallel calculations using slurm
import dill as pickle
import os
pickle.settings['recurse'] = True
def pcall(fin,xs,time=80):
"""Run a parallel calculation with slurm"""
n = len(xs) # number of calculations
f = lambda x: fin(x)
main = "import dill as pickle\nim... | 2,330 | 32.3 | 73 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/gap.py | import numpy as np
from .excited import gram_smith
def sector_gap(self,A,d=1.,lagrange=1.0,info=False):
"""Compute a gap in a sector that commutes with the Hamiltonian"""
mbo = self.copy() # copy the object
h0 = mbo.hamiltonian # get the Hamiltonian
diff = h0*A - A*h0 # check that it commutes
# if n... | 1,321 | 39.060606 | 80 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/groundstate.py | from . import mps
import numpy as np
def best_gs(sc,n=1):
"""Compute many ground states, and retain only the best one"""
wfs = [] # list with GS
es = [] # list with energies
emin = 1e8 # grund state energy
wf0 = None
for i in range(n): # loop
sc.computed_gs = False # initialize
... | 4,745 | 33.391304 | 79 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/vev.py | # compute vacuum expectation values using multioperators
from . import multioperator
import numpy as np
def power_vev(self,wf=None,n=4,X=None,**kwargs):
"""Compute the moments of an operator"""
if wf is None: wf = self.get_gs(**kwargs) # ground state
wfs = [wf.copy()] # wavefunctions
wfi = wf.copy()
... | 1,645 | 25.548387 | 62 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/filesystem.py | import os
import shutil
import subprocess
from pathlib import Path,PurePath
## this is just a wrapper to several functions to deal with files ##
def rmdir(a):
"""Remove a directory with its contents"""
try: shutil.rmtree(a)
except: pass
mkdir = os.makedirs # create a directory
cpdir = shutil.copytree
c... | 495 | 18.84 | 68 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/excited.py | import numpy as np
from . import mps
from scipy import linalg as lg
def get_excited_states_dmrg(self,n=2,noise=0.0,scale=10.0):
"""Return excited state energies"""
self.get_gs()
if self.excited_gram_schmidt: sm = "true"
else: sm = "false"
task = {"excited":"true",
"nexcited":str(n),
... | 2,920 | 34.621951 | 73 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/parallelslurm.py | # this is a special library to launch parallel calculations using slurm
import dill as pickle
import os
from . import filesystem as fs
import signal
import subprocess
pickle.settings['recurse'] = True
def pcall(fin,xs,batch_size=1,**kwargs):
"""Wrapper to allow for a batch size"""
if batch_size==1:
... | 6,099 | 33.659091 | 96 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/spinchain.py | from .manybodychain import Many_Body_Chain
import numpy as np
from .dmrgpy2pychain import correlator as correlatorpychain
from .algebra import algebra
from . import effectivehamiltonian
from . import pychainwrapper
from . import multioperator
class Coupling():
def __init__(self,i,j,g):
self.i = i
self.j = j
... | 5,135 | 35.425532 | 84 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/meanfield.py | # routines to perform mean field calculations
import numpy as np
def spinchain_meanfield(sc,p=0.0,mix=0.9,m0=None,maxerror=1e-06,
mode="default"):
"""Mean field calculation of a spin chain,
p controls the degree of many body correlations"""
sc0 = sc.copy() # copy the spin chain object
if m0 is... | 2,257 | 37.931034 | 79 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/applyoperator.py | from . import taskdmrg
from . import mps
def applyoperator(self,A,wf):
"""Apply operator to a many body wavefunction"""
task = {"applyoperator":"true",
"applyoperator_wf0":wf.name,
"applyoperator_multioperator":"applyoperator_multioperator.in",
"applyoperator_wf1":"applyoper... | 666 | 36.055556 | 75 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/timeevolution.py | import numpy as np
from .edtk.edchain import State
from .mps import MPS
def evolve_WF(h,wf,ts=np.linspace(0.,10.,10),dt=1e-3):
"""Time evolve a wavefunction"""
# if not h.is_hermitian(): raise # only for hermitian Hamiltonians
if type(wf)==State: # ED version
out = []
for t in ts:
... | 1,968 | 34.160714 | 76 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/functionfit.py | import numpy as np
from scipy.optimize import minimize
def fit(f,x0,ntries=10,method="Powell"):
"""Fit a function several times, and estimate the error"""
error = 1e8
x = 0
for i in range(ntries):
opt = minimize(f,x0,method=method) # minimize function
if f(opt.x)<error:
x =... | 437 | 23.333333 | 62 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/wavefunction.py | import numpy as np
import os
from copy import deepcopy
class Wavefunction():
def __init__(self,mode="DMRG",path=None,name=None,v=None):
self.mode = mode
if mode=="DMRG":
if path is None: self.path = os.getcwd()+"/.mpsfolder/"
else: self.path = path
if name is No... | 855 | 28.517241 | 75 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/pychainwrapper.py | import numpy as np
from .kpmdmrg import restrict_interval
from .algebra import algebra
from .edtk import finitetemperature
from . import operatornames
from . import multioperator
def old2ampo(self):
"""Transform an old Hamiltonian into the AMPO form"""
if self.use_ampo_hamiltonian: return self.hamiltonian
... | 5,389 | 36.172414 | 80 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/ampotk.py | # routines to use autompo features
import numpy as np
from . import multioperator
def names(i):
if i==0: return "Sx"
if i==1: return "Sy"
if i==2: return "Sz"
def exchange2ampo(self):
"""Return ampo list for exchange"""
try: self.Sx
except: return 0
h = 0 # initialize
S = [self.Sx,self.Sy,self.S... | 2,179 | 22.956044 | 67 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/dcex.py | import numpy as np
from . import operatornames
from . import taskdmrg
def dynamical_correlator(self,name="XX",i=0,j=0,delta=2e-2,
nex=20,es=np.linspace(-1.0,10.0,1000),scale=20.0,**kwargs):
"""
Compute dynamical correlator with excited states with DMRG
"""
self.gs_energy()
name = operatorna... | 2,065 | 32.322581 | 71 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/__init__.py | 0 | 0 | 0 | py | |
dmrgpy | dmrgpy-master/src/dmrgpy/timedependent.py | from __future__ import print_function
from . import operatornames
from . import taskdmrg
import numpy as np
import os
from scipy.interpolate import interp1d
from . import multioperator
from .edtk import timedependent as tded
def evolution_DC(self,mode="DMRG",**kwargs):
if mode=="DMRG": return evolution_dmrg_DC(... | 5,476 | 36.006757 | 80 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/multioperator.py | import numbers
import types
import collections
from collections.abc import Iterable
import numpy as np
# this class allows to define operators of the form
# A_0@A_1@....
# for mpscpp.x
def isnumber(x):
# print(type(x),isinstance(x, numbers.Number))
return isinstance(x, numbers.Number) or np.iscomplex(x)
ampo... | 10,554 | 32.191824 | 85 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/thermal.py | # this library contains routines to perform thermal calculations
import numpy as np
from .spinchain import Spin_Chain
class Thermal_Spin_Chain():
def __init__(self,sites,T=0.1,**kwargs):
sitesT = []
for s in sites:
sitesT += [s]
sitesT += [s]
n = len(sites) # numbe... | 2,719 | 33.43038 | 72 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/dynamics.py | from . import kpmdmrg
from . import timedependent
from . import cvm
from . import dcex
def get_dynamical_correlator(self,submode="KPM",**kwargs):
self.set_initial_wf(self.wf0) # set the initial wavefunction
if not self.is_hermitian(self.hamiltonian): # non Hermitian Hamiltonian
from .nonhermitian.dynam... | 1,327 | 41.83871 | 77 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/operatornames.py |
def recognize(name):
"""
Recognize which correlator you want to compute
"""
# single operators, for expectation values
if name=="X": return "Id","Sx"
if name=="Y": return "Id","Sy"
if name=="Z": return "Id","Sz"
# next cases
spins = [] # names for spin correlators
for s1 in ["X","Y","Z","+","-"]... | 3,034 | 30.947368 | 99 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/degeneracy.py | import numpy as np
# library to compute degeneracies of eigenstates
def gs_degeneracy(self,mode="DMRG",**kwargs):
"""Compute the degeneracy of the ground state"""
if mode=="DMRG": # for DMRG, it depends
if self.is_hermitian(self.hamiltonian): # brute force should be ok
return gs_degenerac... | 3,089 | 36.228916 | 84 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/entropy.py | import numpy as np
def dynamical_correlator_kpm(self):
"""Return the entropies of the dynamical correlator"""
s = self.execute(lambda: np.genfromtxt("KPM_ENTROPY.OUT"))
return s
try:
from statistics import geometric_mean
except:
def geometric_mean(x):
return np.exp(np.mean(np.log(x)))
d... | 3,426 | 31.028037 | 78 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/extrapolate.py | import numpy as np
import scipy.linalg as lg
from scipy.stats import linregress
from numpy.polynomial.polynomial import polyfit
def size_extrapolation(x,y,n=1):
"""Perform a size extrapolation using a power law
Y(X) = A + B/X"""
xi = (1./np.array(x)) # inverse
# slope, intercept, r_value, p_value, std_... | 496 | 21.590909 | 67 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/bosonchain.py | import numpy as np
import scipy.linalg as lg
from .pyfermion import mbfermion
from .algebra import algebra
from .manybodychain import Many_Body_Chain
from .pyboson import boson
class Bosonic_Chain(Many_Body_Chain):
"""Bosonic Hamiltonian"""
def __init__(self,n,maxnb=None):
if maxnb is None: maxnb = [4 ... | 4,036 | 41.946809 | 78 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/parallel.py | # routines to call a function in parallel
from __future__ import print_function
import scipy.linalg as lg
from . import algebra
import os
try:
from multiprocess import Pool
import multiprocess
maxcpu = multiprocess.cpu_count()
except:
print("Multiprocess not working")
def Pool(n=1): # workaround
... | 1,882 | 21.152941 | 71 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/reconstruct.py | import numpy as np
# routines for distribution reconstruction
try: from .maxenttk.pymaxent import reconstruct as reconstruct_from_moments
except:
print("Reconstruction not functional yet")
raise
def reconstruct_distribution(x,y,bnds=None,delta=1e-3,**kwargs):
"""Given a certain distribution, reconstruct ... | 2,028 | 33.389831 | 78 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/entanglement.py | import numpy as np
import scipy.linalg as lg
from .entropytk.correlationentropy import get_correlation_matrix
def get_correlation_entropy_density(self,**kwargs):
"""Compute the density of spinless correlation entropy"""
from . import fermionchain
cm = get_correlation_matrix(self,**kwargs)
ce,ws = lg.e... | 2,635 | 31.146341 | 78 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/pyparafermion/parafermion.py | from ..edtk import edchain
import numpy as np
omega = np.exp(1j*2*np.pi/3)
class Parafermion_Chain(edchain.EDchain):
"""Z3 parafermion chain"""
def __init__(self,MBO):
n = MBO.ns # number of sites
super().__init__() # super initializetion
# create all operators
Z = MBO.Z # typ... | 2,527 | 31.410256 | 70 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/pyparafermion/__init__.py | 0 | 0 | 0 | py | |
dmrgpy | dmrgpy-master/src/dmrgpy/mpsalgebratk/__init__.py | 0 | 0 | 0 | py | |
dmrgpy | dmrgpy-master/src/dmrgpy/mpsalgebratk/trace.py | import numpy as np
from ..algebra import algebra
def trace(self,A,**kwargs):
"""Return the full trace of an operator"""
return self.toMPO(A,**kwargs).trace() # compute the trace
def inverse_trace(self,A,mode="ED",**kwargs):
"""Return trace of the inverse of an operator"""
if mode=="ED":
ret... | 1,254 | 31.179487 | 79 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/entropytk/correlationentropy.py | import numpy as np
import scipy.linalg as lg
def get_correlation_matrix(self,T=0.,**kwargs):
"""Compute the correlation matrix of a finite temperature state"""
if T==0.: return get_correlation_matrix_zeroT(self,**kwargs)
else: return get_correlation_matrix_finiteT(self,T=T,**kwargs)
def get_correlatio... | 5,066 | 28.631579 | 75 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/entropytk/__init__.py | 0 | 0 | 0 | py | |
dmrgpy | dmrgpy-master/src/dmrgpy/dmtk/densitymatrix.py | import numpy as np
from ..fermionchain import Fermionic_Chain
def dm(self,**kwargs):
"""Return the density matrix of a wavefunction"""
if type(self.MBO)==Fermionic_Chain: # fermionic object
return dm_fermionic(self,**kwargs)
else: raise # not implemented
def dm_fermionic(self,inds=[0]):
"""C... | 684 | 27.541667 | 59 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/dmtk/__init__.py | 0 | 0 | 0 | py | |
dmrgpy | dmrgpy-master/src/dmrgpy/algebra/kpm.py | # kernel polynomial method libraries
from __future__ import print_function,division
import scipy.sparse.linalg as lg
from scipy.sparse import csc_matrix as csc
import numpy.random as rand
from scipy.sparse import coo_matrix,csc_matrix,bmat
import numpy as np
from scipy.signal import hilbert
from . import algebra
# che... | 16,322 | 30.511583 | 120 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/algebra/powermethod.py | import numpy as np
def power_method_several(self,H,verbose=0,n0=10,ntries=10,shift=0.0,
orthogonal=None,unfiltered=False,error=1e-6,**kwargs):
"""Simple implementation of the power method"""
from .arnolditk import random_state
from .krylov import gram_smith,gram_smith_single
def f(): # functio... | 2,963 | 32.681818 | 76 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/algebra/kpmextrapolate.py | import numpy as np
from numba import jit
import scipy.linalg as lg
from numpy.polynomial.polynomial import polyfit
from statsmodels.tsa.ar_model import AutoReg
#from statsmodels.tsa.ar_model import sarimax
import warnings
from statsmodels.tsa.ar_model import AR
from statsmodels.tsa.arima_model import ARIMA
#import... | 3,994 | 27.535714 | 83 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/algebra/inverse.py | # methods to solve linear equations, purely written in Python
# they do not work properly yet
import numpy as np
# these functions are quite buggy, not functional at the current stage
def solve_Ab_cv(A, b,tol=1e-4,nmax=-1):
raise # this is buggy
x = b.copy() # initialize x as the initial guess
A = b.MB... | 3,077 | 28.037736 | 90 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/algebra/__init__.py | 0 | 0 | 0 | py | |
dmrgpy | dmrgpy-master/src/dmrgpy/algebra/krylov.py | import numpy as np
import scipy.linalg as lg
def krylov_matrix_representation(H,wfs):
"""Given a Krylov subspace, return the matrix representation"""
accelerate=False
nw = len(wfs) # number of wavefunction
if nw==0: raise # something wrong
mh = np.zeros((nw,nw),dtype=np.complex) # output matrix
... | 6,380 | 32.062176 | 79 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/algebra/arnolditk.py | import numpy as np
import scipy.linalg as lg
from . import algebra
from . import powermethod
# routines to perform iterative diagonalization
arnoldimode = "DMRG" # mode of the arnoldi method
use_generalized_diagonalize = True # generalized diagonalization
use_gs_gen_diag = True # use gram smith (for Krylov in gen... | 13,111 | 41.990164 | 101 | py |
dmrgpy | dmrgpy-master/src/dmrgpy/algebra/algebra.py | from scipy.sparse import issparse
from scipy.sparse import csc_matrix as csc
import scipy.linalg as dlg
import scipy.sparse.linalg as slg
import numpy as np
det = dlg.det
maxsize = 10000
tol = 1e-7 # tolerancy
maxiter = 1e6 # maximum number of iterations
def braket_wAw(w,A,wi=None):
"""
Compute the braket of ... | 6,539 | 22.109541 | 76 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.