예제 #1
0
    def __init__(self, data, ID, name='', meta_data={}, file_format='cube'):

        self.dk3D = float(config.get_key('orbital', 'dk3D'))

        AbstractData.__init__(self, ID, name, meta_data)
        Orbital.__init__(self, data, file_format=file_format, dk3D=self.dk3D,
                         value='abs2', orbital_name=name)
예제 #2
0
    def setUpClass(cls):

        dir_path = os.path.dirname(os.path.realpath(__file__))
        filepath = dir_path + '/input/pentacene_HOMO.cube'
        with open(filepath) as file:
            cls.cubefile = file.read()
        cls.orbital = Orbital(cls.cubefile, dk3D=0.15, E_kin_max=50)
예제 #3
0
    pov.set_camera({'location':'<5.0,8.0, 7.0>','look_at':'<0.0,0.0,0.0>'})

    # write povray-files
    if domain == 'reciprocal':
        povname = 'ID%i_%s_3DFT.pov'%(ID, orbital_name)
        pov.write_povfile(povname, add_stuff=FT_stuff) # use append to avoid writing header twice

    else:
        povname = 'ID%i_%s.pov'%(ID, orbital_name)
        pov.write_povfile(povname, add_stuff=real_stuff) # use append to avoid writing header twice

    pov.run_povray(executable='povray +W1600 +H1200')


# now compute 2D-momentum map
orbital = Orbital(cubefile, dk3D=0.10, E_kin_max=80)    # compute 3D Fourier transform (see Eqs. 6-11)  
orbital.get_kmap(E_kin=E_kin, Ak_type='no', phi=phi, polarization='p', alpha=45)   # compute momentum map for kinetic energy E_kin (Eq. 12)
data = orbital.Ak['data']*orbital.kmap['data'] 
data = np.abs(data)

# make plot
krange = orbital.kmap['krange']
limits = [krange[0][0], krange[0][1], krange[1][0], krange[1][1]]

plt.rcParams.update({
    "text.usetex": True,
    "font.family": "serif",
    "font.serif": ["Computer Modern Roman"],
})
# plot kmap 
fig, ax = plt.subplots(1,1)
예제 #4
0
    def init_from_cube(cls,
                       cubefile,
                       domain,
                       settingsfile,
                       dk3D=0.15,
                       E_kin_max=150,
                       value='abs2',
                       isosurface=True,
                       structure=True):

        from kmap.library.orbital import Orbital
        # Orbital object contains molecular geometry and psi(x,y,z)
        orbital = Orbital(cubefile,
                          dk3D=dk3D,
                          E_kin_max=E_kin_max,
                          value=value)

        if domain == 'real':
            if isosurface:
                data = orbital.psi['data']
                grid = {
                    'origin': [
                        orbital.psi['x'][0], orbital.psi['y'][0],
                        orbital.psi['z'][0]
                    ],
                    'nx':
                    orbital.psi['nx'],
                    'ny':
                    orbital.psi['ny'],
                    'nz':
                    orbital.psi['nz'],
                    'a': [orbital.psi['x'][-1] - orbital.psi['x'][0], 0, 0],
                    'b': [0, orbital.psi['y'][-1] - orbital.psi['y'][0], 0],
                    'c': [0, 0, orbital.psi['z'][-1] - orbital.psi['z'][0]]
                }
            else:
                data, grid = [], {}

            if structure:
                structure = orbital.molecule

            else:
                structure = None

        elif domain == 'reciprocal':
            if isosurface:
                data = orbital.psik['data']
                grid = {
                    'origin': [
                        orbital.psik['kx'][0], orbital.psik['ky'][0],
                        orbital.psik['kz'][0]
                    ],
                    'nx':
                    orbital.psik['data'].shape[0],
                    'ny':
                    orbital.psik['data'].shape[1],
                    'nz':
                    orbital.psik['data'].shape[2],
                    'a':
                    [orbital.psik['kx'][-1] - orbital.psik['kx'][0], 0, 0],
                    'b':
                    [0, orbital.psik['ky'][-1] - orbital.psik['ky'][0], 0],
                    'c':
                    [0, 0, orbital.psik['kz'][-1] - orbital.psik['kz'][0]]
                }
            else:
                data, grid = [], {}

            structure = None

        return cls(data, grid, structure, settingsfile)
예제 #5
0
# kMap.py Imports
from kmap.library.orbital import Orbital

hdf5_path = '../data/ID_00002.hdf5'  # local hdf5-path
server = '143.50.77.12'
port = '5002'
moleculeID = 2
orbital_names = ['2P_MO_40', '2P_MO_41', '2P_MO_42', '2P_MO_43']
orbital_numbers = [10, 11, 12, 13]

# read orbitals from local hdf5-file
fig, _ax = plt.subplots(2, 2)
ax = _ax.flatten()
for i, orbital_name in enumerate(orbital_names):
    orbital = Orbital.init_from_local_hdf5(hdf5_path, orbital_name)
    orbital._write_cube(orbital_name + '.cube')  # optionally write cube-files
    orbital.get_kmap(E_kin=30.0)
    orbital.plot(ax[i], title=orbital_name)

# read orbitals from remote hdf5-file
fig, _ax2 = plt.subplots(2, 2)
ax2 = _ax2.flatten()
for i, orbital_number in enumerate(orbital_numbers):
    orbital = Orbital.init_from_remote_hdf5(server, port, moleculeID,
                                            orbital_number)
    orbital._write_cube('%s.cube' %
                        orbital_number)  # optionally write cube-files
    orbital.get_kmap(E_kin=30.0)
    orbital.plot(ax2[i], title=orbital.psi['name'])
예제 #6
0
from pathlib import Path

# Third Party Imports
import matplotlib.pyplot as plt

# kMap.py Imports
from kmap.library.orbital import Orbital

# Path to data folder; replace with your own; use '/' instead of '+'
# when concatenating with strings
data_path = Path(__file__).parent / Path('../data/')

cubefile = open(data_path /
                'pentacene_HOMO.cube').read()  # read cube-file from file
h**o = Orbital(
    cubefile,  # compute 3D Fourier transform (see Eqs. 6-11)  
    dk3D=0.15
)  # with a desired k-spacing of dkx = dky = dkz = 0.15 1/Angstroem

fig, ax = plt.subplots(1, 3)  # create empty figure with 3 axes

# plot Figure 3(a): H**O of pentacene with phi = 30°
h**o.get_kmap(
    E_kin=30,  # compute momentum map for E_kin = 30 eV (Eq. 12)
    phi=30)  # Euler angle phi = 30
h**o.plot(ax[0])  # plot kmap in axis 0

# plot Figure 3(b): H**O of pentacene with phi = 0°, theta = -45°
h**o.get_kmap(
    E_kin=30,  # compute momentum map for E_kin = 30 eV (Eq. 12)
    phi=0,  # Euler angle phi = 0   
    theta=-45)  # Euler angle theta = -45
예제 #7
0
    def init_from_orbital_photonenergy(cls, name, orbital, parameters):
        """Returns a SlicedData object with the data[photonenergy,kx,ky] 
           computed from the kmaps of one orbital for a series of
           photon energies.

        Args:
            name (str): name for SlicedData object
            orbital (list): [ 'URL',dict ]
                dict needs keys: 'energy' and 'name' 
            parameters (list): list of parameters
                hnu_min (float): minimal photon energy
                hnu_max (float): maximal photon energy
                hnu_step (float): stepsize for photon energy
                fermi_energy (float): Fermi energy in eV
                dk (float): Desired k-resolution in kmap in Angstroem^-1.
                phi (float): Euler orientation angle phi in degree.
                theta (float): Euler orientation angle theta in degree.
                psi (float): Euler orientation angle psi in degree.
                Ak_type (string): Treatment of |A.k|^2: either 'no',
                        'toroid' or 'NanoESCA'.
                polarization (string): Either 'p', 's', 'unpolarized', C+', 'C-' or
                        'CDAD'.   
                alpha (float): Angle of incidence plane in degree.
                beta (float): Azimuth of incidence plane in degree.
                gamma (float/str): Damping factor for final state in
                        Angstroem^-1. str = 'auto' sets gamma automatically
                symmetrization (str): either 'no', '2-fold', '2-fold+mirror',
                        '3-fold', '3-fold+mirror','4-fold', '4-fold+mirror'
        Returns:
            (SlicedData): SlicedData containing kmaps for various photon energies
        """

        log = logging.getLogger('kmap')
        orbital = orbital[0]  # only consider first orbital in list!

        # extract parameters
        hnu_min = parameters[0]
        hnu_max = parameters[1]
        hnu_step = parameters[2]
        fermi_energy = parameters[3]
        dk = parameters[4]
        phi, theta, psi = parameters[5], parameters[6], parameters[7]
        Ak_type = parameters[8]
        polarization = parameters[9]
        alpha, beta, gamma = parameters[10], parameters[11], parameters[12]
        symmetrization = parameters[13]

        # binding energy of orbital and work function
        BE = orbital[1]['energy'] - fermi_energy
        Phi = -fermi_energy  # work function

        # determine axis_1 = photon energy
        hnu = np.arange(hnu_min, hnu_max, hnu_step)
        n_hnu = len(hnu)

        axis_1 = ['photonenergy', 'eV', [hnu_min, hnu_max]]

        # determine axis_2 and axis_3 kmax at BE_max
        E_kin_max = hnu[-1] - Phi + BE
        k_max = energy_to_k(E_kin_max)
        nk = int((2 * k_max) / dk) + 1
        k_grid = np.linspace(-k_max, +k_max, nk)
        nk = len(k_grid)
        axis_2 = ['kx', '1/Å', [-k_max, +k_max]]
        axis_3 = ['ky', '1/Å', [-k_max, +k_max]]

        # initialize 3D-numpy array with zeros
        data = np.zeros((n_hnu, nk, nk))
        orbital_names = []

        log.info('Adding orbital to SlicedData Object, please wait!')
        # read orbital from cube-file database
        url = orbital[0]
        log.info('Loading from database: %s' % url)
        with urllib.request.urlopen(url) as f:
            file = f.read().decode('utf-8')
            orbital_data = Orbital(file)

        # loop over photon energies
        for i in range(len(hnu)):

            # kinetic energy of emitted electron
            E_kin = hnu[i] - Phi + BE
            kmap = orbital_data.get_kmap(E_kin, dk, phi, theta, psi, Ak_type,
                                         polarization, alpha, beta, gamma,
                                         symmetrization)
            kmap.interpolate(k_grid, k_grid, update=True)
            data[i, :, :] = kmap.data

        # define meta-data for tool-tip display
        orbital_info = orbital[1]

        meta_data = {
            'Fermi energy (eV)': fermi_energy,
            'Molecular orientation': (phi, theta, psi),
            '|A.k|^2 factor': Ak_type,
            'Polarization': polarization,
            'Incidence direction': (alpha, beta),
            'Symmetrization': symmetrization,
            'Orbital Info': orbital_info
        }

        return cls(name, axis_1, axis_2, axis_3, data, meta_data)
예제 #8
0
파일: demo_3D-FT.py 프로젝트: brands-d/kMap
import pyqtgraph as pg
import pyqtgraph.opengl as gl  # pip install PyOpenGL

# kMap.py Imports
from kmap.library.orbital import Orbital
from kmap.library.misc import energy_to_k

### MAIN PROGRAM ######################################################

# Path to data folder; replace with your own; use '/' instead of '+'
# when concatenating with strings
data_path = Path(__file__).parent / Path('../data/')

cubefile = open(data_path /
                'tetracene_HOMO.cube').read()  # read cube-file from file
orbital = Orbital(cubefile, dk3D=0.15, E_kin_max=150, value='imag')
data = orbital.psik['data']
kx, ky, kz = orbital.psik['kx'], orbital.psik['ky'], orbital.psik['kz']
dx, dy, dz = kx[1] - kx[0], ky[1] - ky[0], kz[1] - kz[0]
nx, ny, nz = len(kx), len(ky), len(kz)

# initialize GLViewWidget()
app = QtGui.QApplication([])
w = gl.GLViewWidget()
w.show()
w.setWindowTitle('test')
w.setCameraPosition(distance=100, elevation=90, azimuth=-90)  # view from top

# display grid in (x,y)-plane
g = gl.GLGridItem()
g.setSize(x=8, y=8, z=8)
예제 #9
0
    def init_from_orbitals(cls, name, orbitals, parameters):
        """Returns a SlicedData object with the data[BE,kx,ky] 
           computed from the kmaps of several orbitals and
           broadened in energy.

        Args:
            name (str): name for SlicedData object
            orbitals (list): [[ 'URL1',dict1], ['URL2',dict2], ...]
                dict needs keys: 'energy' and 'name' 
            parameters (list): list of parameters
                photon_energy (float): Photon energy in eV.
                fermi_energy (float): Fermi energy in eV
                energy_broadening (float): FWHM of Gaussian energy broadenening in eV
                dk (float): Desired k-resolution in kmap in Angstroem^-1.
                phi (float): Euler orientation angle phi in degree.
                theta (float): Euler orientation angle theta in degree.
                psi (float): Euler orientation angle psi in degree.
                Ak_type (string): Treatment of |A.k|^2: either 'no',
                        'toroid' or 'NanoESCA'.
                polarization (string): Either 'p', 's', 'unpolarized', C+', 'C-' or
                        'CDAD'.   
                alpha (float): Angle of incidence plane in degree.
                beta (float): Azimuth of incidence plane in degree.
                gamma (float/str): Damping factor for final state in
                        Angstroem^-1. str = 'auto' sets gamma automatically
                symmetrization (str): either 'no', '2-fold', '2-fold+mirror',
                        '3-fold', '3-fold+mirror','4-fold', '4-fold+mirror'
        Returns:
            (SlicedData): SlicedData containing kmaps of all orbitals
        """

        log = logging.getLogger('kmap')
        # extract parameters
        photon_energy = parameters[0]
        fermi_energy = parameters[1]
        energy_broadening = parameters[2]
        dk = parameters[3]
        phi, theta, psi = parameters[4], parameters[5], parameters[6]
        Ak_type = parameters[7]
        polarization = parameters[8]
        alpha, beta, gamma = parameters[9], parameters[10], parameters[11]
        symmetrization = parameters[12]

        # determine axis_1 from minimal and maximal binding energy
        extend_range = 3 * energy_broadening
        energies = []

        for orbital in orbitals:
            energies.append(orbital[1]['energy'])

        BE_min = min(energies) - fermi_energy - extend_range
        BE_max = max(energies) - fermi_energy + extend_range
        # set energy grid spacing 6 times smaller than broadening
        dBE = energy_broadening / 6
        nBE = int((BE_max - BE_min) / dBE) + 1
        BE = np.linspace(BE_min, BE_max, nBE)
        nBE = len(BE)
        axis_1 = ['-BE', 'eV', [BE_min, BE_max]]

        # determine axis_2 and axis_3 kmax at BE_max
        Phi = -fermi_energy  # work function
        E_kin_max = photon_energy - Phi + BE_max
        k_max = energy_to_k(E_kin_max)
        nk = int((2 * k_max) / dk) + 1
        k_grid = np.linspace(-k_max, +k_max, nk)
        nk = len(k_grid)
        axis_2 = ['kx', '1/Å', [-k_max, +k_max]]
        axis_3 = ['ky', '1/Å', [-k_max, +k_max]]

        # initialize 3D-numpy array with zeros
        data = np.zeros((nBE, nk, nk))
        orbital_names = []

        # add kmaps of orbitals to
        log.info('Adding orbitals to SlicedData Object, please wait!')
        for orbital in orbitals:
            # binding energy of orbital
            BE0 = orbital[1]['energy'] - fermi_energy
            # kinetic energy of emitted electron
            E_kin = photon_energy - Phi + BE0

            # Gaussian weight function
            norm = (1 / np.sqrt(2 * np.pi * energy_broadening**2))
            weight = norm * \
                np.exp(-((BE - BE0)**2 / (2 * energy_broadening**2)))

            url = orbital[0]
            log.info('Loading from database: %s' % url)
            with urllib.request.urlopen(url) as f:
                file = f.read().decode('utf-8')
                orbital_data = Orbital(file)

            orbital_names.append(orbital[1]['name'])
            log.info('Computing k-map for %s' % orbital[1]['name'])

            kmap = orbital_data.get_kmap(E_kin, dk, phi, theta, psi, Ak_type,
                                         polarization, alpha, beta, gamma,
                                         symmetrization)
            kmap.interpolate(k_grid, k_grid, update=True)
            log.info('Adding to 3D-array: %s' % orbital[1]['name'])
            for i in range(len(BE)):
                data[i, :, :] += weight[i] * np.nan_to_num(kmap.data)

        # set NaNs outside photoemission horizon
        KX, KY = np.meshgrid(k_grid, k_grid)
        for i in range(len(BE)):
            E_kin = photon_energy - Phi + BE[i]
            k_max = energy_to_k(E_kin)
            out = np.sqrt(KX**2 + KY**2) > k_max
            tmp = data[i, :, :]
            tmp[out] = np.NaN
            data[i, :, :] = tmp

        # define meta-data for tool-tip display
        orbital_info = {}
        for orbital_name, energy in zip(orbital_names, energies):
            orbital_info[orbital_name] = energy

        meta_data = {
            'Photon energy (eV)': photon_energy,
            'Fermi energy (eV)': fermi_energy,
            'Energy broadening (eV)': energy_broadening,
            'Molecular orientation': (phi, theta, psi),
            '|A.k|^2 factor': Ak_type,
            'Polarization': polarization,
            'Incidence direction': (alpha, beta),
            'Symmetrization': symmetrization,
            'Orbital Info': orbital_info
        }

        return cls(name, axis_1, axis_2, axis_3, data, meta_data)
예제 #10
0
from pathlib import Path

# Third Party Imports
import matplotlib.pyplot as plt

# kMap.py Imports
from kmap.library.orbital import Orbital

# Path to data folder; replace with your own; use '/' instead of '+'
# when concatenating with strings
data_path = Path(__file__).parent / Path('../data/')

cubefile = open(data_path /
                'pentacene_HOMO.cube').read()  # read cube-file from file
h**o = Orbital(
    cubefile,  # compute 3D Fourier transform (see Eqs. 6-11)  
    dk3D=0.15
)  # with a desired k-spacing of dkx = dky = dkz = 0.15 1/Angstroem

fig, ax = plt.subplots(1, 3)  # create empty figure with 3 axes

# plot Figure 4(a): H**O of pentacene with polarization P_p according to Eq. 17
h**o.get_kmap(
    E_kin=30,  # compute momentum map for E_kin = 30 eV (Eq. 12)
    dk=0.03,  # desired grid spacing in kmap in 1/Angstroem
    phi=0,
    theta=0,
    psi=0,  # Euler angles phi=0, theta=0, psi=0 
    Ak_type='NanoESCA',  # p-polarized light according to Eq. (17) 
    polarization='p',
    alpha=45,  # angle of incidence
    beta=60)  # azimuth of incidence plane
예제 #11
0
# define common (kx,ky)-grid for deconvolution
k_range, dk = [-3.0, 3.0], 0.04
num = step_size_to_num(k_range, dk)
kx = np.linspace(k_range[0], k_range[1], num)
ky = kx

# read PTCDA orbitals from file and compute kmaps
names = ['PTCDA_C', 'PTCDA_D', 'PTCDA_E', 'PTCDA_F', 'background']
styles = ['.r-', 'k-', 'r--', '^g-', 'k:']
params = Parameters()  # parameters object for minimization

sim_kmaps = []
for name in names[:-1]:
    # read cube-file from file
    cuberead = open(data_path / (name + '.cube')).read()
    orbital = Orbital(cuberead, dk3D=0.12)  # 3D-FT
    sim_kmap = orbital.get_kmap(
        E_kin=27.2,
        dk=(kx, ky),
        phi=0,
        theta=0,
        psi=0,  # Euler angles
        Ak_type='toroid',  # toroidal analyzer
        polarization='p',  # p-polarized light
        alpha=40)  # angle of incidence
    # sim_kmap.interpolate(kx,ky,update=True)
    sim_kmaps.append(sim_kmap)
    params.add(name, value=1, min=0)  # fit parameter weight of orbital

# also use constant background as fit parameter
params.add('background', value=1, min=0)
예제 #12
0
# Third Party Imports
import matplotlib.pyplot as plt

# kMap.py Imports
#from kmap.library.orbital import Orbital
from kmap.library.orbital import Orbital

# Path to data folder; replace with your own; use '/' instead of '+'
# when concatenating with strings
data_path = Path(__file__).parent / Path('../data/')

cubefile = open(data_path /
                'C60_MO_180.cube').read()  # read cube-file from file
#cubefile = open(data_path / 'pentacene_HOMO.cube').read()  # read cube-file from file
h**o = Orbital(cubefile)  # compute 3D Fourier transform (see Eqs. 6-11)

fig, _ax = plt.subplots(3, 3)
ax = _ax.flatten()
E_kin = 30.0
V0_list = [0, 2, 4, 6, 8, 10, 12, 14,
           16]  # list of selected inner potential values
for i, V0 in enumerate(V0_list):
    h**o.get_kmap(
        E_kin=E_kin,
        V0=V0)  # compute momentum map for kinetic energy E_kin (Eq. 12)
    h**o.plot(
        ax[i],  # plot kmap
        title='$E_{kin}=%g$ eV, $V_0=%g$ eV' % (E_kin, V0),
        kxlim=(-3, 3),
        kylim=(-3, 3))
