Verified Commit 0e8be9e5 authored by Adel Kara Slimane's avatar Adel Kara Slimane
Browse files

Update code to import new modules

parent a550889d
Pipeline #35990 failed with stages
in 1 minute and 23 seconds
......@@ -18,7 +18,7 @@ import tinyarray as ta
import matplotlib.pyplot as plt
import kwant
import generalOperator
import tkwant
sigma_0 = ta.array([[1, 0], [0, 1]])
sigma_x = ta.array([[0, 1], [1, 0]])
......@@ -132,9 +132,9 @@ def main():
# spin down components have a minus sign
spin_y = 1j * (down.conjugate() * up - up.conjugate() * down)
rho = generalOperator.Density(syst)
rho_sz = generalOperator.Density(syst, sigma_z)
rho_sy = generalOperator.Density(syst, sigma_y)
rho = tkwant.generalOperator.Density(syst)
rho_sz = tkwant.generalOperator.Density(syst, sigma_z)
rho_sy = tkwant.generalOperator.Density(syst, sigma_y)
# calculate the expectation values of the operators with 'psi'
density = rho(psi)
......@@ -147,9 +147,9 @@ def main():
('$σ_y$', spin_y),
])
J_0 = generalOperator.Current(syst)
J_z = generalOperator.Current(syst, sigma_z)
J_y = generalOperator.Current(syst, sigma_y)
J_0 = tkwant.generalOperator.Current(syst)
J_z = tkwant.generalOperator.Current(syst, sigma_z)
J_y = tkwant.generalOperator.Current(syst, sigma_y)
# calculate the expectation values of the operators with 'psi'
current = J_0(psi)
......@@ -166,7 +166,7 @@ def main():
m_i = field_direction(site.pos, r0, delta)
return np.dot(m_i, sigma)
J_m = generalOperator.Current(syst, following_m_i)
J_m = tkwant.generalOperator.Current(syst, following_m_i)
# evaluate the operator
m_current = J_m(psi, params=dict(r0=25, delta=10))
......@@ -180,7 +180,7 @@ def main():
def circle(site):
return np.linalg.norm(site.pos) < 20
rho_circle = generalOperator.Density(syst, where=circle, sum=True)
rho_circle = tkwant.generalOperator.Density(syst, where=circle, sum=True)
all_states = np.vstack((wf(0), wf(1)))
dos_in_circle = sum(rho_circle(p) for p in all_states) / (2 * pi)
......@@ -192,17 +192,17 @@ def main():
def right_cut(site_to, site_from):
return site_from.pos[0] < 39 and site_to.pos[0] >= 39
J_left = generalOperator.Current(syst, where=left_cut, sum=True)
J_right = generalOperator.Current(syst, where=right_cut, sum=True)
J_left = tkwant.generalOperator.Current(syst, where=left_cut, sum=True)
J_right = tkwant.generalOperator.Current(syst, where=right_cut, sum=True)
Jz_left = generalOperator.Current(syst, sigma_z, where=left_cut, sum=True)
Jz_right = generalOperator.Current(syst, sigma_z, where=right_cut, sum=True)
Jz_left = tkwant.generalOperator.Current(syst, sigma_z, where=left_cut, sum=True)
Jz_right = tkwant.generalOperator.Current(syst, sigma_z, where=right_cut, sum=True)
print('J_left:', J_left(psi), ' J_right:', J_right(psi))
print('Jz_left:', Jz_left(psi), ' Jz_right:', Jz_right(psi))
J_m = generalOperator.Current(syst, following_m_i)
J_z = generalOperator.Current(syst, sigma_z)
J_m = tkwant.generalOperator.Current(syst, following_m_i)
J_z = tkwant.generalOperator.Current(syst, sigma_z)
J_m_bound = J_m.bind(params=dict(r0=25, delta=10, J=1))
J_z_bound = J_z.bind(params=dict(r0=25, delta=10, J=1))
......
......@@ -13,7 +13,7 @@ from __future__ import print_function # so we can tell python2 users to upgrade
import os
import sys
import re
import imp
import importlib
import collections
import subprocess
import configparser
......@@ -51,13 +51,12 @@ SCIPY_SOLVER_LIB = ':' + SCIPY_SOLVER_LIB
# Let tkwant itself determine its own version.
# We cannot simply import tkwant, as it is not built yet.
_dont_write_bytecode_saved = sys.dont_write_bytecode
sys.dont_write_bytecode = True
_common = imp.load_source('_common', 'tkwant/_common.py')
sys.dont_write_bytecode = _dont_write_bytecode_saved
spec = importlib.util.spec_from_file_location('_common', 'tkwant/_common.py')
common_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(common_module)
version = _common.version
version_is_from_git = _common.version_is_from_git
version = common_module.version
version_is_from_git = common_module.version_is_from_git
# Cython setup
try:
......@@ -234,7 +233,31 @@ def extensions():
'include_dirs': ['kwant'],
'depends': ['kwant/operator.pxd'],
}
))
))
# general operator
result.append((['tkwant.generalOperator',
['tkwant/generalOperator.pyx']],
{
# 'libraries': [SCIPY_SOLVER_LIB],
# 'extra_link_args': ['-Wl,-rpath={}'.format(SCIPY_SOLVER_DIR)],
# 'library_dirs': [SCIPY_SOLVER_DIR],
'include_dirs': ['kwant'],
'depends': ['kwant/operator.pxd'],
}
))
# general operator implementation of energy operators
result.append((['tkwant.HeatCurrentMethodsForGenOp',
['tkwant/HeatCurrentMethodsForGenOp.pyx']],
{
# 'libraries': [SCIPY_SOLVER_LIB],
# 'extra_link_args': ['-Wl,-rpath={}'.format(SCIPY_SOLVER_DIR)],
# 'library_dirs': [SCIPY_SOLVER_DIR],
'include_dirs': ['kwant'],
'depends': ['kwant/operator.pxd'],
}
))
#### Add cython tracing macro
if trace_cython:
......@@ -497,22 +520,21 @@ setup_requirements = (
"pytest-runner",
)
classifiers = (
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering",
"Operating System :: POSIX",
"Operating System :: Unix",
)
classifiers = """\
Development Status :: 2 - Pre-Alpha
Intended Audience :: Science/Research
Programming Language :: Python
Programming Language :: Python :: 3 :: Only
Topic :: Scientific/Engineering
Operating System :: POSIX
Operating System :: Unix"""
def main():
setup(name='tkwant',
version=version,
author='tkwant authors',
author_email='authors@kwant-project.org',
author_email='tkwant-authors@kwant-project.org',
description='Package for time-dependent quantum transport simulations',
long_description=long_description(),
platforms=['Unix', 'Linux'],
......
......@@ -15,7 +15,7 @@ from ._common import TkwantDeprecationWarning
__all__ = ['TkwantDeprecationWarning']
for module in ('system', 'leads', 'onebody', 'manybody', 'operatorsHeatCurrent'):
for module in ('system', 'leads', 'onebody', 'manybody', 'operatorsHeatCurrent', 'generalOperator', 'HeatCurrentMethodsForGenOp'):
exec('from . import {0}'.format(module))
__all__.append(module)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment