Git Product home page Git Product logo

Comments (2)

dean0x7d avatar dean0x7d commented on June 16, 2024

Hi @empyriumz,

It's possible. Like with any function-dependent onsite or hopping energy in pybinding, you just need a modifier function:

import pybinding as pb
import numpy as np


def chain_lattice(d):
    lat = pb.Lattice(a1=[d])
    lat.add_sublattices(("A", [0]))
    lat.add_hoppings(([1], "A", "A", 1.0))
    return lat


def random_hopping(mu):
    @pb.hopping_energy_modifier
    def func(energy):
        return np.random.normal(mu, 1, size=energy.size)  # size is required
    return func


model = pb.Model(
    chain_lattice(d=0.1),
    pb.primitive(a1=6),
    random_hopping(mu=0)
)

The model creation process in pybinding is a bit different than kwant. In pybinding, the initial unit cell is created as a constant (usually this represents the pristine material). Any functions which need to be applied to multiple unit cells are introduced using modifiers (which act on the pristine material).

Note that the size argument was given to np.random.normal so that it returns an array of random numbers instead of just a single one. This is because the modifier functions in pybinding are applied to all sites/hoppings at the same time (as numpy array operations), as opposed to kwant which applies one site/hopping at a time.

See this tutorial page for more information about modifier functions: http://docs.pybinding.site/en/stable/tutorial/fields.html

from pybinding.

empyriumz avatar empyriumz commented on June 16, 2024

Hi @dean0x7d,

Great it works! Thx a lot.

from pybinding.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.