├── .LICENSE_header ├── .binder ├── apt.txt └── postBuild ├── .codecov.yml ├── .git-blame-ignore-revs ├── .git_archival.txt ├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── 005_bug.md │ ├── 010_feature.md │ ├── 015_contribute.md │ ├── 020_issue.md │ ├── 100_publication.md │ └── config.yml ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yaml └── workflows │ ├── codeql.yml │ ├── codeql │ └── config.yml │ ├── documentation_ghpages.yaml │ ├── linter.yml │ ├── test.yaml │ └── wheels.yaml ├── .gitignore ├── .gitmodules ├── .mailmap ├── .pre-commit-config.yaml ├── .readthedocs-pre_install.sh ├── .readthedocs.yml ├── CITATION.cff ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── DEPLOY.md ├── LICENSE ├── MANIFEST.in ├── README.md ├── benchmarks ├── bloch.py ├── bz_parallel.py ├── bz_replace.py ├── comparisons │ └── neighbors.py ├── graphene.py ├── graphene_io.py ├── graphene_repeat.py ├── graphene_tile.py ├── graphene_within.py ├── lprofile3.sh ├── optimizations │ ├── array_arange.ipynb │ ├── bloch.ipynb │ └── hamiltonian.ipynb ├── run.sh ├── sparse_matrices.py ├── sparse_matrices_ufunc.py └── stats.py ├── changes ├── 927.change.rst ├── README.rst └── toolbox │ └── .gitignore ├── data └── atomic_radii.dat ├── developments ├── distributions.py ├── miller.py ├── spin.ipynb └── test_numpy_installs.sh ├── docs ├── Makefile ├── _static │ ├── css │ │ └── custom_styles.css │ └── visualization │ │ └── plotly │ │ └── basic-tutorials │ │ └── GUIScreenshot.png ├── _templates │ └── autosummary │ │ ├── class.rst │ │ ├── function.rst │ │ └── module.rst ├── api │ ├── basic.rst │ ├── core.rst │ ├── geom │ │ ├── building.rst │ │ ├── index.rst │ │ ├── indexing.rst │ │ └── neighbors.rst │ ├── index.rst │ ├── io │ │ ├── basic.rst │ │ ├── bigdft-hidden.rst │ │ ├── bigdft.rst │ │ ├── dftb-hidden.rst │ │ ├── dftb.rst │ │ ├── fhiaims-hidden.rst │ │ ├── fhiaims.rst │ │ ├── generic.rst │ │ ├── gulp-hidden.rst │ │ ├── gulp.rst │ │ ├── index.rst │ │ ├── openmx-hidden.rst │ │ ├── openmx.rst │ │ ├── orca-hidden.rst │ │ ├── orca.rst │ │ ├── scaleup-hidden.rst │ │ ├── scaleup.rst │ │ ├── siesta-hidden.rst │ │ ├── siesta.rst │ │ ├── tbtrans-hidden.rst │ │ ├── tbtrans.rst │ │ ├── vasp-hidden.rst │ │ ├── vasp.rst │ │ ├── wannier90-hidden.rst │ │ └── wannier90.rst │ ├── mixing.rst │ ├── physics.brillouinzone.rst │ ├── physics.distribution.rst │ ├── physics.electron-hidden.rst │ ├── physics.electron.rst │ ├── physics.matrix-hidden.rst │ ├── physics.matrix.rst │ ├── physics.phonon.rst │ ├── physics.rst │ ├── typing.rst │ ├── unit_constant.constant.rst │ ├── unit_constant.rst │ ├── unit_constant.unit.rst │ ├── utilities.misc.rst │ ├── utilities.rst │ ├── utilities.shape.rst │ └── viz │ │ └── index.rst ├── build_docs.sh ├── changelog │ ├── index.rst │ ├── v0.10.0.rst │ ├── v0.11.0.rst │ ├── v0.12.0.rst │ ├── v0.12.1.rst │ ├── v0.12.2.rst │ ├── v0.13.0.rst │ ├── v0.14.0.rst │ ├── v0.14.2.rst │ ├── v0.14.3.rst │ ├── v0.15.0.rst │ ├── v0.15.1.rst │ ├── v0.15.2.rst │ ├── v0.8.0.rst │ ├── v0.8.1.rst │ ├── v0.8.2.rst │ ├── v0.8.3.rst │ ├── v0.8.4.rst │ ├── v0.8.5.rst │ ├── v0.9.0.rst │ ├── v0.9.1.rst │ ├── v0.9.2.rst │ ├── v0.9.3.rst │ ├── v0.9.4.rst │ ├── v0.9.5.rst │ ├── v0.9.6.rst │ ├── v0.9.7.rst │ └── v0.9.8.rst ├── cite.rst ├── conf.py ├── dev │ └── index.rst ├── environment.rst ├── index.rst ├── introduction.rst ├── math.rst ├── other.rst ├── quickstart │ ├── basic_deps.dot │ ├── basic_deps.svg │ ├── index.rst │ ├── install.rst │ ├── intro_tutorials │ │ ├── 01_geometry.ipynb │ │ ├── 02_geometry_orbitals.ipynb │ │ └── 03_geometry_sile.ipynb │ └── overview.rst ├── references.bib ├── references.rst ├── release.rst ├── release │ ├── 0.16.0-notes.rst │ ├── 0.16.1-notes.rst │ ├── 0.16.2-notes.rst │ └── template.rst ├── scripts │ ├── index.rst │ ├── sdata.rst │ ├── sgeom.rst │ ├── sgrid.rst │ └── stoolbox.rst ├── sisl_modules │ ├── __init__.py │ └── github_links.py ├── sisl_uses.bib ├── spelling_wordlist.txt ├── toolbox │ ├── btd │ │ └── btd.rst │ ├── index.rst │ ├── siesta │ │ ├── atom_plot.rst │ │ └── atom_plot_output.png │ └── transiesta │ │ └── ts_fft.rst ├── tutorials │ ├── convert.bash │ ├── figures │ │ ├── 04_graphene_couplings.png │ │ ├── 04_supercell.png │ │ ├── 05_graphene_bs.png │ │ └── 05_square_bs.png │ ├── index.rst │ ├── siesta_1 │ │ ├── H.psf │ │ ├── O.psf │ │ └── siesta_1.nc │ ├── siesta_2 │ │ ├── C.psf │ │ └── siesta_2.nc │ ├── tutorial_01.rst │ ├── tutorial_02.rst │ ├── tutorial_04.rst │ ├── tutorial_04.tex │ ├── tutorial_05.rst │ ├── tutorial_05_graphene.py │ ├── tutorial_05_square.py │ ├── tutorial_06.rst │ ├── tutorial_06_square.py │ ├── tutorial_es_1.ipynb │ ├── tutorial_es_2.ipynb │ ├── tutorial_setup.tex │ ├── tutorial_siesta_1.ipynb │ ├── tutorial_siesta_2.ipynb │ └── tutorial_siesta_2_ahc.ipynb └── visualization │ ├── ase │ └── index.rst │ ├── basic-tutorials │ └── Demo.ipynb │ ├── blender │ ├── First animation.rst │ └── Getting started.rst │ ├── combining-plots │ └── Intro to combining plots.ipynb │ ├── diy │ ├── Adding new backends.ipynb │ └── Building a new plot.ipynb │ ├── index.rst │ ├── showcase │ ├── AtomicMatrixPlot.ipynb │ ├── BandsPlot.ipynb │ ├── FatbandsPlot.ipynb │ ├── GeometryPlot.ipynb │ ├── GridPlot.ipynb │ ├── PdosPlot.ipynb │ ├── SitesPlot.ipynb │ ├── WavefunctionPlot.ipynb │ └── _template │ │ ├── Showcase template.ipynb │ │ └── create.py │ └── tests │ └── test_tutorials.py ├── examples ├── ex_01.py ├── ex_02.py └── ex_03.py ├── pyproject.toml ├── src ├── CMakeLists.txt ├── sisl │ ├── CMakeLists.txt │ ├── __init__.py │ ├── __main__.py │ ├── _array.py │ ├── _category.py │ ├── _common.py │ ├── _core │ │ ├── CMakeLists.txt │ │ ├── __init__.py │ │ ├── _dtypes.pxd │ │ ├── _dtypes.pyx │ │ ├── _lattice.pyx │ │ ├── _sparse.pxd │ │ ├── _sparse.pyx │ │ ├── _ufuncs_atom.py │ │ ├── _ufuncs_geometry.py │ │ ├── _ufuncs_grid.py │ │ ├── _ufuncs_lattice.py │ │ ├── _ufuncs_orbital.py │ │ ├── _ufuncs_sparse.py │ │ ├── _ufuncs_sparse_geometry.py │ │ ├── atom.py │ │ ├── geometry.py │ │ ├── grid.py │ │ ├── lattice.py │ │ ├── oplist.py │ │ ├── orbital.py │ │ ├── periodictable.py │ │ ├── quaternion.py │ │ ├── sparse.py │ │ ├── sparse_geometry.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_atom.py │ │ │ ├── test_atoms.py │ │ │ ├── test_geometry.py │ │ │ ├── test_geometry_return.py │ │ │ ├── test_grid.py │ │ │ ├── test_lattice.py │ │ │ ├── test_oplist.py │ │ │ ├── test_orbital.py │ │ │ ├── test_quaternion.py │ │ │ ├── test_sgeom.py │ │ │ ├── test_sgrid.py │ │ │ ├── test_sparse.py │ │ │ ├── test_sparse_geometry.py │ │ │ └── test_sparse_orbital.py │ ├── _dispatch_class.py │ ├── _dispatcher.py │ ├── _environ.py │ ├── _help.py │ ├── _indices.pxd │ ├── _indices.pyx │ ├── _internal.py │ ├── _lazy_viz.py │ ├── _lib │ │ ├── _argparse.py │ │ └── _docscrape.py │ ├── _math_small.pyx │ ├── _namedindex.py │ ├── _nodify.py │ ├── _sparse_grid.py │ ├── _sparse_grid_ops.py │ ├── _ufuncs.py │ ├── conftest.py │ ├── constant.py │ ├── geom │ │ ├── CMakeLists.txt │ │ ├── __init__.py │ │ ├── _category │ │ │ ├── __init__.py │ │ │ ├── _coord.py │ │ │ ├── _kind.py │ │ │ ├── _neighbors.py │ │ │ ├── base.py │ │ │ └── tests │ │ │ │ ├── __init__.py │ │ │ │ └── test_geom_category.py │ │ ├── _common.py │ │ ├── _composite.py │ │ ├── _neighbors │ │ │ ├── CMakeLists.txt │ │ │ ├── __init__.py │ │ │ ├── _finder.py │ │ │ ├── _neighborlists.py │ │ │ ├── _operations.py │ │ │ └── tests │ │ │ │ └── test_finder.py │ │ ├── basic.py │ │ ├── bilayer.py │ │ ├── flat.py │ │ ├── nanoribbon.py │ │ ├── nanotube.py │ │ ├── special.py │ │ ├── surfaces.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ └── test_geom.py │ ├── io │ │ ├── CMakeLists.txt │ │ ├── __init__.py │ │ ├── _except_base.py │ │ ├── _except_objects.py │ │ ├── _help.py │ │ ├── _multiple.py │ │ ├── _zipfile.py │ │ ├── bigdft │ │ │ ├── __init__.py │ │ │ ├── ascii.py │ │ │ └── sile.py │ │ ├── cube.py │ │ ├── dftb │ │ │ ├── __init__.py │ │ │ ├── realdat.py │ │ │ ├── sile.py │ │ │ └── tests │ │ │ │ ├── __init__.py │ │ │ │ └── test_realdat.py │ │ ├── fhiaims │ │ │ ├── __init__.py │ │ │ ├── _geometry.py │ │ │ ├── sile.py │ │ │ └── tests │ │ │ │ ├── __init__.py │ │ │ │ └── test_in.py │ │ ├── gulp │ │ │ ├── __init__.py │ │ │ ├── fc.py │ │ │ ├── got.py │ │ │ ├── sile.py │ │ │ └── tests │ │ │ │ ├── __init__.py │ │ │ │ └── test_gout.py │ │ ├── ham.py │ │ ├── molden.py │ │ ├── openmx │ │ │ ├── __init__.py │ │ │ ├── md.py │ │ │ ├── omx.py │ │ │ └── sile.py │ │ ├── orca │ │ │ ├── __init__.py │ │ │ ├── sile.py │ │ │ ├── stdout.py │ │ │ ├── tests │ │ │ │ ├── __init__.py │ │ │ │ ├── test_stdout.py │ │ │ │ └── test_txt.py │ │ │ └── txt.py │ │ ├── pdb.py │ │ ├── scaleup │ │ │ ├── __init__.py │ │ │ ├── orbocc.py │ │ │ ├── ref.py │ │ │ ├── rham.py │ │ │ └── sile.py │ │ ├── siesta │ │ │ ├── CMakeLists.txt │ │ │ ├── __init__.py │ │ │ ├── _help.py │ │ │ ├── _src │ │ │ │ ├── dm_read.f90 │ │ │ │ ├── dm_write.f90 │ │ │ │ ├── gf_read.f90 │ │ │ │ ├── gf_write.f90 │ │ │ │ ├── grid_read.f90 │ │ │ │ ├── grid_write.f90 │ │ │ │ ├── hsx_read.f90 │ │ │ │ ├── hsx_write.f90 │ │ │ │ ├── io_m.f90 │ │ │ │ ├── precision.f90 │ │ │ │ ├── siesta_sc_off.f90 │ │ │ │ ├── sparse_io.f90 │ │ │ │ ├── tsde_read.f90 │ │ │ │ ├── tsde_write.f90 │ │ │ │ ├── tshs_read.f90 │ │ │ │ ├── tshs_write.f90 │ │ │ │ └── wfsx_read.f90 │ │ │ ├── ani.py │ │ │ ├── bands.py │ │ │ ├── basis.py │ │ │ ├── binaries.py │ │ │ ├── eig.py │ │ │ ├── fa.py │ │ │ ├── fc.py │ │ │ ├── fdf.py │ │ │ ├── kp.py │ │ │ ├── orb_indx.py │ │ │ ├── pdos.py │ │ │ ├── siesta_grid.py │ │ │ ├── siesta_nc.py │ │ │ ├── sile.py │ │ │ ├── stdout.py │ │ │ ├── struct.py │ │ │ ├── tests │ │ │ │ ├── __init__.py │ │ │ │ ├── test_ani.py │ │ │ │ ├── test_bands.py │ │ │ │ ├── test_basis.py │ │ │ │ ├── test_dm.py │ │ │ │ ├── test_eig.py │ │ │ │ ├── test_fa.py │ │ │ │ ├── test_fc.py │ │ │ │ ├── test_fdf.py │ │ │ │ ├── test_gf.py │ │ │ │ ├── test_grid.py │ │ │ │ ├── test_hsx.py │ │ │ │ ├── test_kp.py │ │ │ │ ├── test_matrices.py │ │ │ │ ├── test_orb_indx.py │ │ │ │ ├── test_pdos.py │ │ │ │ ├── test_siesta.py │ │ │ │ ├── test_stdout.py │ │ │ │ ├── test_stdout_charges.py │ │ │ │ ├── test_struct.py │ │ │ │ ├── test_times.py │ │ │ │ ├── test_tsde.py │ │ │ │ ├── test_tshs.py │ │ │ │ ├── test_vibra.py │ │ │ │ ├── test_wfsx.py │ │ │ │ └── test_xv.py │ │ │ ├── times.py │ │ │ ├── transiesta_grid.py │ │ │ ├── vibra.py │ │ │ └── xv.py │ │ ├── sile.py │ │ ├── table.py │ │ ├── tbtrans │ │ │ ├── __init__.py │ │ │ ├── _cdf.py │ │ │ ├── binaries.py │ │ │ ├── delta.py │ │ │ ├── pht.py │ │ │ ├── phtproj.py │ │ │ ├── se.py │ │ │ ├── sile.py │ │ │ ├── tbt.py │ │ │ ├── tbtproj.py │ │ │ └── tests │ │ │ │ ├── __init__.py │ │ │ │ ├── test_delta.py │ │ │ │ ├── test_tbt.py │ │ │ │ └── test_tbtproj.py │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── test_buffers.py │ │ │ ├── test_cube.py │ │ │ ├── test_ham.py │ │ │ ├── test_object.py │ │ │ ├── test_table.py │ │ │ ├── test_xsf.py │ │ │ ├── test_xyz.py │ │ │ └── test_zipfile.py │ │ ├── vasp │ │ │ ├── __init__.py │ │ │ ├── car.py │ │ │ ├── chg.py │ │ │ ├── doscar.py │ │ │ ├── eigenval.py │ │ │ ├── locpot.py │ │ │ ├── outcar.py │ │ │ ├── sile.py │ │ │ └── tests │ │ │ │ ├── __init__.py │ │ │ │ ├── test_car.py │ │ │ │ ├── test_chg.py │ │ │ │ ├── test_doscar.py │ │ │ │ ├── test_eigenval.py │ │ │ │ ├── test_locpot.py │ │ │ │ └── test_outcar.py │ │ ├── wannier90 │ │ │ ├── __init__.py │ │ │ ├── seedname.py │ │ │ ├── sile.py │ │ │ └── tests │ │ │ │ ├── __init__.py │ │ │ │ └── test_seedname.py │ │ ├── xsf.py │ │ └── xyz.py │ ├── linalg │ │ ├── __init__.py │ │ ├── base.py │ │ ├── special.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_eig.py │ │ │ ├── test_inv.py │ │ │ ├── test_solve.py │ │ │ └── test_special.py │ ├── messages.py │ ├── mixing │ │ ├── __init__.py │ │ ├── base.py │ │ ├── diis.py │ │ ├── linear.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_diis.py │ │ │ ├── test_history.py │ │ │ ├── test_linear.py │ │ │ └── test_step.py │ ├── physics │ │ ├── CMakeLists.txt │ │ ├── __init__.py │ │ ├── _bloch.pyx │ │ ├── _brillouinzone_apply.py │ │ ├── _common.py │ │ ├── _feature.py │ │ ├── _matrix_ddk.pyx │ │ ├── _matrix_dk.pyx │ │ ├── _matrix_k.pyx │ │ ├── _matrix_phase.pyx │ │ ├── _matrix_phase3.pyx │ │ ├── _matrix_phase_sc.pyx │ │ ├── _matrix_utils.pxd │ │ ├── _matrix_utils.pyx │ │ ├── _phase.pxd │ │ ├── _phase.pyx │ │ ├── _ufuncs_brillouinzone.py │ │ ├── _ufuncs_densitymatrix.py │ │ ├── _ufuncs_dynamicalmatrix.py │ │ ├── _ufuncs_electron.py │ │ ├── _ufuncs_energydensitymatrix.py │ │ ├── _ufuncs_hamiltonian.py │ │ ├── _ufuncs_matrix.py │ │ ├── _ufuncs_overlap.py │ │ ├── _ufuncs_state.py │ │ ├── bloch.py │ │ ├── brillouinzone.py │ │ ├── densitymatrix.py │ │ ├── distribution.py │ │ ├── dynamicalmatrix.py │ │ ├── electron.py │ │ ├── energydensitymatrix.py │ │ ├── hamiltonian.py │ │ ├── overlap.py │ │ ├── phonon.py │ │ ├── self_energy.py │ │ ├── sparse.py │ │ ├── spin.py │ │ ├── state.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_bloch.py │ │ │ ├── test_brillouinzone.py │ │ │ ├── test_density_matrix.py │ │ │ ├── test_distribution.py │ │ │ ├── test_dynamical_matrix.py │ │ │ ├── test_electron.py │ │ │ ├── test_energy_density_matrix.py │ │ │ ├── test_feature.py │ │ │ ├── test_hamiltonian.py │ │ │ ├── test_overlap.py │ │ │ ├── test_physics_sparse.py │ │ │ ├── test_self_energy.py │ │ │ ├── test_spin.py │ │ │ └── test_state.py │ ├── shape │ │ ├── __init__.py │ │ ├── _cylinder.py │ │ ├── base.py │ │ ├── ellipsoid.py │ │ ├── prism4.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_cylinder.py │ │ │ ├── test_ellipsoid.py │ │ │ ├── test_prism4.py │ │ │ └── test_shape.py │ ├── tests │ │ ├── __init__.py │ │ ├── test_help.py │ │ ├── test_messages.py │ │ ├── test_namedindex.py │ │ ├── test_package.py │ │ └── test_sparse_grid.py │ ├── typing │ │ ├── __init__.py │ │ ├── _atom.py │ │ ├── _common.py │ │ ├── _core.py │ │ ├── _indices.py │ │ ├── _physics.py │ │ ├── _units.py │ │ └── tests │ │ │ └── test_typing.py │ ├── unit │ │ ├── __init__.py │ │ ├── base.py │ │ ├── codata.py │ │ ├── codata_2010.txt │ │ ├── codata_2014.txt │ │ ├── codata_2018.txt │ │ ├── codata_2022.txt │ │ ├── siesta.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_codata.py │ │ │ ├── test_unit.py │ │ │ └── test_unit_siesta.py │ ├── utils │ │ ├── __init__.py │ │ ├── _arrays.py │ │ ├── _search_mro.py │ │ ├── _sisl_cmd.py │ │ ├── cmd.py │ │ ├── mathematics.py │ │ ├── misc.py │ │ ├── ranges.py │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_arrays.py │ │ │ ├── test_cmd.py │ │ │ ├── test_mathematics.py │ │ │ ├── test_misc.py │ │ │ └── test_ranges.py │ └── viz │ │ ├── __init__.py │ │ ├── _plotables.py │ │ ├── _plotables_register.py │ │ ├── _presets.py │ │ ├── _single_dispatch.py │ │ ├── _splot.py │ │ ├── _xarray_accessor.py │ │ ├── data │ │ ├── __init__.py │ │ ├── bands.py │ │ ├── data.py │ │ ├── eigenstate.py │ │ ├── pdos.py │ │ ├── sisl_objs.py │ │ ├── tests │ │ │ ├── .coverage │ │ │ ├── test_bands.py │ │ │ └── test_pdos.py │ │ └── xarray.py │ │ ├── data_sources │ │ ├── __init__.py │ │ ├── atom_data.py │ │ ├── bond_data.py │ │ ├── data_source.py │ │ ├── eigenstate_data.py │ │ ├── file │ │ │ ├── __init__.py │ │ │ ├── file_source.py │ │ │ └── siesta.py │ │ ├── hamiltonian_source.py │ │ └── orbital_data.py │ │ ├── figure │ │ ├── __init__.py │ │ ├── blender.py │ │ ├── figure.py │ │ ├── matplotlib.py │ │ ├── plotly.py │ │ └── py3dmol.py │ │ ├── plot.py │ │ ├── plots │ │ ├── __init__.py │ │ ├── bands.py │ │ ├── geometry.py │ │ ├── grid.py │ │ ├── matrix.py │ │ ├── merged.py │ │ ├── orbital_groups_plot.py │ │ ├── pdos.py │ │ └── tests │ │ │ ├── .coverage │ │ │ ├── __init__.py │ │ │ ├── test_bands.py │ │ │ ├── test_geometry.py │ │ │ ├── test_grid.py │ │ │ ├── test_matrix.py │ │ │ └── test_pdos.py │ │ ├── plotters │ │ ├── __init__.py │ │ ├── cell.py │ │ ├── grid.py │ │ ├── matrix.py │ │ ├── plot_actions.py │ │ ├── tests │ │ │ ├── test_matrix.py │ │ │ └── test_xarray.py │ │ └── xarray.py │ │ ├── plotutils.py │ │ ├── processors │ │ ├── __init__.py │ │ ├── atom.py │ │ ├── axes.py │ │ ├── bands.py │ │ ├── cell.py │ │ ├── coords.py │ │ ├── data.py │ │ ├── eigenstate.py │ │ ├── geometry.py │ │ ├── grid.py │ │ ├── logic.py │ │ ├── math.py │ │ ├── matrix.py │ │ ├── orbital.py │ │ ├── spin.py │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── test_axes.py │ │ │ ├── test_bands.py │ │ │ ├── test_cell.py │ │ │ ├── test_coords.py │ │ │ ├── test_data.py │ │ │ ├── test_eigenstate.py │ │ │ ├── test_geometry.py │ │ │ ├── test_grid.py │ │ │ ├── test_groupreduce.py │ │ │ ├── test_logic.py │ │ │ ├── test_math.py │ │ │ ├── test_matrix.py │ │ │ ├── test_orbital.py │ │ │ ├── test_sci_groupreduce.py │ │ │ └── test_spin.py │ │ ├── wavefunction.py │ │ └── xarray.py │ │ └── types.py └── sisl_toolbox │ ├── README │ ├── btd │ ├── __init__.py │ └── _btd.py │ ├── cli │ ├── __init__.py │ ├── _cli.py │ └── _cli_imports.py │ ├── models │ ├── __init__.py │ ├── _base.py │ └── _graphene │ │ ├── __init__.py │ │ ├── _base.py │ │ └── _hamiltonian.py │ ├── siesta │ ├── atom │ │ ├── __init__.py │ │ └── _atom.py │ └── minimizer │ │ ├── __init__.py │ │ ├── _atom_basis.py │ │ ├── _atom_pseudo.py │ │ ├── _metric.py │ │ ├── _metric_siesta.py │ │ ├── _minimize.py │ │ ├── _minimize_siesta.py │ │ ├── _path.py │ │ ├── _runner.py │ │ ├── _variable.py │ │ ├── _yaml_reader.py │ │ └── optimize.yaml │ └── transiesta │ └── poisson │ ├── __init__.py │ └── fftpoisson_fix.py └── tools ├── _debug_info.py.conf ├── add_header.sh ├── build_tools ├── build_wheels.sh └── test_wheels.sh ├── changelog.py ├── codata.py ├── pep8.sh ├── runlint.bash └── tag.sh /.LICENSE_header: -------------------------------------------------------------------------------- 1 | This Source Code Form is subject to the terms of the Mozilla Public 2 | License, v. 2.0. If a copy of the MPL was not distributed with this 3 | file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | -------------------------------------------------------------------------------- /.binder/apt.txt: -------------------------------------------------------------------------------- 1 | gcc 2 | gfortran 3 | -------------------------------------------------------------------------------- /.binder/postBuild: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Stop at errors 4 | set -ex 5 | 6 | echo "### mybinder environment" 7 | env 8 | echo "### mybinder environment^^^" 9 | 10 | # Manually install the necessary stuff for sisl 11 | python3 -m pip install -vv tqdm matplotlib netCDF4 plotly . 12 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - benchmarks 3 | - data 4 | - developments 5 | 6 | codecov: 7 | notify: 8 | after_n_builds: 6 9 | 10 | coverage: 11 | status: 12 | project: 13 | default: 14 | target: auto 15 | base: auto 16 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Add here the commits that should be ignored 2 | # when issuing blames 3 | 0ff17210003a85b08f683307e9a73555142c8707 4 | -------------------------------------------------------------------------------- /.git_archival.txt: -------------------------------------------------------------------------------- 1 | node: 1899f26d79c72b14d28c3206c389851055b4be19 2 | node-date: 2025-06-04T15:02:32+02:00 3 | describe-name: v0.16.2-5-g1899f26d79 4 | ref-names: HEAD -> main 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | CITATION.cff export-subst 2 | pyproject.toml export-subst 3 | .git_archival.txt export-subst 4 | *.ipynb filter=strip-notebook-output 5 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: zerothi 2 | ko_fi: nickpapior 3 | custom: "paypal.me/npapior" 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/005_bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Let us know if something went wrong 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | 9 | **Code to reproduce problem** 10 | ```python 11 | 12 | ``` 13 | 14 | **Version details** 15 | Run the below code and add to bug-report: 16 | ```python 17 | import sisl._debug_info as sd 18 | sd.print_debug_info() 19 | ``` 20 | Additionally, if the bug occurred while processing a DFT code, please specify the exact version of the software and any input files that may be required to reproduce. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/010_feature.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Let us know if you miss a feature 4 | 5 | --- 6 | 7 | **Describe the feature** 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/015_contribute.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Contribute toolbox 3 | about: Workflow for specific use-cases 4 | 5 | --- 6 | 7 | **Describe what the toolbox script does** 8 | 9 | **Example case** 10 | 11 | **Make a pull-request referencing this issue** 12 | 13 | When contributing a toolbox you will automatically comply to the MPL-2.0 licence. 14 | 15 | Ensure that your code has the following information: 16 | - [ ] Name of developer 17 | - [ ] Which version of sisl it was originally developed and tested with 18 | - [ ] Document the use in the script 19 | - [ ] Ensure the script is Python 3 compliant 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/020_issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Issue 3 | about: Let us know if something is bothering you 4 | 5 | --- 6 | 7 | **Describe the issue** 8 | 9 | **Version details** 10 | Run the below code and add to issue (if an issue is relevant for the issue): 11 | ```python 12 | import sisl._debug_info as sd 13 | sd.print_debug_info() 14 | ``` 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/100_publication.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: I used sisl in a publication 3 | about: Add the publication to the documentation page of sisl 4 | 5 | --- 6 | 9 | 10 | - [ ] Author list 11 | - [ ] Publication title 12 | - [ ] Journal information 13 | - [ ] DOI 14 | 15 | 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Community support + discussions 4 | url: https://discord.gg/bvJ9Zuk 5 | about: "If you have basic user questions like *How do I create a Hamiltonian tight-binding model?*" 6 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | - [ ] Closes # 4 | - [ ] Added tests for new/changed functions? 5 | - [ ] Documentation for functionality in `docs/` 6 | - [ ] Changes documented in `changes/..rst` 7 | 8 | 19 | -------------------------------------------------------------------------------- /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | 8 | - package-ecosystem: "pip" 9 | directory: "/" 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | pull_request: 5 | branches: [ "main" ] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | analyze: 10 | name: Analyze 11 | if: ${{ github.actor != 'dependabot[bot]' }} 12 | runs-on: ubuntu-latest 13 | permissions: 14 | actions: read 15 | contents: read 16 | security-events: write 17 | 18 | strategy: 19 | fail-fast: false 20 | matrix: 21 | language: [ python ] 22 | 23 | steps: 24 | - name: Checkout 25 | uses: actions/checkout@v4 26 | 27 | - name: Initialize CodeQL 28 | uses: github/codeql-action/init@v3 29 | with: 30 | languages: ${{ matrix.language }} 31 | config-file: ./.github/workflows/codeql/config.yml 32 | 33 | - name: Autobuild 34 | uses: github/codeql-action/autobuild@v3 35 | 36 | - name: Perform CodeQL Analysis 37 | uses: github/codeql-action/analyze@v3 38 | with: 39 | category: "/language:${{ matrix.language }}" 40 | -------------------------------------------------------------------------------- /.github/workflows/codeql/config.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL configuration" 2 | 3 | queries: 4 | - uses: security-and-quality 5 | 6 | paths: 7 | - src 8 | -------------------------------------------------------------------------------- /.github/workflows/linter.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | - workflow_call 5 | 6 | jobs: 7 | lint: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v4 11 | - uses: psf/black@stable 12 | with: 13 | version: "~= 25.0" 14 | jupyter: true 15 | - uses: isort/isort-action@master 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | ci 3 | .coverage 4 | .*/ 5 | dist 6 | build* 7 | *.pyc 8 | *.so 9 | *.c 10 | __config__.py 11 | 12 | .*/ 13 | docs/build 14 | docs/**/generated/ 15 | docs/tutorials/**/*.{cube,xyz,fdf} 16 | */sisl.egg-info 17 | src/sisl/**/*.html 18 | src/sisl/_version.py 19 | src/sisl/_debug_info.py 20 | 21 | # OS generated files 22 | .DS_Store 23 | .DS_Store? 24 | Thumbs.db 25 | ehtumbs.db 26 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "files"] 2 | path = files 3 | url = https://github.com/zerothi/sisl-files.git 4 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | # Prevent git from showing duplicate names with commands like "git shortlog" 2 | # See the manpage of git-shortlog for details. 3 | # The syntax is: 4 | # Name that should be used Bad name 5 | # 6 | # You can skip Bad name if it is the same as the one that should be used, and is unique. 7 | # 8 | # This file is up-to-date if the command git log --format="%aN <%aE>" | sort -u 9 | # gives no duplicates. 10 | 11 | A.H. Kole 12 | Jonas Lundholm Bertelsen 13 | Jonas Lundholm Bertelsen Jonas L. B 14 | Jonas Lundholm Bertelsen Jonas Lundholm Bertelsen 15 | Nick Papior 16 | Nick Papior Nick Papior Andersen 17 | Nick Papior Nick R. Papior 18 | Pol Febrer Calabozo 19 | Pol Febrer Calabozo pfebrer <42074085+pfebrer@users.noreply.github.com> 20 | Pol Febrer Calabozo pfebrer96 <42074085+pfebrer96@users.noreply.github.com> 21 | Pol Febrer Calabozo Pol 22 | Pol Febrer Calabozo Pol Febrer 23 | Sofia Sanz Wuhl 24 | Sofia Sanz Wuhl Sofia Sanz 25 | Thomas Frederiksen 26 | -------------------------------------------------------------------------------- /.readthedocs-pre_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Pre-install commands for read-the-docs 4 | # 5 | set -euxo pipefail 6 | 7 | if [[ "${READTHEDOCS:-no}" == "no" ]]; then 8 | echo "This script is only intended to be run in the read-the-docs environment" 9 | exit 1 10 | fi 11 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | submodules: 4 | include: 5 | - files 6 | 7 | build: 8 | os: "ubuntu-lts-latest" 9 | apt_packages: 10 | - cmake 11 | - build-essential 12 | - gcc 13 | - gfortran 14 | - pandoc 15 | tools: 16 | python: "latest" 17 | jobs: 18 | pre_install: 19 | - ./.readthedocs-pre_install.sh 20 | 21 | sphinx: 22 | configuration: docs/conf.py 23 | fail_on_warning: false 24 | 25 | python: 26 | install: 27 | - method: pip 28 | path: . 29 | extra_requirements: 30 | - analysis 31 | - viz 32 | - test 33 | - docs 34 | 35 | formats: [] 36 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | version: 0.16.2 2 | commit: "v0.16.2" 3 | date-released: "2025-04-10" 4 | cff-version: 1.2.0 5 | message: "Please cite sisl in any paper to acknowledge and support development." 6 | type: software 7 | authors: 8 | - family-names: Papior 9 | given-names: Nick 10 | orcid: "https://orcid.org/0000-0003-3038-1855" 11 | alias: zerothi 12 | - family-names: Febrer Calabozo 13 | given-names: Pol 14 | orcid: "https://orcid.org/0000-0003-0904-2234" 15 | alias: pfebrer 16 | title: sisl 17 | identifiers: 18 | - description: "Collection DOI for any sisl version." 19 | type: doi 20 | value: 10.5281/zenodo.597181 21 | url: https://github.com/zerothi/sisl 22 | repository-code: https://github.com/zerothi/sisl 23 | license: MPL-2.0 24 | keywords: 25 | - physics 26 | - tight-binding 27 | - DFT 28 | - LCAO 29 | - NEGF 30 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include MANIFEST.in 2 | include LICENSE 3 | include README.md 4 | 5 | include pyproject.toml 6 | exclude DEPLOY.md 7 | 8 | prune .git 9 | prune .github 10 | prune benchmarks 11 | prune deprecated 12 | prune developments 13 | prune ci 14 | prune files 15 | prune build 16 | prune _skbuild 17 | 18 | # forcefully add this one, not really needed 19 | graft docs 20 | prune docs/build 21 | prune docs/**/generated 22 | graft src 23 | include src/sisl/_version.py 24 | include src/sisl/_debug_info.py 25 | include data 26 | 27 | prune __pycache__ 28 | 29 | # lastly, remove all these files 30 | global-exclude *.py[cod] __pycache__ *.so *.sh 31 | global-exclude *.html .git* CMakeLists.txt 32 | -------------------------------------------------------------------------------- /benchmarks/bloch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | # This benchmark creates a very large graphene flake and uses construct 7 | # to create it. 8 | 9 | # This benchmark may be called using: 10 | # 11 | # python $0 12 | # 13 | # and it may be post-processed using 14 | # 15 | # python stats.py $0.profile 16 | # 17 | from __future__ import annotations 18 | 19 | import cProfile 20 | import pstats 21 | import sys 22 | import time 23 | 24 | import numpy as np 25 | 26 | import sisl 27 | 28 | pr = cProfile.Profile() 29 | pr.disable() 30 | 31 | if len(sys.argv) > 1: 32 | N = int(sys.argv[1]) 33 | else: 34 | N = 1 35 | print(f"N = {N}") 36 | 37 | # Always fix the random seed to make each profiling concurrent 38 | np.random.seed(1234567890) 39 | 40 | gr = sisl.geom.graphene().tile(N, 0).tile(N, 1) 41 | H = sisl.Hamiltonian(gr) 42 | H.construct([(0.1, 1.44), (0.0, -2.7)], eta=True) 43 | H.finalize() 44 | bloch = sisl.Bloch((N, N, N)) 45 | 46 | pr.enable() 47 | t0 = time.time() 48 | while time.time() < t0 + 10: 49 | bloch(H.Hk, [0] * 3, format="array") 50 | pr.disable() 51 | pr.dump_stats(f"{sys.argv[0]}.profile") 52 | 53 | 54 | stat = pstats.Stats(pr) 55 | # We sort against total-time 56 | stat.sort_stats("tottime") 57 | # Only print the first 20% of the routines. 58 | stat.print_stats("sisl", 0.2) 59 | -------------------------------------------------------------------------------- /benchmarks/bz_parallel.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | # This benchmark creates a Hamiltonian and does eigenstate DOS + PDOS 7 | # calculations. 8 | 9 | # This benchmark may be called using: 10 | # 11 | # python -m cProfile -o $0.profile $0 12 | # 13 | # and it may be post-processed using 14 | # 15 | # python stats.py $0.profile 16 | # 17 | 18 | from __future__ import annotations 19 | 20 | import os 21 | import sys 22 | 23 | import numpy as np 24 | 25 | import sisl 26 | 27 | if len(sys.argv) > 1: 28 | N = int(sys.argv[1]) 29 | else: 30 | N = 10 31 | print(f"orbitals = {N*2}") 32 | if len(sys.argv) > 2: 33 | nk = int(sys.argv[2]) 34 | else: 35 | nk = 100 36 | print(f"nk = {nk}") 37 | 38 | # Always fix the random seed to make each profiling concurrent 39 | np.random.seed(1234567890) 40 | 41 | gr = sisl.geom.graphene() 42 | H = sisl.Hamiltonian(gr) 43 | H.construct([(0.1, 1.44), (0.0, -2.7)]) 44 | H.finalize() 45 | H = H.tile(N, 0) 46 | bz = sisl.MonkhorstPack(H, [nk, nk, 1], trs=False) 47 | 48 | nprocs = int(os.environ.get("SISL_NUM_PROCS", 1)) 49 | print(f"nprocs = {nprocs}") 50 | if nprocs > 1: 51 | par = bz.apply.renew(pool=nprocs) 52 | else: 53 | par = bz.apply.renew(eta=True) 54 | 55 | E = np.linspace(-2, 2, 200) 56 | 57 | 58 | def wrap_DOS(es): 59 | return es.DOS(E) 60 | 61 | 62 | dos = par.ndarray.eigenstate(wrap=wrap_DOS) 63 | # dos = par.average.eigenstate(wrap=wrap_DOS) 64 | -------------------------------------------------------------------------------- /benchmarks/graphene.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | # This benchmark creates a very large graphene flake and uses construct 7 | # to create it. 8 | 9 | # This benchmark may be called using: 10 | # 11 | # python $0 12 | # 13 | # and it may be post-processed using 14 | # 15 | # python stats.py $0.profile 16 | # 17 | from __future__ import annotations 18 | 19 | import cProfile 20 | import pstats 21 | import sys 22 | 23 | import numpy as np 24 | 25 | import sisl 26 | 27 | pr = cProfile.Profile() 28 | pr.disable() 29 | 30 | if len(sys.argv) > 1: 31 | N = int(sys.argv[1]) 32 | else: 33 | N = 200 34 | print(f"N = {N}") 35 | 36 | # Always fix the random seed to make each profiling concurrent 37 | np.random.seed(1234567890) 38 | 39 | gr = sisl.geom.graphene(orthogonal=True).tile(N, 0).tile(N, 1) 40 | H = sisl.Hamiltonian(gr) 41 | pr.enable() 42 | H.construct([(0.1, 1.44), (0.0, -2.7)], eta=True) 43 | H.finalize() 44 | pr.disable() 45 | pr.dump_stats(f"{sys.argv[0]}.profile") 46 | 47 | 48 | stat = pstats.Stats(pr) 49 | # We sort against total-time 50 | stat.sort_stats("tottime") 51 | # Only print the first 20% of the routines. 52 | stat.print_stats("sisl", 0.2) 53 | -------------------------------------------------------------------------------- /benchmarks/graphene_io.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | # This benchmark creates a very large graphene flake and uses construct 7 | # to create it. 8 | 9 | # This benchmark may be called using: 10 | # 11 | # python $0 12 | # 13 | # and it may be post-processed using 14 | # 15 | # python stats.py $0.profile 16 | # 17 | from __future__ import annotations 18 | 19 | import cProfile 20 | import pstats 21 | import sys 22 | 23 | import numpy as np 24 | 25 | import sisl 26 | 27 | pr = cProfile.Profile() 28 | pr.disable() 29 | 30 | if len(sys.argv) > 1: 31 | N = int(sys.argv[1]) 32 | else: 33 | N = 200 34 | print(f"N = {N}") 35 | 36 | # Always fix the random seed to make each profiling concurrent 37 | np.random.seed(1234567890) 38 | 39 | gr = sisl.geom.graphene(orthogonal=True) 40 | H = sisl.Hamiltonian(gr) 41 | H.construct([(0.1, 1.44), (0.0, -2.7)]) 42 | H = H.tile(N, 0).tile(N, 1) 43 | pr.enable() 44 | H.write("graphene_io.nc") 45 | H.write("graphene_io.nc") 46 | pr.disable() 47 | pr.dump_stats(f"{sys.argv[0]}.profile") 48 | 49 | 50 | stat = pstats.Stats(pr) 51 | # We sort against total-time 52 | stat.sort_stats("tottime") 53 | # Only print the first 20% of the routines. 54 | stat.print_stats("sisl", 0.2) 55 | -------------------------------------------------------------------------------- /benchmarks/graphene_repeat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | # This benchmark creates a very large graphene flake and uses construct 7 | # to create it. 8 | 9 | # This benchmark may be called using: 10 | # 11 | # python $0 12 | # 13 | # and it may be post-processed using 14 | # 15 | # python stats.py $0.profile 16 | # 17 | from __future__ import annotations 18 | 19 | import cProfile 20 | import pstats 21 | import sys 22 | 23 | import numpy as np 24 | 25 | import sisl 26 | 27 | pr = cProfile.Profile() 28 | pr.disable() 29 | 30 | if len(sys.argv) > 1: 31 | N = int(sys.argv[1]) 32 | else: 33 | N = 200 34 | print(f"N = {N}") 35 | 36 | # Always fix the random seed to make each profiling concurrent 37 | np.random.seed(1234567890) 38 | 39 | gr = sisl.geom.graphene(orthogonal=True) 40 | H = sisl.Hamiltonian(gr) 41 | H.construct([(0.1, 1.44), (0.0, -2.7)]) 42 | pr.enable() 43 | H.repeat(N, 0).repeat(N, 1) 44 | H.finalize() 45 | pr.disable() 46 | pr.dump_stats(f"{sys.argv[0]}.profile") 47 | 48 | 49 | stat = pstats.Stats(pr) 50 | # We sort against total-time 51 | stat.sort_stats("tottime") 52 | # Only print the first 20% of the routines. 53 | stat.print_stats("sisl", 0.2) 54 | -------------------------------------------------------------------------------- /benchmarks/graphene_tile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | # This benchmark creates a very large graphene flake and uses construct 7 | # to create it. 8 | 9 | # This benchmark may be called using: 10 | # 11 | # python $0 12 | # 13 | # and it may be post-processed using 14 | # 15 | # python stats.py $0.profile 16 | # 17 | from __future__ import annotations 18 | 19 | import cProfile 20 | import pstats 21 | import sys 22 | 23 | import numpy as np 24 | 25 | import sisl 26 | 27 | pr = cProfile.Profile() 28 | pr.disable() 29 | 30 | if len(sys.argv) > 1: 31 | N = int(sys.argv[1]) 32 | else: 33 | N = 200 34 | print(f"N = {N}") 35 | 36 | # Always fix the random seed to make each profiling concurrent 37 | np.random.seed(1234567890) 38 | 39 | gr = sisl.geom.graphene(orthogonal=True) 40 | H = sisl.Hamiltonian(gr) 41 | H.construct([(0.1, 1.44), (0.0, -2.7)]) 42 | pr.enable() 43 | H = H.tile(N, 0).tile(N, 1) 44 | H.finalize() 45 | pr.disable() 46 | pr.dump_stats(f"{sys.argv[0]}.profile") 47 | 48 | 49 | stat = pstats.Stats(pr) 50 | # We sort against total-time 51 | stat.sort_stats("tottime") 52 | # Only print the first 20% of the routines. 53 | stat.print_stats("sisl", 0.2) 54 | -------------------------------------------------------------------------------- /benchmarks/graphene_within.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | # This benchmark creates a very large graphene flake and uses construct 7 | # to create it. 8 | 9 | # This benchmark may be called using: 10 | # 11 | # python -m cProfile -o $0.profile $0 12 | # 13 | # and it may be post-processed using 14 | # 15 | # python stats.py $0.profile 16 | # 17 | 18 | from __future__ import annotations 19 | 20 | import sys 21 | 22 | import sisl 23 | 24 | method = "cube" 25 | if "cube" in sys.argv: 26 | method = "cube" 27 | sys.argv.remove("cube") 28 | elif "sphere" in sys.argv: 29 | method = "sphere" 30 | sys.argv.remove("sphere") 31 | 32 | if len(sys.argv) > 1: 33 | N = int(sys.argv[1]) 34 | else: 35 | N = 200 36 | print(f"N = {N}") 37 | 38 | gr = sisl.geom.graphene(orthogonal=True).tile(N, 0).tile(N, 1) 39 | H = sisl.Hamiltonian(gr) 40 | H.construct([(0.1, 1.44), (0.0, -2.7)], method=method, eta=True) 41 | H.finalize() 42 | -------------------------------------------------------------------------------- /benchmarks/lprofile3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | script=graphene.py 4 | if [ $# -gt 0 ]; then 5 | script=$1 6 | shift 7 | fi 8 | 9 | # Base name 10 | base=${script%.py} 11 | 12 | # Stats 13 | stats=$base.line_stats 14 | 15 | echo "script: $script $@" 16 | echo "saving stats to: $stats" 17 | 18 | kernprof -l $script $@ 19 | python3 -m line_profiler $script.lprof > $stats 20 | -------------------------------------------------------------------------------- /benchmarks/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | script=graphene.py 4 | if [ $# -gt 0 ]; then 5 | script=$1 6 | shift 7 | fi 8 | 9 | # Base name 10 | base=${script%.py} 11 | 12 | # Determine output profile 13 | profile=$base.profile 14 | 15 | # Stats 16 | stats=$base.stats 17 | 18 | python3 -m cProfile -o $profile $script $@ 19 | python3 stats.py $profile > $stats 20 | -------------------------------------------------------------------------------- /benchmarks/sparse_matrices.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | # This benchmark creates a very large graphene flake and uses construct 7 | # to create it. 8 | 9 | # This benchmark may be called using: 10 | # 11 | # python $0 12 | # 13 | # and it may be post-processed using 14 | # 15 | # python stats.py $0.profile 16 | # 17 | from __future__ import annotations 18 | 19 | import cProfile 20 | import pstats 21 | import sys 22 | 23 | import numpy as np 24 | 25 | import sisl 26 | 27 | pr = cProfile.Profile() 28 | pr.disable() 29 | 30 | randint = np.random.randint 31 | 32 | if len(sys.argv) > 1: 33 | N = int(sys.argv[1]) 34 | else: 35 | N = 200 36 | if len(sys.argv) > 2: 37 | frac = float(sys.argv[2]) 38 | else: 39 | frac = 0.2 40 | print(f"N = {N}") 41 | print(f"sparsity = {frac}") 42 | 43 | # Always fix the random seed to make each profiling concurrent 44 | np.random.seed(1234567890) 45 | 46 | pr.enable() 47 | n = int(N * frac) 48 | s = sisl.SparseCSR((N, N), dtype=np.int32) 49 | for i in range(N): 50 | dat = randint(0, N, n) 51 | s[i, dat] = 1 52 | pr.disable() 53 | pr.dump_stats(f"{sys.argv[0]}.profile") 54 | 55 | 56 | stat = pstats.Stats(pr) 57 | # We sort against total-time 58 | stat.sort_stats("tottime") 59 | # Only print the first 20% of the routines. 60 | stat.print_stats("sisl", 0.2) 61 | -------------------------------------------------------------------------------- /benchmarks/stats.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | from __future__ import annotations 7 | 8 | import pstats 9 | 10 | # Script for analysing profile scripts created by the 11 | # cProfile module. 12 | import sys 13 | 14 | if len(sys.argv) > 1: 15 | fname = sys.argv[1] 16 | else: 17 | raise ValueError("Must supply a profile file-name") 18 | 19 | stat = pstats.Stats(fname) 20 | 21 | # We sort against total-time 22 | stat.sort_stats("tottime") 23 | # Only print the first 20% of the routines. 24 | stat.print_stats("sisl", 0.2) 25 | -------------------------------------------------------------------------------- /changes/927.change.rst: -------------------------------------------------------------------------------- 1 | Change `trs` default in `MonkhorstPack` depending on spin 2 | 3 | Now for non-collinear or higher spin-configurations it defaults 4 | to ``trs=False``. 5 | -------------------------------------------------------------------------------- /changes/toolbox/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zerothi/sisl/1899f26d79c72b14d28c3206c389851055b4be19/changes/toolbox/.gitignore -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | 3 | .PHONY: default 4 | default: html 5 | 6 | # You can set these variables from the command line. 7 | SPHINXOPTS ?= 8 | SPHINXBUILD ?= sphinx-build 9 | SOURCEDIR = . 10 | BUILDDIR = build 11 | LINKCHECKDIR = $(BUILDDIR)/linkcheck 12 | 13 | # Put it first so that "make" without argument is like "make help". 14 | help: 15 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 16 | 17 | 18 | .PHONY: help Makefile 19 | 20 | # Catch-all target: route all unknown targets to Sphinx using the new 21 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 22 | %: Makefile 23 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 24 | 25 | 26 | .PHONY: spelling spell 27 | spell: spelling 28 | spelling: 29 | $(SPHINXBUILD) -b spelling "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 30 | 31 | 32 | .PHONY: checklinks linkcheck 33 | checklinks: linkcheck 34 | linkcheck: 35 | $(SPHINXBUILD) -b linkcheck "$(SOURCEDIR)" "$(LINKCHECKDIR)" $(SPHINXOPTS) $(O) 36 | @echo 37 | @echo "Check finished. Report is in $(LINKCHECKDIR)." 38 | -------------------------------------------------------------------------------- /docs/_static/css/custom_styles.css: -------------------------------------------------------------------------------- 1 | /*STYLES TO MAKE TABS MORE VISUAL*/ 2 | 3 | /*The parent container of tabs*/ 4 | .tab-set { 5 | border: 1px solid #ccc 6 | } 7 | 8 | /*Individual box of each tab*/ 9 | .tab-set > label { 10 | margin-bottom: 0 11 | } 12 | 13 | /*Container appearing below the tabs, with the contents of the active tab*/ 14 | .tab-content { 15 | background-color: aliceblue; 16 | padding: 20px 17 | } 18 | 19 | /*Initial paragraph of the content. By default there's a top margin 20 | but we already specify a padding of 20 px for the content no matter what the 21 | first child is.*/ 22 | .tab-content > p:first-child { 23 | margin-top: 0 24 | } 25 | -------------------------------------------------------------------------------- /docs/_static/visualization/plotly/basic-tutorials/GUIScreenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zerothi/sisl/1899f26d79c72b14d28c3206c389851055b4be19/docs/_static/visualization/plotly/basic-tutorials/GUIScreenshot.png -------------------------------------------------------------------------------- /docs/_templates/autosummary/function.rst: -------------------------------------------------------------------------------- 1 | {{ objname }} 2 | {{ underline }} 3 | 4 | .. currentmodule:: {{ module }} 5 | 6 | .. auto{{ objtype }}:: {{ objname }} 7 | -------------------------------------------------------------------------------- /docs/_templates/autosummary/module.rst: -------------------------------------------------------------------------------- 1 | .. automodule:: {{ fullname }} 2 | :no-members: 3 | :no-undoc-members: 4 | :no-inherited-members: 5 | -------------------------------------------------------------------------------- /docs/api/geom/index.rst: -------------------------------------------------------------------------------- 1 | .. _geom: 2 | 3 | ******************************* 4 | Geometry handling (`sisl.geom`) 5 | ******************************* 6 | 7 | .. module:: sisl.geom 8 | 9 | The `~sisl.Geometry` class is the workhorse of basically 10 | all computational details of large parts of `sisl`. 11 | It defines atomic species, coordinates, associated orbitals 12 | and much more. Therefore an extended suite of tools and methods 13 | are available to handle this complex object. 14 | 15 | 16 | .. toctree:: 17 | :maxdepth: 2 18 | 19 | building 20 | 21 | .. toctree:: 22 | :maxdepth: 1 23 | 24 | neighbors 25 | indexing 26 | -------------------------------------------------------------------------------- /docs/api/geom/indexing.rst: -------------------------------------------------------------------------------- 1 | .. _geom-indexing: 2 | 3 | Indexing atoms 4 | =================== 5 | 6 | .. currentmodule:: sisl.geom 7 | 8 | There are *many* methods in `sisl` that will do stuff based no atomic indices. 9 | Generally one can index subsets of atoms via direct indices, but sometimes 10 | it can be beneficial to index atoms based on other things, such as: 11 | 12 | - species name 13 | - odd/even indices 14 | - specific coordinates 15 | 16 | To accommodate more powerful indices one can use the below class constructs 17 | to select atoms based on particular things: 18 | 19 | .. autosummary:: 20 | :toctree: generated/ 21 | 22 | AtomCategory 23 | AtomFracSite 24 | AtomXYZ 25 | AtomZ 26 | AtomIndex 27 | AtomSeq 28 | AtomTag 29 | AtomOdd 30 | AtomEven 31 | AtomNeighbors 32 | NullCategory 33 | -------------------------------------------------------------------------------- /docs/api/index.rst: -------------------------------------------------------------------------------- 1 | .. _api: 2 | 3 | ################# 4 | API reference 5 | ################# 6 | 7 | :Release: |version| 8 | :Date: |today| 9 | 10 | 11 | .. currentmodule:: sisl 12 | 13 | This reference manual describes in detail how the modules, classes 14 | and functions can be used and how their API's are defined. 15 | 16 | These documents are complemented with the sisl tutorial. 17 | 18 | All methods and submodules are listed :ref:`here ` and 19 | :ref:`here `, respectively. 20 | 21 | .. toctree:: 22 | :maxdepth: 2 23 | 24 | basic 25 | 26 | .. toctree:: 27 | :maxdepth: 3 28 | 29 | geom/index 30 | 31 | .. toctree:: 32 | :maxdepth: 2 33 | 34 | physics 35 | mixing 36 | viz/index 37 | unit_constant 38 | utilities 39 | 40 | .. toctree:: 41 | :maxdepth: 1 42 | 43 | core 44 | io/index 45 | typing 46 | -------------------------------------------------------------------------------- /docs/api/io/basic.rst: -------------------------------------------------------------------------------- 1 | .. _io.basic: 2 | 3 | .. currentmodule:: sisl.io 4 | 5 | Basic IO methods/classes 6 | ======================== 7 | 8 | Regular users may only need `get_sile` which retrieves the correct *sile* 9 | based on parsing the filename. 10 | 11 | 12 | Retrieval methods and warnings 13 | ------------------------------ 14 | 15 | .. autosummary:: 16 | :toctree: generated/ 17 | 18 | get_sile 19 | add_sile - add a file to the list of files that sisl can interact with 20 | get_siles 21 | get_sile_class 22 | SileError - sisl specific error 23 | SileWarning - sisl specific warning 24 | SileInfo - sisl specific information 25 | 26 | 27 | Base classes 28 | ------------ 29 | 30 | All `sisl` files inherit from the `BaseSile` class. 31 | While ASCII files are based on the `Sile` class, NetCDF files are based on the 32 | `SileCDF` and finally binary files inherit from `SileBin`. 33 | 34 | .. autosummary:: 35 | :toctree: generated/ 36 | 37 | BaseSile - all siles inherit this one 38 | Sile - sisl specific error 39 | SileCDF 40 | SileBin 41 | -------------------------------------------------------------------------------- /docs/api/io/bigdft-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.io.bigdft 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | SileBigDFT 9 | SileBinBigDFT 10 | -------------------------------------------------------------------------------- /docs/api/io/bigdft.rst: -------------------------------------------------------------------------------- 1 | .. _io.bigdft: 2 | 3 | .. module:: sisl.io.bigdft 4 | 5 | BigDFT 6 | ====== 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | asciiSileBigDFT 12 | -------------------------------------------------------------------------------- /docs/api/io/dftb-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.io.dftb 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | SileDFTB 9 | SileBinDFTB 10 | -------------------------------------------------------------------------------- /docs/api/io/dftb.rst: -------------------------------------------------------------------------------- 1 | .. _io.dftb: 2 | 3 | DFTB+ 4 | ===== 5 | 6 | .. module:: sisl.io.dftb 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | overrealSileDFTB - overlap matrix file 12 | hamrealSileDFTB - Hamiltonian matrix file 13 | -------------------------------------------------------------------------------- /docs/api/io/fhiaims-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.io.fhiaims 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | SileFHIaims 9 | SileBinFHIaims 10 | -------------------------------------------------------------------------------- /docs/api/io/fhiaims.rst: -------------------------------------------------------------------------------- 1 | .. _io.fhiaims: 2 | 3 | .. module:: sisl.io.fhiaims 4 | 5 | FHIaims 6 | ======= 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | inSileFHIaims 12 | -------------------------------------------------------------------------------- /docs/api/io/generic.rst: -------------------------------------------------------------------------------- 1 | .. _io.generic: 2 | 3 | Generic files 4 | ============= 5 | 6 | .. currentmodule:: sisl.io 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | tableSile 12 | xyzSile 13 | pdbSile 14 | cubeSile 15 | moldenSile 16 | xsfSile 17 | -------------------------------------------------------------------------------- /docs/api/io/gulp-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.io.gulp 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | SileGULP 9 | SileBinGULP 10 | -------------------------------------------------------------------------------- /docs/api/io/gulp.rst: -------------------------------------------------------------------------------- 1 | .. _io.gulp: 2 | 3 | GULP 4 | ==== 5 | 6 | .. module:: sisl.io.gulp 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | gotSileGULP - the output from GULP 12 | fcSileGULP - force constant output from GULP 13 | -------------------------------------------------------------------------------- /docs/api/io/openmx-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.io.openmx 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | SileOpenMX 9 | SileCDFOpenMX 10 | SileBinOpenMX 11 | -------------------------------------------------------------------------------- /docs/api/io/openmx.rst: -------------------------------------------------------------------------------- 1 | .. _io.openmx: 2 | 3 | OpenMX 4 | ====== 5 | 6 | .. module:: sisl.io.openmx 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | omxSileOpenMX - input file 12 | mdSileOpenMX - moleculer dynamics file 13 | -------------------------------------------------------------------------------- /docs/api/io/orca-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.io.orca 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | SileORCA 9 | SileBinORCA 10 | -------------------------------------------------------------------------------- /docs/api/io/orca.rst: -------------------------------------------------------------------------------- 1 | .. _io.orca: 2 | 3 | ORCA 4 | ==== 5 | 6 | .. module:: sisl.io.orca 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | stdoutSileORCA - standard output file 12 | txtSileORCA - property.txt output file 13 | -------------------------------------------------------------------------------- /docs/api/io/scaleup-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.io.scaleup 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | SileScaleUp 9 | SileBinScaleUp 10 | -------------------------------------------------------------------------------- /docs/api/io/scaleup.rst: -------------------------------------------------------------------------------- 1 | .. _io.scaleup: 2 | 3 | .. module:: sisl.io.scaleup 4 | 5 | ScaleUP 6 | ======= 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | orboccSileScaleUp - orbital information 12 | refSileScaleUp - reference coordinates 13 | rhamSileScaleUp - Hamiltonian file 14 | -------------------------------------------------------------------------------- /docs/api/io/siesta-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.io.siesta 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | SileSiesta 9 | SileCDFSiesta 10 | SileBinSiesta 11 | -------------------------------------------------------------------------------- /docs/api/io/siesta.rst: -------------------------------------------------------------------------------- 1 | .. _io.siesta: 2 | 3 | Siesta 4 | ====== 5 | 6 | .. module:: sisl.io.siesta 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | aniSileSiesta - ANI file 12 | fdfSileSiesta - input file 13 | stdoutSileSiesta - output file 14 | xvSileSiesta - xyz and vxyz file 15 | bandsSileSiesta - band structure information 16 | eigSileSiesta - EIG file 17 | pdosSileSiesta - PDOS file 18 | gridSileSiesta - Grid charge information (binary) 19 | gridncSileSiesta - NetCDF grid output files (netcdf) 20 | onlysSileSiesta - Overlap matrix information 21 | dmSileSiesta - density matrix information 22 | hsxSileSiesta - Hamiltonian and overlap matrix information 23 | wfsxSileSiesta - wavefunctions 24 | ncSileSiesta - NetCDF output file 25 | ionxmlSileSiesta - Basis-information from the ion.xml files 26 | ionncSileSiesta - Basis-information from the ion.nc files 27 | orbindxSileSiesta - Basis set information (no geometry information) 28 | faSileSiesta - Forces on atoms 29 | fcSileSiesta - Force constant matrix 30 | kpSileSiesta - k-points from simulation 31 | rkpSileSiesta - k-points to simulation 32 | structSileSiesta - geometry in STRUCT_* files 33 | timesSileSiesta - timings from siesta 34 | 35 | 36 | TranSiesta 37 | ========== 38 | 39 | .. autosummary:: 40 | :toctree: generated/ 41 | 42 | tshsSileSiesta - TranSiesta Hamiltonian 43 | tsdeSileSiesta - TranSiesta (energy) density matrix 44 | tsgfSileSiesta - TranSiesta surface Green function files 45 | tsvncSileSiesta - TranSiesta specific Hartree potential file 46 | -------------------------------------------------------------------------------- /docs/api/io/tbtrans-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.io.tbtrans 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | SileTBtrans 9 | SileCDFTBtrans 10 | SileBinTBtrans 11 | -------------------------------------------------------------------------------- /docs/api/io/tbtrans.rst: -------------------------------------------------------------------------------- 1 | .. _io.tbtrans: 2 | 3 | TBtrans 4 | ======= 5 | 6 | .. module:: sisl.io.tbtrans 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | tbtncSileTBtrans 12 | deltancSileTBtrans 13 | tbtgfSileTBtrans - TBtrans surface Green function files 14 | tbtsencSileTBtrans 15 | tbtavncSileTBtrans 16 | tbtprojncSileTBtrans 17 | 18 | 19 | PHtrans 20 | ======= 21 | 22 | `TBtrans`_ is per default a ballistic electron transport utility. It may also 23 | be compiled in a ballistic phonon transport mode, named ``PHtrans``. 24 | 25 | .. autosummary:: 26 | :toctree: generated/ 27 | 28 | phtncSilePHtrans 29 | phtsencSilePHtrans 30 | phtavncSilePHtrans 31 | phtprojncSilePHtrans 32 | -------------------------------------------------------------------------------- /docs/api/io/vasp-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.io.vasp 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | SileVASP 9 | SileBinVASP 10 | -------------------------------------------------------------------------------- /docs/api/io/vasp.rst: -------------------------------------------------------------------------------- 1 | .. _io.vasp: 2 | 3 | VASP 4 | ==== 5 | 6 | .. module:: sisl.io.vasp 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | carSileVASP 12 | doscarSileVASP 13 | eigenvalSileVASP 14 | chgSileVASP 15 | locpotSileVASP 16 | outcarSileVASP 17 | -------------------------------------------------------------------------------- /docs/api/io/wannier90-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.io.wannier90 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | SileWannier90 9 | SileBinWannier90 10 | -------------------------------------------------------------------------------- /docs/api/io/wannier90.rst: -------------------------------------------------------------------------------- 1 | .. _io.wannier90: 2 | 3 | Wannier90 4 | ========= 5 | 6 | .. module:: sisl.io.wannier90 7 | 8 | .. autosummary:: 9 | :toctree: generated/ 10 | 11 | winSileWannier90 - input file 12 | tbSileWannier90 - Hamiltonian and Position operator information 13 | hrSileWannier90 - Hamiltonian information 14 | centresSileWannier90 - Wannier charge center information 15 | -------------------------------------------------------------------------------- /docs/api/mixing.rst: -------------------------------------------------------------------------------- 1 | .. _mixing: 2 | 3 | Mixing (`sisl.mixing`) 4 | ================================= 5 | 6 | .. module:: sisl.mixing 7 | 8 | Mixing various quantities in self-consistent manners are quite frequent. 9 | This module enables a variety of methods based on the Pulay (DIIS) mixing 10 | methods and may be used for externally driven SC cycles. 11 | 12 | Container classes 13 | ----------------- 14 | 15 | Mixing makes use of so called *metrics* and several steps of quantities 16 | stored in *history*. 17 | 18 | The basic classes that are used internally are 19 | 20 | .. autosummary:: 21 | :toctree: generated/ 22 | 23 | History 24 | BaseMixer 25 | BaseWeightMixer 26 | BaseHistoryWeightMixer 27 | StepMixer 28 | 29 | 30 | Mixing algorithms 31 | ----------------- 32 | 33 | .. autosummary:: 34 | :toctree: generated/ 35 | 36 | LinearMixer 37 | AndersonMixer 38 | DIISMixer 39 | PulayMixer 40 | AdaptiveDIISMixer 41 | AdaptivePulayMixer 42 | -------------------------------------------------------------------------------- /docs/api/physics.distribution.rst: -------------------------------------------------------------------------------- 1 | .. _physics.distribution: 2 | 3 | Distribution functions 4 | ====================== 5 | 6 | .. currentmodule:: sisl.physics 7 | 8 | Various distributions using different smearing techniques. 9 | 10 | .. autosummary:: 11 | :toctree: generated/ 12 | 13 | get_distribution 14 | gaussian 15 | lorentzian 16 | fermi_dirac 17 | bose_einstein 18 | cold 19 | step_function 20 | heaviside 21 | -------------------------------------------------------------------------------- /docs/api/physics.electron-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.physics.electron 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | _electron_State 9 | -------------------------------------------------------------------------------- /docs/api/physics.electron.rst: -------------------------------------------------------------------------------- 1 | .. _physics.electron: 2 | 3 | Electron related functions 4 | ========================== 5 | 6 | .. module:: sisl.physics.electron 7 | 8 | In sisl electronic structure calculations are relying on routines 9 | specific for electrons. For instance density of states calculations from 10 | electronic eigenvalues and other quantities. 11 | 12 | This module implements the necessary tools required for calculating 13 | DOS, PDOS, band-velocities and spin moments of non-colinear calculations. 14 | One may also plot real-space wavefunctions. 15 | 16 | .. autosummary:: 17 | :toctree: generated/ 18 | 19 | DOS 20 | PDOS 21 | COP 22 | berry_phase 23 | ahc 24 | shc 25 | conductivity 26 | wavefunction 27 | spin_moment 28 | spin_contamination 29 | 30 | 31 | Supporting classes 32 | ------------------ 33 | 34 | Certain classes aid in the usage of the above methods by implementing them 35 | using automatic arguments. 36 | 37 | For instance, the PDOS method requires the overlap matrix in non-orthogonal 38 | basis sets at the :math:`k`-point corresponding to the eigenstates. Hence, the 39 | argument ``S`` must be :math:`\mathbf S(\mathbf k)`. The `EigenstateElectron` class 40 | automatically passes the correct ``S`` because it knows the states :math:`k`-point. 41 | 42 | .. autosummary:: 43 | :toctree: generated/ 44 | 45 | CoefficientElectron 46 | StateElectron 47 | StateCElectron 48 | EigenvalueElectron 49 | EigenvectorElectron 50 | EigenstateElectron 51 | -------------------------------------------------------------------------------- /docs/api/physics.matrix-hidden.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. currentmodule:: sisl.physics 4 | 5 | .. autosummary:: 6 | :toctree: generated/ 7 | 8 | densitymatrix._densitymatrix 9 | -------------------------------------------------------------------------------- /docs/api/physics.matrix.rst: -------------------------------------------------------------------------------- 1 | .. _physics.matrix: 2 | 3 | Physical quantites 4 | ================== 5 | 6 | .. currentmodule:: sisl.physics 7 | 8 | Physical quantities such as Hamiltonian and density matrices are representated 9 | through specific classes enabling various handlings. 10 | 11 | 12 | Spin 13 | ---- 14 | 15 | .. autosummary:: 16 | :toctree: generated/ 17 | 18 | Spin 19 | 20 | Matrices 21 | -------- 22 | 23 | .. autosummary:: 24 | :toctree: generated/ 25 | 26 | EnergyDensityMatrix 27 | DensityMatrix 28 | Hamiltonian 29 | DynamicalMatrix 30 | Overlap 31 | 32 | 33 | Self energies 34 | ------------- 35 | 36 | Self-energies are specific physical quantities that enables integrating 37 | out semi-infinite regions. 38 | 39 | .. autosummary:: 40 | :toctree: generated/ 41 | 42 | SelfEnergy 43 | WideBandSE 44 | SemiInfinite 45 | RecursiveSI 46 | RealSpaceSE 47 | RealSpaceSI 48 | 49 | 50 | Bloch's theorem 51 | --------------- 52 | 53 | Bloch's theorem is a very powerful procedure that enables one to utilize 54 | the periodicity of a given direction to describe the complete system. 55 | 56 | .. autosummary:: 57 | :toctree: generated/ 58 | 59 | Bloch 60 | -------------------------------------------------------------------------------- /docs/api/physics.phonon.rst: -------------------------------------------------------------------------------- 1 | .. _physics.phonon: 2 | 3 | Phonon related functions 4 | ========================== 5 | 6 | .. module:: sisl.physics.phonon 7 | 8 | In sisl phonon calculations are relying on routines 9 | specific for phonons. For instance density of states calculations from 10 | phonon eigenvalues and other quantities. 11 | 12 | This module implements the necessary tools required for calculating 13 | DOS, PDOS, group-velocities and real-space displacements. 14 | 15 | .. autosummary:: 16 | :toctree: generated/ 17 | 18 | DOS 19 | PDOS 20 | 21 | 22 | Supporting classes 23 | ------------------ 24 | 25 | Certain classes aid in the usage of the above methods by implementing them 26 | using automatic arguments. 27 | 28 | .. autosummary:: 29 | :toctree: generated/ 30 | 31 | CoefficientPhonon 32 | ModePhonon 33 | ModeCPhonon 34 | EigenvaluePhonon 35 | EigenvectorPhonon 36 | EigenmodePhonon 37 | -------------------------------------------------------------------------------- /docs/api/physics.rst: -------------------------------------------------------------------------------- 1 | .. _physics: 2 | 3 | ********************************* 4 | Physical objects (`sisl.physics`) 5 | ********************************* 6 | 7 | .. module:: sisl.physics 8 | 9 | Implementations of various DFT and tight-binding related quantities 10 | are defined. The implementations range from simple Brillouin zone 11 | perspectives to self-energy calculations from Hamiltonians. 12 | 13 | In `sisl` the general usage of physical matrices are considering sparse 14 | matrices. Hence Hamiltonians, density matrices, etc. are considered 15 | sparse. There are exceptions, but it is generally advisable to have this in mind. 16 | 17 | 18 | .. toctree:: 19 | :maxdepth: 2 20 | 21 | physics.brillouinzone 22 | physics.matrix 23 | physics.electron 24 | physics.phonon 25 | 26 | .. toctree:: 27 | :maxdepth: 1 28 | 29 | physics.distribution 30 | 31 | 32 | Low level objects 33 | ================= 34 | 35 | The low level objects are the driving objects for some of the physical 36 | objects found here. They are rarely (if ever) required to be used, but they 37 | may be important for developers wishing to extend the functionality of `sisl` 38 | using generic class-structures. For instance the `Hamiltonian` inherits the 39 | `SparseOrbitalBZSpin` class and `EigenvalueElectron` inherits from `Coefficient`. 40 | 41 | States 42 | ------ 43 | 44 | .. autosummary:: 45 | :toctree: generated/ 46 | 47 | degenerate_decouple 48 | Coefficient 49 | State 50 | StateC 51 | 52 | 53 | Sparse matrices 54 | --------------- 55 | 56 | .. autosummary:: 57 | :toctree: generated/ 58 | 59 | SparseOrbitalBZ 60 | SparseOrbitalBZSpin 61 | -------------------------------------------------------------------------------- /docs/api/typing.rst: -------------------------------------------------------------------------------- 1 | .. _typing: 2 | 3 | Typing (`sisl.typing`) 4 | ====================== 5 | 6 | .. module:: sisl.typing 7 | 8 | sisl will use `typing `__ 9 | to enable static analyzers and to aid users when reading documentation. 10 | 11 | The typing types are shown below: 12 | 13 | .. autosummary:: 14 | :toctree: generated/ 15 | 16 | AxisIntLiteral 17 | CellAxisStrLiteral 18 | CellAxisLiteral 19 | CartesianAxisStrLiteral 20 | CartesianAxisLiteral 21 | CellAxis 22 | CellAxes 23 | CartesianAxis 24 | CartesianAxes 25 | AnyAxis 26 | AnyAxes 27 | 28 | .. autosummary:: 29 | :toctree: generated/ 30 | 31 | SimpleIndex 32 | AtomsIndex 33 | OrbitalsIndex 34 | 35 | .. autosummary:: 36 | :toctree: generated/ 37 | 38 | AtomLike 39 | AtomsLike 40 | CellLike 41 | Coord 42 | CoordOrScalar 43 | FuncType 44 | GaugeType 45 | GeometryLike 46 | GridLike 47 | KPoint 48 | LatticeLike 49 | LatticeOrGeometry 50 | LatticeOrGeometryLike 51 | ProjectionTypeMatrix 52 | ProjectionTypeTrace 53 | ProjectionTypeDiag 54 | ProjectionTypeHadamard 55 | ProjectionTypeHadamardAtoms 56 | ProjectionType 57 | DistributionStr 58 | DistributionFunc 59 | DistributionType 60 | SileLike 61 | SparseMatrix 62 | SparseMatrixExt 63 | SparseMatrixGeometry 64 | SparseMatrixPhysical 65 | SpinType 66 | UnitsVar 67 | 68 | .. autosummary:: 69 | :toctree: generated/ 70 | 71 | SeqBool 72 | SeqOrScalarBool 73 | SeqInt 74 | SeqOrScalarInt 75 | SeqFloat 76 | SeqOrScalarFloat 77 | -------------------------------------------------------------------------------- /docs/api/unit_constant.constant.rst: -------------------------------------------------------------------------------- 1 | 2 | Constants 3 | ========= 4 | 5 | .. currentmodule:: sisl.constant 6 | 7 | 8 | A pre-set set of physical constants. The SI units are following the *new* convention 9 | that takes effect on 20 May 2019. 10 | 11 | The currently stored constants are (all are given in SI units): 12 | 13 | .. autosummary:: 14 | :toctree: generated/ 15 | 16 | PhysicalConstant 17 | q 18 | c 19 | h 20 | hbar 21 | m_e 22 | m_p 23 | G0 24 | G 25 | 26 | All constants may be used like an ordinary float (which converts it to a float): 27 | 28 | >>> c 29 | 299792458.0 m/s 30 | >>> c * 2 31 | 599584916 32 | 33 | while one can just as easily convert the units (which ensures thay stay like another `PhysicalConstant`): 34 | 35 | >>> c('Ang/ps') 36 | 2997924.58 Ang/ps 37 | -------------------------------------------------------------------------------- /docs/api/unit_constant.rst: -------------------------------------------------------------------------------- 1 | .. _unit_constant: 2 | 3 | ******************* 4 | Units and constants 5 | ******************* 6 | 7 | .. currentmodule:: sisl 8 | 9 | In `sisl` values are forced to be in the following units: 10 | 11 | ====== ==== 12 | Type Unit 13 | ====== ==== 14 | Length Ang 15 | Energy eV 16 | Time ps 17 | ====== ==== 18 | 19 | More units will be added as they enter the code. 20 | For this `sisl` requires methods to convert between different units and also 21 | the handling of physical constants. 22 | 23 | .. toctree:: 24 | :maxdepth: 2 25 | 26 | unit_constant.unit 27 | unit_constant.constant 28 | -------------------------------------------------------------------------------- /docs/api/utilities.misc.rst: -------------------------------------------------------------------------------- 1 | .. _utilities.misc: 2 | 3 | Several utility functions are used throughout sisl. 4 | 5 | Range routines 6 | ============== 7 | 8 | .. currentmodule:: sisl.utils 9 | 10 | .. autosummary:: 11 | :toctree: generated/ 12 | 13 | strmap 14 | strseq 15 | lstranges 16 | erange 17 | list2str 18 | fileindex 19 | 20 | 21 | Miscellaneous routines 22 | ====================== 23 | 24 | .. autosummary:: 25 | :toctree: generated/ 26 | 27 | str_spec 28 | direction - abc/012 -> 012 29 | listify 30 | angle - radian to degree 31 | iter_shape 32 | math_eval 33 | batched_indices 34 | -------------------------------------------------------------------------------- /docs/api/utilities.rst: -------------------------------------------------------------------------------- 1 | .. .. _utilities: 2 | 3 | ************************ 4 | Utilities (`sisl.utils`) 5 | ************************ 6 | 7 | .. module:: sisl.utils 8 | 9 | Various helper classes and functions that make using `sisl` easier. 10 | 11 | 12 | .. toctree:: 13 | :maxdepth: 2 14 | 15 | utilities.shape 16 | utilities.misc 17 | -------------------------------------------------------------------------------- /docs/api/utilities.shape.rst: -------------------------------------------------------------------------------- 1 | .. _shapes: 2 | 3 | Shapes 4 | ====== 5 | 6 | .. module:: sisl.shape 7 | 8 | Shapes are geometric objects that enables one to locate positions in- or 9 | out-side a given shape. 10 | 11 | Shapes are constructed from basic geometric shapes, such as cubes, ellipsoids 12 | and spheres, and they enable any _set_ operation on them, 13 | intersection (``A & B``), union (``A | B``), disjunction (``A ^ B``) 14 | or complementary (``A - B``). 15 | 16 | All shapes in sisl allows one to perform arithmetic on them. 17 | I.e. one may *add* two shapes to accomblish what would be equivalent 18 | to an ``&`` operation. The resulting shape will be a `CompositeShape` which 19 | implements the necessary routines to ensure correct operation. 20 | 21 | 22 | .. autosummary:: 23 | :toctree: generated/ 24 | 25 | Shape - base class 26 | Cuboid - 3d cube 27 | Cube - 3d box 28 | Ellipsoid 29 | Sphere 30 | EllipticalCylinder 31 | NullShape 32 | -------------------------------------------------------------------------------- /docs/api/viz/index.rst: -------------------------------------------------------------------------------- 1 | .. _viz: 2 | 3 | ============= 4 | Visualization 5 | ============= 6 | 7 | .. module:: sisl.viz 8 | 9 | The visualization module contains tools to plot common visualizations, as well 10 | as to create custom visualizations that support multiple plotting backends 11 | automatically. 12 | 13 | Plot classes 14 | ----------------- 15 | 16 | Plot classes are workflow classes that implement some specific plotting. 17 | 18 | .. autosummary:: 19 | :toctree: generated/ 20 | 21 | Plot 22 | BandsPlot 23 | FatbandsPlot 24 | GeometryPlot 25 | SitesPlot 26 | GridPlot 27 | WavefunctionPlot 28 | PdosPlot 29 | AtomicMatrixPlot 30 | 31 | Utilities 32 | --------- 33 | 34 | Utilities to build custom plots 35 | 36 | .. autosummary:: 37 | :toctree: generated/ 38 | 39 | get_figure 40 | merge_plots 41 | subplots 42 | animation 43 | Figure 44 | -------------------------------------------------------------------------------- /docs/build_docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _clean=0 4 | 5 | while [[ $# -gt 0 ]]; do 6 | 7 | case $1 in 8 | clean) 9 | _clean=1 10 | ;; 11 | esac 12 | shift 13 | 14 | done 15 | 16 | echo 17 | which python 18 | which python3 19 | which sphinx-build 20 | echo 21 | 22 | if [ -n "$PYTHONUSERBASE" ]; then 23 | v=$(python3 -c "from sys import version_info as v ; print(f'{v[0]}.{v[1]}', end='')") 24 | export PYTHONPATH=$PYTHONUSERBASE/lib/python${v}/site-packages:$PYTHONPATH 25 | fi 26 | 27 | # No threading 28 | export OMP_NUM_THREADS=1 29 | 30 | if [ -z "$SISL_NUM_PROCS" ]; then 31 | # Ensure single-core 32 | export SISL_NUM_PROCS=1 33 | fi 34 | 35 | if [ $_clean -eq 1 ]; then 36 | echo "cleaning build **/generated" 37 | rm -rf build **/generated 38 | echo 39 | fi 40 | 41 | # Now ensure everything is ready... 42 | make html 43 | retval=$? 44 | 45 | # If succeeded, we may overwrite the old 46 | # documentation (if it exists) 47 | if [ $retval -eq 0 ]; then 48 | echo "Success = $retval" 49 | else 50 | echo "Failure = $retval" 51 | fi 52 | -------------------------------------------------------------------------------- /docs/changelog/index.rst: -------------------------------------------------------------------------------- 1 | .. toctree:: 2 | :maxdepth: 1 3 | 4 | v0.15.2 5 | v0.15.1 6 | v0.15.0 7 | v0.14.3 8 | v0.14.2 9 | v0.14.0 10 | v0.13.0 11 | v0.12.2 12 | v0.12.1 13 | v0.12.0 14 | v0.11.0 15 | v0.10.0 16 | v0.9.8 17 | v0.9.7 18 | v0.9.6 19 | v0.9.5 20 | v0.9.4 21 | v0.9.3 22 | v0.9.2 23 | v0.9.1 24 | v0.9.0 25 | v0.8.5 26 | v0.8.4 27 | v0.8.3 28 | v0.8.2 29 | v0.8.1 30 | v0.8.0 31 | -------------------------------------------------------------------------------- /docs/changelog/v0.12.1.rst: -------------------------------------------------------------------------------- 1 | ****** 2 | 0.12.1 3 | ****** 4 | 5 | Released 10 of February 2022. 6 | 7 | 8 | Contributors 9 | ============ 10 | 11 | A total of 2 people contributed to this release. People with a "+" by their 12 | names contributed a patch for the first time. 13 | 14 | * Nick Papior 15 | * Pol Febrer 16 | 17 | Pull requests merged 18 | ==================== 19 | 20 | A total of 0 pull requests were merged for this release. 21 | 22 | 23 | Added 24 | ^^^^^^ 25 | * return spin moment from SCF output files of Siesta 26 | * read_fermi_level to siesta.PDOS files 27 | 28 | Fixed 29 | ^^^^^^ 30 | * MacOS builds 31 | * `sdata` handling of siesta.PDOS* files, much more versatily now 32 | * masking import of xarray 33 | * Fixes to sisl.viz module related to 3.10 and other details 34 | -------------------------------------------------------------------------------- /docs/changelog/v0.14.2.rst: -------------------------------------------------------------------------------- 1 | ****** 2 | 0.14.2 3 | ****** 4 | 5 | Released 4 of October 2023. 6 | 7 | 8 | Contributors 9 | ============ 10 | 11 | A total of 2 people contributed to this release. People with a "+" by their 12 | names contributed a patch for the first time. 13 | 14 | * Nick Papior 15 | * Pol Febrer 16 | 17 | Pull requests merged 18 | ==================== 19 | 20 | A total of 5 pull requests were merged for this release. 21 | 22 | * #619: Some fixes in `sisl.viz` 23 | * #620: bug: register data classes as plotables 24 | * #621: Cleaning tutorial notebooks. 25 | * #623: bug: introduction of meta attribute broke heatmaps 26 | * #624: bug: origin not properly preserved during grid plotting 27 | 28 | [0.14.2] - 2023-10-04 29 | ---------------------- 30 | 31 | Fixed 32 | ^^^^^^ 33 | * problems in the sisl.viz module got fixed 34 | 35 | Changed 36 | ^^^^^^^^ 37 | * xarray is now a full dependency (this also implies pandas) 38 | -------------------------------------------------------------------------------- /docs/changelog/v0.15.1.rst: -------------------------------------------------------------------------------- 1 | ****** 2 | 0.15.1 3 | ****** 4 | 5 | Released 10 of September 2024. 6 | 7 | Contributors 8 | ============ 9 | 10 | A total of 2 people contributed to this release. People with a "+" by their 11 | names contributed a patch for the first time. 12 | 13 | * Nick Papior 14 | * Pol Febrer 15 | 16 | Pull requests merged 17 | ==================== 18 | 19 | A total of 5 pull requests were merged for this release. 20 | 21 | * :pull:`#819 <819>`: Make sure wheels are uploaded to pypi 22 | * :pull:`#822 <822>`: Bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.0 23 | * :pull:`#823 <823>`: Fix orbital values 24 | * :pull:`#824 <824>`: Bump pypa/gh-action-pypi-publish from 1.10.0 to 1.10.1 25 | * :pull:`#825 <825>`: Bump JamesIves/github-pages-deploy-action from 4.6.3 to 4.6.4 26 | 27 | Added 28 | ^^^^^ 29 | * enabled `lowdin` to return the Lowdin transformation matrix, and also 30 | allow it to be calculated using SVD 31 | 32 | Fixed 33 | ^^^^^ 34 | * bugfix for wrong call `Lattice.to.cuboid` which caused wrong densities, :pull:`#821 <821>` 35 | -------------------------------------------------------------------------------- /docs/changelog/v0.8.3.rst: -------------------------------------------------------------------------------- 1 | ***** 2 | 0.8.3 3 | ***** 4 | 5 | Released 5 of April 2017. 6 | 7 | 8 | Contributors 9 | ============ 10 | 11 | A total of 1 people contributed to this release. People with a "+" by their 12 | names contributed a patch for the first time. 13 | 14 | * Nick Papior 15 | 16 | Pull requests merged 17 | ==================== 18 | 19 | A total of 0 pull requests were merged for this release. 20 | 21 | 22 | * Fixed bug in __write_default (should have been _write_default) 23 | 24 | * API change in `close` functions, now ret_coord => ret_xyz, 25 | ret_dist => ret_rij 26 | 27 | * Added `SparseCSR` math operations work on other `SparseCSR` matrices 28 | Thus one may now do: 29 | 30 | >>> a, b = SparseCSR(...), SparseCSR(...) 31 | >>> aMb, aPb = a * b, a + b 32 | 33 | Which makes many things much easier. 34 | If this is used, you are encouraged to assert that the math is correct. 35 | Currently are the routines largely untested. Assistance is greatly appreciated 36 | in creating tests. 37 | 38 | * Geometries now _always_ create a supercell. This was not the case when 39 | an atom with no defined orbital radius was used. Now this returns a 40 | supercell with 10 A of vacuum along each Cartesian direction. 41 | -------------------------------------------------------------------------------- /docs/changelog/v0.9.1.rst: -------------------------------------------------------------------------------- 1 | ***** 2 | 0.9.1 3 | ***** 4 | 5 | Released 23 of October 2017. 6 | 7 | 8 | Contributors 9 | ============ 10 | 11 | A total of 1 people contributed to this release. People with a "+" by their 12 | names contributed a patch for the first time. 13 | 14 | * Nick Papior 15 | 16 | Pull requests merged 17 | ==================== 18 | 19 | A total of 0 pull requests were merged for this release. 20 | 21 | 22 | * Fixed scaling of bond-currents in case 'all' is used, makes comparison 23 | with '+' and '-' easier. 24 | 25 | * Updated defaults in bond_current to '+' such that only forward 26 | going electrons are captured. 27 | 28 | * Updated defaults in vector_current to '+' such that only forward 29 | going electrons are captured. 30 | -------------------------------------------------------------------------------- /docs/changelog/v0.9.2.rst: -------------------------------------------------------------------------------- 1 | ***** 2 | 0.9.2 3 | ***** 4 | 5 | Released 25 of October 2017. 6 | 7 | 8 | Contributors 9 | ============ 10 | 11 | A total of 1 people contributed to this release. People with a "+" by their 12 | names contributed a patch for the first time. 13 | 14 | * Nick Papior 15 | 16 | Pull requests merged 17 | ==================== 18 | 19 | A total of 0 pull requests were merged for this release. 20 | 21 | 22 | * Various minor bug-fixes 23 | -------------------------------------------------------------------------------- /docs/changelog/v0.9.3.rst: -------------------------------------------------------------------------------- 1 | ***** 2 | 0.9.3 3 | ***** 4 | 5 | Released 4 of August 2018. 6 | 7 | 8 | Contributors 9 | ============ 10 | 11 | A total of 2 people contributed to this release. People with a "+" by their 12 | names contributed a patch for the first time. 13 | 14 | * Nick Papior 15 | * Thomas Frederiksen + 16 | 17 | Pull requests merged 18 | ==================== 19 | 20 | A total of 5 pull requests were merged for this release. 21 | 22 | * #49: Fixed some typos 23 | * #52: Enabled sub-directory travis coverage tests with .coveragerc... 24 | * #54: WIP updated states, first progress 25 | * #57: Updated RTD to Py-3 26 | * #63: Implementation of charge density on grids 27 | -------------------------------------------------------------------------------- /docs/changelog/v0.9.5.rst: -------------------------------------------------------------------------------- 1 | ***** 2 | 0.9.5 3 | ***** 4 | 5 | Released 12 of November 2018. 6 | 7 | 8 | Contributors 9 | ============ 10 | 11 | A total of 2 people contributed to this release. People with a "+" by their 12 | names contributed a patch for the first time. 13 | 14 | * Nick Papior 15 | * Thomas Frederiksen 16 | 17 | Pull requests merged 18 | ==================== 19 | 20 | A total of 2 pull requests were merged for this release. 21 | 22 | * #82: Introduced option for berry_phase(...) to not close the integration... 23 | * #84: Zak phase from closed-loop integration 24 | 25 | * Fixed temperature for phonon output pht*nc files 26 | 27 | * Added tbtprojncSileTBtrans sile for analyzing projected transmissions 28 | 29 | * Removed deprecated dhSileTBtrans 30 | 31 | * Bug fix for binary grid files with Siesta and also reads using fdf-files 32 | 33 | * Changed default self-energy eta values to 1e-4 eV 34 | 35 | * Added Zak-phase calculations (thanks to T. Frederiksen) 36 | 37 | * Updated lots of State methods 38 | 39 | * added Bloch expansion class which can expand any method 40 | 41 | * self-energy calculations: 42 | * Much faster 43 | * enabled left/right self-energies in one method 44 | 45 | * fixed AtomicOrbital copies 46 | 47 | * enabled TSGF reads 48 | 49 | * Added noise-power calculations for TBT.nc files 50 | 51 | * Fixed TBT.SE.nc files, units and scattering matrix retrieval 52 | 53 | * added more VASP files 54 | -------------------------------------------------------------------------------- /docs/changelog/v0.9.8.rst: -------------------------------------------------------------------------------- 1 | ***** 2 | 0.9.8 3 | ***** 4 | 5 | Released 10 of February 2020. 6 | 7 | 8 | Contributors 9 | ============ 10 | 11 | A total of 3 people contributed to this release. People with a "+" by their 12 | names contributed a patch for the first time. 13 | 14 | * Jonas Lundholm Bertelsen 15 | * Nick Papior 16 | * Sofia Sanz Wuhl 17 | 18 | Pull requests merged 19 | ==================== 20 | 21 | A total of 2 pull requests were merged for this release. 22 | 23 | * #145: Dynamical matrix from gulp works for norbs%12!=0 24 | * #149: Take into account double occupancy in fermi_level 25 | 26 | * fixed #160 by removing all(?) TRS k-points in a Monkhorst Pack grid 27 | 28 | * fixed repeat for SparseGeometryOrbital #161 29 | 30 | * changed lots of places for einsum in electron.py for increased performance 31 | 32 | * added AHC conductivity calculations `conductivity` (not tested) 33 | 34 | * added Berry curvature calculations `berry_flux` (not tested) 35 | 36 | * added Overlap class to directly use overlap matrices (without having a 37 | second matrix). 38 | 39 | * fixed geometry align issue when reading geometries from Siesta output #153 40 | 41 | * fixed pickling a sparse matrix #150 42 | 43 | * Fixed TSV.nc write-out for grid files (see poisson_explicit.py) 44 | 45 | * Fixed fermi level calculation for non-polarized calculations 46 | 47 | * Reverted Fermi calculation routine for more stable implementation 48 | 49 | * fixed DynamiclMatrix reading for number of atoms not divisable by 4 #145 50 | 51 | A huge thanks to Jonas L. B. for fixes, suggestions etc. 52 | -------------------------------------------------------------------------------- /docs/other.rst: -------------------------------------------------------------------------------- 1 | .. _other: 2 | 3 | Related software 4 | ================= 5 | 6 | One of `sisl`'s goals is an easy interaction between a variety of DFT simulations, much like `ASE`_ with 7 | a high emphasis on `Siesta`_, while simultaneously providing the tools necessary to perform tight-binding 8 | calculations. 9 | 10 | 11 | However, `sisl` is far from the only Python package that implements simplistic tight-binding calculations. 12 | We are currently aware of 3 established tight-binding methods used in literature (in random order): 13 | 14 | - `PythTB `__ 15 | - `kwant`_ 16 | - `pybinding `__ 17 | - `ASE`_ 18 | 19 | `sisl`'s philosophy is drastically different in the sense that the Hamiltonian (and other 20 | physical quantities described via matrices) is defined in matrix form. As for kwant and 21 | pybinding the model is *descriptive* as *shapes* define the geometries. 22 | Secondly, both kwant and pybinding are self-contained packages where all physics is handled by the 23 | scripts them-selves, while sisl can calculate band-structures, but transport properties should be 24 | off-loaded to `TBtrans`_. 25 | -------------------------------------------------------------------------------- /docs/quickstart/basic_deps.dot: -------------------------------------------------------------------------------- 1 | # Currently creates a nice graphics with: 2 | # sfdp -Tsvg ... 3 | digraph basic_dep { 4 | "Orbital" 5 | "Orbital" -> {"Atom", "Sile"} 6 | "Atom" 7 | "Atom" -> {"Atoms"} 8 | "Atoms" 9 | "Atoms" -> {"Geometry", "Sile"} 10 | "Lattice" 11 | "Lattice" -> {"Geometry", "Sile", "Grid"} 12 | "Geometry" 13 | "Geometry" -> {"Grid", "Sile"} 14 | "Grid" 15 | "Grid" -> {"Sile"} 16 | "Sile" 17 | } 18 | -------------------------------------------------------------------------------- /docs/quickstart/index.rst: -------------------------------------------------------------------------------- 1 | .. _quickstart: 2 | 3 | Quickstart 4 | ========== 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | overview 10 | 11 | Installation 12 | ------------ 13 | 14 | .. this document is heavily inspired by pandas 15 | All credit should go to the pandas contributors! 16 | 17 | .. grid:: 1 2 2 2 18 | :gutter: 4 19 | 20 | .. grid-item-card:: Using conda? 21 | :columns: 12 12 6 6 22 | 23 | sisl can be installed with `Anaconda/Miniconda `_. 24 | 25 | ++++++++++++++++++++++ 26 | 27 | .. code-block:: bash 28 | 29 | conda install -c conda-forge sisl 30 | 31 | .. grid-item-card:: Using pip? 32 | :columns: 12 12 6 6 33 | 34 | sisl can be installed via pip from `PyPI `_. 35 | 36 | ++++ 37 | 38 | .. code-block:: bash 39 | 40 | python3 -m pip install sisl 41 | 42 | .. grid-item-card:: Detailed installation instructions? 43 | :link: install 44 | :link-type: doc 45 | :columns: 12 46 | :padding: 1 47 | 48 | Check out the advanced installation page. 49 | 50 | .. toctree:: 51 | :maxdepth: 2 52 | :hidden: 53 | 54 | install 55 | 56 | Tutorials 57 | -------------------- 58 | 59 | .. nbgallery:: 60 | :name: intro-tutorials-gallery 61 | 62 | intro_tutorials/01_geometry.ipynb 63 | intro_tutorials/02_geometry_orbitals.ipynb 64 | intro_tutorials/03_geometry_sile.ipynb 65 | -------------------------------------------------------------------------------- /docs/references.rst: -------------------------------------------------------------------------------- 1 | .. _references: 2 | 3 | Bibliography 4 | ============ 5 | 6 | .. create the bibliography will all references. 7 | We may still use local footnote bib's for clarity. 8 | 9 | .. bibliography:: references.bib 10 | -------------------------------------------------------------------------------- /docs/release.rst: -------------------------------------------------------------------------------- 1 | .. _release_notes: 2 | 3 | ************* 4 | Release Notes 5 | ************* 6 | 7 | Sometimes the API of `sisl` changes and users needs to adapt their 8 | scripts to the API changes. 9 | 10 | Generally this can be accommodated by using a code ``if`` block: 11 | 12 | .. code-block:: 13 | 14 | if sisl.__version_tuple__[:3] >= (0, 16, 0): 15 | pass 16 | else: 17 | pass 18 | 19 | this will allow one to reliably test different versions. 20 | 21 | We will generally advice users to follow the latest releases as bug-fixes 22 | may supersede API changes and bring more performance overall. 23 | 24 | In any case the following list of release notes may be used to check changes 25 | between versions. 26 | 27 | 28 | .. toctree:: 29 | :maxdepth: 2 30 | 31 | 0.16.2 32 | 0.16.1 33 | 34 | .. toctree:: 35 | :maxdepth: 1 36 | 37 | 0.16.0 38 | 39 | 40 | 41 | Changelogs 42 | ---------- 43 | 44 | The old format changelogs (for older release <=0.15.2) is contained 45 | here. 46 | 47 | .. toctree:: 48 | :maxdepth: 1 49 | 50 | changelog/index.rst 51 | -------------------------------------------------------------------------------- /docs/release/0.16.2-notes.rst: -------------------------------------------------------------------------------- 1 | sisl 0.16.2 Release Notes 2 | ************************* 3 | 4 | Released on 2025-05-30. 5 | 6 | (bugfix for wheel-creation) 7 | -------------------------------------------------------------------------------- /docs/release/template.rst: -------------------------------------------------------------------------------- 1 | 2 | Released on {{ versiondata.date }}. 3 | 4 | {% for section, _ in sections.items() %} 5 | {% set underline = underlines[0] %}{% if section and sections[section] %}{{ section }} 6 | {{ underline * section|length }}{% set underline = underlines[1] %} 7 | 8 | {% endif %} 9 | {% if sections[section] %} 10 | {% for category, val in definitions.items() if category in sections[section] %} 11 | 12 | {{ definitions[category]['name'] }} 13 | {{ underline * definitions[category]['name']|length }} 14 | 15 | {% if definitions[category]['showcontent'] %} 16 | {% for text, values in sections[section][category].items() %} 17 | - {{ text }} 18 | {% if values %} 19 | 20 | {{ get_indent(text) }}({{values|join(', ') }}) 21 | {% endif %} 22 | 23 | 24 | {% endfor %} 25 | {% else %} 26 | - {{ sections[section][category]['']|join(', ') }} 27 | 28 | {% endif %} 29 | {% if sections[section][category]|length == 0 %} 30 | No significant changes. 31 | 32 | {% endif %} 33 | {% endfor %} 34 | {% endif %} 35 | {% endfor %} 36 | -------------------------------------------------------------------------------- /docs/scripts/index.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _toc-scripts: 3 | 4 | Command line scripts 5 | ==================== 6 | 7 | `sisl` implements a set of command-line utitilies that enables easy interaction 8 | with *all* the data files compatible with `sisl`. 9 | 10 | 11 | .. grid:: 1 1 2 2 12 | :gutter: 2 13 | 14 | .. grid-item-card:: :fas:`shapes` -- Geometry manipulation 15 | :link: sgeom 16 | :link-type: doc 17 | 18 | Process files containing geometries. 19 | 20 | Manipulate, by extending/removing atoms and write to 21 | a large variety of file formats. 22 | 23 | Can be used as a file format conversion tool. 24 | 25 | .. grid-item-card:: :fas:`table-cells` -- Grid manipulation 26 | :link: sgrid 27 | :link-type: doc 28 | 29 | Process files containing grid-data. 30 | 31 | Manipulation of the grids, by subtracting/reducing grids. 32 | 33 | Can be used as a file format conversion tool. 34 | 35 | .. grid-item-card:: :fas:`toolbox` -- Generic data manipulator 36 | :link: sdata 37 | :link-type: doc 38 | 39 | Click here for details. 40 | 41 | .. grid-item-card:: :fas:`toolbox` -- Toolboxes 42 | :link: stoolbox 43 | :link-type: doc 44 | 45 | Toolbox interfaces that can be extended with user-defined 46 | functionality. 47 | 48 | .. toctree:: 49 | :hidden: 50 | :maxdepth: 1 51 | 52 | sgeom 53 | sgrid 54 | stoolbox 55 | sdata 56 | -------------------------------------------------------------------------------- /docs/scripts/sdata.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: console 2 | 3 | .. _script_sdata: 4 | 5 | `sdata` 6 | ======= 7 | 8 | The `sdata` executable is a tool for reading and performing actions 9 | on *all* `sisl` file formats applicable. 10 | 11 | Essentially it performs operations dependent on the file that is being 12 | processed. If for instance the file contains any kind of `Geometry` 13 | it allows the same operations as `sgeom`. 14 | 15 | For a short help description of the possible uses do:: 16 | 17 | sdata --help 18 | 19 | which shows a help dependent on which kind of file ```` is. 20 | 21 | As the options for this utility depends on the input *file*, it 22 | is not completely documented. 23 | 24 | 25 | 26 | Files with `Geometry` 27 | --------------------- 28 | 29 | If a file contains a `Geometry` one gets *all* the options like 30 | `sgeom`. I.e. `sdata` is a generic form of the `sgeom` script. 31 | 32 | 33 | Files with `Grid` 34 | ----------------- 35 | 36 | If the file contains a `Grid` one gets *all* the options like 37 | `sgrid`. I.e. `sdata` is a generic form of the `sgrid` script. 38 | 39 | 40 | .. highlight:: python 41 | -------------------------------------------------------------------------------- /docs/scripts/stoolbox.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: bash 2 | 3 | .. _script_stoolbox: 4 | 5 | `stoolbox` 6 | ========== 7 | 8 | sisl exposes user contributed tool-box command line interfaces through a common 9 | interface. 10 | 11 | The `sisl` toolbox is a separate package (shipped together with sisl) which contains 12 | tools that are thought to be good tools for sisl users but are too specialized in 13 | terms of usability to enter the sisl API. 14 | 15 | We encourage users to contribute toolboxes to increase visibility and usability. 16 | 17 | For a short description of the possible toolboxes do:: 18 | 19 | stoolbox --help 20 | 21 | For available toolboxes, please see :ref:`Toolboxes `. 22 | 23 | 24 | Have an idea? 25 | ------------- 26 | 27 | If you want to contribute or have an idea for a toolbox, feel free to open an issue `here `_. 28 | 29 | 30 | .. highlight:: python 31 | -------------------------------------------------------------------------------- /docs/sisl_modules/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | """sisl-defined extensions""" 5 | -------------------------------------------------------------------------------- /docs/spelling_wordlist.txt: -------------------------------------------------------------------------------- 1 | wavefunction 2 | sisl 3 | -------------------------------------------------------------------------------- /docs/toolbox/btd/btd.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _toc-tool-btd: 3 | 4 | .. module:: sisl_toolbox.btd 5 | 6 | 7 | Block-tri-diagonal inversion algorithms 8 | ======================================= 9 | 10 | Enables block-tri-diagonal inversion algorithms directly in Python. 11 | 12 | 13 | .. autosummary:: 14 | :toctree: generated/ 15 | 16 | PivotSelfEnergy 17 | DownfoldSelfEnergy 18 | DeviceGreen 19 | -------------------------------------------------------------------------------- /docs/toolbox/index.rst: -------------------------------------------------------------------------------- 1 | .. _toc-toolbox: 2 | 3 | .. module:: sisl_toolbox 4 | 5 | Toolboxes 6 | ========= 7 | 8 | Installing `sisl` will install two packages, `sisl` and `sisl_toolbox`. 9 | 10 | The latter are user-contributed tools that are useful for end-users but are 11 | very focused on solving a particular problem. In order to maintain a stable 12 | and sufficiently clean API any `sisl` extensions that are thought to be specialized 13 | would go into the `sisl_toolbox` suite. 14 | 15 | Some toolboxes have a command-line-interface, see :ref:`script_stoolbox` for details. 16 | 17 | Toolboxes should be imported directly. 18 | 19 | .. code-block:: python 20 | 21 | import sisl_toolbox.siesta.atom 22 | 23 | 24 | The implemented toolboxes are listed here: 25 | 26 | .. toctree:: 27 | :maxdepth: 1 28 | 29 | transiesta/ts_fft 30 | siesta/atom_plot 31 | btd/btd 32 | -------------------------------------------------------------------------------- /docs/toolbox/siesta/atom_plot_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zerothi/sisl/1899f26d79c72b14d28c3206c389851055b4be19/docs/toolbox/siesta/atom_plot_output.png -------------------------------------------------------------------------------- /docs/tutorials/convert.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for pdf in figures/*.pdf 4 | do 5 | png=${pdf//pdf/png} 6 | if [ ! -e $png ]; then 7 | echo "Converting $pdf to $png" 8 | convert -density 300 $pdf $png 9 | optipng -o7 $png 2>/dev/null >/dev/null 10 | fi 11 | done 12 | 13 | -------------------------------------------------------------------------------- /docs/tutorials/figures/04_graphene_couplings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zerothi/sisl/1899f26d79c72b14d28c3206c389851055b4be19/docs/tutorials/figures/04_graphene_couplings.png -------------------------------------------------------------------------------- /docs/tutorials/figures/04_supercell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zerothi/sisl/1899f26d79c72b14d28c3206c389851055b4be19/docs/tutorials/figures/04_supercell.png -------------------------------------------------------------------------------- /docs/tutorials/figures/05_graphene_bs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zerothi/sisl/1899f26d79c72b14d28c3206c389851055b4be19/docs/tutorials/figures/05_graphene_bs.png -------------------------------------------------------------------------------- /docs/tutorials/figures/05_square_bs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zerothi/sisl/1899f26d79c72b14d28c3206c389851055b4be19/docs/tutorials/figures/05_square_bs.png -------------------------------------------------------------------------------- /docs/tutorials/index.rst: -------------------------------------------------------------------------------- 1 | 2 | Tutorials 3 | ========= 4 | 5 | sisl is shipped with these tutorials which introduce the basics. 6 | 7 | All examples are assumed to have this in the header:: 8 | 9 | import numpy as np 10 | import sisl as si 11 | 12 | to enable `numpy`_ and sisl. 13 | 14 | Below is a list of the current tutorials: 15 | 16 | .. toctree:: 17 | :maxdepth: 1 18 | 19 | tutorial_es_1.ipynb 20 | tutorial_es_2.ipynb 21 | tutorial_siesta_2_ahc.ipynb 22 | 23 | 24 | Siesta/TranSiesta support 25 | ------------------------- 26 | 27 | sisl was initiated around the `Siesta`_/`TranSiesta`_ code. And it may be *very* educational to 28 | look at the sisl+TBtrans+TranSiesta tutorial located `here `_. 29 | 30 | If you plan on using sisl as an analysis tool for Siesta you are highly recommended to follow 31 | these tutorials: 32 | 33 | .. toctree:: 34 | :maxdepth: 1 35 | 36 | tutorial_siesta_1.ipynb 37 | tutorial_siesta_2.ipynb 38 | 39 | 40 | Deprecated tutorials 41 | -------------------- 42 | 43 | Once everything has been moved to the IPython notebook notation, these tutorials will be 44 | removed. Until that happens they are located here for consistency: 45 | 46 | .. toctree:: 47 | :maxdepth: 1 48 | 49 | Geometry creation -- part 1 50 | Geometry creation -- part 2 51 | Supercells 52 | Electronic structure setup -- part 1 53 | Electronic structure setup -- part 2 54 | -------------------------------------------------------------------------------- /docs/tutorials/siesta_1/siesta_1.nc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zerothi/sisl/1899f26d79c72b14d28c3206c389851055b4be19/docs/tutorials/siesta_1/siesta_1.nc -------------------------------------------------------------------------------- /docs/tutorials/siesta_2/siesta_2.nc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zerothi/sisl/1899f26d79c72b14d28c3206c389851055b4be19/docs/tutorials/siesta_2/siesta_2.nc -------------------------------------------------------------------------------- /docs/tutorials/tutorial_02.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _tutorial-02: 3 | 4 | Geometry creation -- part 2 5 | --------------------------- 6 | 7 | Many geometries are intrinsically enabled via the `sisl.geom` submodule. 8 | 9 | Here we list the currently default geometries: 10 | 11 | * `honeycomb` (graphene unit-cell):: 12 | 13 | hBN = geom.honeycomb(1.5, [Atom('B'), Atom('N')]) 14 | 15 | * `graphene` (equivalent to `honeycomb` with Carbon atoms):: 16 | 17 | graphene = geom.graphene(1.42) 18 | 19 | * Simple-, body- and face-centered cubic as well as HCP 20 | All have the same interface:: 21 | 22 | sc = geom.sc(2.5) 23 | bcc = geom.bcc(2.5) 24 | fcc = geom.fcc(2.5) 25 | hcp = geom.hcp(2.5) 26 | 27 | * Nanotubes with different chirality:: 28 | 29 | ntb = geom.nanotube(1.54, chirality=(n, m)) 30 | 31 | * Diamond:: 32 | 33 | d = geom.diamond(3.57) 34 | -------------------------------------------------------------------------------- /docs/tutorials/tutorial_05_graphene.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | import sisl as si 5 | 6 | graphene = si.geom.graphene() 7 | 8 | # Generate Hamiltonian 9 | H = si.Hamiltonian(graphene) 10 | 11 | # Show the initial state of the Hamiltonian 12 | print(H) 13 | 14 | H[0, 1] = 2.7 15 | H[0, 1, (-1, 0)] = 2.7 16 | H[0, 1, (0, -1)] = 2.7 17 | H[1, 0] = 2.7 18 | H[1, 0, (1, 0)] = 2.7 19 | H[1, 0, (0, 1)] = 2.7 20 | 21 | # Show that we indeed have added some code 22 | print(H) 23 | 24 | # Create band-structure for the supercell. 25 | band = si.BandStructure( 26 | H, [[0.0, 0.0], [2.0 / 3, 1.0 / 3], [0.5, 0.5], [0.0, 0.0]], 300 27 | ) 28 | 29 | # Calculate eigenvalues of the band-structure 30 | eigs = band.apply.ndarray.eigh() 31 | 32 | # Plot them 33 | import matplotlib.pyplot as plt 34 | 35 | plt.figure() 36 | plt.title("Bandstructure of graphene, nearest neighbor") 37 | plt.xlabel("k") 38 | plt.ylabel("Eigenvalue") 39 | 40 | # Generate linear-k for plotting (ensures correct spacing) 41 | lband = band.lineark() 42 | for i in range(eigs.shape[1]): 43 | plt.plot(lband, eigs[:, i]) 44 | plt.savefig("05_graphene_bs.png") 45 | -------------------------------------------------------------------------------- /docs/tutorials/tutorial_05_square.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | import sisl as si 5 | 6 | # Generate square lattice with nearest neighbor couplings 7 | square = si.Geometry([[0.5, 0.5, 0]], lattice=si.Lattice([1, 1, 10], [3, 3, 1])) 8 | 9 | # Generate Hamiltonian 10 | H = si.Hamiltonian(square) 11 | 12 | # Show the initial state of the Hamiltonian 13 | print(H) 14 | 15 | # Specify matrix elements (on-site and coupling elements) 16 | H[0, 0] = -4.0 17 | H[0, 0, (1, 0)] = 1.0 18 | H[0, 0, (-1, 0)] = 1.0 19 | H[0, 0, (0, 1)] = 1.0 20 | H[0, 0, (0, -1)] = 1.0 21 | 22 | # Show that we indeed have added some code 23 | print(H) 24 | 25 | # Create band-structure for the supercell. 26 | band = si.BandStructure(H, [[0.0, 0.0], [0.5, 0.0], [0.5, 0.5], [0.0, 0.0]], 300) 27 | 28 | # Calculate eigenvalues of the band-structure 29 | eigs = band.apply.ndarray.eigh() 30 | 31 | # Plot them 32 | import matplotlib.pyplot as plt 33 | 34 | plt.figure() 35 | plt.title("Bandstructure of square, nearest neighbor") 36 | plt.xlabel("k") 37 | plt.ylabel("Eigenvalue") 38 | 39 | # Generate linear-k for plotting (ensures correct spacing) 40 | lband = band.lineark() 41 | for i in range(eigs.shape[1]): 42 | plt.plot(lband, eigs[:, i]) 43 | plt.savefig("05_square_bs.png") 44 | -------------------------------------------------------------------------------- /docs/tutorials/tutorial_06_square.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | import sisl as si 5 | 6 | # Generate square lattice with nearest neighbor couplings 7 | Hydrogen = si.Atom(1, R=1.0) 8 | square = si.Geometry( 9 | [[0.5, 0.5, 0]], Hydrogen, lattice=si.Lattice([1, 1, 10], [3, 3, 1]) 10 | ) 11 | 12 | # Generate Hamiltonian 13 | H = si.Hamiltonian(square) 14 | 15 | # Show the initial state of the Hamiltonian 16 | print(H) 17 | 18 | # Specify matrix elements 19 | for ias, idxs in square.iter_block(): 20 | for ia in ias: 21 | idx_a = square.close(ia, R=[0.1, 1.1], atoms=idxs) 22 | H[ia, idx_a[0]] = -4.0 23 | H[ia, idx_a[1]] = 1.0 24 | 25 | # Show that we indeed have added some code 26 | print(H) 27 | 28 | # Create band-structure for the supercell. 29 | band = si.BandStructure(H, [[0.0, 0.0], [0.5, 0.0], [0.5, 0.5], [0.0, 0.0]], 300) 30 | 31 | # Calculate eigenvalues of the band-structure 32 | eigs = band.apply.ndarray.eigh() 33 | 34 | # Plot them 35 | import matplotlib.pyplot as plt 36 | 37 | plt.figure() 38 | plt.title("Bandstructure of square, nearest neighbor") 39 | plt.xlabel("k") 40 | plt.ylabel("Eigenvalue") 41 | 42 | # Generate linear-k for plotting (ensures correct spacing) 43 | lband = band.lineark() 44 | for i in range(eigs.shape[1]): 45 | plt.plot(lband, eigs[:, i]) 46 | plt.savefig("06_square_bs.png") 47 | -------------------------------------------------------------------------------- /docs/tutorials/tutorial_setup.tex: -------------------------------------------------------------------------------- 1 | \usepackage{tikz} 2 | \usetikzlibrary{calc,external} 3 | 4 | \tikzexternalize 5 | 6 | \tikzsetexternalprefix{figures/} 7 | -------------------------------------------------------------------------------- /docs/visualization/ase/index.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | ASE 4 | --- 5 | 6 | A sisl `Geometry` object may easily be converted to ASE objects and thus directly 7 | plotted. 8 | 9 | 10 | .. code-block:: 11 | 12 | import sisl as si 13 | from ase.visualize import view 14 | 15 | geom = si.geom.graphene() 16 | view(geom.to.ase()) 17 | 18 | will open a new window showing the atoms. 19 | -------------------------------------------------------------------------------- /docs/visualization/blender/First animation.rst: -------------------------------------------------------------------------------- 1 | First animation 2 | --------------- 3 | 4 | Below is a script that generates an animation of graphene breathing in blender: 5 | 6 | .. code-block:: python 7 | 8 | import sisl as si 9 | from sisl.viz import merge_plots 10 | 11 | plots = [] 12 | for color, opacity, scale in zip(["red", "orange", "green"], [1, 0.2, 1], [0.5, 1, 0.5]): 13 | geom_plot = si.geom.graphene().plot(backend="blender", 14 | atoms_style={"color": color, "opacity": opacity}, 15 | bonds_scale=0.01, 16 | atoms_scale=scale 17 | ) 18 | 19 | plots.append(geom_plot) 20 | 21 | merge_plots(*plots, backend="blender", composite_method="animation", interpolated_frames=50).show() 22 | 23 | .. raw:: html 24 | 25 |
View post on imgur.com
26 | -------------------------------------------------------------------------------- /docs/visualization/showcase/_template/create.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import argparse 7 | from pathlib import Path 8 | 9 | from sisl.viz.plotutils import get_plot_classes 10 | 11 | 12 | def create_showcase_nb(cls, force=False): 13 | """ 14 | Creates a new notebook to showcase a plot class from the showcase template. 15 | 16 | Parameters 17 | ----------- 18 | cls: str 19 | the name of the class that you want to 20 | """ 21 | if cls not in [c.__name__ for c in get_plot_classes()]: 22 | message = f"We didn't find a plot class with the name '{cls}'" 23 | 24 | if force: 25 | print(message) 26 | else: 27 | raise ValueError(message) 28 | 29 | with open(Path(__file__).parent / "Showcase template.ipynb", "r") as f: 30 | lines = f.read() 31 | 32 | with open(Path(__file__).parent.parent / f"{cls}.ipynb", "w") as f: 33 | f.write(lines.replace("<$plotclass$>", cls)) 34 | 35 | 36 | if __name__ == "__main__": 37 | parser = argparse.ArgumentParser() 38 | 39 | parser.add_argument("-c", "--cls", type=str, required=True) 40 | parser.add_argument("-f", "--force", action="store_true") 41 | 42 | args = parser.parse_args() 43 | create_showcase_nb(args.cls, getattr(args, "force", False)) 44 | -------------------------------------------------------------------------------- /examples/ex_01.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | # This example creates the tight-binding Hamiltonian 7 | # for graphene with on-site energy 0, and hopping energy 8 | # -2.7 eV. 9 | 10 | from __future__ import annotations 11 | 12 | import sisl 13 | 14 | bond = 1.42 15 | # Construct the atom with the appropriate orbital range 16 | # Note the 0.01 which is for numerical accuracy. 17 | C = sisl.Atom(6, R=bond + 0.01) 18 | # Create graphene unit-cell 19 | gr = sisl.geom.graphene(bond, C) 20 | 21 | # Create the tight-binding Hamiltonian 22 | H = sisl.Hamiltonian(gr) 23 | R = [0.1 * bond, bond + 0.01] 24 | 25 | for ia in gr: 26 | idx_a = gr.close(ia, R) 27 | # On-site 28 | H[ia, idx_a[0]] = 0.0 29 | # Nearest neighbor hopping 30 | H[ia, idx_a[1]] = -2.7 31 | 32 | # Calculate eigenvalues at K-point 33 | print(H.eigh([2.0 / 3, 1.0 / 3, 0.0])) 34 | -------------------------------------------------------------------------------- /examples/ex_02.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 | 6 | # This example creates the tight-binding Hamiltonian 7 | # for graphene with on-site energy 0, and hopping energy 8 | # -2.7 eV using a simpler method to construct the 9 | # Hamiltonian. 10 | 11 | from __future__ import annotations 12 | 13 | import sisl 14 | 15 | bond = 1.42 16 | # Construct the atom with the appropriate orbital range 17 | # Note the 0.01 which is for numerical accuracy. 18 | C = sisl.Atom(6, R=bond + 0.01) 19 | # Create graphene unit-cell 20 | gr = sisl.geom.graphene(bond, C) 21 | 22 | # Create the tight-binding Hamiltonian 23 | H = sisl.Hamiltonian(gr) 24 | 25 | # Create function to be passed to the construct method. 26 | # This method is *much* faster for large scale simulations. 27 | func = H.create_construct([0.1 * bond, bond + 0.01], [0.0, -2.7]) 28 | H.construct(func) 29 | 30 | # Calculate eigenvalues at K-point 31 | print(H.eigh([2.0 / 3, 1.0 / 3, 0.0])) 32 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory("sisl") 2 | # when it comes 3 | #add_subdirectory("sisl_toolbox") 4 | -------------------------------------------------------------------------------- /src/sisl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set_property(DIRECTORY 2 | APPEND 3 | PROPERTY INCLUDE_DIRECTORIES 4 | ${CMAKE_CURRENT_SOURCE_DIR}/_core 5 | ) 6 | 7 | foreach(source _indices _math_small) 8 | add_cython_library( 9 | SOURCE ${source}.pyx 10 | LIBRARY ${source} 11 | OUTPUT ${source}_C 12 | ) 13 | install(TARGETS ${source} LIBRARY 14 | DESTINATION ${SKBUILD_PROJECT_NAME}) 15 | endforeach() 16 | 17 | # Python files that can be compiled with cython (Pure Python syntax) 18 | foreach(source _sparse_grid_ops) 19 | sisl_compile_source(${source} compile) 20 | if( compile ) 21 | add_cython_library( 22 | SOURCE ${source}.py 23 | LIBRARY ${source} 24 | OUTPUT ${source}_C 25 | ) 26 | install(TARGETS ${source} LIBRARY 27 | DESTINATION ${SKBUILD_PROJECT_NAME}) 28 | endif() 29 | endforeach() 30 | 31 | # We do the configure step here 32 | # We do not have the configure file in the current directory 33 | # Otherwise it would be installed together with it 34 | # Also get the compile definitions 35 | get_directory_property( SISL_DEFINITIONS DIRECTORY 36 | ${CMAKE_CURRENT_SOURCE_DIR} 37 | COMPILE_DEFINITIONS ) 38 | 39 | # Join to stringify list 40 | list(JOIN SISL_DEFINITIONS " " SISL_DEFINITIONS) 41 | 42 | configure_file( 43 | ${PROJECT_SOURCE_DIR}/tools/_debug_info.py.conf 44 | ${CMAKE_CURRENT_SOURCE_DIR}/_debug_info.py 45 | @ONLY 46 | ) 47 | 48 | # Add other sub-directories 49 | add_subdirectory("_core") 50 | add_subdirectory("io") 51 | add_subdirectory("physics") 52 | add_subdirectory("geom") 53 | -------------------------------------------------------------------------------- /src/sisl/__main__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from .utils._sisl_cmd import sisl_cmd 7 | 8 | sisl_cmd() 9 | -------------------------------------------------------------------------------- /src/sisl/_common.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ Global common files """ 7 | from enum import Flag, auto, unique 8 | 9 | __all__ = ["Opt"] 10 | 11 | 12 | @unique 13 | class Opt(Flag): 14 | """Global option arguments used throughout sisl 15 | 16 | These flags may be combined via bit-wise operations 17 | """ 18 | 19 | NONE = auto() 20 | ANY = auto() 21 | ALL = auto() 22 | -------------------------------------------------------------------------------- /src/sisl/_core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | foreach(source _lattice _dtypes _sparse) 2 | add_cython_library( 3 | SOURCE ${source}.pyx 4 | LIBRARY ${source} 5 | OUTPUT ${source}_C 6 | ) 7 | install(TARGETS ${source} LIBRARY 8 | DESTINATION ${SKBUILD_PROJECT_NAME}/_core) 9 | endforeach() 10 | -------------------------------------------------------------------------------- /src/sisl/_core/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Core functionality exposed here. 8 | """ 9 | from .oplist import * 10 | from .quaternion import * 11 | 12 | # isort: off 13 | from .orbital import * 14 | from .periodictable import * 15 | from .atom import * 16 | from .lattice import * 17 | from .geometry import * 18 | from .grid import * 19 | from .sparse import * 20 | from .sparse_geometry import * 21 | 22 | # isort: on 23 | 24 | # We will not expose anything here, it is a registration module 25 | from . import ( 26 | _ufuncs_atom, 27 | _ufuncs_geometry, 28 | _ufuncs_grid, 29 | _ufuncs_lattice, 30 | _ufuncs_orbital, 31 | _ufuncs_sparse, 32 | _ufuncs_sparse_geometry, 33 | ) 34 | -------------------------------------------------------------------------------- /src/sisl/_core/_sparse.pxd: -------------------------------------------------------------------------------- 1 | # Define the interfaces for the functions exposed through cimport 2 | from sisl._core._dtypes cimport int_sp_st 3 | 4 | 5 | cdef void ncol2ptr(const int_sp_st nr, const int_sp_st[::1] ncol, int_sp_st[::1] ptr, 6 | const int_sp_st per_row, const int_sp_st per_elem) noexcept nogil 7 | -------------------------------------------------------------------------------- /src/sisl/_core/_ufuncs_sparse.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | # Nothing gets exposed here 7 | __all__ = [] 8 | -------------------------------------------------------------------------------- /src/sisl/_core/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl """ 7 | -------------------------------------------------------------------------------- /src/sisl/_indices.pxd: -------------------------------------------------------------------------------- 1 | # Define the interfaces for the functions exposed through cimport 2 | from numpy cimport int16_t, int32_t, int64_t 3 | 4 | from sisl._core._dtypes cimport ints_st 5 | 6 | 7 | cdef bint in_1d(const ints_st[::1] array, const ints_st v) noexcept nogil 8 | 9 | ctypedef fused _ints_index_sorted_st: 10 | short 11 | int 12 | long 13 | int16_t 14 | int32_t 15 | int64_t 16 | 17 | cdef Py_ssize_t _index_sorted(const ints_st[::1] array, const _ints_index_sorted_st v) noexcept nogil 18 | -------------------------------------------------------------------------------- /src/sisl/_internal.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | r""" Internal sisl-only methods that should not be used outside """ 7 | 8 | # override module level, inspired by numpy 9 | 10 | __all__ = ["set_module"] 11 | 12 | 13 | def set_module(module): 14 | r"""Decorator for overriding __module__ on a function or class""" 15 | 16 | def deco(f_or_c): 17 | if module is not None: 18 | f_or_c.__module__ = module 19 | return f_or_c 20 | 21 | return deco 22 | -------------------------------------------------------------------------------- /src/sisl/_lib/_argparse.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | try: 5 | from rich_argparse import RichHelpFormatter 6 | 7 | SislHelpFormatter = RichHelpFormatter 8 | except ImportError: 9 | import argparse 10 | 11 | SislHelpFormatter = argparse.RawDescriptionHelpFormatter 12 | -------------------------------------------------------------------------------- /src/sisl/_nodify.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | import sisl 6 | 7 | 8 | def on_nodify(): 9 | from nodify.server.session import register_file_plot_handler 10 | 11 | def _get_plot_options(file_name: str) -> list[str]: 12 | try: 13 | plot_handler = sisl.get_sile(file_name).plot 14 | except: 15 | return [] 16 | 17 | options = list(plot_handler._dispatchs.keys()) 18 | 19 | return options 20 | 21 | def _plot_file(file_name: str, method: str): 22 | plot_handler = sisl.get_sile(file_name).plot 23 | print(plot_handler) 24 | if method is None: 25 | plot = plot_handler() 26 | else: 27 | plot = getattr(plot_handler, method)() 28 | 29 | try: 30 | plot.get() 31 | except: 32 | pass 33 | 34 | return plot 35 | 36 | register_file_plot_handler("sisl", _get_plot_options, _plot_file) 37 | -------------------------------------------------------------------------------- /src/sisl/geom/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory("_neighbors") 2 | -------------------------------------------------------------------------------- /src/sisl/geom/_category/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | from __future__ import annotations 6 | 7 | from .base import * 8 | 9 | # isort: split 10 | 11 | from ._coord import * 12 | from ._kind import * 13 | from ._neighbors import * 14 | -------------------------------------------------------------------------------- /src/sisl/geom/_category/base.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from functools import wraps 7 | 8 | from sisl._category import NullCategory 9 | from sisl._core import AtomCategory, Geometry 10 | from sisl.typing import AtomsIndex 11 | 12 | __all__ = ["NullCategory", "AtomCategory"] 13 | 14 | 15 | def _sanitize_loop(func): 16 | @wraps(func) 17 | def loop_func(self, geometry: Geometry, atoms: AtomsIndex = None): 18 | if atoms is None: 19 | return [func(self, geometry, ia) for ia in geometry] 20 | 21 | # extract based on atoms selection 22 | atoms = geometry._sanitize_atoms(atoms) 23 | if atoms.ndim == 0: 24 | return func(self, geometry, atoms) 25 | return [func(self, geometry, ia) for ia in atoms] 26 | 27 | return loop_func 28 | -------------------------------------------------------------------------------- /src/sisl/geom/_category/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/geom/category """ 7 | -------------------------------------------------------------------------------- /src/sisl/geom/_common.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | 8 | __all__ = ["geometry_define_nsc", "geometry2uc"] 9 | 10 | 11 | def geometry_define_nsc(geometry, periodic=(True, True, True)): 12 | """Define the number of supercells for a geometry based on the periodicity""" 13 | 14 | # Pre-set nsc, PBC and the axes 15 | nsc, pbc, axes = {}, {}, [] 16 | 17 | for ax, (d, per) in enumerate(zip("abc", periodic)): 18 | if per: 19 | nsc[d] = 3 20 | pbc[d] = "Periodic" 21 | axes.append(ax) 22 | else: 23 | nsc[d] = 1 24 | pbc[d] = "Unknown" 25 | 26 | geometry.set_nsc(**nsc) 27 | 28 | if np.all(geometry.maxR(True) > 0.0): 29 | nsc = geometry.find_nsc(axes) 30 | geometry.set_nsc(nsc) 31 | 32 | geometry.lattice.set_boundary_condition(**pbc) 33 | 34 | 35 | def geometry2uc(geometry, dx=1e-8): 36 | """Translate the geometry to the unit cell by first shifting `dx`""" 37 | geometry = geometry.move(dx).translate2uc().move(-dx) 38 | geometry.xyz[geometry.xyz < 0] = 0 39 | return geometry 40 | -------------------------------------------------------------------------------- /src/sisl/geom/_neighbors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # In this directory we have a set of libraries 2 | # We will need to link to the Numpy includes 3 | foreach(source _operations) 4 | sisl_compile_source(${source} compile) 5 | if( compile ) 6 | add_cython_library( 7 | SOURCE ${source}.py 8 | LIBRARY ${source} 9 | OUTPUT ${source}_C 10 | ) 11 | install(TARGETS ${source} LIBRARY 12 | DESTINATION ${SKBUILD_PROJECT_NAME}/geom/_neighbors) 13 | endif() 14 | endforeach() 15 | -------------------------------------------------------------------------------- /src/sisl/geom/_neighbors/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from ._finder import * 7 | from ._neighborlists import * 8 | -------------------------------------------------------------------------------- /src/sisl/geom/special.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from typing import Optional 7 | 8 | import numpy as np 9 | 10 | from sisl import Atom, Geometry, Lattice 11 | from sisl._internal import set_module 12 | from sisl.typing import AtomsLike 13 | 14 | from ._common import geometry_define_nsc 15 | 16 | __all__ = ["diamond"] 17 | 18 | 19 | @set_module("sisl.geom") 20 | def diamond(alat: float = 3.57, atoms: Optional[AtomsLike] = None) -> Geometry: 21 | """Diamond lattice with 2 atoms in the unitcell 22 | 23 | Parameters 24 | ---------- 25 | alat : float 26 | the lattice constant for the diamond 27 | atoms : Atom, optional 28 | atom in the lattice, may be one or two atoms. Default is Carbon 29 | """ 30 | dist = alat * 3.0**0.5 / 4 31 | if atoms is None: 32 | atoms = Atom(Z=6, R=dist * 1.01) 33 | lattice = Lattice( 34 | np.array([[0, 1, 1], [1, 0, 1], [1, 1, 0]], np.float64) * alat / 2 35 | ) 36 | dia = Geometry( 37 | np.array([[0, 0, 0], [1, 1, 1]], np.float64) * alat / 4, atoms, lattice=lattice 38 | ) 39 | 40 | geometry_define_nsc(dia) 41 | return dia 42 | -------------------------------------------------------------------------------- /src/sisl/geom/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/geom """ 7 | -------------------------------------------------------------------------------- /src/sisl/io/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # In this directory we have a set of libraries 2 | # We will need to link to the Numpy includes 3 | add_subdirectory("siesta") 4 | -------------------------------------------------------------------------------- /src/sisl/io/_except_objects.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl._internal import set_module 7 | 8 | from ._except_base import * 9 | 10 | __all__ = ["MissingFermiLevelWarning"] 11 | 12 | 13 | @set_module("sisl.io") 14 | class MissingFermiLevelWarning(SileWarning): 15 | """The Fermi level is not present in the file.""" 16 | -------------------------------------------------------------------------------- /src/sisl/io/bigdft/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | BigDFT 8 | ====== 9 | 10 | asciiSileBigDFT - the input for BigDFT 11 | 12 | """ 13 | from .sile import * # isort: split 14 | from .ascii import * 15 | -------------------------------------------------------------------------------- /src/sisl/io/bigdft/sile.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Define a common BigDFT Sile 8 | """ 9 | from sisl._internal import set_module 10 | 11 | from ..sile import Sile, SileBin 12 | 13 | __all__ = ["SileBigDFT", "SileBinBigDFT"] 14 | 15 | 16 | @set_module("sisl.io.bigdft") 17 | class SileBigDFT(Sile): 18 | pass 19 | 20 | 21 | @set_module("sisl.io.bigdft") 22 | class SileBinBigDFT(SileBin): 23 | pass 24 | -------------------------------------------------------------------------------- /src/sisl/io/dftb/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | DFTB+ 8 | ========= 9 | 10 | DFTB+ interoperability is mainly targeted at extracting 11 | tight-binding models. 12 | 13 | hamrealSileDFTB -- the Hamiltonian output file 14 | overrealSileDFTB -- the overlap output file 15 | 16 | """ 17 | from .sile import * # isort: split 18 | from .realdat import * 19 | -------------------------------------------------------------------------------- /src/sisl/io/dftb/sile.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Define a common DFTB+ Sile 8 | """ 9 | from sisl._internal import set_module 10 | 11 | from ..sile import Sile, SileBin 12 | 13 | __all__ = ["SileDFTB", "SileBinDFTB"] 14 | 15 | 16 | @set_module("sisl.io.dftb") 17 | class SileDFTB(Sile): 18 | pass 19 | 20 | 21 | @set_module("sisl.io.DFTB") 22 | class SileBinDFTB(SileBin): 23 | pass 24 | -------------------------------------------------------------------------------- /src/sisl/io/dftb/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/io/dftb """ 7 | -------------------------------------------------------------------------------- /src/sisl/io/dftb/tests/test_realdat.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ pytest test configures """ 7 | 8 | 9 | import numpy as np 10 | import pytest 11 | 12 | import sisl 13 | 14 | pytestmark = [pytest.mark.io, pytest.mark.dftb] 15 | 16 | 17 | def test_molecule_overlap(sisl_files): 18 | si = sisl.get_sile(sisl_files("dftb", "h2o", "overreal.dat")) 19 | S = si.read_overlap() 20 | 21 | assert S.na == 3 22 | assert S.no == 6 23 | assert S[0, 4] == pytest.approx(2.439705710593631e-01) 24 | 25 | 26 | def test_molecule_hamiltonian(sisl_files): 27 | si = sisl.get_sile(sisl_files("dftb", "h2o", "hamreal1.dat")) 28 | S = si.read_overlap() 29 | H = si.read_hamiltonian() 30 | 31 | assert H.na == 3 32 | assert H.no == 6 33 | assert H[0, 4, 0] == pytest.approx(-2.885462383598692e-01) 34 | 35 | assert np.allclose(H._csr._D[:, -1], S._csr._D.ravel()) 36 | -------------------------------------------------------------------------------- /src/sisl/io/fhiaims/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | FHI-aims 8 | ======== 9 | 10 | inSileFHIaims - geometry for FHI-aims 11 | 12 | """ 13 | from .sile import * # isort: split 14 | from ._geometry import * 15 | -------------------------------------------------------------------------------- /src/sisl/io/fhiaims/sile.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Define a common FHI-AIMS Sile 8 | """ 9 | from sisl._internal import set_module 10 | 11 | from ..sile import Sile, SileBin 12 | 13 | __all__ = ["SileFHIaims", "SileBinFHIaims"] 14 | 15 | 16 | @set_module("sisl.io.fhiaims") 17 | class SileFHIaims(Sile): 18 | pass 19 | 20 | 21 | @set_module("sisl.io.fhiaims") 22 | class SileBinFHIaims(SileBin): 23 | pass 24 | -------------------------------------------------------------------------------- /src/sisl/io/fhiaims/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/io/fhiaims """ 7 | -------------------------------------------------------------------------------- /src/sisl/io/gulp/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | GULP 8 | ==== 9 | 10 | gotSileGULP - the output from GULP 11 | fcSileGULP - force constant output from GULP 12 | 13 | """ 14 | from .sile import * # isort: split 15 | from .fc import * 16 | from .got import * 17 | -------------------------------------------------------------------------------- /src/sisl/io/gulp/sile.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Define a common GULP Sile 8 | """ 9 | from sisl._internal import set_module 10 | 11 | from ..sile import Sile, SileBin 12 | 13 | __all__ = ["SileGULP", "SileBinGULP"] 14 | 15 | 16 | @set_module("sisl.io.gulp") 17 | class SileGULP(Sile): 18 | pass 19 | 20 | 21 | @set_module("sisl.io.gulp") 22 | class SileBinGULP(SileBin): 23 | pass 24 | -------------------------------------------------------------------------------- /src/sisl/io/gulp/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/io/gulp """ 7 | -------------------------------------------------------------------------------- /src/sisl/io/openmx/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | OpenMX 8 | ====== 9 | 10 | omxSileOpenMX - input file 11 | mdSileOpenMX 12 | """ 13 | from .sile import * # isort: split 14 | from .md import * 15 | from .omx import * 16 | -------------------------------------------------------------------------------- /src/sisl/io/openmx/md.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Sile object for reading OpenMX md files 8 | """ 9 | from sisl._internal import set_module 10 | 11 | from ..sile import add_sile 12 | from ..xyz import xyzSile 13 | from .sile import SileOpenMX 14 | 15 | __all__ = ["mdSileOpenMX"] 16 | 17 | 18 | @set_module("sisl.io.openmx") 19 | class mdSileOpenMX(xyzSile, SileOpenMX): 20 | pass 21 | 22 | 23 | add_sile("md", mdSileOpenMX, gzip=True) 24 | -------------------------------------------------------------------------------- /src/sisl/io/openmx/sile.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl._internal import set_module 7 | 8 | from ..sile import Sile, SileBin, SileCDF 9 | 10 | __all__ = ["SileOpenMX", "SileCDFOpenMX", "SileBinOpenMX"] 11 | 12 | 13 | @set_module("sisl.io.openmx") 14 | class SileOpenMX(Sile): 15 | pass 16 | 17 | 18 | @set_module("sisl.io.openmx") 19 | class SileCDFOpenMX(SileCDF): 20 | pass 21 | 22 | 23 | @set_module("sisl.io.openmx") 24 | class SileBinOpenMX(SileBin): 25 | pass 26 | -------------------------------------------------------------------------------- /src/sisl/io/orca/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | ORCA 8 | ==== 9 | 10 | stdoutSileORCA - ORCA output file 11 | txtSileORCA - ORCA property.txt file 12 | """ 13 | from .sile import * # isort: split 14 | from .stdout import * 15 | from .txt import * 16 | -------------------------------------------------------------------------------- /src/sisl/io/orca/sile.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl._internal import set_module 7 | 8 | from ..sile import Sile, SileBin 9 | 10 | __all__ = ["SileORCA", "SileBinORCA"] 11 | 12 | 13 | @set_module("sisl.io.orca") 14 | class SileORCA(Sile): 15 | pass 16 | 17 | 18 | @set_module("sisl.io.orca") 19 | class SileBinORCA(SileBin): 20 | pass 21 | -------------------------------------------------------------------------------- /src/sisl/io/orca/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/io/orca """ 7 | -------------------------------------------------------------------------------- /src/sisl/io/scaleup/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | ScaleUp 8 | ======= 9 | 10 | The interaction between sisl and `ScaleUp`_ allows constructing large TB models 11 | to be post-processed in the NEGF code `TBtrans`_. 12 | 13 | orboccSileScaleUp - orbital information 14 | refSileScaleUp - reference coordinates 15 | rhamSileScaleUp - Hamiltonian file 16 | 17 | """ 18 | from .sile import * # isort: split 19 | from .orbocc import * 20 | from .ref import * 21 | from .rham import * 22 | -------------------------------------------------------------------------------- /src/sisl/io/scaleup/orbocc.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | # Import sile objects 5 | # Import the geometry object 6 | from __future__ import annotations 7 | 8 | from sisl import Atom, Atoms 9 | 10 | from ..sile import * 11 | from .sile import SileScaleUp 12 | 13 | __all__ = ["orboccSileScaleUp"] 14 | 15 | 16 | class orboccSileScaleUp(SileScaleUp): 17 | """orbocc file object for ScaleUp""" 18 | 19 | @sile_fh_open() 20 | def read_basis(self) -> Atoms: 21 | """Reads a the atoms and returns an `Atoms` object""" 22 | self.readline() 23 | _, ns = map(int, self.readline().split()[:2]) 24 | species = self.readline().split()[:ns] # species 25 | orbs = self.readline().split()[:ns] # orbs per species 26 | # Create list of species with correct # of orbitals per specie 27 | species = [Atom(s, [-1] * int(o)) for s, o in zip(species, orbs)] 28 | return Atoms(species) 29 | 30 | 31 | add_sile("orbocc", orboccSileScaleUp, case=False, gzip=True) 32 | -------------------------------------------------------------------------------- /src/sisl/io/scaleup/sile.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Define a common ScaleUP Sile 8 | """ 9 | from sisl._internal import set_module 10 | 11 | from ..sile import Sile, SileBin 12 | 13 | __all__ = ["SileScaleUp", "SileBinScaleUp"] 14 | 15 | 16 | @set_module("sisl.io.scaleup") 17 | class SileScaleUp(Sile): 18 | pass 19 | 20 | 21 | @set_module("sisl.io.scaleup") 22 | class SileBinScaleUp(SileBin): 23 | pass 24 | -------------------------------------------------------------------------------- /src/sisl/io/siesta/_src/dm_write.f90: -------------------------------------------------------------------------------- 1 | ! This Source Code Form is subject to the terms of the Mozilla Public 2 | ! License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ! file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | subroutine write_dm(fname, nspin, no_u, nsc, nnz, ncol, list_col, DM) 5 | 6 | use precision, only: i4, r8 7 | use sparse_io_m, only: write_sparse, write_data_2d2 8 | use io_m, only: open_file, close_file 9 | use io_m, only: iostat_update 10 | 11 | implicit none 12 | 13 | ! Input parameters 14 | character(len=*), intent(in) :: fname 15 | integer(i4), intent(in) :: nspin, no_u, nsc(3), nnz 16 | integer(i4), intent(in) :: ncol(no_u), list_col(nnz) 17 | real(r8), intent(in) :: DM(nnz,nspin) 18 | 19 | ! Define f2py intents 20 | !f2py intent(in) :: fname 21 | !f2py intent(in) :: nspin, no_u, nsc, nnz 22 | !f2py intent(in) :: ncol, list_col 23 | !f2py intent(in) :: DM 24 | 25 | ! Internal variables and arrays 26 | integer :: iu, is, i, idx, ierr 27 | 28 | call open_file(fname, 'write', 'unknown', 'unformatted', iu) 29 | 30 | ! Also write the supercell. 31 | write(iu, iostat=ierr) no_u, nspin, nsc 32 | call iostat_update(ierr) 33 | 34 | ! Sparse pattern 35 | call write_sparse(iu, no_u, nnz, ncol, list_col) 36 | call write_data_2d2(iu, no_u, nspin, nnz, ncol, DM) 37 | 38 | call close_file(iu) 39 | 40 | end subroutine write_dm 41 | -------------------------------------------------------------------------------- /src/sisl/io/siesta/_src/precision.f90: -------------------------------------------------------------------------------- 1 | module precision 2 | 3 | implicit none 4 | 5 | integer, parameter :: r4 = selected_real_kind(6) 6 | integer, parameter :: r8 = selected_real_kind(15) 7 | integer, parameter :: i4 = selected_int_kind(6) 8 | integer, parameter :: i8 = selected_int_kind(18) 9 | 10 | end module precision 11 | -------------------------------------------------------------------------------- /src/sisl/io/siesta/_src/siesta_sc_off.f90: -------------------------------------------------------------------------------- 1 | ! This Source Code Form is subject to the terms of the Mozilla Public 2 | ! License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ! file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | subroutine siesta_sc_off(nsa, nsb, nsc, isc) 5 | integer, intent(in) :: nsa, nsb, nsc 6 | ! Sadly product requires -lgfortran 7 | ! and f2py assumes nsc(1) to be a function 8 | integer, intent(out) :: isc(3,nsa*nsb*nsc) 9 | 10 | integer :: x, y, z, i 11 | integer :: nx, ny, nz 12 | 13 | i = 0 14 | do z = 0, nsc - 1 15 | nz = linear2pm(z, nsc) 16 | do y = 0, nsb - 1 17 | ny = linear2pm(y, nsb) 18 | do x = 0, nsa - 1 19 | nx = linear2pm(x, nsa) 20 | i = i + 1 21 | isc(1,i) = nx 22 | isc(2,i) = ny 23 | isc(3,i) = nz 24 | end do 25 | end do 26 | end do 27 | 28 | contains 29 | 30 | pure function linear2pm(i,n) result(j) 31 | integer, intent(in) :: i, n 32 | integer :: j 33 | if ( i > n / 2 ) then 34 | j = -n + i 35 | else 36 | j = i 37 | end if 38 | end function linear2pm 39 | 40 | end subroutine siesta_sc_off 41 | -------------------------------------------------------------------------------- /src/sisl/io/siesta/ani.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Sile object for reading ANI files 8 | """ 9 | from sisl._internal import set_module 10 | 11 | from ..sile import add_sile 12 | from ..xyz import xyzSile 13 | from .sile import SileSiesta 14 | 15 | __all__ = ["aniSileSiesta"] 16 | 17 | 18 | @set_module("sisl.io.siesta") 19 | class aniSileSiesta(xyzSile, SileSiesta): 20 | pass 21 | 22 | 23 | add_sile("ANI", aniSileSiesta, gzip=True) 24 | -------------------------------------------------------------------------------- /src/sisl/io/siesta/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/io/siesta """ 7 | -------------------------------------------------------------------------------- /src/sisl/io/siesta/tests/test_fa.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | 9 | from sisl.io.siesta.fa import * 10 | 11 | pytestmark = [pytest.mark.io, pytest.mark.siesta] 12 | 13 | 14 | def test_si_pdos_kgrid_fa(sisl_files): 15 | f = sisl_files("siesta", "Si_pdos_k", "Si_pdos.FA") 16 | fa = faSileSiesta(f).read_data() 17 | 18 | assert len(fa) == 2 19 | fa1 = faSileSiesta(f).read_force() 20 | assert np.allclose(fa, fa1) 21 | 22 | 23 | def test_read_write_fa(sisl_tmp): 24 | f = sisl_tmp("test.FA") 25 | 26 | fa = np.random.rand(10, 3) 27 | faSileSiesta(f, "w").write_force(fa) 28 | fa2 = faSileSiesta(f).read_force() 29 | 30 | assert len(fa) == len(fa2) 31 | assert np.allclose(fa, fa2) 32 | -------------------------------------------------------------------------------- /src/sisl/io/siesta/tests/test_times.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | 9 | from sisl.io.siesta.times import * 10 | 11 | pytestmark = [pytest.mark.io, pytest.mark.siesta] 12 | 13 | 14 | def test_h2o_dipole_times(sisl_files): 15 | f1 = sisl_files("siesta", "H2O_dipole", "TIMES") 16 | f2 = sisl_files("siesta", "H2O_dipole", "h2o_dipole.times") 17 | t1 = timesSileSiesta(f1).read_data() 18 | t2 = timesSileSiesta(f2).read_data() 19 | 20 | assert np.allclose(t1.to_array(), t2.to_array()) 21 | -------------------------------------------------------------------------------- /src/sisl/io/siesta/tests/test_wfsx.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import pytest 7 | 8 | import sisl 9 | 10 | pytestmark = [pytest.mark.io, pytest.mark.siesta] 11 | 12 | 13 | def test_wfsx_read(sisl_files): 14 | fdf = sisl.get_sile(sisl_files("siesta", "Bi2Se3_3layer", "Bi2Se3.fdf")) 15 | wfsx = sisl.get_sile( 16 | sisl_files("siesta", "Bi2Se3_3layer", "Bi2Se3.bands.WFSX"), 17 | parent=fdf.read_geometry(), 18 | ) 19 | 20 | info = wfsx.read_info() 21 | sizes = wfsx.read_sizes() 22 | basis = wfsx.read_basis() 23 | 24 | # yield states 25 | nstates = 0 26 | nstates_total = 0 27 | for state in wfsx.yield_eigenstate(): 28 | nstates += 1 29 | nstates_total += len(state) 30 | # in this example we a SOC calculation, so we should not muliply by spin 31 | assert nstates == len(info[0]) 32 | assert nstates_total == info[2].sum() 33 | 34 | bz = wfsx.read_brillouinzone() 35 | assert len(bz) == 16 36 | -------------------------------------------------------------------------------- /src/sisl/io/tbtrans/binaries.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl._internal import set_module 7 | from sisl.io.siesta.binaries import _gfSileSiesta 8 | 9 | from ..sile import add_sile 10 | 11 | __all__ = ["tbtgfSileTBtrans"] 12 | 13 | 14 | dic = {} 15 | try: 16 | dic["__doc__"] = _gfSileSiesta.__doc__.replace( 17 | _gfSileSiesta.__name__, "tbtgfSileTBtrans" 18 | ) 19 | except Exception: 20 | pass 21 | 22 | tbtgfSileTBtrans = set_module("sisl.io.tbtrans")( 23 | type("tbtgfSileTBtrans", (_gfSileSiesta,), dic) 24 | ) 25 | del dic 26 | 27 | add_sile("TBTGF", tbtgfSileTBtrans) 28 | -------------------------------------------------------------------------------- /src/sisl/io/tbtrans/phtproj.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl._internal import set_module 7 | 8 | from ..sile import add_sile 9 | from .tbt import Ry2eV 10 | from .tbtproj import tbtprojncSileTBtrans 11 | 12 | __all__ = ["phtprojncSilePHtrans"] 13 | 14 | 15 | @set_module("sisl.io.phtrans") 16 | class phtprojncSilePHtrans(tbtprojncSileTBtrans): 17 | """PHtrans projection file object""" 18 | 19 | _trans_type = "PHT.Proj" 20 | _E2eV = Ry2eV**2 21 | 22 | 23 | add_sile("PHT.Proj.nc", phtprojncSilePHtrans) 24 | -------------------------------------------------------------------------------- /src/sisl/io/tbtrans/sile.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | from __future__ import annotations 6 | 7 | from sisl._internal import set_module 8 | from sisl.io.siesta import MissingFDFSiestaError 9 | 10 | from ..sile import Sile, SileBin, SileCDF, missing_input 11 | 12 | __all__ = [ 13 | "SileTBtrans", 14 | "SileCDFTBtrans", 15 | "SileBinTBtrans", 16 | "MissingFDFTBtransError", 17 | "missing_input_fdf", 18 | ] 19 | 20 | 21 | @set_module("sisl.io.tbtrans") 22 | class MissingFDFTBtransError(MissingFDFSiestaError): 23 | pass 24 | 25 | 26 | @set_module("sisl.io.tbtrans") 27 | def missing_input_fdf( 28 | inputs, executable: str = "siesta", when_exception: Exception = KeyError 29 | ): 30 | return missing_input(executable, inputs, MissingFDFTBtransError, when_exception) 31 | 32 | 33 | @set_module("sisl.io.tbtrans") 34 | class SileTBtrans(Sile): 35 | pass 36 | 37 | 38 | @set_module("sisl.io.tbtrans") 39 | class SileCDFTBtrans(SileCDF): 40 | # all netcdf output should not be masked 41 | def _setup(self, *args, **kwargs): 42 | super()._setup(*args, **kwargs) 43 | # all NetCDF routines actually returns masked arrays 44 | # this is to prevent TBtrans CDF files from doing this. 45 | if hasattr(self, "fh"): 46 | self.fh.set_auto_mask(False) 47 | 48 | 49 | @set_module("sisl.io.tbtrans") 50 | class SileBinTBtrans(SileBin): 51 | pass 52 | -------------------------------------------------------------------------------- /src/sisl/io/tbtrans/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/io/tbtrans """ 7 | -------------------------------------------------------------------------------- /src/sisl/io/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/io """ 7 | -------------------------------------------------------------------------------- /src/sisl/io/vasp/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | VASP 8 | ==== 9 | 10 | carSileVASP 11 | doscarSileVASP 12 | eigenvalSileVASP 13 | chgSileVASP 14 | locpotSileVASP 15 | outcarSileVASP 16 | 17 | """ 18 | from .sile import * # isort: split 19 | from .car import * 20 | from .chg import * 21 | from .doscar import * 22 | from .eigenval import * 23 | from .locpot import * 24 | from .outcar import * 25 | -------------------------------------------------------------------------------- /src/sisl/io/vasp/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/io/vasp """ 7 | -------------------------------------------------------------------------------- /src/sisl/io/vasp/tests/test_doscar.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | 9 | from sisl.io.vasp.doscar import * 10 | 11 | pytestmark = [pytest.mark.io, pytest.mark.vasp] 12 | 13 | 14 | def test_graphene_doscar(sisl_files): 15 | f = sisl_files("vasp", "graphene", "DOSCAR") 16 | E, DOS = doscarSileVASP(f).read_data() 17 | 18 | EHa, DOSHa = doscarSileVASP(f).read_data(units=("Ha", "Bohr")) 19 | assert not np.allclose(E, EHa) 20 | assert not np.allclose(DOS, DOSHa) 21 | -------------------------------------------------------------------------------- /src/sisl/io/vasp/tests/test_eigenval.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | 9 | from sisl.io.vasp.eigenval import * 10 | 11 | pytestmark = [pytest.mark.io, pytest.mark.vasp] 12 | 13 | 14 | def test_read_eigenval(sisl_files): 15 | f = sisl_files("vasp", "graphene", "EIGENVAL") 16 | eigs = eigenvalSileVASP(f).read_data() 17 | eigsHa = eigenvalSileVASP(f).read_data(units="Ha") 18 | assert not np.allclose(eigs, eigsHa) 19 | -------------------------------------------------------------------------------- /src/sisl/io/vasp/tests/test_locpot.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | 9 | from sisl.io.vasp.locpot import * 10 | 11 | pytestmark = [pytest.mark.io, pytest.mark.vasp] 12 | 13 | 14 | def test_graphene_locpot(sisl_files): 15 | f = sisl_files("vasp", "graphene", "LOCPOT") 16 | gridf64 = locpotSileVASP(f).read_grid() 17 | gridf32 = locpotSileVASP(f).read_grid(dtype=np.float32) 18 | geom = locpotSileVASP(f).read_geometry() 19 | 20 | assert gridf64.dtype == np.float64 21 | assert gridf32.dtype == np.float32 22 | assert geom == gridf32.geometry 23 | 24 | gridHa = locpotSileVASP(f).read_grid(units="Ha") 25 | assert not np.allclose(gridf64.grid, gridHa.grid) 26 | 27 | 28 | def test_graphene_locpot_index_float(sisl_files): 29 | f = sisl_files("vasp", "graphene", "LOCPOT") 30 | grid = locpotSileVASP(f).read_grid() 31 | gridh = locpotSileVASP(f).read_grid(index=[0.5]) 32 | 33 | assert grid.grid.sum() / 2 == pytest.approx(gridh.grid.sum()) 34 | -------------------------------------------------------------------------------- /src/sisl/io/wannier90/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Wannier90 8 | ========= 9 | 10 | Wannier90 interoperability is mainly targeted at extracting 11 | tight-binding models from Wannier90 output from *any* DFT code. 12 | 13 | winSileWannier90 -- input file 14 | 15 | """ 16 | from .sile import * # isort: split 17 | from .seedname import * 18 | -------------------------------------------------------------------------------- /src/sisl/io/wannier90/sile.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Define a common Wannier90 Sile 8 | """ 9 | from sisl._internal import set_module 10 | 11 | from ..sile import Sile, SileBin 12 | 13 | __all__ = ["SileWannier90", "SileBinWannier90"] 14 | 15 | 16 | @set_module("sisl.io.wannier90") 17 | class SileWannier90(Sile): 18 | pass 19 | 20 | 21 | @set_module("sisl.io.wannier90") 22 | class SileBinWannier90(SileBin): 23 | pass 24 | -------------------------------------------------------------------------------- /src/sisl/io/wannier90/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/io/wannier90 """ 7 | -------------------------------------------------------------------------------- /src/sisl/linalg/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Linear algebra 8 | ============== 9 | 10 | Although `numpy` and `scipy` provides a large set of 11 | linear algebra routines, sisl re-implements some of them with 12 | a reduced memory and/or computational effort. This is because 13 | `numpy.linalg` and `scipy.linalg` routines are defaulting 14 | to a large variety of checks to assert the input matrices. 15 | 16 | sisl implements its own variants which has interfaces much 17 | like `numpy` and `scipy`. 18 | 19 | inv 20 | solve 21 | eig 22 | eigh 23 | svd 24 | eigs 25 | eigsh 26 | 27 | """ 28 | from .base import * 29 | from .special import * 30 | -------------------------------------------------------------------------------- /src/sisl/linalg/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/linalg """ 7 | -------------------------------------------------------------------------------- /src/sisl/linalg/tests/test_inv.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | import scipy.linalg as sl 9 | 10 | from sisl.linalg import inv, inv_destroy 11 | 12 | pytestmark = [pytest.mark.linalg, pytest.mark.inv] 13 | 14 | 15 | def test_inv1(): 16 | np.random.seed(1204982) 17 | a = np.random.rand(10, 10) 18 | ac = a.copy() 19 | xs = sl.inv(a) 20 | x = inv(a) 21 | assert np.allclose(xs, x) 22 | assert np.allclose(a, ac) 23 | 24 | 25 | def test_inv_d1(): 26 | np.random.seed(1204982) 27 | a = np.random.rand(10, 10) 28 | xs = sl.inv(a) 29 | x = inv_destroy(a) 30 | assert np.allclose(xs, x) 31 | -------------------------------------------------------------------------------- /src/sisl/linalg/tests/test_solve.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | import scipy.linalg as sl 9 | 10 | from sisl.linalg import solve, solve_destroy 11 | 12 | pytestmark = [pytest.mark.linalg, pytest.mark.eig] 13 | 14 | 15 | def test_solve1(): 16 | np.random.seed(1285947159) 17 | a = np.random.rand(10, 10) 18 | b = np.random.rand(10, 10) 19 | xs = sl.solve(a, b) 20 | x = solve(a, b) 21 | assert np.allclose(xs, x) 22 | 23 | 24 | def test_solve2(): 25 | np.random.seed(1285947159) 26 | a = np.random.rand(10, 10) 27 | ac = a.copy() 28 | b = np.random.rand(10) 29 | bc = b.copy() 30 | xs = sl.solve(a, b) 31 | x = solve(a, b) 32 | assert np.allclose(xs, x) 33 | assert x.shape == (10,) 34 | assert np.allclose(a, ac) 35 | assert np.allclose(b, bc) 36 | 37 | 38 | def test_solve3(): 39 | np.random.seed(1285947159) 40 | a = np.random.rand(10, 2) 41 | b = np.random.rand(10) 42 | with pytest.raises(ValueError): 43 | solve(a, b) 44 | 45 | 46 | def test_solve4(): 47 | np.random.seed(1285947159) 48 | a = np.random.rand(10, 10) 49 | b = np.random.rand(10) 50 | xs = sl.solve(a, b) 51 | x = solve_destroy(a, b) 52 | assert np.allclose(xs, x) 53 | assert x.shape == (10,) 54 | -------------------------------------------------------------------------------- /src/sisl/mixing/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Mixing objects 8 | ============== 9 | 10 | Implementation of various mixing methods. 11 | 12 | Mixing methods are typical objects used for speeding up convergence 13 | for self-consistent methods. 14 | 15 | sisl implements a variety of the standard methods used in the electronic 16 | structure community and its easy implementations allows easy testing for 17 | new methods. 18 | """ 19 | 20 | from .base import * 21 | from .diis import * 22 | from .linear import * 23 | -------------------------------------------------------------------------------- /src/sisl/mixing/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/mixing """ 7 | -------------------------------------------------------------------------------- /src/sisl/mixing/tests/test_diis.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | 9 | from sisl.mixing import AdaptiveDIISMixer, DIISMixer 10 | 11 | pytestmark = pytest.mark.mixing 12 | 13 | 14 | @pytest.mark.parametrize("history", [2, 10]) 15 | def test_diis_mixer(history): 16 | # test for different history lengths 17 | def scf(f): 18 | return np.cos(f) 19 | 20 | f = np.linspace(0, 7, 1000) 21 | mix = DIISMixer(history=history) 22 | s = str(mix) 23 | 24 | dmax = 1 25 | i = 0 26 | while dmax > 1e-6: 27 | i += 1 28 | df = scf(f) - f 29 | dmax = np.fabs(df).max() 30 | f = mix(f, df) 31 | 32 | 33 | @pytest.mark.parametrize("history", [2, 10]) 34 | @pytest.mark.parametrize("weight", [0.5, (0.3, 0.7)]) 35 | def test_adiis_mixer(weight, history): 36 | # test for different history lengths 37 | def scf(f): 38 | return np.cos(f) 39 | 40 | f = np.linspace(0, 7, 1000) 41 | mix = AdaptiveDIISMixer(weight, history=history) 42 | 43 | dmax = 1 44 | i = 0 45 | while dmax > 1e-6: 46 | i += 1 47 | df = scf(f) - f 48 | dmax = np.fabs(df).max() 49 | f = mix(f, df) 50 | -------------------------------------------------------------------------------- /src/sisl/mixing/tests/test_history.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import pytest 7 | 8 | from sisl.mixing import History 9 | 10 | pytestmark = pytest.mark.mixing 11 | 12 | 13 | def test_simple(): 14 | hist = History(5) 15 | 16 | assert len(hist) == 0 17 | assert hist.max_elements == 5 18 | 19 | hist.append(1, 2) 20 | assert len(hist) == 1 21 | assert len(hist[0]) == 2 22 | hist.append(1, 2, 3) 23 | assert len(hist) == 2 24 | assert len(hist[0]) == 2 25 | assert len(hist[1]) == 3 26 | hist.append(1, 2, 3) 27 | assert len(hist) == 3 28 | assert len(hist[0]) == 2 29 | assert len(hist[1]) == 3 30 | assert len(hist[2]) == 3 31 | 32 | # test clear 33 | hist.clear(0) 34 | assert len(hist) == 2 35 | hist.append(1) 36 | assert len(hist) == 3 37 | hist.clear() 38 | assert len(hist) == 0 39 | -------------------------------------------------------------------------------- /src/sisl/physics/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # In this directory we have a set of libraries 2 | # We will need to link to the Numpy includes 3 | set_property(DIRECTORY 4 | APPEND 5 | PROPERTY INCLUDE_DIRECTORIES 6 | ${CMAKE_CURRENT_SOURCE_DIR}/.. 7 | ${CMAKE_CURRENT_SOURCE_DIR}/../_core 8 | ) 9 | 10 | foreach(source 11 | _bloch _phase 12 | _matrix_utils 13 | _matrix_k _matrix_dk _matrix_ddk 14 | _matrix_phase _matrix_phase_sc _matrix_phase3 15 | ) 16 | add_cython_library( 17 | SOURCE ${source}.pyx 18 | LIBRARY ${source} 19 | OUTPUT ${source}_C 20 | ) 21 | install(TARGETS ${source} LIBRARY 22 | DESTINATION ${SKBUILD_PROJECT_NAME}/physics) 23 | endforeach() 24 | -------------------------------------------------------------------------------- /src/sisl/physics/_common.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl.typing import GaugeType, ProjectionType 7 | 8 | __all__ = ["comply_gauge", "comply_projection"] 9 | 10 | 11 | def comply_gauge(gauge: GaugeType) -> str: 12 | """Comply the gauge to one of two words: atom | cell""" 13 | return { 14 | "R": "lattice", 15 | "cell": "lattice", 16 | "lattice": "lattice", 17 | "r": "atomic", 18 | "orbital": "atomic", 19 | "orbitals": "atomic", 20 | "atom": "atomic", 21 | "atoms": "atomic", 22 | "atomic": "atomic", 23 | }[gauge] 24 | 25 | 26 | def comply_projection(projection: ProjectionType) -> str: 27 | """Comply the projection to one of the allowed variants""" 28 | return { 29 | "matrix": "matrix", 30 | "ij": "matrix", 31 | "trace": "trace", 32 | "sum": "trace", 33 | "diagonal": "diagonal", 34 | "diag": "diagonal", 35 | "ii": "diagonal", 36 | "hadamard": "hadamard", 37 | "basis": "hadamard", 38 | "orbital": "hadamard", 39 | "orbitals": "hadamard", 40 | "hadamard:atoms": "hadamard:atoms", 41 | "atoms": "hadamard:atoms", 42 | "atom": "hadamard:atoms", 43 | }[projection] 44 | -------------------------------------------------------------------------------- /src/sisl/physics/_phase.pxd: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from sisl._core._dtypes cimport floats_st 5 | 6 | 7 | cdef bint is_gamma(const floats_st[::1] k) noexcept nogil 8 | -------------------------------------------------------------------------------- /src/sisl/physics/_ufuncs_densitymatrix.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl._ufuncs import register_sisl_dispatch 7 | from sisl.typing import SileLike 8 | 9 | from .densitymatrix import DensityMatrix 10 | 11 | # Nothing gets exposed here 12 | __all__ = [] 13 | 14 | 15 | @register_sisl_dispatch(DensityMatrix, module="sisl.physics") 16 | def write(dm: DensityMatrix, sile: SileLike, *args, **kwargs) -> None: 17 | """Writes a density matrix to the `Sile` as implemented in the :code:`Sile.write_density_matrix` method""" 18 | # This only works because, they *must* 19 | # have been imported previously 20 | from sisl.io import BaseSile, get_sile 21 | 22 | if isinstance(sile, BaseSile): 23 | sile.write_density_matrix(dm, *args, **kwargs) 24 | else: 25 | with get_sile(sile, mode="w") as fh: 26 | fh.write_density_matrix(dm, *args, **kwargs) 27 | -------------------------------------------------------------------------------- /src/sisl/physics/_ufuncs_dynamicalmatrix.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl._ufuncs import register_sisl_dispatch 7 | from sisl.typing import SileLike 8 | 9 | from .dynamicalmatrix import DynamicalMatrix 10 | 11 | # Nothing gets exposed here 12 | __all__ = [] 13 | 14 | 15 | @register_sisl_dispatch(DynamicalMatrix, module="sisl.physics") 16 | def write(dyn: DynamicalMatrix, sile: SileLike, *args, **kwargs) -> None: 17 | """Writes a dynamical matrix to the `Sile` as implemented in the :code:`Sile.write_dynamical_matrix` method""" 18 | # This only works because, they *must* 19 | # have been imported previously 20 | from sisl.io import BaseSile, get_sile 21 | 22 | if isinstance(sile, BaseSile): 23 | sile.write_dynamical_matrix(dyn, *args, **kwargs) 24 | else: 25 | with get_sile(sile, mode="w") as fh: 26 | fh.write_dynamical_matrix(dyn, *args, **kwargs) 27 | -------------------------------------------------------------------------------- /src/sisl/physics/_ufuncs_energydensitymatrix.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl._ufuncs import register_sisl_dispatch 7 | from sisl.typing import SileLike 8 | 9 | from .energydensitymatrix import EnergyDensityMatrix 10 | 11 | # Nothing gets exposed here 12 | __all__ = [] 13 | 14 | 15 | @register_sisl_dispatch(EnergyDensityMatrix, module="sisl.physics") 16 | def write(edm: EnergyDensityMatrix, sile: SileLike, *args, **kwargs) -> None: 17 | """Writes an energy density matrix to the `Sile` as implemented in the :code:`Sile.write_energy_density_matrix` method""" 18 | # This only works because, they *must* 19 | # have been imported previously 20 | from sisl.io import BaseSile, get_sile 21 | 22 | if isinstance(sile, BaseSile): 23 | sile.write_energy_density_matrix(edm, *args, **kwargs) 24 | else: 25 | with get_sile(sile, mode="w") as fh: 26 | fh.write_energy_density_matrix(edm, *args, **kwargs) 27 | -------------------------------------------------------------------------------- /src/sisl/physics/_ufuncs_hamiltonian.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl._ufuncs import register_sisl_dispatch 7 | from sisl.typing import SileLike 8 | 9 | from .hamiltonian import Hamiltonian 10 | 11 | # Nothing gets exposed here 12 | __all__ = [] 13 | 14 | 15 | @register_sisl_dispatch(Hamiltonian, module="sisl.physics") 16 | def write(H: Hamiltonian, sile: SileLike, *args, **kwargs) -> None: 17 | """Writes a Hamiltonian to the `Sile` as implemented in the :code:`Sile.write_hamiltonian` method""" 18 | # This only works because, they *must* 19 | # have been imported previously 20 | from sisl.io import BaseSile, get_sile 21 | 22 | if isinstance(sile, BaseSile): 23 | sile.write_hamiltonian(H, *args, **kwargs) 24 | else: 25 | with get_sile(sile, mode="w") as fh: 26 | fh.write_hamiltonian(H, *args, **kwargs) 27 | -------------------------------------------------------------------------------- /src/sisl/physics/_ufuncs_overlap.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl._ufuncs import register_sisl_dispatch 7 | from sisl.typing import SileLike 8 | 9 | from .overlap import Overlap 10 | 11 | # Nothing gets exposed here 12 | __all__ = [] 13 | 14 | 15 | @register_sisl_dispatch(Overlap, module="sisl.physics") 16 | def write(S: Overlap, sile: SileLike, *args, **kwargs) -> None: 17 | """Writes the Overlap to the `Sile` as implemented in the :code:`Sile.write_overlap` method""" 18 | # This only works because, they *must* 19 | # have been imported previously 20 | from sisl.io import BaseSile, get_sile 21 | 22 | if isinstance(sile, BaseSile): 23 | sile.write_overlap(S, *args, **kwargs) 24 | else: 25 | with get_sile(sile, mode="w") as fh: 26 | fh.write_overlap(S, *args, **kwargs) 27 | -------------------------------------------------------------------------------- /src/sisl/physics/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/physics """ 7 | -------------------------------------------------------------------------------- /src/sisl/physics/tests/test_electron.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | 9 | from sisl import Atom, Geometry, Hamiltonian, HydrogenicOrbital 10 | 11 | pytestmark = [pytest.mark.physics] 12 | 13 | 14 | def test_EigenstateElectron_norm2(): 15 | pz = HydrogenicOrbital(2, 1, 0, 3.2) 16 | C1 = Atom(6, (pz)) 17 | C2 = Atom(6, (pz, pz)) 18 | na = 4 19 | xyz = np.zeros((na, 3)) 20 | xyz[:, 0] = 1.42 * np.arange(na) 21 | g = Geometry(xyz, atoms=(C1, C2)) 22 | H = Hamiltonian(g) 23 | for i in range(H.no - 1): 24 | H[i, i + 1] = -2.7 25 | H[i + 1, i] = -2.7 26 | 27 | state = H.eigenstate() 28 | assert len(state) == H.no 29 | assert state.norm2()[0] == pytest.approx(1) 30 | assert state.norm2().shape == (H.no,) 31 | for p in ("diagonal", "orbital", "atom"): 32 | assert state.norm2(projection=p).sum() == pytest.approx(H.no) 33 | 34 | ns = 3 35 | state3 = state.sub(range(ns)) 36 | assert state3.norm2(projection="trace").ndim == 0 37 | assert state3.norm2(projection="diagonal").shape == (ns,) 38 | assert state3.norm2(projection="orbital").shape == (ns, H.no) 39 | assert state3.norm2(projection="atom").shape == (ns, H.na) 40 | assert state3.norm2(projection="atom").sum() == pytest.approx(ns) 41 | -------------------------------------------------------------------------------- /src/sisl/physics/tests/test_feature.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | 9 | from sisl import Atom, Geometry, Hamiltonian, Lattice 10 | from sisl.physics import yield_manifolds 11 | 12 | pytestmark = [pytest.mark.physics, pytest.mark.physics_feature] 13 | 14 | 15 | def test_yield_manifolds_eigenvalues(): 16 | g = Geometry( 17 | [[i, 0, 0] for i in range(10)], 18 | Atom(6, R=1.01), 19 | lattice=Lattice([10, 1, 5.0], nsc=[3, 3, 1]), 20 | ) 21 | H = Hamiltonian(g, dtype=np.float64) 22 | H.construct([(0.1, 1.5), (1.0, 0.1)]) 23 | 24 | all_manifolds = [] 25 | for manifold in yield_manifolds(H.eigh()): 26 | all_manifolds.extend(manifold) 27 | 28 | assert np.allclose(all_manifolds, np.arange(len(H))) 29 | 30 | all_manifolds = [] 31 | for manifold in yield_manifolds(H.tile(2, 0).eigh()): 32 | all_manifolds.extend(manifold) 33 | 34 | assert np.allclose(all_manifolds, np.arange(len(H) * 2)) 35 | -------------------------------------------------------------------------------- /src/sisl/shape/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Shapes 8 | ====== 9 | 10 | A variety of default shapes. 11 | 12 | All shapes inherit the `Shape` class. 13 | 14 | All shapes in sisl allows one to perform arithmetic on them. 15 | I.e. one may *add* two shapes to accomblish what would be equivalent 16 | to an ``&`` operation. The resulting shape will be a ``CompositeShape`` which 17 | implements the necessary routines to ensure correct operation. 18 | 19 | Currently these mathematical/boolean operators are implemented: 20 | 21 | `A & B` 22 | intersection of shapes 23 | 24 | `A | B` or `A + B` 25 | union of shapes 26 | 27 | `A ^ B` 28 | the disjunction union 29 | 30 | `A - B` 31 | complementary shape 32 | 33 | Shape - base class 34 | Cuboid - 3d cube 35 | Cube - 3d box 36 | Ellipsoid 37 | Sphere 38 | EllipticalCylinder 39 | NullShape 40 | 41 | """ 42 | from ._cylinder import * 43 | from .base import * 44 | from .ellipsoid import * 45 | from .prism4 import * 46 | 47 | __all__ = [s for s in dir() if not s.startswith("_")] 48 | -------------------------------------------------------------------------------- /src/sisl/shape/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/shape """ 7 | -------------------------------------------------------------------------------- /src/sisl/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl """ 7 | -------------------------------------------------------------------------------- /src/sisl/tests/test_package.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import pytest 7 | 8 | import sisl 9 | 10 | pytestmark = pytest.mark.version 11 | 12 | 13 | def test_version(): 14 | sisl.__bibtex__ 15 | sisl.__version__ 16 | 17 | 18 | def test_import_simple(): 19 | # The imports should only be visible in the io module 20 | sisl.BaseSile 21 | sisl.Sile 22 | sisl.SileCDF 23 | sisl.SileBin 24 | sisl.io.xyzSile 25 | 26 | 27 | def test_submodule_attr_access(): 28 | for mod in ( 29 | "geom", 30 | "io", 31 | "physics", 32 | "linalg", 33 | "shape", 34 | "mixing", 35 | "utils", 36 | "unit", 37 | "C", 38 | "constant", 39 | ): 40 | getattr(sisl, mod) 41 | 42 | 43 | def test_submodule_attr_access_viz(): 44 | pytest.importorskip("plotly") 45 | sisl.viz 46 | 47 | 48 | def test_import_in_io(): 49 | # The imports should only be visible in the io module 50 | with pytest.raises(AttributeError): 51 | sisl.xyzSile 52 | 53 | 54 | def test_import_in_io_from(): 55 | # The imports should only be visible in the io module 56 | with pytest.raises(ImportError): 57 | from sisl import xyzSile # noqa: F401 58 | 59 | 60 | @pytest.mark.parametrize("obj", [dict(), 2]) 61 | def test_dispatch_methods_not_allowed(obj): 62 | with pytest.raises(sisl.SislError): 63 | sisl.tile(obj, 0, 2) 64 | -------------------------------------------------------------------------------- /src/sisl/typing/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from ._atom import * 7 | from ._common import * 8 | from ._core import * 9 | from ._indices import * 10 | from ._physics import * 11 | from ._units import * 12 | -------------------------------------------------------------------------------- /src/sisl/typing/_atom.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from collections.abc import Sequence 7 | from typing import TYPE_CHECKING, Union 8 | 9 | # To prevent import cycles place any internal imports in the branch below 10 | # and use a string literal forward reference to it in subsequent types 11 | # https://mypy.readthedocs.io/en/latest/common_issues.html#import-cycles 12 | if TYPE_CHECKING: 13 | from sisl import Atom, Atoms 14 | 15 | __all__ = [ 16 | "AtomLike", 17 | "AtomsLike", 18 | ] 19 | 20 | 21 | # A definition of a type that can be parsed to an Atom object 22 | # It should be anything that the Atom can accept instead of Z 23 | AtomLike = Union[int, str, "Atom"] 24 | AtomsLike = Union[AtomLike, Sequence[AtomLike], "Atoms"] 25 | -------------------------------------------------------------------------------- /src/sisl/typing/_units.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from collections.abc import Mapping, Sequence 7 | from typing import Union 8 | 9 | __all__ = ["UnitsVar"] 10 | 11 | UnitsVar = Union[str, Mapping[str, str], Sequence[str]] 12 | -------------------------------------------------------------------------------- /src/sisl/typing/tests/test_typing.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import pytest 7 | 8 | import sisl.typing as st 9 | 10 | pytestmark = pytest.mark.typing 11 | 12 | 13 | def test_argument(): 14 | def func(a: st.AtomsIndex): 15 | str(a) 16 | -------------------------------------------------------------------------------- /src/sisl/unit/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/unit """ 7 | -------------------------------------------------------------------------------- /src/sisl/unit/tests/test_codata.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import pytest 7 | 8 | from sisl.unit.codata import read_codata 9 | 10 | pytestmark = pytest.mark.unit 11 | 12 | 13 | @pytest.mark.parametrize("year", (2010, 2014, 2018, 2022)) 14 | def test_codata(year): 15 | codata = read_codata(year) 16 | assert codata["year"] == f"{year}" 17 | -------------------------------------------------------------------------------- /src/sisl/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Utility routines 8 | ================ 9 | 10 | Several utility functions are used throughout sisl. 11 | 12 | Range routines 13 | ============== 14 | 15 | strmap 16 | strseq 17 | lstranges 18 | erange 19 | list2str 20 | fileindex 21 | 22 | Miscellaneous routines 23 | ====================== 24 | 25 | str_spec 26 | direction - abc/012 -> 012 27 | angle - radian to degree 28 | listify 29 | iter_shape 30 | math_eval 31 | batched_indices 32 | 33 | """ 34 | from . import mathematics as math 35 | from ._arrays import * 36 | from .cmd import * 37 | from .misc import * 38 | from .ranges import * 39 | -------------------------------------------------------------------------------- /src/sisl/utils/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ tests for sisl/utils """ 7 | -------------------------------------------------------------------------------- /src/sisl/utils/tests/test_arrays.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | 9 | from sisl.utils._arrays import * 10 | 11 | pytestmark = pytest.mark.utils 12 | 13 | 14 | def test_batched_indices_2d(): 15 | ref = np.random.rand(10, 3) 16 | y = ref[[0, 3, 5]] 17 | assert np.allclose(batched_indices(ref, y)[0], [0, 3, 5]) 18 | assert np.allclose(batched_indices(ref, y[1])[0], [3]) 19 | 20 | 21 | def test_batched_indices_3d(): 22 | ref = np.random.rand(10, 3, 3) 23 | y = np.random.rand(3, 3) 24 | y = ref[[0, 3, 5], [0, 1, 2]] 25 | idx = batched_indices(ref, y) 26 | assert np.allclose(idx[0], [0, 3, 5]) 27 | assert np.allclose(idx[1], [0, 1, 2]) 28 | -------------------------------------------------------------------------------- /src/sisl/viz/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Visualization utilities 8 | ======================= 9 | 10 | """ 11 | 12 | try: 13 | import nodify as _ # noqa: F401 14 | except ModuleNotFoundError as e: 15 | raise ModuleNotFoundError( 16 | """\ 17 | sisl.viz requires additional packages. 18 | Install them with pip: 19 | pip install sisl[viz] 20 | Or conda (only possible if inside a conda environment): 21 | conda install nodify plotly netCDF4 scikit-image pathos 22 | """ 23 | ) from e 24 | 25 | # Placeholders for 'plot' attributes are set in the classes while 26 | # sisl.viz is not loaded. Now we are loading it, so just remove those 27 | # placeholders. 28 | from sisl._lazy_viz import clear_viz_placeholders 29 | 30 | clear_viz_placeholders() 31 | 32 | del clear_viz_placeholders 33 | 34 | from . import _xarray_accessor 35 | from ._plotables import register_plotable 36 | from ._plotables_register import * 37 | from .figure import Figure, get_figure 38 | from .plot import Plot 39 | from .plots import * 40 | from .plotters import plot_actions 41 | -------------------------------------------------------------------------------- /src/sisl/viz/_presets.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """Presets are not used for now, but I would like to use them again at some point""" 7 | 8 | __all__ = ["add_presets", "get_preset"] 9 | 10 | PRESETS = { 11 | "dark": { 12 | "layout": {"template": "sisl_dark"}, 13 | "bands_color": "#ccc", 14 | "bands_width": 2, 15 | }, 16 | } 17 | 18 | 19 | def add_presets(**presets): 20 | """ 21 | Registers new presets 22 | 23 | Parameters 24 | ---------- 25 | **presets: 26 | as many as you want. Each preset is a dict. 27 | """ 28 | PRESETS.update(presets) 29 | 30 | 31 | def get_preset(name): 32 | """ 33 | Gets the asked preset. 34 | 35 | Parameters 36 | ----------- 37 | name: str 38 | the name of the preset that you are looking for 39 | """ 40 | return PRESETS.get(name, None) 41 | -------------------------------------------------------------------------------- /src/sisl/viz/_single_dispatch.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | # This is a single dispatch method that works with class methods that have annotations. 5 | # TODO when forward refs work with annontations 6 | # from __future__ import annotations 7 | 8 | from functools import singledispatchmethod as real_singledispatchmethod 9 | 10 | 11 | class singledispatchmethod(real_singledispatchmethod): 12 | def register(self, cls, method=None): 13 | if hasattr(cls, "__func__"): 14 | setattr(cls, "__annotations__", cls.__func__.__annotations__) 15 | return self.dispatcher.register(cls, func=method) 16 | 17 | def __get__(self, obj, cls=None): 18 | _method = super().__get__(obj, cls) 19 | _method.dispatcher = self.dispatcher 20 | return _method 21 | -------------------------------------------------------------------------------- /src/sisl/viz/data/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from .bands import BandsData 7 | from .data import Data 8 | from .eigenstate import EigenstateData 9 | from .pdos import PDOSData 10 | from .sisl_objs import GeometryData, GridData, HamiltonianData 11 | from .xarray import XarrayData 12 | -------------------------------------------------------------------------------- /src/sisl/viz/data/data.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from typing import Any, Union, get_args, get_origin, get_type_hints 7 | 8 | 9 | class Data: 10 | """Base data class""" 11 | 12 | _data: Any 13 | 14 | def __init__(self, data): 15 | if isinstance(data, self.__class__): 16 | data = data._data 17 | 18 | self._data = data 19 | 20 | def sanity_check(self): 21 | def is_valid(data, expected_type) -> bool: 22 | if expected_type is Any: 23 | return True 24 | 25 | return isinstance(data, expected_type) 26 | 27 | expected_type = get_type_hints(self.__class__)["_data"] 28 | if get_origin(expected_type) is Union: 29 | valid = False 30 | for valid_type in get_args(expected_type): 31 | valid = valid | is_valid(self._data, valid_type) 32 | 33 | else: 34 | valid = is_valid(self._data, expected_type) 35 | 36 | assert ( 37 | valid 38 | ), f"Data must be of type {expected_type} but is {type(self._data).__name__}" 39 | 40 | def __getattr__(self, key): 41 | return getattr(self._data, key) 42 | 43 | def __dir__(self): 44 | return dir(self._data) 45 | -------------------------------------------------------------------------------- /src/sisl/viz/data/sisl_objs.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from typing import Any, get_type_hints 7 | 8 | from sisl import Geometry, Grid, Hamiltonian 9 | 10 | from .data import Data 11 | 12 | 13 | class SislObjData(Data): 14 | """Base class for sisl objects""" 15 | 16 | def __instancecheck__(self, instance: Any) -> bool: 17 | expected_type = get_type_hints(self.__class__)["_data"] 18 | return isinstance(instance, expected_type) 19 | 20 | def __subclasscheck__(self, subclass: Any) -> bool: 21 | expected_type = get_type_hints(self.__class__)["_data"] 22 | return issubclass(subclass, expected_type) 23 | 24 | 25 | class GeometryData(Data): 26 | """Geometry data class""" 27 | 28 | _data: Geometry 29 | 30 | 31 | class GridData(Data): 32 | """Grid data class""" 33 | 34 | _data: Grid 35 | 36 | 37 | class HamiltonianData(Data): 38 | """Hamiltonian data class""" 39 | 40 | _data: Hamiltonian 41 | -------------------------------------------------------------------------------- /src/sisl/viz/data/tests/.coverage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zerothi/sisl/1899f26d79c72b14d28c3206c389851055b4be19/src/sisl/viz/data/tests/.coverage -------------------------------------------------------------------------------- /src/sisl/viz/data/xarray.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from typing import Union 7 | 8 | from xarray import DataArray, Dataset 9 | 10 | from .data import Data 11 | 12 | 13 | class XarrayData(Data): 14 | _data: Union[DataArray, Dataset] 15 | 16 | def __init__(self, data: Union[DataArray, Dataset]): 17 | super().__init__(data) 18 | 19 | def __getattr__(self, key): 20 | sisl_accessor = self._data.sisl 21 | 22 | if hasattr(sisl_accessor, key): 23 | return getattr(sisl_accessor, key) 24 | 25 | return getattr(self._data, key) 26 | 27 | def __dir__(self): 28 | return dir(self._data.sisl) + dir(self._data) 29 | 30 | 31 | class OrbitalData(XarrayData): 32 | pass 33 | -------------------------------------------------------------------------------- /src/sisl/viz/data_sources/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from .atom_data import * 7 | from .bond_data import * 8 | from .data_source import * 9 | from .eigenstate_data import * 10 | from .file import * 11 | from .hamiltonian_source import * 12 | from .orbital_data import * 13 | -------------------------------------------------------------------------------- /src/sisl/viz/data_sources/data_source.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from nodify import Node 7 | 8 | 9 | class DataSource(Node): 10 | """Generic class for data sources. 11 | 12 | Data sources are a way of specifying and manipulating data without providing it explicitly. 13 | Data sources can be passed to the settings of the plots as if they were arrays. 14 | When the plot is being created, the data source receives the necessary inputs and is evaluated using 15 | its ``get`` method. 16 | 17 | Therefore, passing a data source is like passing a function that will receive 18 | inputs and calculate the values needed on the fly. However, it has some extra functionality. You can 19 | perform operations with a data source. These operations will be evaluated lazily, that is, when 20 | inputs are provided. That allows for very convenient manipulation of the data. 21 | 22 | Data sources are also useful for graphical interfaces, where the user is unable to explicitly 23 | pass a function. Some of them are 24 | """ 25 | 26 | pass 27 | -------------------------------------------------------------------------------- /src/sisl/viz/data_sources/eigenstate_data.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from typing import Literal 7 | 8 | import xarray as xr 9 | 10 | from .data_source import DataSource 11 | 12 | 13 | class EigenstateData(DataSource): 14 | pass 15 | 16 | 17 | def spin_moments_from_dataset( 18 | axis: Literal["x", "y", "z"], data: xr.Dataset 19 | ) -> xr.DataArray: 20 | if "spin_moments" not in data: 21 | raise ValueError("The dataset does not contain spin moments") 22 | 23 | spin_moms = data.spin_moments.sel(axis=axis) 24 | spin_moms = spin_moms.rename(f"spin_moments_{axis}") 25 | return spin_moms 26 | 27 | 28 | class SpinMoment(EigenstateData): 29 | function = staticmethod(spin_moments_from_dataset) 30 | -------------------------------------------------------------------------------- /src/sisl/viz/data_sources/file/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from .file_source import * 7 | from .siesta import * 8 | -------------------------------------------------------------------------------- /src/sisl/viz/data_sources/file/file_source.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from pathlib import Path 7 | 8 | import sisl 9 | 10 | from ..data_source import DataSource 11 | 12 | 13 | class FileData(DataSource): 14 | """Generic data source for reading data from a file. 15 | 16 | The aim of this class is twofold: 17 | - Standarize the way data sources read files. 18 | - Provide automatic updating features when the read files are updated. 19 | """ 20 | 21 | def __init__(self, **kwargs): 22 | super().__init__(**kwargs) 23 | self._files_to_read = [] 24 | 25 | def follow_file(self, path): 26 | self._files_to_read.append(Path(path).resolve()) 27 | 28 | def get_sile(self, path, **kwargs): 29 | """A wrapper around get_sile so that the reading of the file is registered""" 30 | self.follow_file(path) 31 | return sisl.get_sile(path, **kwargs) 32 | 33 | def function(self, **kwargs): 34 | if isinstance(kwargs.get("path"), sisl.io.BaseSile): 35 | kwargs["path"] = kwargs["path"].file 36 | return self.get_sile(**kwargs) 37 | -------------------------------------------------------------------------------- /src/sisl/viz/data_sources/hamiltonian_source.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from pathlib import Path 7 | 8 | import sisl 9 | 10 | from .data_source import DataSource 11 | from .file.siesta import FileData 12 | 13 | 14 | class HamiltonianDataSource(DataSource): 15 | def __init__(self, H=None, kwargs={}): 16 | super().__init__(H=H, kwargs=kwargs) 17 | 18 | def get_hamiltonian(self, H, **kwargs): 19 | """Setup the Hamiltonian object. 20 | 21 | Parameters 22 | ---------- 23 | H : sisl.Hamiltonian 24 | The Hamiltonian object to be setup. 25 | """ 26 | 27 | if isinstance(H, (str, Path)): 28 | H = FileData(path=H) 29 | if isinstance(H, (sisl.io.BaseSile)): 30 | H = H.read_hamiltonian(**kwargs) 31 | 32 | if H is None: 33 | raise ValueError("No hamiltonian found.") 34 | 35 | return H 36 | 37 | def function(self, H, kwargs): 38 | return self.get_hamiltonian(H=H, **kwargs) 39 | -------------------------------------------------------------------------------- /src/sisl/viz/data_sources/orbital_data.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | 8 | from ..plotutils import random_color 9 | from .data_source import DataSource 10 | 11 | # from ..processors.orbital import reduce_orbital_data, get_orbital_request_sanitizer 12 | 13 | 14 | class OrbitalData(DataSource): 15 | pass 16 | 17 | 18 | def style_fatbands(data, groups=[{}]): 19 | # Get the function that is going to convert our request to something that can actually 20 | # select orbitals from the xarray object. 21 | _sanitize_request = get_orbital_request_sanitizer( 22 | data, 23 | gens={ 24 | "color": lambda req: req.get("color") or random_color(), 25 | }, 26 | ) 27 | 28 | styled = reduce_orbital_data( 29 | data, 30 | groups, 31 | orb_dim="orb", 32 | spin_dim="spin", 33 | sanitize_group=_sanitize_request, 34 | group_vars=("color", "dash"), 35 | groups_dim="group", 36 | drop_empty=True, 37 | spin_reduce=np.sum, 38 | ) 39 | 40 | return styled # .color 41 | 42 | 43 | class FatbandsData(OrbitalData): 44 | function = staticmethod(style_fatbands) 45 | -------------------------------------------------------------------------------- /src/sisl/viz/plots/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ 7 | Module containing all sisl-provided plots, both in a functional form and as Workflows. 8 | """ 9 | 10 | from .bands import BandsPlot, FatbandsPlot, bands_plot, fatbands_plot 11 | from .geometry import GeometryPlot, SitesPlot, geometry_plot, sites_plot 12 | from .grid import GridPlot, WavefunctionPlot, grid_plot, wavefunction_plot 13 | from .matrix import AtomicMatrixPlot, atomic_matrix_plot 14 | from .merged import animation, merge_plots, subplots 15 | from .pdos import PdosPlot, pdos_plot 16 | -------------------------------------------------------------------------------- /src/sisl/viz/plots/tests/.coverage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zerothi/sisl/1899f26d79c72b14d28c3206c389851055b4be19/src/sisl/viz/plots/tests/.coverage -------------------------------------------------------------------------------- /src/sisl/viz/plots/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | from __future__ import annotations 4 | -------------------------------------------------------------------------------- /src/sisl/viz/plots/tests/test_bands.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import pytest 7 | 8 | from sisl import Spin 9 | from sisl.viz.data import BandsData 10 | from sisl.viz.plots import bands_plot 11 | 12 | pytestmark = [pytest.mark.viz, pytest.mark.plots] 13 | 14 | 15 | @pytest.fixture(scope="module", params=["plotly", "matplotlib"]) 16 | def backend(request): 17 | pytest.importorskip(request.param) 18 | return request.param 19 | 20 | 21 | @pytest.fixture( 22 | scope="module", params=["unpolarized", "polarized", "noncolinear", "spinorbit"] 23 | ) 24 | def spin(request): 25 | return Spin(request.param) 26 | 27 | 28 | @pytest.fixture(scope="module") 29 | def gap(): 30 | return 2.5 31 | 32 | 33 | @pytest.fixture(scope="module") 34 | def bands_data(spin, gap): 35 | return BandsData.toy_example(spin=spin, gap=gap) 36 | 37 | 38 | def test_bands_plot(bands_data, backend): 39 | bands_plot(bands_data, backend=backend) 40 | -------------------------------------------------------------------------------- /src/sisl/viz/plots/tests/test_geometry.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import pytest 7 | 8 | import sisl 9 | from sisl.viz.plots import geometry_plot 10 | 11 | pytestmark = [pytest.mark.viz, pytest.mark.plots] 12 | 13 | 14 | @pytest.fixture(scope="module", params=["plotly", "matplotlib"]) 15 | def backend(request): 16 | pytest.importorskip(request.param) 17 | return request.param 18 | 19 | 20 | @pytest.fixture(scope="module", params=["x", "xy", "xyz"]) 21 | def axes(request): 22 | return request.param 23 | 24 | 25 | @pytest.fixture(scope="module") 26 | def geometry(): 27 | return sisl.geom.graphene() 28 | 29 | 30 | def test_geometry_plot(geometry, axes, backend): 31 | if axes == "xyz" and backend == "matplotlib": 32 | with pytest.raises(NotImplementedError): 33 | geometry_plot(geometry, axes=axes, backend=backend) 34 | else: 35 | geometry_plot(geometry, axes=axes, backend=backend) 36 | -------------------------------------------------------------------------------- /src/sisl/viz/plots/tests/test_grid.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | 9 | import sisl 10 | from sisl import Grid 11 | from sisl.viz.plots import grid_plot 12 | 13 | pytestmark = [pytest.mark.viz, pytest.mark.plots] 14 | 15 | 16 | @pytest.fixture(scope="module", params=["plotly", "matplotlib"]) 17 | def backend(request): 18 | pytest.importorskip(request.param) 19 | return request.param 20 | 21 | 22 | @pytest.fixture(scope="module", params=["x", "xy", "xyz"]) 23 | def axes(request): 24 | return request.param 25 | 26 | 27 | @pytest.fixture(scope="module") 28 | def grid(): 29 | geometry = sisl.geom.graphene() 30 | grid = Grid((10, 10, 10), geometry=geometry) 31 | 32 | grid.grid[:] = np.linspace(0, 1000, 1000).reshape(10, 10, 10) 33 | return grid 34 | 35 | 36 | def test_grid_plot(grid, axes, backend): 37 | if axes == "xyz" and backend == "matplotlib": 38 | with pytest.raises(NotImplementedError): 39 | grid_plot(grid, axes=axes, backend=backend) 40 | else: 41 | grid_plot(grid, axes=axes, backend=backend) 42 | -------------------------------------------------------------------------------- /src/sisl/viz/plots/tests/test_matrix.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import pytest 7 | 8 | import sisl 9 | from sisl.viz.plots import atomic_matrix_plot 10 | 11 | 12 | def test_atomic_matrix_plot(): 13 | pytest.importorskip("skimage", reason="scikit-image not importable") 14 | 15 | graphene = sisl.geom.graphene() 16 | H = sisl.Hamiltonian(graphene) 17 | 18 | atomic_matrix_plot(H) 19 | -------------------------------------------------------------------------------- /src/sisl/viz/plots/tests/test_pdos.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import pytest 7 | 8 | from sisl import Spin 9 | from sisl.viz.data import PDOSData 10 | from sisl.viz.plots import pdos_plot 11 | 12 | pytestmark = [pytest.mark.viz, pytest.mark.plots] 13 | 14 | 15 | @pytest.fixture(scope="module", params=["plotly", "matplotlib"]) 16 | def backend(request): 17 | pytest.importorskip(request.param) 18 | return request.param 19 | 20 | 21 | @pytest.fixture( 22 | scope="module", params=["unpolarized", "polarized", "noncolinear", "spinorbit"] 23 | ) 24 | def spin(request): 25 | return Spin(request.param) 26 | 27 | 28 | @pytest.fixture(scope="module") 29 | def pdos_data(spin): 30 | return PDOSData.toy_example(spin=spin) 31 | 32 | 33 | def test_pdos_plot(pdos_data, backend): 34 | pdos_plot(pdos_data, backend=backend) 35 | -------------------------------------------------------------------------------- /src/sisl/viz/plotters/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """Functions that generate plot actions to be passed to figures.""" 7 | 8 | from . import plot_actions 9 | -------------------------------------------------------------------------------- /src/sisl/viz/plotters/tests/test_xarray.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import pytest 7 | import xarray as xr 8 | 9 | from sisl.viz.plotters.xarray import draw_xarray_xy 10 | 11 | pytestmark = [pytest.mark.viz, pytest.mark.plotters] 12 | 13 | 14 | def test_empty_dataset(): 15 | ds = xr.Dataset({"x": ("dim", []), "y": ("dim", [])}) 16 | 17 | drawings = draw_xarray_xy(ds, x="x", y="y") 18 | 19 | assert isinstance(drawings, list) 20 | assert len(drawings) == 0 21 | 22 | 23 | def test_empty_dataarray(): 24 | arr = xr.DataArray([], name="values", dims=["x"]) 25 | 26 | drawings = draw_xarray_xy(arr, x="x") 27 | 28 | assert isinstance(drawings, list) 29 | assert len(drawings) == 0 30 | -------------------------------------------------------------------------------- /src/sisl/viz/processors/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | # from .bands import * 5 | # from .fatbands import * 6 | # from .pdos import * 7 | # from .geometry import * 8 | from __future__ import annotations 9 | -------------------------------------------------------------------------------- /src/sisl/viz/processors/data.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from typing import TypeVar 7 | 8 | from ..data import Data 9 | 10 | DataInstance = TypeVar("DataInstance", bound=Data) 11 | 12 | 13 | def accept_data( 14 | data: DataInstance, cls: type[Data], check: bool = True 15 | ) -> DataInstance: 16 | if not isinstance(data, cls): 17 | raise TypeError( 18 | f"Data must be of type {cls.__name__} and was {type(data).__name__}" 19 | ) 20 | 21 | if check: 22 | data.sanity_check() 23 | 24 | return data 25 | 26 | 27 | def extract_data(data: Data, cls: type[Data], check: bool = True): 28 | if not isinstance(data, cls): 29 | raise TypeError( 30 | f"Data must be of type {cls.__name__} and was {type(data).__name__}" 31 | ) 32 | 33 | if check: 34 | data.sanity_check() 35 | 36 | return data._data 37 | -------------------------------------------------------------------------------- /src/sisl/viz/processors/logic.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from typing import TypeVar, Union 7 | 8 | T1 = TypeVar("T1") 9 | T2 = TypeVar("T2") 10 | 11 | 12 | def swap(val: Union[T1, T2], vals: tuple[T1, T2]) -> Union[T1, T2]: 13 | """Given two values, returns the one that is not the input value.""" 14 | if val == vals[0]: 15 | return vals[1] 16 | elif val == vals[1]: 17 | return vals[0] 18 | else: 19 | raise ValueError(f"Value {val} not in {vals}") 20 | -------------------------------------------------------------------------------- /src/sisl/viz/processors/math.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | 8 | 9 | def normalize(data, vmin=0, vmax=1): 10 | """Normalize data to [vmin, vmax] range. 11 | 12 | Parameters 13 | ---------- 14 | data : array_like 15 | Data to normalize. 16 | vmin : float, optional 17 | Minimum value of normalized data. 18 | vmax : float, optional 19 | Maximum value of normalized data. 20 | 21 | Returns 22 | ------- 23 | data : array_like 24 | Normalized data. 25 | """ 26 | data = np.asarray(data) 27 | data_min = np.min(data) 28 | data_max = np.max(data) 29 | return vmin + (vmax - vmin) * (data - data_min) / (data_max - data_min) 30 | -------------------------------------------------------------------------------- /src/sisl/viz/processors/spin.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from typing import Literal, Union 7 | 8 | from sisl import Spin 9 | 10 | _options = { 11 | Spin.UNPOLARIZED: [], 12 | Spin.POLARIZED: [ 13 | {"label": "↑", "value": 0}, 14 | {"label": "↓", "value": 1}, 15 | {"label": "Total", "value": "total"}, 16 | {"label": "Net z", "value": "z"}, 17 | ], 18 | Spin.NONCOLINEAR: [ 19 | {"label": val, "value": val} for val in ("total", "x", "y", "z") 20 | ], 21 | Spin.SPINORBIT: [{"label": val, "value": val} for val in ("total", "x", "y", "z")], 22 | } 23 | 24 | 25 | def get_spin_options( 26 | spin: Union[Spin, str], only_if_polarized: bool = False 27 | ) -> list[Literal[0, 1, "total", "x", "y", "z"]]: 28 | """Returns the options for a given spin class. 29 | 30 | Parameters 31 | ---------- 32 | spin: sisl.Spin or str 33 | The spin class to get the options for. 34 | only_if_polarized: bool, optional 35 | If set to `True`, non colinear spins will not have multiple options. 36 | """ 37 | spin = Spin(spin) 38 | 39 | if only_if_polarized and not spin.is_polarized: 40 | options_spin = Spin("") 41 | else: 42 | options_spin = spin 43 | 44 | return [option["value"] for option in _options[options_spin.kind]] 45 | -------------------------------------------------------------------------------- /src/sisl/viz/processors/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | from __future__ import annotations 4 | -------------------------------------------------------------------------------- /src/sisl/viz/processors/tests/test_logic.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import pytest 7 | 8 | from sisl.viz.processors.logic import swap 9 | 10 | pytestmark = [pytest.mark.viz, pytest.mark.processors] 11 | 12 | 13 | def test_swap(): 14 | assert swap(1, (1, 2)) == 2 15 | assert swap(2, (1, 2)) == 1 16 | 17 | with pytest.raises(ValueError): 18 | swap(3, (1, 2)) 19 | -------------------------------------------------------------------------------- /src/sisl/viz/processors/tests/test_math.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import numpy as np 7 | import pytest 8 | 9 | from sisl.viz.processors.math import normalize 10 | 11 | pytestmark = [pytest.mark.viz, pytest.mark.processors] 12 | 13 | 14 | def test_normalize(): 15 | data = [0, 1, 2] 16 | 17 | assert np.allclose(normalize(data), [0, 0.5, 1]) 18 | 19 | assert np.allclose(normalize(data, vmin=-1, vmax=1), [-1, 0, 1]) 20 | -------------------------------------------------------------------------------- /src/sisl/viz/processors/tests/test_spin.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | import pytest 7 | 8 | from sisl.viz.processors.spin import get_spin_options 9 | 10 | pytestmark = [pytest.mark.viz, pytest.mark.processors] 11 | 12 | 13 | def test_get_spin_options(): 14 | # Unpolarized spin 15 | assert len(get_spin_options("unpolarized")) == 0 16 | 17 | # Polarized spin 18 | options = get_spin_options("polarized") 19 | assert len(options) == 4 20 | assert 0 in options 21 | assert 1 in options 22 | assert "total" in options 23 | assert "z" in options 24 | 25 | # Non colinear spin 26 | options = get_spin_options("noncolinear") 27 | assert len(options) == 4 28 | assert "total" in options 29 | assert "x" in options 30 | assert "y" in options 31 | assert "z" in options 32 | 33 | options = get_spin_options("noncolinear", only_if_polarized=True) 34 | assert len(options) == 0 35 | -------------------------------------------------------------------------------- /src/sisl_toolbox/README: -------------------------------------------------------------------------------- 1 | This directory contains contributed examples which may be used 2 | as examples in extended calculations. 3 | 4 | Once modules are present in this toolbox users may import them using 5 | 6 | from sisl_toolbox.transiesta import * 7 | 8 | and use them. Note that toolboxes imported _have_ to have the full 9 | name on import line. No top-level imports are done. 10 | 11 | We welcome *any* user to contribute a toolbox such that other users 12 | may benefit from it. 13 | 14 | When contributing it is essential that these guidelines regarding the 15 | code is followed: 16 | 17 | - Name of developer should be present in the code, preferentially contact details 18 | - Which version of sisl it was originally developed and tested with 19 | - Document the use in the script 20 | - Ensure the script is *only* Python 3 compliant 21 | -------------------------------------------------------------------------------- /src/sisl_toolbox/btd/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ Block-tri-diagonal calculation for N-terminal electrodes """ 7 | from ._btd import * 8 | -------------------------------------------------------------------------------- /src/sisl_toolbox/cli/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ A command-line-interface for toolboxes that provide CLI 7 | 8 | This is a wrapper with sub-commands the toolboxes that are 9 | accessible. 10 | """ 11 | from ._cli import * 12 | from ._cli_imports import * 13 | -------------------------------------------------------------------------------- /src/sisl_toolbox/cli/_cli_imports.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | # This module is only to pre-import the local toolboxes that 7 | # going to be added. If they are not imported, they wont be registered 8 | __all__ = [] 9 | 10 | 11 | import sisl_toolbox.siesta.atom # noqa: F401 12 | import sisl_toolbox.transiesta.poisson # noqa: F401 13 | -------------------------------------------------------------------------------- /src/sisl_toolbox/models/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ All defalut TB models should be imported here """ 7 | 8 | from ._base import * 9 | from ._graphene import * 10 | -------------------------------------------------------------------------------- /src/sisl_toolbox/models/_base.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl._dispatcher import AbstractDispatch, ClassDispatcher 7 | 8 | 9 | class ModelDispatcher(ClassDispatcher): 10 | """Container for dispatch models""" 11 | 12 | pass 13 | 14 | 15 | class BaseModel: 16 | """Base class used for inheritance for creating separate models""" 17 | 18 | ref = ModelDispatcher( 19 | "ref", 20 | type_dispatcher=None, 21 | obj_getattr=lambda obj, key: (_ for _ in ()).throw( 22 | AttributeError( 23 | ( 24 | f"{obj}.to does not implement '{key}' " 25 | f"dispatcher, are you using it incorrectly?" 26 | ) 27 | ) 28 | ), 29 | ) 30 | 31 | def __getattr__(self, attr): 32 | return getattr(self.ref, attr) 33 | 34 | 35 | # Each model should inherit from this 36 | 37 | 38 | class ReferenceDispatch(AbstractDispatch): 39 | """Base dispatcher that implemnets different models""" 40 | 41 | pass 42 | -------------------------------------------------------------------------------- /src/sisl_toolbox/models/_graphene/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ Default graphene models """ 7 | from sisl.utils import PropertyDict 8 | 9 | # Here we import the specific details that are exposed 10 | from ._hamiltonian import * 11 | 12 | __all__ = ["graphene"] 13 | 14 | # Define the graphene model 15 | graphene = PropertyDict() 16 | graphene.hamiltonian = GrapheneHamiltonian() 17 | graphene.H = graphene.hamiltonian 18 | -------------------------------------------------------------------------------- /src/sisl_toolbox/models/_graphene/_base.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from sisl_toolbox.models._base import BaseModel 7 | 8 | __all__ = ["GrapheneModel"] 9 | 10 | 11 | class GrapheneModel(BaseModel): 12 | # copy the dispatcher method 13 | ref = BaseModel.ref.copy() 14 | 15 | # A graphene model is generally made of 1-3 nearest neighbor 16 | # couplings 17 | # The distances are here kept 18 | @classmethod 19 | def distance(cls, n=1, a=1.42): 20 | """Return the distance to the nearest neighbor according to the bond-length `a` 21 | 22 | Currently only up to 3rd nearest neighbor is implemneted 23 | 24 | Parameters 25 | ---------- 26 | n : int, optional 27 | the nearest neighbor, 1 means first nearest neighbor, and 0 means it self 28 | a : float, optional 29 | the bond length of the intrinsic graphene lattice 30 | """ 31 | dist = { 32 | 0: 0.0, 33 | 1: a, 34 | 2: a * 3**0.5, 35 | 3: a * 2, 36 | } 37 | return dist[n] 38 | -------------------------------------------------------------------------------- /src/sisl_toolbox/siesta/atom/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from ._atom import AtomInput 7 | 8 | __all__ = ["AtomInput"] 9 | -------------------------------------------------------------------------------- /src/sisl_toolbox/siesta/minimizer/_path.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | from pathlib import Path 7 | 8 | 9 | def path_rel_or_abs(path, base=None): 10 | path = Path(path) 11 | if path.is_absolute(): 12 | return path 13 | if base is None: 14 | base = Path.cwd() 15 | return base / path 16 | 17 | 18 | def path_abs(path, base=None): 19 | path = Path(path) 20 | if path.is_absolute(): 21 | return path 22 | if base is None: 23 | base = Path.cwd() 24 | return base / path 25 | -------------------------------------------------------------------------------- /src/sisl_toolbox/transiesta/poisson/__init__.py: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | from __future__ import annotations 5 | 6 | """ TranSiesta FFT Poisson corrections """ 7 | from .fftpoisson_fix import * 8 | -------------------------------------------------------------------------------- /tools/add_header.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Small snippet script to *recursively* add 4 | # a header describing the license for all *.py files. 5 | shopt -s globstar 6 | 7 | declare -a extensions=(py pyx) 8 | 9 | function add_license { 10 | local f=$1 ; shift 11 | if ! $(grep -Fq "mozilla.org/MPL/2.0" $f) ; then 12 | local tmpdir=$(mktemp -d) 13 | local basef=$(basename $f) 14 | cp $f $tmpdir/$basef 15 | { 16 | echo "# This Source Code Form is subject to the terms of the Mozilla Public" 17 | echo "# License, v. 2.0. If a copy of the MPL was not distributed with this" 18 | echo "# file, You can obtain one at https://mozilla.org/MPL/2.0/." 19 | cat $tmpdir/$basef 20 | } > $f 21 | rm -fr $tmpdir 22 | fi 23 | } 24 | 25 | function add_future { 26 | local f=$1 ; shift 27 | if ! $(grep -Fq "__future__ import annotations" $f) ; then 28 | local tmpdir=$(mktemp -d) 29 | local basef=$(basename $f) 30 | cp $f $tmpdir/$basef 31 | { 32 | sed -n '0,/^[^#]/p' $tmpdir/$basef | head -n -1 33 | echo "from __future__ import annotations" 34 | sed -n '/^[^#]/,$p' $tmpdir/$basef 35 | } > $f 36 | rm -fr $tmpdir 37 | fi 38 | } 39 | 40 | for ext in ${extensions[@]} 41 | do 42 | for f in **/*.$ext 43 | do 44 | add_license $f 45 | [ $ext == py ] && add_future $f 46 | done 47 | done 48 | -------------------------------------------------------------------------------- /tools/build_tools/test_wheels.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -x 5 | 6 | WHEEL=$1 7 | 8 | python -c "import joblib; print(f'Number of cores (physical): \ 9 | {joblib.cpu_count()} ({joblib.cpu_count(only_physical_cores=True)})')" 10 | 11 | FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))")" 12 | if [[ $FREE_THREADED_BUILD == "True" ]]; then 13 | # TODO: delete when importing numpy no longer enables the GIL 14 | # setting to zero ensures the GIL is disabled while running the 15 | # tests under free-threaded python 16 | export PYTHON_GIL=0 17 | fi 18 | 19 | # First output... simple import and print of version 20 | python -c "import sisl; print(sisl.__version__)" 21 | 22 | if [ -d sisl/files/tests ]; then 23 | export SISL_FILES_TESTS=sisl/files/tests 24 | echo "will run with sisl-files tests" 25 | echo "SISL_FILES_TESTS=$SISL_FILES_TESTS" 26 | else 27 | echo "will not run with sisl-files tests" 28 | fi 29 | 30 | if pip show -qq pytest-xdist; then 31 | XDIST_WORKERS=$(python -c "import joblib; print(joblib.cpu_count(only_physical_cores=True))") 32 | pytest --pyargs sisl -n $XDIST_WORKERS -m "not slow" 33 | else 34 | pytest --pyargs sisl -m "not slow" 35 | fi 36 | -------------------------------------------------------------------------------- /tools/pep8.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Enable **/* expansions 4 | shopt -s globstar 5 | 6 | # This script will only do removal of whitespace 7 | # It relies on the autopep8 tool and the 8 | # specifics of whitespace error/warnings 9 | 10 | # List of errors of whitespace stuff 11 | select="E101,E20,E211,E231,E301,E302,E303,E304,E309,W291,W293,W391" 12 | # Errors of comparison with None and bool 13 | select="$select,E711,E712" 14 | # Imports on single lines 15 | select="$select,E401" 16 | # trailing whitespace 17 | select="$select,C0303" 18 | # imports at top 19 | select="$select,C0413" 20 | # import order 21 | select="$select,C0411" 22 | 23 | # pretty print command select running 24 | echo "autopep8 --select \"$select\"" 25 | autopep8 -j -1 --select "$select" --in-place -r --exclude build,sisl.egg-info,dist . **/*.pyx **/*.pxd 26 | 27 | # Non-Python files 28 | autopep8 --select "W291,W293" --in-place CHANGELOG.md & 29 | 30 | # Remove white-space on empty lines 31 | sed -i -s -e 's/^[[:space:]]*$//g' {sisl,toolbox}/**/*.f90 32 | # Remove trailing white-space 33 | sed -i -s -e 's/\([^[:space:]]\)[[:space:]]?$/\1/g' {sisl,toolbox}/**/*.f90 34 | -------------------------------------------------------------------------------- /tools/runlint.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Run pylint from top of dev repo 4 | pylint --py-version=3.7 -E sisl 5 | --------------------------------------------------------------------------------