keyword
stringclasses
7 values
repo_name
stringlengths
8
98
file_path
stringlengths
4
244
file_extension
stringclasses
29 values
file_size
int64
0
84.1M
line_count
int64
0
1.6M
content
stringlengths
1
84.1M
language
stringclasses
14 values
2D
dean0x7d/pybinding
pybinding/pltutils.py
.py
14,833
517
"""Collection of utility functions for matplotlib""" import warnings from contextlib import contextmanager, suppress import numpy as np import matplotlib as mpl import matplotlib.style as mpl_style import matplotlib.pyplot as plt from .utils import with_defaults __all__ = ['cm2inch', 'colorbar', 'despine', 'despine_...
Python
2D
dean0x7d/pybinding
pybinding/chebyshev.py
.py
22,251
583
"""Computations based on Chebyshev polynomial expansion The kernel polynomial method (KPM) can be used to approximate various functions by expanding them in a series of Chebyshev polynomials. """ import warnings import numpy as np import scipy from . import _cpp from . import results from .model import Model from .s...
Python
2D
dean0x7d/pybinding
pybinding/modifier.py
.py
18,397
538
"""Modifier function decorators Used to create functions which express some feature of a tight-binding model, such as various fields, defects or geometric deformations. """ import inspect import functools import warnings import numpy as np from . import _cpp from .system import Sites from .support.inspect import get...
Python
2D
dean0x7d/pybinding
pybinding/model.py
.py
5,858
163
"""Main model definition interface""" import numpy as np from scipy.sparse import csr_matrix from . import _cpp from . import results from .system import System, decorate_structure_plot from .lattice import Lattice from .leads import Leads __all__ = ['Model'] class Model(_cpp.Model): """Builds a Hamiltonian fro...
Python
2D
dean0x7d/pybinding
pybinding/shape.py
.py
10,808
345
"""System shape and symmetry""" import numpy as np import matplotlib.pyplot as plt from . import _cpp from . import pltutils from .utils import with_defaults __all__ = ['FreeformShape', 'Polygon', 'CompositeShape', 'circle', 'line', 'primitive', 'rectangle', 'regular_polygon', 'translational_sym...
Python
2D
dean0x7d/pybinding
pybinding/results.py
.py
36,387
1,051
"""Processing and presentation of computed data Result objects hold computed data and offer postprocessing and plotting functions which are specifically adapted to the nature of the stored data. """ from copy import copy import numpy as np import matplotlib.pyplot as plt from . import pltutils from .utils import wit...
Python
2D
dean0x7d/pybinding
pybinding/__init__.py
.py
3,159
79
from .__about__ import (__author__, __copyright__, __doc__, __email__, __license__, __summary__, __title__, __url__, __version__) import os import sys if sys.platform.startswith("linux"): # When the _pybinding C++ extension is compiled with MKL, it requires specific # dlopen flags on Li...
Python
2D
dean0x7d/pybinding
pybinding/solver.py
.py
17,892
489
"""Eigensolvers with a few extra computation methods The :class:`.Solver` class is the main interface for dealing with eigenvalue problems. It is made to work specifically with pybinding's :class:`.Model` objects, but it may use any eigensolver algorithm under the hood. A few different algorithms are provided out of ...
Python
2D
dean0x7d/pybinding
pybinding/constants.py
.py
749
28
"""A few useful physical constants Note that energy is expressed in units of eV. """ from math import pi import numpy as np c = 299792458 #: [m/s] speed of light e = 1.602 * 10**-19 #: [C] electron charge epsilon0 = 8.854 * 10**-12 #: [F/m] vacuum permittivity hbar = 6.58211899 * 10**-16 #: [eV*s] reduced Plank c...
Python
2D
dean0x7d/pybinding
pybinding/lattice.py
.py
20,663
559
"""Crystal lattice specification""" import itertools import warnings from copy import deepcopy from math import pi, atan2, sqrt import numpy as np import matplotlib.pyplot as plt from . import _cpp from . import pltutils from .utils import x_pi, with_defaults, rotate_axes from .support.deprecated import LoudDeprecati...
Python
2D
dean0x7d/pybinding
pybinding/system.py
.py
19,487
526
"""Structural information and utilities""" import functools import itertools import numpy as np import matplotlib.pyplot as plt from matplotlib.collections import LineCollection from . import _cpp from . import pltutils from .lattice import Lattice from .utils import with_defaults, rotate_axes from .support.alias imp...
Python
2D
dean0x7d/pybinding
pybinding/greens.py
.py
577
22
"""Green's function computation and related methods Deprecated: use the chebyshev module instead """ import warnings from . import chebyshev from .support.deprecated import LoudDeprecationWarning __all__ = ['Greens', 'kpm', 'kpm_cuda'] Greens = chebyshev.KPM def kpm(*args, **kwargs): warnings.warn("Use pb.kpm(...
Python
2D
dean0x7d/pybinding
pybinding/leads.py
.py
7,279
198
"""Lead interface for scattering models The only way to create leads is using the :meth:`.Model.attach_lead` method. The classes represented here are the final product of that process, listed in :attr:`.Model.leads`. """ import numpy as np import matplotlib.pyplot as plt from math import pi from scipy.sparse import cs...
Python
2D
dean0x7d/pybinding
pybinding/parallel.py
.py
13,695
428
"""Multi-threaded functions for parameter sweeps""" import sys import inspect import itertools from copy import copy from functools import partial import numpy as np import matplotlib.pyplot as plt from pybinding.support.inspect import get_call_signature from . import _cpp from .utils import cpuinfo, progressbar, dec...
Python
2D
dean0x7d/pybinding
pybinding/repository/__init__.py
.py
0
0
null
Python
2D
dean0x7d/pybinding
pybinding/repository/group6_tmd.py
.py
4,432
112
"""Tight-binding models for group 6 transition metal dichalcogenides (TMD).""" import re import math import pybinding as pb _default_3band_params = { # from https://doi.org/10.1103/PhysRevB.88.085433 # -> a, eps1, eps2, t0, t1, t2, t11, t12, t22 "MoS2": [0.3190, 1.046, 2.104, -0...
Python
2D
dean0x7d/pybinding
pybinding/repository/phosphorene.py
.py
2,298
64
"""A single layer of black phosphorus""" from math import pi, sin, cos import pybinding as pb def monolayer_4band(num_hoppings=5): """Monolayer phosphorene lattice using the four-band model Parameters ---------- num_hoppings : int Number of hopping terms to consider: from t2 to t5. """ ...
Python
2D
dean0x7d/pybinding
pybinding/repository/examples.py
.py
1,000
50
"""Example components: lattices, shapes and modifiers Components which aren't very useful for simulations, but great for examples and testing. """ import pybinding as pb def chain_lattice(a=1, t=-1, v=0): """1D lattice Parameters ---------- a : float Unit cell length. t : float H...
Python
2D
dean0x7d/pybinding
pybinding/repository/graphene/shape.py
.py
1,168
32
import math import pybinding as pb from .constants import a, a_cc __all__ = ['hexagon_ac'] def hexagon_ac(side_width, lattice_offset=(-a/2, 0)): """A graphene-specific shape which guaranties armchair edges on all sides Parameters ---------- side_width : float Hexagon side width. It may be ad...
Python
2D
dean0x7d/pybinding
pybinding/repository/graphene/__init__.py
.py
178
7
"""A one-atom thick layer of carbon in a honeycomb structure""" from . import utils from .constants import * from .lattice import * from .modifiers import * from .shape import *
Python
2D
dean0x7d/pybinding
pybinding/repository/graphene/constants.py
.py
319
9
from pybinding.constants import hbar a = 0.24595 #: [nm] unit cell length a_cc = 0.142 #: [nm] carbon-carbon distance t = -2.8 #: [eV] nearest neighbor hopping t_nn = 0.1 #: [eV] next-nearest neighbor hopping vf = 3 / (2 * hbar) * abs(t) * a_cc #: [nm/s] Fermi velocity beta = 3.37 #: strain hopping modulation
Python
2D
dean0x7d/pybinding
pybinding/repository/graphene/lattice.py
.py
5,652
196
import pybinding as pb __all__ = ['monolayer', 'monolayer_alt', 'monolayer_4atom', 'bilayer'] def monolayer(nearest_neighbors=1, onsite=(0, 0), **kwargs): """Monolayer graphene lattice up to `nearest_neighbors` hoppings Parameters ---------- nearest_neighbors : int Number of nearest neighbor...
Python
2D
dean0x7d/pybinding
pybinding/repository/graphene/utils.py
.py
273
9
from math import sqrt from .constants import hbar, vf def landau_level(magnetic_field: float, n: int): """ Calculate the energy of Landau level n in the given magnetic field. """ lb = sqrt(hbar / magnetic_field) return hbar * (vf * 10**-9) / lb * sqrt(2 * n)
Python
2D
dean0x7d/pybinding
pybinding/repository/graphene/modifiers.py
.py
3,680
138
import numpy as np import pybinding as pb from pybinding.constants import pi, phi0, hbar __all__ = ['mass_term', 'coulomb_potential', 'constant_magnetic_field', 'triaxial_strain', 'gaussian_bump'] def mass_term(delta): """Break sublattice symmetry, make massive Dirac electrons, open a band gap On...
Python
2D
dean0x7d/pybinding
pybinding/utils/misc.py
.py
3,785
151
import os from functools import wraps from contextlib import contextmanager import numpy as np from ..support.inspect import get_call_signature def to_tuple(o): try: return tuple(o) except TypeError: return (o,) if o is not None else () def to_list(o): try: return list(o) e...
Python
2D
dean0x7d/pybinding
pybinding/utils/progressbar.py
.py
5,796
224
import datetime import io import os import sys def percentage(template="{:3.0%}"): def widget(pbar): return template.format(pbar.percent) return widget def bar(marker='/', left='[', right=']', fill=' '): def widget(pbar, width): width -= len(left) + len(right) marked = marker * i...
Python
2D
dean0x7d/pybinding
pybinding/utils/__init__.py
.py
75
4
from . import cpuinfo, progressbar from .misc import * from .time import *
Python
2D
dean0x7d/pybinding
pybinding/utils/cpuinfo.py
.py
1,702
65
import os from .. import _cpp _cached_info = None def cpu_info(): """Forwarded from `cpuinfo.get_cpu_info()`""" global _cached_info if not _cached_info: try: from cpuinfo import get_cpu_info except ImportError: def get_cpu_info(): return {} ...
Python
2D
dean0x7d/pybinding
pybinding/utils/time.py
.py
2,669
116
import time __all__ = ['tic', 'toc', 'timed', 'pretty_duration'] _tic_times = [] def tic(): """Set a start time""" global _tic_times _tic_times.append(time.time()) def toc(message=""): """Print the elapsed time from the last :func:`.tic` Parameters ---------- message : str Pri...
Python
2D
dean0x7d/pybinding
pybinding/support/kwant.py
.py
3,368
105
"""Kwant compatibility layer""" import warnings import numpy as np try: from kwant.system import FiniteSystem, InfiniteSystem kwant_installed = True except ImportError: FiniteSystem = InfiniteSystem = object kwant_installed = False def _warn_if_not_empty(args, params): if args or params: ...
Python
2D
dean0x7d/pybinding
pybinding/support/pickle.py
.py
2,912
110
"""Utility functions for getting data to/from files""" import gzip import os import pathlib import pickle from ..utils import decorator_decorator __all__ = ['pickleable', 'save', 'load'] def _normalize(file): """Convenience function to support path objects.""" if 'Path' in type(file).__name__: retur...
Python
2D
dean0x7d/pybinding
pybinding/support/fuzzy_set.py
.py
1,002
45
import copy import numpy as np __all__ = ['FuzzySet'] class FuzzySet: def __init__(self, iterable=None, rtol=1.e-3, atol=1.e-5): self.data = [] self.rtol = rtol self.atol = atol if iterable: for item in iterable: self.add(item) def __getitem__(sel...
Python
2D
dean0x7d/pybinding
pybinding/support/deprecated.py
.py
112
5
class LoudDeprecationWarning(UserWarning): """Python's DeprecationWarning is silent by default""" pass
Python
2D
dean0x7d/pybinding
pybinding/support/__init__.py
.py
0
0
null
Python
2D
dean0x7d/pybinding
pybinding/support/inspect.py
.py
4,158
123
import inspect from collections import OrderedDict __all__ = ['CallSignature', 'get_call_signature'] class CallSignature: """Holds a function and the arguments it was called with""" def __init__(self, function: callable, positional: OrderedDict, args: tuple, keyword_only: OrderedDict, kwargs...
Python
2D
dean0x7d/pybinding
pybinding/support/collections.py
.py
3,143
85
import numpy as np from matplotlib.collections import Collection from matplotlib.artist import allow_rasterization # noinspection PyAbstractClass class CircleCollection(Collection): """Custom circle collection The default matplotlib `CircleCollection` creates circles based on their area in screen units. ...
Python
2D
dean0x7d/pybinding
pybinding/support/structure.py
.py
6,913
244
from abc import ABCMeta, abstractmethod from collections import namedtuple import numpy as np from numpy import ma from scipy.sparse import csr_matrix, coo_matrix def _slice_csr_matrix(csr, idx): """Return a slice of a CSR matrix matching the given indices (applied to both rows and cols""" from copy import c...
Python
2D
dean0x7d/pybinding
pybinding/support/alias.py
.py
6,352
233
import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendly string identifiers. The mapping parameter transla...
Python
2D
dean0x7d/pybinding
docs/test_examples.py
.py
710
24
import pytest import pathlib import warnings docs = pathlib.Path(__file__).parent examples = list(docs.glob("tutorial/**/*.py")) + list(docs.glob("examples/**/*.py")) assert len(examples) != 0 @pytest.fixture(scope='module', ids=[e.stem for e in examples], params=examples) def example_file(request): """An examp...
Python
2D
dean0x7d/pybinding
docs/conf.py
.py
12,076
361
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import os import shutil import filecmp import sphinx_rtd_theme from recommonmark.parser import CommonMarkParser # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative...
Python
2D
dean0x7d/pybinding
docs/benchmarks/system_build.py
.py
6,109
173
#! /usr/bin/env python3 """Tight-binding system construction benchmark Usage: Make sure you have all the requirements and then run this script using python3. The considered system sizes can be changed in the `__name__ == '__main__'` section at the bottom. Requires Python >= 3.6 and the following packages which can be...
Python
2D
dean0x7d/pybinding
docs/tutorial/strain_example.py
.py
1,268
49
"""Strain a triangular system by pulling on its vertices""" import pybinding as pb import numpy as np import matplotlib.pyplot as plt from pybinding.repository import graphene from math import pi pb.pltutils.use_style() def triaxial_strain(c): """Strain-induced displacement and hopping energy modification""" ...
Python
2D
dean0x7d/pybinding
docs/tutorial/fields_example.py
.py
1,518
58
"""PN junction and broken sublattice symmetry in a graphene nanoribbon""" import pybinding as pb import matplotlib.pyplot as plt from pybinding.repository import graphene from math import pi, sqrt pb.pltutils.use_style() def mass_term(delta): """Break sublattice symmetry with opposite A and B onsite energy""" ...
Python
2D
dean0x7d/pybinding
docs/tutorial/shape_symmetry_example.py
.py
1,480
55
"""Model an infinite nanoribbon consisting of graphene rings""" import pybinding as pb import numpy as np import matplotlib.pyplot as plt from pybinding.repository import graphene from math import pi pb.pltutils.use_style() def ring(inner_radius, outer_radius): """A simple ring shape""" def contains(x, y, z)...
Python
2D
dean0x7d/pybinding
docs/tutorial/twisted_heterostructures.py
.py
6,393
192
"""Construct a circular flake of twisted bilayer graphene (arbitrary angle)""" import numpy as np import matplotlib.pyplot as plt import math import pybinding as pb from scipy.spatial import cKDTree from pybinding.repository import graphene c0 = 0.335 # [nm] graphene interlayer spacing def two_graphene_monolayers(...
Python
2D
dean0x7d/pybinding
docs/tutorial/bands_example.py
.py
835
27
"""Calculate and plot the band structure of monolayer graphene""" import pybinding as pb import matplotlib.pyplot as plt from math import sqrt, pi from pybinding.repository import graphene pb.pltutils.use_style() model = pb.Model( graphene.monolayer(), # predefined lattice from the material repository pb.tr...
Python
2D
dean0x7d/pybinding
docs/tutorial/finite_example.py
.py
892
34
"""Model a graphene ring structure and calculate the local density of states""" import pybinding as pb import numpy as np import matplotlib.pyplot as plt from pybinding.repository import graphene pb.pltutils.use_style() def ring(inner_radius, outer_radius): """A simple ring shape""" def contains(x, y, z): ...
Python
2D
dean0x7d/pybinding
docs/tutorial/lattice_example.py
.py
965
44
"""Create and plot a monolayer graphene lattice and it's Brillouin zone""" import pybinding as pb import matplotlib.pyplot as plt from math import sqrt pb.pltutils.use_style() def monolayer_graphene(): """Return the lattice specification for monolayer graphene""" a = 0.24595 # [nm] unit cell length a_c...
Python
2D
dean0x7d/pybinding
docs/examples/ribbons/bilayer_graphene.py
.py
1,484
48
"""Bilayer graphene nanoribbon with zigzag edges""" import pybinding as pb import matplotlib.pyplot as plt from pybinding.repository import graphene from math import pi, sqrt pb.pltutils.use_style() def bilayer_graphene(): """Bilayer lattice in the AB-stacked form (Bernal-stacked)""" lat = pb.Lattice(a1=[gra...
Python
2D
dean0x7d/pybinding
docs/examples/lattice/monolayer_graphene_soc.py
.py
2,087
71
"""Calculate the band structure of graphene with Rashba spin-orbit coupling""" import pybinding as pb import numpy as np import matplotlib.pyplot as plt from math import pi, sqrt def monolayer_graphene_soc(): """Return the lattice specification for monolayer graphene with Rashba SOC, see http://doi.org/10....
Python
2D
dean0x7d/pybinding
docs/examples/lattice/trestle.py
.py
737
38
"""One dimensional lattice with complex hoppings""" import pybinding as pb import matplotlib.pyplot as plt pb.pltutils.use_style() def trestle(d=0.2, t1=0.8 + 0.6j, t2=2): lat = pb.Lattice(a1=1.3*d) lat.add_sublattices( ('A', [0, 0], 0), ('B', [d/2, d], 0) ) lat.add_hoppings( ...
Python
2D
dean0x7d/pybinding
docs/examples/lattice/monolayer_graphene.py
.py
1,445
61
"""Create and plot a monolayer graphene lattice, its Brillouin zone and band structure""" import pybinding as pb import matplotlib.pyplot as plt from math import sqrt, pi pb.pltutils.use_style() def monolayer_graphene(): """Return the lattice specification for monolayer graphene""" a = 0.24595 # [nm] unit ...
Python
2D
dean0x7d/pybinding
docs/examples/lattice/phosphorene.py
.py
2,236
91
"""Create and plot a phosphorene lattice, its Brillouin zone and band structure""" import pybinding as pb import matplotlib.pyplot as plt from math import pi, sin, cos pb.pltutils.use_style() def phosphorene_4band(): """Monolayer phosphorene lattice using the four-band model""" a = 0.222 ax = 0.438 a...
Python
2D
dean0x7d/pybinding
docs/examples/lattice/checkerboard.py
.py
801
36
"""Two dimensional checkerboard lattice with real hoppings""" import pybinding as pb import matplotlib.pyplot as plt from math import pi pb.pltutils.use_style() def checkerboard(d=0.2, delta=1.1, t=0.6): lat = pb.Lattice(a1=[d, 0], a2=[0, d]) lat.add_sublattices( ('A', [0, 0], -delta), ('B', ...
Python
2D
dean0x7d/pybinding
docs/examples/lattice/bilayer_graphene.py
.py
1,728
68
"""Build the simplest model of bilayer graphene and compute its band structure""" import pybinding as pb import matplotlib.pyplot as plt from math import sqrt, pi pb.pltutils.use_style() def bilayer_graphene(): """Bilayer lattice in the AB-stacked form (Bernal-stacked) This is the simplest model with just a...
Python
2D
dean0x7d/pybinding
docs/examples/lattice/monolayer_graphene_nn.py
.py
1,535
60
"""Monolayer graphene with next-nearest hoppings""" import pybinding as pb import matplotlib.pyplot as plt from math import sqrt, pi pb.pltutils.use_style() def monolayer_graphene_nn(): a = 0.24595 # [nm] unit cell length a_cc = 0.142 # [nm] carbon-carbon distance t = -2.8 # [eV] nearest neighbou...
Python
2D
dean0x7d/pybinding
docs/examples/finite/line.py
.py
951
42
"""1D lattice chains - finite dimension are imposed using builtin `pb.line` shape""" import pybinding as pb import matplotlib.pyplot as plt pb.pltutils.use_style() def simple_chain_lattice(a=1, t=-1): """Very simple 1D lattice""" lat = pb.Lattice(a) lat.add_one_sublattice('A', [0, 0]) lat.add_one_hop...
Python
2D
dean0x7d/pybinding
docs/examples/finite/shapes.py
.py
632
32
"""Several finite-sized systems created using builtin lattices and shapes""" import pybinding as pb from pybinding.repository import graphene import matplotlib.pyplot as plt from math import pi pb.pltutils.use_style() model = pb.Model( graphene.monolayer(), pb.rectangle(x=2, y=1.2) ) model.plot() plt.show() ...
Python
2D
dean0x7d/pybinding
docs/_ext/generate.py
.py
5,931
156
"""Adapted from sphinx.ext.autosummary.generate Modified to only consider module members listed in `__all__` and only class members listed in `autodoc_allowed_special_members`. Copyright 2007-2016 by the Sphinx team, https://github.com/sphinx-doc/sphinx/blob/master/AUTHORS License: BSD, see https://github.com/sphinx-...
Python
2D
dean0x7d/pybinding
docs/_ext/nbexport.py
.py
9,303
289
import os import itertools import posixpath from sphinx import addnodes, roles from docutils import nodes, writers import nbformat from nbconvert.preprocessors import ExecutePreprocessor from nbconvert.preprocessors.execute import CellExecutionError def _finilize_markdown_cells(nb): markdown_cells = (c for c in...
Python
2D
dean0x7d/pybinding
docs/advanced/kwant_example.py
.py
5,647
167
#! /usr/bin/env python3 """Transport through a barrier The `main()` function builds identical models in pybinding and kwant and then calculates the transmission using `kwant.smatrix`. The results are plotted to verify that they are identical. The `measure_and_plot()` function compares transport calculation time for v...
Python
2D
dean0x7d/pybinding
tests/test_model.py
.py
5,050
155
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene from scipy.sparse import csr_matrix def point_to_same_memory(a, b): """Check if two numpy arrays point to the same data in memory""" return a.data == b.data @pytest.fixture(scope='module') def model(): ret...
Python
2D
dean0x7d/pybinding
tests/test_kpm.py
.py
7,527
198
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene, group6_tmd models = { 'graphene-pristine': [graphene.monolayer(), pb.rectangle(15)], 'graphene-pristine-oversized': [graphene.monolayer(), pb.rectangle(20)], 'graphene-const_potential': [graphene.monolayer()...
Python
2D
dean0x7d/pybinding
tests/test_system.py
.py
3,047
77
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene, group6_tmd models = { 'graphene-monolayer': [graphene.monolayer(), graphene.hexagon_ac(1)], 'graphene-monolayer-alt': [graphene.monolayer_alt(), pb.rectangle(1.6, 1.4)], 'graphene-monolayer-4atom': [graphene...
Python
2D
dean0x7d/pybinding
tests/test_kwant.py
.py
4,093
110
import pytest import numpy as np import pybinding as pb from pybinding.support.kwant import kwant_installed from pybinding.repository import graphene, group6_tmd if not kwant_installed: def test_kwant_error(): """Raise an exception if kwant isn't installed""" model = pb.Model(graphene.monolayer(...
Python
2D
dean0x7d/pybinding
tests/test_parallel.py
.py
1,675
53
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene def silence_parallel_output(factory): factory.hooks.status.clear() factory.config.pbar_fd = None factory.config.filename = None def test_sweep(baseline, plot_if_fails): @pb.parallelize(v=np.linspace(0,...
Python
2D
dean0x7d/pybinding
tests/test_results.py
.py
3,741
118
import pytest import pickle import numpy as np import pybinding as pb from pybinding.repository import graphene @pytest.fixture(scope='module') def model(): return pb.Model(graphene.monolayer(), pb.rectangle(1)) def test_sweep(): x0 = np.arange(3) y0 = np.arange(-1, 2) data0 = np.arange(9).reshape...
Python
2D
dean0x7d/pybinding
tests/__init__.py
.py
0
0
null
Python
2D
dean0x7d/pybinding
tests/test_shape.py
.py
3,216
95
import pytest import math import numpy as np import pybinding as pb from pybinding.repository import graphene, examples polygons = { 'triangle': pb.regular_polygon(3, radius=1.1), 'triangle90': pb.regular_polygon(3, radius=1.1, angle=math.pi/2), 'diamond': pb.regular_polygon(4, radius=1), 'square': p...
Python
2D
dean0x7d/pybinding
tests/test_pickle.py
.py
915
43
import pytest import pathlib import pybinding as pb mock_data = list(range(10)) def round_trip(obj, file): pb.save(obj, file) return pb.load(file) == obj def test_path_type(tmpdir): # str file = str(tmpdir / 'file') assert round_trip(mock_data, file) # py.path.local object file = tmpd...
Python
2D
dean0x7d/pybinding
tests/test_wrapper.py
.py
525
20
import numpy as np from _pybinding import wrapper_tests def test_variant_caster(): assert wrapper_tests.variant_cast() == (5, "Hello") assert wrapper_tests.variant_load(1) == "int" assert wrapper_tests.variant_load("1") == "std::string" def test_array_ref(): r = wrapper_tests.TestArrayRef() as...
Python
2D
dean0x7d/pybinding
tests/test_modifiers.py
.py
23,419
663
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene one, zero = np.ones(1), np.zeros(1) complex_one = np.ones(1, dtype=np.complex64) def build_model(*params): model = pb.Model(graphene.monolayer(), *params) model.report() return model def test_modifier_fu...
Python
2D
dean0x7d/pybinding
tests/test_lattice.py
.py
11,364
308
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene from pybinding.support.deprecated import LoudDeprecationWarning lattices = { "graphene-monolayer": graphene.monolayer(), "graphene-monolayer-nn": graphene.monolayer(2), "graphene-monolayer-4atom": graphene.mo...
Python
2D
dean0x7d/pybinding
tests/test_solver.py
.py
3,071
92
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene solvers = ['arpack'] if hasattr(pb._cpp, 'FEAST'): solvers.append('feast') models = { 'graphene-magnetic_field': {'model': [graphene.monolayer(), pb.rectangle(6), graphe...
Python
2D
dean0x7d/pybinding
tests/test_leads.py
.py
3,665
107
import pytest import numpy as np import pybinding as pb from pybinding.repository import graphene, examples @pytest.fixture def ring_model(): def ring(inner_radius, outer_radius): def contains(x, y, _): r = np.sqrt(x**2 + y**2) return np.logical_and(inner_radius < r, r < outer_rad...
Python
2D
dean0x7d/pybinding
tests/conftest.py
.py
3,408
109
import pytest from contextlib import suppress import matplotlib as mpl mpl.use('Agg') # disable `plt.show()` popup window during testing import matplotlib.pyplot as plt import pybinding as pb from .utils.path import path_from_fixture from .utils.compare_figures import CompareFigure from .utils.fuzzy_equal import F...
Python
2D
dean0x7d/pybinding
tests/utils/fuzzy_equal.py
.py
5,396
160
import math import numbers from functools import singledispatch, update_wrapper import numpy as np from scipy.sparse import csr_matrix, coo_matrix import pybinding as pb def _assertdispatch(func): """Adapted `@singledispatch` for custom assertions * Works with methods instead of functions * Keeps track...
Python
2D
dean0x7d/pybinding
tests/utils/__init__.py
.py
0
0
null
Python
2D
dean0x7d/pybinding
tests/utils/compare_figures.py
.py
4,392
130
import os import shutil import tempfile import warnings from contextlib import suppress import matplotlib as mpl import matplotlib.style import matplotlib.units import matplotlib.pyplot as plt from matplotlib.testing.compare import compare_images import pybinding.pltutils as pltutils from .path import path_from_fixt...
Python
2D
dean0x7d/pybinding
tests/utils/path.py
.py
1,192
37
import pathlib def path_from_fixture(request, prefix, variant='', ext='', override_group=''): """Use a fixture's `request` argument to create a unique file path The final return path will look like: prefix/module_name/test_name[fixture_param]variant.ext Parameters ---------- request ...
Python
2D
AbbasHub/Improved_Phase-Field_LBM_2D
Improved_phase-field_Periodic_2D.f90
.f90
12,048
486
!**************************************************************** ! ! Improved conservative phase-field LBM solver ! for two-phase flows in a periodic domain (2D) ! !---------------------------------------------------------------- ! Based on the following paper: ! ! A. Fakhari, T. Mitchell, C. Leonardi, and D. Bolster,...
Fortran
2D
cheminfo/nmrium
CHANGELOG.md
.md
187,750
1,835
# Changelog ## [1.10.1](https://github.com/cheminfo/nmrium/compare/v1.10.0...v1.10.1) (2025-12-12) ### Bug Fixes * display molecule when no active tab ([bc903f7](https://github.com/cheminfo/nmrium/commit/bc903f77a5fbc35b0a52d6fb5c7d48781d62c301)) ## [1.10.0](https://github.com/cheminfo/nmrium/compare/v1.9.0...v1.1...
Markdown
2D
lherron2/thermomaps-ising
thermomaps_ising.ipynb
.ipynb
453,636
1,411
{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "gpuType": "T4", "authorship_tag": "ABX9TyOLqvU13qBmIUH3Vd3sPTRK", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info"...
Unknown
2D
lherron2/thermomaps-ising
thermomaps-root/setup.py
.py
719
27
from setuptools import setup, find_packages import os setup( name="thermomaps", version="0.1", packages=find_packages(), install_requires=[], author="Lukas", author_email="lherron@umd.edu", description="A Python module to study molecular dynamics simulations using Thermodynamic Maps", c...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/cli/tm_cli.py
.py
4,080
99
import os import numpy as np # import matplotlib.pyplot as plt from slurmflow.serializer import ObjectSerializer from data.generic import Summary import argparse import logging # logging.getLogger('matplotlib').setLevel(logging.WARNING) logging.getLogger('tm.core.DiffusionModel').setLevel(logging.INFO) logging.getLo...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/cli/ising_cli.py
.py
6,656
117
import numpy as np import os from slurmflow.config import ConfigParser from slurmflow.serializer import ObjectSerializer from slurmflow.driver import SlurmDriver from ising.base import IsingModel from ising.samplers import SwendsenWangSampler, SingleSpinFlipSampler from ising.observables import Energy, Magnetization ...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/cli/__init__.py
.py
14
2
import pprint
Python
2D
lherron2/thermomaps-ising
thermomaps-root/cli/thermomap.py
.py
10,407
332
import os import torch import argparse import numpy as np from tm.core.backbone import ConvBackbone from tm.core.diffusion_model import DiffusionTrainer, SteeredDiffusionSampler from tm.core.diffusion_process import VPDiffusion from tm.core.loader import Loader from tm.core.prior import LocalEquilibriumHarmonicPrior, G...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/ising/samplers.py
.py
5,609
166
import numpy as np import random from typing import Callable, Dict, List, Type from abc import ABC, abstractmethod from ising.base import IsingModel import logging logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) class Sampler(ABC): """ Abstract base class for samplers in the Ising model. ...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/ising/swedsen_wang_simulator.py
.py
14,503
375
import numpy as np import random from typing import Callable, Dict, List from abc import ABC, abstractmethod class Observable(ABC): """ Abstract base class for observables in the Ising model. An observable is a physical quantity that can be measured in a simulation. Attributes: name (str): Th...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/ising/__init__.py
.py
0
0
null
Python
2D
lherron2/thermomaps-ising
thermomaps-root/ising/base.py
.py
3,147
84
import numpy as np import random import sys from typing import Callable, Dict, List, Type from abc import ABC, abstractmethod from data.trajectory import EnsembleIsingTrajectory from data.generic import Summary from ising.observables import Energy, Magnetization from slurmflow.serializer import ObjectSerializer impor...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/ising/observables.py
.py
3,640
112
import numpy as np from abc import ABC, abstractmethod from data.observables import Observable import logging logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) class Energy(Observable): """ Class for calculating the energy of a lattice. Energy is defined as the sum of the interaction ene...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/tm/__init__.py
.py
0
0
null
Python
2D
lherron2/thermomaps-ising
thermomaps-root/tm/core/FluctuationDataset.py
.py
6,436
190
import numpy as np from inspect import signature from scipy.optimize import curve_fit import types def safe_index(arr, idx): if idx < len(arr): return arr[idx] else: return arr[-1] def linear_fit(x, a, b): return x*a + b class Fluctuation: """ A class for performing fluctuation a...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/tm/core/Directory.py
.py
3,276
124
import os class Directory: """ Reads relevant paths from a YAML file defined for an experiment. """ def __init__( self, pdb: str, expid: str, iter: str, identifier: str, device: str, num_devices: int, **paths ): """ I...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/tm/core/backbone.py
.py
7,574
237
import torch.nn as nn import torch from torch.optim.lr_scheduler import MultiStepLR import os from tm.core.utils import Interpolater, default import logging logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) class Backbone(nn.Module): """ Diffusion wrapper for instances of deep learning archit...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/tm/core/diffusion_model.py
.py
17,506
530
import torch import os import numpy as np import logging logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) def temperature_density_rescaling(std_temp, ref_temp): """ Calculate temperature density rescaling factor. Args: std_temp (float): The standard temperature. ref_temp...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/tm/core/diffusion_process.py
.py
8,409
267
import torch from torch import vmap import logging logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) def polynomial_noise(t, alpha_max, alpha_min, s=1e-5, **kwargs): """ Generate polynomial noise schedule used in Hoogeboom et. al. Args: t (torch.Tensor): Time steps. alph...
Python
2D
lherron2/thermomaps-ising
thermomaps-root/tm/core/prior.py
.py
3,435
69
import torch import numpy as np from typing import Any, Callable, Dict, List import sys import logging logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) logger.addHandler(logging.StreamHandler(sys.stdout)) class UnitNormalPrior: def __init__(self, shape, channels_info): self.channels_info ...
Python