dipc-cc / hubbard

Python tools for mean-field Hubbard models
https://dipc-cc.github.io/hubbard/
GNU Lesser General Public License v3.0
21 stars 8 forks source link

Add H-Atoms #107

Closed mlorenznano closed 2 years ago

mlorenznano commented 2 years ago

Hello,

I wanted to add H-Atoms to one edge of an AGNR-structure using the command geom.add_Hatoms but I found that this comment was removed during one update (probably because the geometry module used currently is the one from sisl and not the one from the Hubbard code itself).

Is there another way of adding H-Atoms except creating a new .xyz file?

Thank you very much! Lorenz

sofiasanz commented 2 years ago

Hi! Yes, we removed that function since it doesn't actually belong to this package. I don't know if sisl has a function to add H atoms, @zerothi ?

In any case I can leave you here the function that we had for adding H atoms to sp2 carbon-like nanostructures, hope is useful:

import numpy as np
import sisl

def add_Hatoms(geom, d=1.1, sp3=[]):
    ''' Function to saturate edge C atoms with Hydrogen 

    Parameters
    ----------
    geom : sisl.Geometry instance
        geometry of the system that is going to be saturated with H-atoms
    d : float, optional
        distance from the saturated C-atom to the H-atom
    sp3 : array_like, optional
        atomic indices where an sp3 configuration is desired

    Returns
    -------
    sisl.Geometry object of the system saturated with H-atoms
    '''
    Hxyz = []
    for ia in geom:
        idx = geom.close(ia, R=(0.1, 1.6))
        if len(idx[1]) == 2:
            a, b = idx[1]
            v1 = geom.axyz(a) - geom.xyz[ia, :]
            v2 = geom.axyz(b) - geom.xyz[ia, :]
            p = -1*(v1 + v2)
            p = p * d / ((p**2).sum())**0.5
            Hxyz.append(p+geom.xyz[ia, :])
            if ia in sp3:
                Hxyz[-1][2] -= 1.5
                p = Hxyz[-1]-geom.xyz[ia, :]
                p = p * d / ((p**2).sum())**0.5
                Hxyz[-1] = p + geom.xyz[ia, :]
                Hxyz.append(Hxyz[-1]*1.0)
                Hxyz[-1][2] -= 2*Hxyz[-1][2]
    Hgeom = sisl.Geometry(Hxyz, sisl.Atom(Z=1, R=d), sc=geom.sc)
    return geom.add(Hgeom)
zerothi commented 2 years ago

Yes, I really wanted to expand on Thomas' idea in https://github.com/zerothi/sisl/pull/202 I just never got there... :(

tfrederiksen commented 2 years ago

Yes, I really wanted to expand on Thomas' idea in zerothi/sisl#202 I just never got there... :(

Me neither...

sofiasanz commented 2 years ago

Hi @mlorenznano was this useful for you? Can we close this issue?

mlorenznano commented 2 years ago

Sorry I completely forgot to answer.. Yes we can close the issue.