From 24ee248fdb214f57918249a788f35cde0942d498 Mon Sep 17 00:00:00 2001 From: e3fm8 <wolf.widdra@physik.uni-halle.de> Date: Wed, 18 Nov 2020 19:05:18 +0100 Subject: [PATCH] add_Drude included, minor corrections --- libhreels/__init__.py | 4 ++-- libhreels/calcHREELS.py | 44 ++++++++++++++++++++++++++++++---------- libhreels/dielectrics.py | 3 ++- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/libhreels/__init__.py b/libhreels/__init__.py index 4ddc7ba..cb031ae 100644 --- a/libhreels/__init__.py +++ b/libhreels/__init__.py @@ -1,6 +1,6 @@ try: -Â Â Â import importlib.metadata as importlib_metadata + import importlib.metadata as importlib_metadata except ModuleNotFoundError: -Â Â Â import importlib_metadata + import importlib_metadata __version__ = importlib_metadata.version(__name__) diff --git a/libhreels/calcHREELS.py b/libhreels/calcHREELS.py index aa5f0e1..948c859 100644 --- a/libhreels/calcHREELS.py +++ b/libhreels/calcHREELS.py @@ -3,9 +3,19 @@ import numpy as np import json import sys, re, os from libhreels.HREELS import myPath +from copy import deepcopy libDir = os.path.dirname(os.path.realpath(__file__)) +if not (sys.version.startswith('3.6') or sys.version.startswith('3.8')): + print('''Make sure the Fortran routines 'myEels2' and 'myBoson' + have been complied with the proper f2py3 for the right + python version!!''') +try: + from libhreels import myEels2 as LambinEELS # wrapper for myEels2.f90 + from libhreels import myBoson as LambinBoson # wrapper for myBoson.f90 +except: + print('myEels2 and MyBoson are not available here (Check your version)') # Experimental setup as dictionary: setup = { @@ -26,6 +36,10 @@ instrument = { def importMaterials(string='', path=libDir): + ''' Returns a dictionary with all phonon parameters for the material provided + as string argument. If the string is empty or not matching, a list of all available + materials is printed. + ''' file = os.path.join(myPath(path),'materials.json') with open(file) as json_file: materials = json.load(json_file) @@ -36,20 +50,28 @@ def importMaterials(string='', path=libDir): print('Available materials:\n{}\n'.format(materials.keys())) mat = 'None' return mat - -########################################################### -try: - from libhreels import myEels2 as LambinEELS # wrapper for myEels2.f90 - from libhreels import myBoson as LambinBoson # wrapper for myBoson.f90 -except: - print('myEels2 and MyBoson are not available here (Check your version)') + +def addDrude(wPlasma, gPlasma, material): + ''' Adds a Drude response and returns a dictionary with all phonon parameters for the material provided + as 3rd argument. + ''' + newMaterial = deepcopy(material) + try: + if len(newMaterial['wTO']) > 0: + newMaterial['wTO'] += [-1*wPlasma] + newMaterial['gTO'] += [-1*gPlasma] + newMaterial['wLO'] += [0] + newMaterial['gLO'] += [0] + return newMaterial + except: + print('Cannot add Drude to material',material) + return material + +################################################################################ +################################################################################ class lambin: def __init__(self, film, setup=setup, instrument=instrument): - if not (sys.version.startswith('3.6') or sys.version.startswith('3.8')): - print('''Make sure the Fortran routines 'myEels2' and 'myBoson' - have been complied with the proper f2py3 for the right - python version!!''') self.e0 = setup['e0'] self.theta = setup['theta'] self.phia = setup['phia'] diff --git a/libhreels/dielectrics.py b/libhreels/dielectrics.py index 2a40dbc..38c49ec 100644 --- a/libhreels/dielectrics.py +++ b/libhreels/dielectrics.py @@ -34,7 +34,8 @@ def sigma(eps,w,eps_Infinity=1): # Complex conductivity def plotDielectrics(x,eps): fig, axs = plt.subplots(3, 1, sharex=True, figsize=(6,6)) axs[0].plot(x, -np.imag(eps), label='-Im $\epsilon (\omega )$') - axs[0].plot(x, np.real(eps), label='Re $\epsilon (\omega )$') axs[0].legend() + axs[0].plot(x, np.real(eps), label='Re $\epsilon (\omega )$') + axs[0].legend() axs[0].set_ylabel('Dielectric Function') axs[1].plot(x, surfaceLoss(eps), linestyle='-') -- GitLab