예제 #13
0
# Load experimental data-file and choose a constant-binding energy slice
exp_data = SlicedData.init_from_hdf5(data_path / 'example4_3271.hdf5')
exp_kmap = exp_data.slice_from_index(2)  # take slice #2 from exp. data

# define common (kx,ky)-grid for fitting
k_range, dk = [-3.0, 3.0], 0.04
num = step_size_to_num(k_range, dk)
kx = np.linspace(k_range[0], k_range[1], num)
ky = kx
exp_kmap.interpolate(kx, ky, update=True)

# read pentacene H**O cube-file from file
cubefile = open(data_path /
                'pentacene_HOMO.cube').read()  # read cube-file from file
h**o = Orbital(cubefile, dk3D=0.12)  # 3D-FT


# define function which returns the difference between exp. and simulated k-map
def chi2_function(params):

    theta = params['theta']
    weight = params['weight']
    background = params['background']

    # simulate momentum map for given theta
    sim_kmap = h**o.get_kmap(
        E_kin=28,
        dk=(kx, ky),
        phi=90,
        theta=theta.value,
예제 #14
0
# Python Imports
from pathlib import Path

# Third Party Imports
import matplotlib.pyplot as plt
import numpy as np

# kMap.py Imports
from kmap.library.orbital import Orbital

# Path to data folder; replace with your own
data_path = Path(__file__).parent / Path('../data/')

cubefile = open(data_path /
                'pentacene_HOMO.cube').read()  # read cube-file from file
h**o = Orbital(cubefile)  # compute 3D Fourier transform (see Eqs. 6-11)

fig, _ax = plt.subplots(2, 3)
ax = _ax.flatten()
h**o.get_kmap(E_kin=20)
h**o.plot(ax[0], title='0', kxlim=(-3, 3), kylim=(-3, 3), interpolation='none')

h**o.get_kmap(E_kin=20, dk=0.1)
h**o.plot(ax[1], title='1', kxlim=(-3, 3), kylim=(-3, 3), interpolation='none')

h**o.get_kmap(E_kin=20, dk=0.2)
h**o.plot(ax[2], title='2', kxlim=(-3, 3), kylim=(-3, 3), interpolation='none')

kx = np.linspace(-2, 2, 50)
ky = np.linspace(-2, 2, 50)
h**o.get_kmap(E_kin=30, dk=(kx, ky))
예제 #15
0
# Python Imports
from pathlib import Path

# Third Party Imports
import matplotlib.pyplot as plt

# kMap.py Imports
from kmap.library.orbital import Orbital

# Path to data folder; replace with your own; use '/' instead of '+'
# when concatenating with strings
data_path = Path(__file__).parent / Path('../data/')

cubefile = open(data_path / 'pentacene_HOMO.cube').read()  # read cube-file from file
h**o     = Orbital(cubefile,        # compute 3D Fourier transform (see Eqs. 6-11)  
                   dk3D=0.15)       # with a desired k-spacing of dkx = dky = dkz = 0.15 1/Angstroem                           


# plot Figure 5(c): H**O of pentacene with tilt angles of theta = 0°, 10°, 20° and 30°
fig, _ax = plt.subplots(2,2)
ax       = _ax.flatten() 
thetas   = [0, 10, 20, 30]
for i, theta in enumerate(thetas):
    h**o.get_kmap(E_kin=30,              # compute momentum map for E_kin = 30 eV (Eq. 12)
              dk=0.03,                   # desired grid spacing in kmap in 1/Angstroem
              phi=90,theta=theta,psi=0,  # Euler angles 
              Ak_type='toroid',          # p-polarized light according to Eq. (19) 
              polarization='p',
              alpha=45,                  # angle of incidence
              symmetrization='2-fold')   #  symmetrize kmap
    h**o.plot(ax[i],title='$\\vartheta=%g^\circ$'%theta)   # plot kmap 
예제 #16
0
    def init_from_orbital_cube(cls, name, orbital, parameters):
        """Returns a SlicedData object with the data[x,y,z] 
           taken from the real space wave function in orbital.

        Args:
            name (str): name for SlicedData object
            orbital (list): [ 'URL',dict ]
                dict needs keys: 'energy' and 'name'         
            parameters (list): list of parameters
                domain (str): either 'real-space' or 'k-space'
                dk3D (float): Desired resolution for 3D-Fourier-Transform.
                    Single number.
                E_kin_max (float): maximum kinetic energy in eV is used to
                    reduce the size of the 3D-numpy-array in momentum space
                value (string): choose between 'real', 'imag', 'abs' or 'abs2'
                    for Re(), Im(), |..| or |..|^2

        Returns:
            (SlicedData): SlicedData containing the real space orbital
        """
        log = logging.getLogger('kmap')

        orbital = orbital[0]  # only consider first orbital in list!

        # extract parameters
        domain = parameters[0]
        dk3D = parameters[1]
        E_kin_max = parameters[2]
        value = parameters[3]

        orbital_file = orbital[0]
        log.info('Loading from database: %s' % orbital_file)

        # decision if reading cube-file from URL or local file
        if orbital_file[:4] == 'http':
            with urllib.request.urlopen(orbital_file) as f:
                file = f.read().decode('utf-8')

        else:
            file = open(orbital_file).read()

        orbital_data = Orbital(file,
                               dk3D=dk3D,
                               E_kin_max=E_kin_max,
                               value=value)

        # set name for SliceData object
        name = orbital_data.psi['name']

        # set axis and data
        if domain == 'real-space':
            axis_1 = [
                'x', 'Å',
                [orbital_data.psi['x'][0], orbital_data.psi['x'][-1]]
            ]
            axis_2 = [
                'y', 'Å',
                [orbital_data.psi['y'][0], orbital_data.psi['y'][-1]]
            ]
            axis_3 = [
                'z', 'Å',
                [orbital_data.psi['z'][0], orbital_data.psi['z'][-1]]
            ]
            data = orbital_data.psi['data']

        else:
            axis_1 = [
                'kx', '1/Å',
                [orbital_data.psik['kx'][0], orbital_data.psik['kx'][-1]]
            ]
            axis_2 = [
                'ky', '1/Å',
                [orbital_data.psik['ky'][0], orbital_data.psik['ky'][-1]]
            ]
            axis_3 = [
                'kz', '1/Å',
                [orbital_data.psik['kz'][0], orbital_data.psik['kz'][-1]]
            ]
            data = orbital_data.psik['data']

        # no meta data
        meta_data = {}

        return cls(name, axis_1, axis_2, axis_3, data, meta_data)
예제 #17
0
        self.phi = phi
        self.theta = theta
        self.psi = psi

        return


### MAIN PROGRAM #######################################################

# Path to data folder; replace with your own; use '/' instead of '+'
# when concatenating with strings
data_path = Path(__file__).parent / Path('../data/')

cubefile = open(data_path / 'PTCDA_B.cube').read()  # read cube-file from file
molecule = Orbital(
    cubefile)  # Orbital object contains molecular geometry and psi(x,y,z)

# initialize GLViewWidget()
app = QtGui.QApplication([])
w = gl.GLViewWidget()
w.show()
w.setWindowTitle('test')
w.setCameraPosition(distance=100, elevation=90, azimuth=-90)  # view from top

molecule_view = Plot3DMolecule(w,
                               molecule,
                               photon={
                                   'polarization': 'p',
                                   'alpha': 60,
                                   'beta': 115
                               })
예제 #18
0
# Python Imports
from pathlib import Path

# Third Party Imports
import matplotlib.pyplot as plt

# kMap.py Imports
from kmap.library.orbital import Orbital

# Path to data folder; replace with your own; use '/' instead of '+'
# when concatenating with strings
data_path = Path(__file__).parent / Path('../data/')

cubefile = open(data_path /
                'pentacene_HOMO.cube').read()  # read cube-file from file
h**o = Orbital(cubefile)  # compute 3D Fourier transform (see Eqs. 6-11)

fig, _ax = plt.subplots(2, 3)
ax = _ax.flatten()
energies = [10, 20, 30, 50, 75, 100]  # list of selected kinetic energies
for i, E_kin in enumerate(energies):
    h**o.get_kmap(
        E_kin=E_kin)  # compute momentum map for kinetic energy E_kin (Eq. 12)
    h**o.plot(
        ax[i],  # plot kmap
        title='$E_{kin}=%g (eV)$' % E_kin,
        kxlim=(-4, 4),
        kylim=(-4, 4))

plt.tight_layout()
plt.show()  # show figure