Commit 0e8be9e5 by Adel Kara Slimane

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