{"id":34036071,"url":"https://github.com/joselado/pyqula","last_synced_at":"2026-04-02T03:50:44.936Z","repository":{"id":40048578,"uuid":"390243500","full_name":"joselado/pyqula","owner":"joselado","description":"Python library to compute properties of quantum tight binding models, including topological, electronic and magnetic properties and including the effect of many-body interactions.","archived":false,"fork":false,"pushed_at":"2026-02-19T06:06:22.000Z","size":93146,"stargazers_count":123,"open_issues_count":0,"forks_count":38,"subscribers_count":6,"default_branch":"master","last_synced_at":"2026-02-19T12:17:49.033Z","etag":null,"topics":["density-of-states","disorder","electronic-structure","fermi-surface","heavy-fermions","interactions","magnetism","mean-field-theory","moire-pattern","non-collinear-magnetism","quantum-transport","spectral-functions","spin-textures","superconductivity","symmetry-breaking","tight-binding","topological-insulator","topology"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joselado.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-07-28T06:43:24.000Z","updated_at":"2026-02-19T06:06:25.000Z","dependencies_parsed_at":"2023-02-09T23:15:29.923Z","dependency_job_id":"b58ac462-475e-4013-8322-9a88f1b3256e","html_url":"https://github.com/joselado/pyqula","commit_stats":{"total_commits":439,"total_committers":3,"mean_commits":"146.33333333333334","dds":"0.013667425968109326","last_synced_commit":"42c351989267cc2ecf50dcaef9cfdd3cb3a7a638"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/joselado/pyqula","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joselado%2Fpyqula","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joselado%2Fpyqula/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joselado%2Fpyqula/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joselado%2Fpyqula/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joselado","download_url":"https://codeload.github.com/joselado/pyqula/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joselado%2Fpyqula/sbom","scorecard":{"id":533324,"data":{"date":"2025-08-11","repo":{"name":"github.com/joselado/pyqula","commit":"13367dd3a20333758724a3b0b718e9010d46f8fb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":8,"reason":"9 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 8","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: GNU General Public License v3.0: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-20T06:16:28.435Z","repository_id":40048578,"created_at":"2025-08-20T06:16:28.436Z","updated_at":"2025-08-20T06:16:28.436Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31294527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:43:37.129Z","status":"online","status_checked_at":"2026-04-02T02:00:08.535Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["density-of-states","disorder","electronic-structure","fermi-surface","heavy-fermions","interactions","magnetism","mean-field-theory","moire-pattern","non-collinear-magnetism","quantum-transport","spectral-functions","spin-textures","superconductivity","symmetry-breaking","tight-binding","topological-insulator","topology"],"created_at":"2025-12-13T20:09:57.602Z","updated_at":"2026-04-02T03:50:44.925Z","avatar_url":"https://github.com/joselado.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SUMMARY #\nThis is a **Py**thon library to compute **qu**antum-**la**ttice \ntight-binding models in different dimensionalities.\n\n\n# INSTALLATION #\n## With pip (release version) ##\n```bash\npip install --upgrade pyqula\n```\n\n## Manual installation (most recent version) ##\nClone the Github repository with\n\n```bash\ngit clone https://github.com/joselado/pyqula\n```\n\nand add the \"pyqula/src\" path to your Python script with\n\n```python\nimport sys\nsys.path.append(PATH_TO_PYQULA+\"/src\")\n```\n\n## Recommended library versions\nThese are the recommended versions of several required libraries\n- numpy 1.26.4\n- numba 0.60.0\n- scipy 1.13.1\n\n\n# Tutorials #\nJupyter notebooks with tutorials can be found in the links below\n\nFrom the [\"Advanced Quantum Materials course at Aalto University 2025\"](https://github.com/joselado/Advanced_Quantum_Materials_2025)\n- [Electronic structure theory](https://github.com/joselado/Advanced_Quantum_Materials_2025/blob/main/jupyter-notebooks/session3.ipynb)\n- [Topological band structure theory](https://github.com/joselado/Advanced_Quantum_Materials_2025/blob/main/jupyter-notebooks/session4.ipynb)\n- [The Quantum Hall state](https://github.com/joselado/Advanced_Quantum_Materials_2025/blob/main/jupyter-notebooks/session5.ipynb)\n- [Superconductivity and Majorana physics](https://github.com/joselado/Advanced_Quantum_Materials_2025/blob/main/jupyter-notebooks/session6.ipynb)\n- [Interactions and magnetism](https://github.com/joselado/Advanced_Quantum_Materials_2025/blob/main/jupyter-notebooks/session7.ipynb)\n- [Excitations and defects in quantum materials](https://github.com/joselado/Advanced_Quantum_Materials_2025/blob/main/jupyter-notebooks/session8.ipynb)\n\n\nFrom the [Jyvaskyla Summer School 2022](https://github.com/joselado/jyvaskyla_summer_school_2022) \n- [Electronic structure](https://github.com/joselado/jyvaskyla_summer_school_2022/blob/main/sessions/session1.ipynb)\n- [Superconductivity](https://github.com/joselado/jyvaskyla_summer_school_2022/blob/main/sessions/session2.ipynb)\n- [Magnetism](https://github.com/joselado/jyvaskyla_summer_school_2022/blob/main/sessions/session3.ipynb)\n- [Moire physics](https://github.com/joselado/jyvaskyla_summer_school_2022/blob/main/sessions/session4.ipynb)\n- [Topological matter](https://github.com/joselado/jyvaskyla_summer_school_2022/blob/main/sessions/session5.ipynb)\n\n\n# FUNCTIONALITIES #\n## Single particle Hamiltonians ##\n- Spinless, spinful and Nambu basis for orbitals\n- Full non-collinear electron and Nambu formalism\n- Include magnetism, spin-orbit coupling and superconductivity\n- Band structures with state-resolved expectation values\n- Momentum-resolved spectral functions\n- Local and full operator-resolved density of states\n- 0d, 1d, 2d and 3d tight binding models \n- Electronic structure unfolding in supercells\n\n## Interacting mean-field Hamiltonians ##\n- Selfconsistent mean-field calculations with local/non-local interactions\n- Both collinear and non-collinear formalism\n- Anomalous mean-field for non-collinear superconductors\n- Full selfconsistency with all Wick terms for non-collinear superconductors\n- Constrained and unconstrained mean-field calculations\n- Automatic identification of order parameters for symmetry broken states\n- Hermitian and non-Hermitian mean-field calculations\n- Random phase approximation many-body response functions\n\n## Topological characterization ##\n- Berry phases, Berry curvatures, Chern numbers and Z2 invariants\n- Operator-resolved Chern numbers and Berry density\n- Frequency resolved topological density\n- Spatially resolved topological flux\n- Real-space Chern density for amorphous systems\n- Wilson loop and Green's function formalism\n\n## Spectral functions ##\n- Spectral functions in infinite geometries\n- Surface spectral functions for semi-infinite systems\n- Interfacial spectral function in semi-infinite junctions\n- Single impurities in infinite systems\n- Green's function renormalization algorithm\n- Operator and momentum resolved spectral functions\n\n## Chebyshev kernel polynomial based-algorithms ##\n- Local and full spectral functions\n- Non-local correlators and Green's functions\n- Locally resolved expectation values\n- Operator resolved spectral functions\n- Reaching system sizes up to 10000000 atoms on a single-core laptop\n\n## Quantum transport ##\n- Metal-metal transport\n- Metal-superconductor transport\n- Fully non-collinear Nambu basis\n- Non-equilibrium Green's function formalism\n- Operator-resolved transport\n- Differential decay rate\n- Tunneling and contact scanning probe spectroscopy\n\n# EXAMPLES #\nA variety of examples can be found in pyqula/examples. Short examples are shown below\n\n\n## Band structure of a Kagome lattice\n```python\nfrom pyqula import geometry\ng = geometry.kagome_lattice() # get the geometry object\nh = g.get_hamiltonian() # get the Hamiltonian object\n(k,e) = h.get_bands() # compute the band structure\n```\n![Alt text](images/kagome.png?raw=true \"Band structure of a Kagome lattice\")\n\n\n## Valley-resolved band structure of a honeycomb superlattice\n```python\nfrom pyqula import geometry\ng = geometry.honeycomb_lattice() # get the geometry object\ng = g.get_supercell(7) # create a supercell\nh = g.get_hamiltonian() # get the Hamiltonian object\n(k,e,v) = h.get_bands(operator=\"valley\") # compute the band structure\n```\n![Alt text](images/valley_supercell.png?raw=true \"Valley-resolved band structure of a honeycomb superlattice\")\n\n\n\n\n## Interaction-driven spin-singlet superconductivity\n```python\nfrom pyqula import geometry\nimport numpy as np\ng = geometry.triangular_lattice() # geometry of a triangular lattice\nh = g.get_hamiltonian()  # get the Hamiltonian\nh.setup_nambu_spinor() # setup the Nambu form of the Hamiltonian\nh = h.get_mean_field_hamiltonian(U=-1.0,filling=0.15,mf=\"swave\") # perform SCF\n# electron spectral-function\nh.get_kdos_bands(operator=\"electron\",nk=400,energies=np.linspace(-1.0,1.0,100))\n```\n\n![Alt text](images/scf_SC.png?raw=true \"Interaction-driven superconductivity\")\n\n\n## Interaction driven non-unitary spin-triplet superconductor\n```python\nimport numpy as np\nfrom pyqula import geometry\ng = geometry.triangular_lattice() # generate the geometry\nh = g.get_hamiltonian() # create Hamiltonian of the system\nh.add_exchange([0.,0.,1.]) # add exchange field\nh.setup_nambu_spinor() # initialize the Nambu basis\n# perform a superconducting non-collinear mean-field calculation\nh = h.get_mean_field_hamiltonian(V1=-1.0,filling=0.3,mf=\"random\")\n# compute the non-unitarity of the spin-triplet superconducting d-vector\nd = h.get_dvector_non_unitarity() # non-unitarity of spin-triplet\n# electron spectral-function\nh.get_kdos_bands(operator=\"electron\",nk=400,energies=np.linspace(-2.0,2.0,400))\n```\n\n![Alt text](images/scf_SC_triplet.png?raw=true \"Interaction driven non-unitary spin-triplet superconductor\")\n\n\n\n\n\n## Mean-field with local interactions of a zigzag honeycomb ribbon\n```python\nfrom pyqula import geometry\ng = geometry.honeycomb_zigzag_ribbon(10) # create geometry of a zigzag ribbon\nh = g.get_hamiltonian() # create hamiltonian of the system\nh = h.get_mean_field_hamiltonian(U=1.0,filling=0.5,mf=\"ferro\")\n(k,e,sz) = h.get_bands(operator=\"sz\") # calculate band structure\n```\n![Alt text](images/scf_zigzag.png?raw=true \"Mean-field with local interactions of a zigzag honeycomb ribbon\")\n\n\n## Non-collinear mean-field with local interactions of a square lattice\n```python\nfrom pyqula import geometry\ng = geometry.square_lattice() # geometry of a square lattice\ng = g.get_supercell([2,2]) # generate a 2x2 supercell\nh = g.get_hamiltonian() # create hamiltonian of the system\nh.add_zeeman([0.,0.,0.1]) # add out-of-plane Zeeman field\nh = h.get_mean_field_hamiltonian(U=2.0,filling=0.5,mf=\"random\") # perform SCF\n(k,e,c) = h.get_bands(operator=\"sz\") # calculate band structure\nm = h.get_magnetization() # get the magnetization\n```\n\n![Alt text](images/scf_square.png?raw=true \"Non-collinear mean-field interactions with local interactions of a square lattice\")\n\n\n## Interaction-induced non-collinear magnetism in a defective square lattice with spin-orbit coupling\n```python\nfrom pyqula import geometry\ng = geometry.square_lattice() # geometry of a square lattice\ng = g.get_supercell([7,7]) # generate a 7x7 supercell\ng = g.remove(i=g.get_central()[0]) # remove the central site\nh = g.get_hamiltonian() # create hamiltonian of the system\nh.add_rashba(.4) # add Rashba spin-orbit coupling\nh = h.get_mean_field_hamiltonian(U=2.0,filling=0.5,mf=\"random\") # perform SCF\n(k,e,c) = h.get_bands(operator=\"sz\") # calculate band structure\nm = h.get_magnetization() # get the magnetization\n```\n\n![Alt text](images/scf_square_vacancy.png?raw=true \"Interaction-induced non-collinear magnetism in a defective square lattice with spin-orbit coupling\")\n\n\n## RPA many-body response function in an antiferromagnet\n```python\nfrom pyqula import geometry ; import numpy as np\ng = geometry.bisquare_ribbon(2) # square bipartite ribbon\nh = g.get_hamiltonian() # generate Hamiltonian\nh = h.get_mean_field_hamiltonian(U=3.,mf=\"antiferro\",filling=0.5) # perform SCF\nqs = np.linspace(0.,.5,50) # qvectors\nenergies=np.linspace(.0,1.6,400) # energies\n\nchimap = [] # storage for the results\nfor q in qs: # loop over qvectors\n    es,chis = h.get_spinchi_ladder(q=q,energies=energies) # compute RPA tensor\n    cs = [np.trace(c).imag for c in chis] # imaginary part of the trace\n    chimap.append(cs) # store \n```\n\n![Alt text](images/spin_chi_rpa.png?raw=true \"RPA many-body spin response function, showing the appearence of linearly-dispersing magnons\")\n\n\n\n\n## RPA many-body response function in a ferromagnet\n```python\nfrom pyqula import geometry ; import numpy as np\ng = geometry.lieb_ribbon(2) # Lieb lattice ribbon\nh = g.get_hamiltonian() # generate Hamiltonian\nh = h.get_mean_field_hamiltonian(U=3.,mf=\"ferro\",filling=0.5) # perform SCF\nqs = np.linspace(0.,.5,50) # qvectors\nenergies=np.linspace(.0,1.,400) # energies\n\nchimap = [] # storage for the results\nfor q in qs: # loop over qvectors\n    es,chis = h.get_spinchi_ladder(q=q,energies=energies) # compute RPA tensor\n    cs = [np.trace(c).imag for c in chis] # imaginary part of the trace\n    chimap.append(cs) # store \n```\n\n![Alt text](images/spin_chi_rpa_ferro.png?raw=true \"RPA many-body spin response function of ferromagnetic lattice, showing the appearence of quadratically-dispersing magnons\")\n\n\n\n## Band structure of twisted bilayer graphene\n```python\nfrom pyqula import specialhamiltonian # special Hamiltonians library\nh = specialhamiltonian.twisted_bilayer_graphene() # TBG Hamiltonian\n(k,e) = h.get_bands() # compute band structure\n```\n\n![Alt text](images/tbg.png?raw=true \"Band structure of twisted bilayer graphene\")\n\n## Band structure of monolayer NbSe2\n```python\nfrom pyqula import specialhamiltonian # special Hamiltonians library\nh = specialhamiltonian.NbSe2(soc=0.5) # NbSe2 Hamiltonian\n(k,e,c) = h.get_bands(operator=\"sz\",kpath=[\"G\",\"K\",\"M\",\"G\"]) # compute bands\n```\n\n![Alt text](images/NbSe2.png?raw=true \"Band structure of monolayer NbSe2\")\n\n\n\n\n## Chern number of an artificial Chern insulator\n```python\nfrom pyqula import geometry\ng = geometry.honeycomb_lattice()\nh = g.get_hamiltonian()\nh.add_rashba(0.2) # Rashba spin-orbit coupling\nh.add_zeeman([0.,0.,0.6]) # Zeeman field\nfrom pyqula import topology\n(kx,ky,omega) = h.get_berry_curvature() # compute Berry curvature\nc = h.get_chern() # compute the Chern number\n```\n\n![Alt text](images/berry_curvature.png?raw=true \"Chern number of an artificial Chern insulator\")\n\n## Topological phase transition in an artificial topological superconductor\n```python\nimport numpy as np\nfrom pyqula import geometry\ng = geometry.chain() # create a chain\ng = g.supercell(100) # create a large supercell\ng.dimensionality = 0 # make it finite\nfor J in np.linspace(0.,0.2,50): # loop over exchange couplings\n    h = g.get_hamiltonian() # create a new hamiltonian\n    h.add_onsite(2.0) # shift the chemical potential\n    h.add_rashba(.3) # add rashba spin-orbit coupling\n    h.add_exchange([0.,0.,J]) # add exchange coupling\n    h.add_swave(.1) # add s-wave superconductivity\n    edge = h.get_operator(\"location\",r=g.r[0]) # projector on the edge\n    energies = np.linspace(-.2,.2,200) # set of energies\n    (e0,d0) = h.get_dos(operator=edge,energies=energies,delta=2e-3) # edge DOS\n```\n\n![Alt text](images/TSC.png?raw=true \"Topological phase transition in an artificial topological superconductor\")\n\n\n## Spatial distribution of Majorana modes in an artificial topological superconductor\n```python\nimport numpy as np\nfrom pyqula import geometry\ng = geometry.chain() # create a chain\ng = g.supercell(100) # create a large supercell\ng.dimensionality = 0 # make it finite\nh = g.get_hamiltonian() # create a new hamiltonian\nh.add_onsite(2.0) # shift the chemical potential\nh.add_rashba(.3) # add rashba spin-orbit coupling\nh.add_exchange([0.,0.,0.15]) # add exchange coupling\nh.add_swave(.1) # add s-wave superconductivity\nenergies = np.linspace(-.15,.15,200) # set of energies\nfor ri in g.r: # loop over sites\n    edge = h.get_operator(\"location\",r=ri) # projector on that site\n    (e0,d0) = h.get_dos(operator=edge,energies=energies,delta=2e-3) # local DOS\n```\n\n![Alt text](images/TSC_spatial.png?raw=true \"Spatial distribution of Majorana modes in an artificial topological superconductor\")\n\n\n\n\n\n\n## Unfolded electronic structure of a supercell with a defect\n```python\nfrom pyqula import geometry\nimport numpy as np\ng = geometry.honeycomb_lattice() # create a honeycomb lattice\nn = 3 # size of the supercell\ng = g.get_supercell(n,store_primal=True) # create a supercell\nh = g.get_hamiltonian() # get the Hamiltonian\nfons = lambda r: (np.sum((r - g.r[0])**2)\u003c1e-2)*100 # onsite in the impurity\nh.add_onsite(fons) # add onsite energy\nkpath = np.array(g.get_kpath(nk=200))*n # enlarged k-path\nh.get_kdos_bands(operator=\"unfold\",delta=1e-1,kpath=kpath) # unfolded bands\n```\n![Alt text](images/unfolded.png?raw=true \"Unfolded electronic structure of a supercell with a defect\")\n\n\n## Moire band structure of a moire superlattice\n```python\nfrom pyqula import geometry\nfrom pyqula import potentials\ng = geometry.triangular_lattice() # create geometry\ng = g.get_supercell([7,7]) # create a supercell\nh = g.get_hamiltonian() # get the Hamiltonian\nfmoire = potentials.commensurate_potential(g,n=3,minmax=[0,1]) # moire potential\nh.add_onsite(fmoire) # add onsite energy following the moire\nh.get_bands(operator=fmoire) # project on the moire\n```\n\n![Alt text](images/moire_bands.png?raw=true \"Moire band structure of a moire superstructure\")\n\n\n## Unfolded electronic structure of a moire superstructure\n```python\nfrom pyqula import geometry\nfrom pyqula import potentials\nimport numpy as np\ng0 = geometry.triangular_lattice() # create geometry\nn = 5 # supercell\ng = g0.get_supercell(n,store_primal=True) # create a supercell\nh = g.get_hamiltonian() # get the Hamiltonian\nfmoire = potentials.commensurate_potential(g,n=3,minmax=[0,1]) # moire potential\nh.add_onsite(fmoire) # add onsite energy following the moire\nkpath = np.array(g.get_kpath(nk=400))*n # enlarged k-path\nh.get_kdos_bands(operator=\"unfold\",delta=2e-2,kpath=kpath,\n                  energies=np.linspace(-3,-1,300)) # unfolded bands\n\n```\n\n![Alt text](images/unfolding_moire.png?raw=true \"Unfolded electronic structure of a moire superstructure\")\n\n\n\n\n\n\n## Band structure of a nodal line semimetal slab\n```python\nfrom pyqula import geometry\nfrom pyqula import films\ng = geometry.diamond_lattice()\ng = films.geometry_film(g,nz=20)\nh = g.get_hamiltonian()\n(k,e) = h.get_bands()\n```\n\n![Alt text](images/NLSM.png?raw=true \"Band structure of a nodal line semimetal slab\")\n\n\n## Band structure of a three dimensional topological insulator slab\n```python\nfrom pyqula import geometry\nfrom pyqula import films\nimport numpy as np\ng = geometry.diamond_lattice() # create a diamond lattice\ng = films.geometry_film(g,nz=60) # create a thin film\nh = g.get_hamiltonian() # generate Hamiltonian\nh.add_strain(lambda r: 1.+abs(r[2])*0.8,mode=\"directional\") # add axial strain\nh.add_kane_mele(0.1) # add intrinsic spin-orbit coupling\n(k,e,c)= h.get_bands(operator=\"surface\") # compute band structure\n```\n\n![Alt text](images/3DTI.png?raw=true \"Band structure of a three dimensional topological insulator\")\n\n\n\n## Surface spectral function of a 2D quantum spin-Hall insulator\n\n```python\nfrom pyqula import geometry\ng = geometry.honeycomb_lattice() # create a honeycomb lattice\nh = g.get_hamiltonian() # generate Hamiltonian\nh.add_soc(0.15) # add intrinsic spin-orbit coupling\nh.add_rashba(0.1) # add Rashba spin-orbit coupling\n(es,ks,ds,db) = h.get_surface_kdos(delta=1e-2) # compute surface spectral function\n```\n\n![Alt text](images/2DTI.png?raw=true \"Surface spectral function of a 2D quantum spin-Hall insulator\")\n\n\n\n## Local density of states with atomic orbitals of a honeycomb nanoisland\n```python\nfrom pyqula import islands\ng = islands.get_geometry(name=\"honeycomb\",n=3,nedges=3) # get an island\nh = g.get_hamiltonian() # get the Hamiltonian\nh.get_multildos(projection=\"atomic\") # get the LDOS\n```\n![Alt text](images/ldos_island.png?raw=true \"Local density of states with atomic orbitals of a honeycomb nanoisland\")\n\n\n\n## Interaction-driven magnetism in a honeycomb nanoisland\n```python\nfrom pyqula import islands\ng = islands.get_geometry(name=\"honeycomb\",n=3,nedges=3) # get an island\nh = g.get_hamiltonian() # get the Hamiltonian\nh = h.get_mean_field_hamiltonian(U=1.0,filling=0.5,mf=\"ferro\") # perform SCF\nm = h.get_magnetization() # get the magnetization in each site\n```\n\n![Alt text](images/scf_island.png?raw=true \"Interaction-driven magnetism in a honeycomb nanoisland\")\n\n## Hofstadter's butterfly of a square lattice\n```python\nimport numpy as np\nfrom pyqula import geometry\ng = geometry.square_ribbon(40) # create square ribbon geometry\n\nfor B in np.linspace(0.,1.0,300): # loop over magnetic field\n    h = g.get_hamiltonian() # create a new hamiltonian\n    h.add_orbital_magnetic_field(B) # add an orbital magnetic field\n    # calculate DOS projected on the bulk\n    (e,d) = h.get_dos(operator=\"bulk\",energies=np.linspace(-4.5,4.5,200))\n```\n\n![Alt text](images/hofstadter.png?raw=true \"Hofstadter's butterfly of a square lattice\")\n\n\n## Landau levels of a Dirac semimetal\n```python\nimport numpy as np\nfrom pyqula import geometry\ng = geometry.honeycomb_ribbon(30) # create a honeycomb ribbon\n\nfor B in np.linspace(0.,0.02,100): # loop over magnetic field\n    h = g.get_hamiltonian() # create a new hamiltonian\n    h.add_orbital_magnetic_field(B) # add an orbital magnetic field\n    # calculate DOS projected on the bulk\n    (e,d) = h.get_dos(operator=\"bulk\",energies=np.linspace(-1.0,1.0,200),\n                       delta=1e-2)\n```\n\n![Alt text](images/LL_Dirac.png?raw=true \"Landau levels of a Dirac semimetal\")\n\n\n\n## Surface spectral function of a Chern insulator\n```python\nfrom pyqula import geometry\nfrom pyqula import kdos\ng = geometry.honeycomb_lattice() # create honeycomb lattice\nh = g.get_hamiltonian() # create hamiltonian of the system\nh.add_haldane(0.05) # Add Haldane coupling\nkdos.surface(h) # surface spectral function\n```\n\n![Alt text](images/kdos.png?raw=true \"Surface spectral function of a Chern insulator\")\n\n\n## Surface states and Berry curvature of a artificial 2D topological superconductor\n```python\nfrom pyqula import geometry\nimport numpy as np\ng = geometry.triangular_lattice() # get the geometry\nh = g.get_hamiltonian() # get the Hamiltonian\nh.add_onsite(2.0) # shift chemical potential\nh.add_rashba(1.0) # Rashba spin-orbit coupling\nh.add_zeeman([0.,0.,0.6]) # Zeeman field\nh.add_swave(.3) # add superconductivity\n(kx,ky,omega) = h.get_berry_curvature() # compute Berry curvature\n(es,ks,ds,db) = h.get_surface_kdos(energies=np.linspace(-.4,.4,300)) # surface spectral function\n```\n\n![Alt text](images/2DTSC.png?raw=true \"Surface states and Berry curvature of a artificial 2D topological superconductor\")\n\n\n\n# Surface states in a topological superconductor nanoisland\n\n```python\nfrom pyqula import islands\ng = islands.get_geometry(name=\"triangular\",shape=\"flower\",\n                           r=14.2,dr=2.0,nedges=6) # get a flower-shaped island\nh = g.get_hamiltonian() # get the Hamiltonian\nh.add_onsite(3.0) # shift chemical potential\nh.add_rashba(1.0) # Rashba spin-orbit coupling\nh.add_zeeman([0.,0.,0.6]) # Zeeman field\nh.add_swave(.3) # add superconductivity\nh.get_ldos() # Spatially resolved DOS\n```\n\n![Alt text](images/island_TSC.png?raw=true \"Surface states in a topological superconductor nanoisland\")\n\n\n\n\n\n## Antiferromagnet-superconductor interface\n```python\nfrom pyqula import geometry\ng = geometry.honeycomb_zigzag_ribbon(20) # create geometry of a zigzag ribbon\nh = g.get_hamiltonian(has_spin=True) # create hamiltonian of the system\nh.add_antiferromagnetism(lambda r: (r[1]\u003e0)*0.5) # add antiferromagnetism\nh.add_onsite(lambda r: (r[1]\u003e0)*0.3) # add chemical potential\nh.add_swave(lambda r: (r[1]\u003c0)*0.3) # add superconductivity\n(k,e,sz) = h.get_bands(operator=\"sz\") # calculate band structure\n```\n\n\n\n![Alt text](images/AF_SC.png?raw=true \"Antiferromagnet-superconductor interface\")\n\n## Fermi surface of a triangular lattice supercell\n```python\nfrom pyqula import geometry\nimport numpy as np\ng = geometry.triangular_lattice() # create geometry of the system\ng = g.get_supercell(2) # create a supercell\nh = g.get_hamiltonian() # create hamiltonian of the system\nh.get_multi_fermi_surface(energies=np.linspace(-4,4,100),delta=1e-1)\n```\n\n![Alt text](images/fermi_surface.png?raw=true \"Fermi surface of a triangular lattice supercell\")\n\n\n\n## Unfolded Fermi surface of a supercell with a defect\n```python\nfrom pyqula import geometry\nimport numpy as np\ng0 = geometry.triangular_lattice()\nn = 3 # size of the supercell\ng = g0.get_supercell(n,store_primal=True) # create a supercell\nh = g.get_hamiltonian() # get the Hamiltonian\nfons = lambda r: (np.sum((r - g.r[0])**2)\u003c1e-2)*100 # onsite in the impurity\nh.add_onsite(fons) # add onsite energy\nkpath = np.array(g.get_kpath(nk=200))*n # enlarged k-path\nh.get_multi_fermi_surface(nk=50,energies=np.linspace(-4,4,100),\n        delta=0.1,nsuper=n,operator=\"unfold\")\n```\n\n![Alt text](images/unfolded_FS.png?raw=true \"Unfolded Fermi surface of a supercell with a defect\")\n\n\n\n## Tunneling and Andreev reflection in a metal-superconductor junction\n\n```python\nfrom pyqula import geometry\nfrom pyqula import heterostructures\nimport numpy as np\ng = geometry.chain() # create the geometry\nh = g.get_hamiltonian() # create the Hamiltonian\nh1 = h.copy() # first lead\nh2 = h.copy() # second lead\nh2.add_swave(.01) # the second lead is superconducting\nes = np.linspace(-.03,.03,100) # set of energies for dIdV\nfor T in np.linspace(1e-3,1.0,6): # loop over transparencies\n    HT = heterostructures.build(h1,h2) # create the junction\n    HT.set_coupling(T) # set the coupling between the leads\n    Gs = [HT.didv(energy=e) for e in es] # calculate conductance\n```\n\n![Alt text](images/andreev.png?raw=true \"Tunneling and Andreev reflection in a metal-superconductor junction\")\n\n\n\n\n## From tunneling to contact transport of a topological superconductor\n\n```python\nfrom pyqula import geometry\nfrom pyqula import heterostructures\nimport numpy as np\n\ng = geometry.chain() # create the geometry\nh = g.get_hamiltonian() # create teh Hamiltonian\nh1 = h.copy() # first lead\nh2 = h.copy() # second lead\nh2.add_onsite(2.0) # shift chemical potential in the second lead\nh2.add_exchange([0.,0.,.3]) # add exchange in the second lead\nh2.add_rashba(.3) # add Rashba SOC in the second lead\nh2.add_swave(.05) # add s-wave SC in the second lead\nes = np.linspace(-.1,.1,100) # grid of energies\nfor T in np.linspace(1e-3,0.5,10): # loop over transparencies\n    HT = heterostructures.build(h1,h2) # create the junction\n    HT.set_coupling(T) # set the coupling between the leads\n    Gs = [HT.didv(energy=e) for e in es] # calculate transmission\n```\n\n![Alt text](images/dIdV_TSC.png?raw=true \"From tunneling to contact transport of a topological superconductor\")\n\n\n\n\n## Single impurity in an infinite honeycomb lattice\n```python\nfrom pyqula import geometry\nimport numpy as np\nfrom pyqula import embedding\ng = geometry.honeycomb_lattice() # create geometry \nh = g.get_hamiltonian() # get the Hamiltonian\nhv = h.copy() # copy Hamiltonian to create a defective one\nhv.add_onsite(lambda r: (np.sum((r - g.r[0])**2)\u003c1e-2)*100) # add a defect\neb = embedding.Embedding(h,m=hv) # create an embedding object\n(x,y,d) = eb.ldos(nsuper=19,energy=0.,delta=1e-2) # compute LDOS\n```\n\n![Alt text](images/single_vacancy.png?raw=true \"Single impurity in an infinite honeycomb lattice\")\n\n\n\n## Bound state of a single magnetic impurity in an infinite superconductor\n```python\nfrom pyqula import geometry\nimport numpy as np\nfrom pyqula import embedding\ng = geometry.square_lattice() # create geometry\nh = g.get_hamiltonian() # get the Hamiltonian\nh.add_swave(0.1) # add s-wave superconductivity\nh.add_onsite(3.0) # shift chemical potential\nhv = h.copy() # copy Hamiltonian to create a defective one\nhv.add_exchange(lambda r: [0.,0.,(np.sum((r - g.r[0])**2)\u003c1e-2)*6.]) # add magnetic site\neb = embedding.Embedding(h,m=hv) # create an embedding object\nei = eb.get_energy_ingap_state() # get energy of the impurity state\n(x,y,d) = eb.ldos(nsuper=19,energy=ei,delta=1e-3) # compute LDOS\n```\n\n![Alt text](images/single_YSR.png?raw=true \"Single magnetic impurity in an infinite superconductor\")\n\n\n\n## Parity switching of a magnetic impurity in an infinite superconductor\n\n```python\nfrom pyqula import geometry\nfrom pyqula import embedding\nimport numpy as np\n\ng = geometry.square_lattice() # create geometry\nfor J in np.linspace(0.,4.0,100): # loop over exchange\n    h = g.get_hamiltonian() # get the Hamiltonian,spinless\n    h.add_onsite(3.0) # shift chemical potential\n    h.add_swave(0.2) # add s-wave superconductivity\n    hv = h.copy() # copy Hamiltonian to create a defective one\n    # add magnetic site\n    hv.add_exchange(lambda r: [0.,0.,(np.sum((r - g.r[0])**2)\u003c1e-2)*J])\n    eb = embedding.Embedding(h,m=hv) # create an embedding object\n    energies = np.linspace(-0.4,0.4,100) # energies\n    d = [eb.dos(nsuper=2,delta=1e-2,energy=ei) for ei in energies] # compute DOS\n```\n\n![Alt text](images/YSR.png?raw=true \"Parity switching of a magnetic impurity in an infinite superconductor\")\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoselado%2Fpyqula","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoselado%2Fpyqula","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoselado%2Fpyqula/lists"}