Git Product home page Git Product logo

Comments (4)

BertJorissen avatar BertJorissen commented on July 28, 2024

Hi
you have to define the hopping names first, and pass them as a string to the hoppings that you want.
The modifier should be applied in the model.
I modified you script a bit, but the part you sent was incomplete.

import pybinding as pb
from pybinding.repository.graphene import a
import matplotlib.pyplot as plt
from numpy import sqrt, pi

phi0 = 1
a_cc = a/np.sqrt(3) # nm, carbon carbon bond length
gamma = 3.033 # eV hopping energy from full solution of tight binding nearest neighbor
t1 = gamma
t2 = gamma
t3 = gamma

lat = pb.Lattice(a1=a*np.array([1/2,np.sqrt(3)/2]), a2=a*np.array([1/2,-np.sqrt(3)/2]))
lat.add_sublattices(
        ('A',[0, -a_cc/2], 0),
        ('B', [0, a_cc/2], 0)
)
lat.register_hopping_energies({'t1':t1, 't2': t2, 't3': t3})
lat.add_hoppings(
        ([0,0],'A','B',"t1"),
        ([0,1],'A','B',"t2"),
        ([1,0],'B','A',"t3")
)
lat.plot()
plt.show()
plt.savefig("lat.pdf")
def vectorPotential(ab, x, y):
    b1Term = -(1/sqrt(3))*np.sin((2*pi*x/ab) - (2*pi*y/(ab*sqrt(3))))
    b2Term = (2/sqrt(3))*np.cos(4*pi*y/(sqrt(3)*ab))
    b3Term = (1/sqrt(3))*np.cos((2*pi*x/ab)+(2*pi*y/(ab*sqrt(3))))
    Ax = b1Term + b2Term + b3Term
    return Ax

shiftInEnergies = []
def pilarStrain(B,ab):
    @pb.hopping_energy_modifier
    def strained_hopping(energy, x1, y1, z1, x2, y2, z2, hop_id):
        Ax = vectorPotential(ab,x1,y1)
        t1_shifted = gamma*(1-(((3*pi*a_cc*B)/(2*phi0))*Ax))
        t2_shifted = gamma*(1+(((3*pi*a_cc*B)/(2*phi0))*Ax))
        t3_shifted = t2_shifted
        xVec = x2-x1
        yVec = y2-y1
        energy[hop_id == 't1'] *= 1.1
        if hop_id == 't1':
            energy = t1_shifted
        elif hop_id == 't2':
            energy = t2_shifted
        elif hop_id == 't3':
            energy = t3_shifted
        global shiftInEnergies
        shiftInEnergies = energy - gamma
        return energy
    return  strained_hopping

model = pb.Model(
        lat,
        pb.primitive(10, 10),
        pb.translational_symmetry(10*a,10*a),
        pilarStrain(1, 1)
)

plt.figure()
bz = lat.brillouin_zone()
bands = pb.solver.lapack(model).calc_wavefunction(bz[3]*0, bz[3]/100, (bz[3]+bz[4])/200, bz[3]*0, step=0.001).bands_disentangled
plt.plot(bands.k_path.as_1d(), bands.energy)
plt.gca().set_ylim([-.5, .5])
plt.show()
plt.savefig("band.pdf")

from pybinding.

oldpoppasmurf avatar oldpoppasmurf commented on July 28, 2024

Thanks that now works and it modifies all the energies, I thought I needed to name after as the hoppings didn't exist yet. The only problem now is when running the example you added it gives an error 'Solver' object has no attribute 'calc_wavefunction'?

from pybinding.

BertJorissen avatar BertJorissen commented on July 28, 2024

Dean hasn't yet given me write permissions to pybinding, it's a new feature to disentangle large bands. It is also possible to do a calculation on a larger system with ARPACK and disentangling the bands to see if you have a crossing or not at an intersection of two bands.
You can install the new version with the following commands:

pip uninstall pybinding
pip install -i https://test.pypi.org/simple/ pybinding

Due to recent changes in Matplotlib, there is a possibility that you encounter an error when plotting certain things. This will be solved in a new release of Matplotlib.

from pybinding.

oldpoppasmurf avatar oldpoppasmurf commented on July 28, 2024

Ah ok then, worked fine with new version thanks for the help, disintangling bands will be a great help as I will be using some fairly large superlattices

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.