Allow the use of external potential files.
A new keyword in TMatrixParameters allows to use an external file for the potential energy of atoms. It should be used like this: calc.tmatrix_parameters.potential = 'spkkr' calc.tmatrix_parameters.potential_file = 'Cu.pot' # the name does not matter
This commit is contained in:
parent
15b344cf5f
commit
927ac8a8a3
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
# vim: set et sw=4 ts=4 sts=4 nu ai cc=+0 fdm=indent mouse=a:
|
# vim: set et sw=4 ts=4 sts=4 nu ai cc=+0 fdm=indent mouse=a tw=80:
|
||||||
"""
|
"""
|
||||||
Module calculator
|
Module calculator
|
||||||
=================
|
=================
|
||||||
|
@ -47,7 +47,8 @@ import numpy as np
|
||||||
from msspec import iodata
|
from msspec import iodata
|
||||||
from msspec.data import electron_be
|
from msspec.data import electron_be
|
||||||
from msspec.config import Config
|
from msspec.config import Config
|
||||||
from msspec.misc import (UREG, LOGGER, get_call_info, get_level_from_electron_configuration,
|
from msspec.misc import (UREG, LOGGER, get_call_info,
|
||||||
|
get_level_from_electron_configuration,
|
||||||
XRaySource, set_log_output, log_process_output)
|
XRaySource, set_log_output, log_process_output)
|
||||||
from msspec.utils import get_atom_index
|
from msspec.utils import get_atom_index
|
||||||
|
|
||||||
|
@ -62,9 +63,9 @@ from msspec.calcio import PhagenIO, SpecIO
|
||||||
|
|
||||||
from msspec.phagen.fortran.libphagen import main as do_phagen
|
from msspec.phagen.fortran.libphagen import main as do_phagen
|
||||||
|
|
||||||
from msspec.spec.fortran import phd_se_noso_nosp_nosym, phd_mi_noso_nosp_nosym
|
from msspec.spec.fortran import _phd_se_noso_nosp_nosym, _phd_mi_noso_nosp_nosym
|
||||||
from msspec.spec.fortran import eig_mi
|
from msspec.spec.fortran import _eig_mi
|
||||||
from msspec.spec.fortran import eig_pw
|
from msspec.spec.fortran import _eig_pw
|
||||||
|
|
||||||
|
|
||||||
from terminaltables.ascii_table import AsciiTable
|
from terminaltables.ascii_table import AsciiTable
|
||||||
|
@ -289,14 +290,21 @@ class _MSCALCULATOR(Calculator):
|
||||||
# run phagen
|
# run phagen
|
||||||
#self._make('tmatrix')
|
#self._make('tmatrix')
|
||||||
os.chdir(os.path.join(self.tmp_folder, 'output'))
|
os.chdir(os.path.join(self.tmp_folder, 'output'))
|
||||||
|
# copy external potential file to the workspace
|
||||||
|
if self.tmatrix_parameters.potential in ('lmto', 'spkkr', 'msf'):
|
||||||
|
fname = os.path.join(self.init_folder,
|
||||||
|
self.tmatrix_parameters.potential_file)
|
||||||
|
shutil.copy(fname, 'fort.2')
|
||||||
do_phagen()
|
do_phagen()
|
||||||
# rename some output files to be more explicit
|
# rename some output files to be more explicit
|
||||||
#os.rename('fort.10', 'cluster.clu')
|
#os.rename('fort.10', 'cluster.clu')
|
||||||
#os.rename('fort.35', 'tmatrix.tl')
|
#os.rename('fort.35', 'tmatrix.tl')
|
||||||
#os.rename('fort.55', 'tmatrix.rad')
|
#os.rename('fort.55', 'tmatrix.rad')
|
||||||
shutil.copy('fort.10', 'cluster.clu')
|
#shutil.copy('fort.10', 'cluster.clu')
|
||||||
|
shutil.copy('clus/clus.out', 'cluster.clu')
|
||||||
shutil.copy('fort.35', 'tmatrix.tl')
|
shutil.copy('fort.35', 'tmatrix.tl')
|
||||||
shutil.copy('fort.55', 'tmatrix.rad')
|
shutil.copy('fort.55', 'tmatrix.rad')
|
||||||
|
|
||||||
os.chdir(self.init_folder)
|
os.chdir(self.init_folder)
|
||||||
|
|
||||||
|
|
||||||
|
@ -362,9 +370,9 @@ class _MSCALCULATOR(Calculator):
|
||||||
# Get the spec function to launch
|
# Get the spec function to launch
|
||||||
if self.global_parameters.spectroscopy == 'PED':
|
if self.global_parameters.spectroscopy == 'PED':
|
||||||
if self.global_parameters.algorithm == 'expansion':
|
if self.global_parameters.algorithm == 'expansion':
|
||||||
do_spec = phd_se_noso_nosp_nosym.run
|
do_spec = _phd_se_noso_nosp_nosym.run
|
||||||
elif self.global_parameters.algorithm == 'inversion':
|
elif self.global_parameters.algorithm == 'inversion':
|
||||||
do_spec = phd_mi_noso_nosp_nosym.run
|
do_spec = _phd_mi_noso_nosp_nosym.run
|
||||||
else:
|
else:
|
||||||
LOGGER.error("\'{}\' spectroscopy with \'{}\' algorithm is not "
|
LOGGER.error("\'{}\' spectroscopy with \'{}\' algorithm is not "
|
||||||
"an allowed combination.".format(self.global_parameters.spectroscopy,
|
"an allowed combination.".format(self.global_parameters.spectroscopy,
|
||||||
|
@ -372,9 +380,9 @@ class _MSCALCULATOR(Calculator):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
elif self.global_parameters.spectroscopy == 'EIG':
|
elif self.global_parameters.spectroscopy == 'EIG':
|
||||||
if self.global_parameters.algorithm == 'inversion':
|
if self.global_parameters.algorithm == 'inversion':
|
||||||
do_spec = eig_mi.run
|
do_spec = _eig_mi.run
|
||||||
elif self.global_parameters.algorithm == 'power':
|
elif self.global_parameters.algorithm == 'power':
|
||||||
do_spec = eig_pw.run
|
do_spec = _eig_pw.run
|
||||||
else:
|
else:
|
||||||
LOGGER.error("\'{}\' spectroscopy with \'{}\' algorithm is not "
|
LOGGER.error("\'{}\' spectroscopy with \'{}\' algorithm is not "
|
||||||
"an allowed combination.".format(self.global_parameters.spectroscopy,
|
"an allowed combination.".format(self.global_parameters.spectroscopy,
|
||||||
|
@ -745,7 +753,10 @@ class _PED(_MSCALCULATOR):
|
||||||
filename = os.path.join(self.tmp_folder, 'output/cluster.clu')
|
filename = os.path.join(self.tmp_folder, 'output/cluster.clu')
|
||||||
self.phagenio.load_cluster_file(filename)
|
self.phagenio.load_cluster_file(filename)
|
||||||
|
|
||||||
filename = os.path.join(self.tmp_folder, 'bin/plot/plot_vc.dat')
|
if self.phagen_parameters.potgen in ('in'):
|
||||||
|
filename = os.path.join(self.tmp_folder, 'output/plot/plot_vc.dat')
|
||||||
|
else:
|
||||||
|
filename = os.path.join(self.tmp_folder, 'output/plot/plot_v.dat')
|
||||||
pot_data = self.phagenio.load_potential_file(filename)
|
pot_data = self.phagenio.load_potential_file(filename)
|
||||||
|
|
||||||
cluster = self.phagen_parameters.get_parameter('atoms').value
|
cluster = self.phagen_parameters.get_parameter('atoms').value
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
# vim: set fdm=indent ts=4 sw=4 sts=4 et tw=80 ai cc=+0 mouse=a nu : #
|
||||||
"""
|
"""
|
||||||
Module misc
|
Module misc
|
||||||
===========
|
===========
|
||||||
|
@ -9,6 +10,7 @@ from pint import UnitRegistry
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import inspect
|
import inspect
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
class XRaySource(object):
|
class XRaySource(object):
|
||||||
MG_KALPHA = 1253.6
|
MG_KALPHA = 1253.6
|
||||||
|
|
|
@ -265,6 +265,7 @@ class BaseParameters(object):
|
||||||
class PhagenParameters(BaseParameters):
|
class PhagenParameters(BaseParameters):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
parameters = (
|
parameters = (
|
||||||
|
Parameter('version', types=(str,), fmt='>3s', default='1.1'),
|
||||||
Parameter('calctype', allowed_values=('xpd', 'xas', 'aed', 'led',
|
Parameter('calctype', allowed_values=('xpd', 'xas', 'aed', 'led',
|
||||||
'rex', 'els', 'e2e'#, 'dos'
|
'rex', 'els', 'e2e'#, 'dos'
|
||||||
),
|
),
|
||||||
|
@ -273,7 +274,7 @@ class PhagenParameters(BaseParameters):
|
||||||
types=(str,), default='cis'),
|
types=(str,), default='cis'),
|
||||||
Parameter('coor', allowed_values=('angs', 'au'), types=(str,),
|
Parameter('coor', allowed_values=('angs', 'au'), types=(str,),
|
||||||
default='angs'),
|
default='angs'),
|
||||||
Parameter('enunit', allowed_values=('ryd', 'eV'), fmt='3>s',
|
Parameter('enunit', allowed_values=('ryd', 'eV'), fmt='>3s',
|
||||||
types=(str,), default='ryd'),
|
types=(str,), default='ryd'),
|
||||||
Parameter('einc', types=(int, float), limits=(0, None), fmt='.1f',
|
Parameter('einc', types=(int, float), limits=(0, None), fmt='.1f',
|
||||||
default=700.),
|
default=700.),
|
||||||
|
@ -281,7 +282,7 @@ class PhagenParameters(BaseParameters):
|
||||||
default=580.),
|
default=580.),
|
||||||
Parameter('scangl', types=(int, float), limits=(0, 360), fmt='.2f',
|
Parameter('scangl', types=(int, float), limits=(0, 360), fmt='.2f',
|
||||||
default=0.),
|
default=0.),
|
||||||
Parameter('lambda', types=(int, float), fmt='.2f', default=20.),
|
Parameter('lambda', types=(int, float), fmt='.1f', default=0.),
|
||||||
Parameter('emin', types=(int, float), limits=(0, None), fmt='.4f',
|
Parameter('emin', types=(int, float), limits=(0, None), fmt='.4f',
|
||||||
default=13.5236),
|
default=13.5236),
|
||||||
Parameter('emax', types=(int, float), limits=(0, None), fmt='.4f',
|
Parameter('emax', types=(int, float), limits=(0, None), fmt='.4f',
|
||||||
|
@ -294,9 +295,9 @@ class PhagenParameters(BaseParameters):
|
||||||
default='in'),
|
default='in'),
|
||||||
Parameter('potype', allowed_values=('hdrel', 'hedin', 'xalph',
|
Parameter('potype', allowed_values=('hdrel', 'hedin', 'xalph',
|
||||||
'dhrel', 'dhcmp',
|
'dhrel', 'dhcmp',
|
||||||
#'lmto', 'msf', 'spkkr'
|
'lmto', 'msf', 'spkkr'
|
||||||
),
|
),
|
||||||
types=(str,), fmt='5>s', default='hedin'),
|
types=(str,), fmt='>5s', default='hedin'),
|
||||||
Parameter('relc', allowed_values=('nr', 'sr', 'so'), types=(str,),
|
Parameter('relc', allowed_values=('nr', 'sr', 'so'), types=(str,),
|
||||||
default='nr'),
|
default='nr'),
|
||||||
Parameter('norman', allowed_values=('stdcrm', 'scaled', 'extrad'),
|
Parameter('norman', allowed_values=('stdcrm', 'scaled', 'extrad'),
|
||||||
|
@ -308,9 +309,9 @@ class PhagenParameters(BaseParameters):
|
||||||
Parameter('charelx', allowed_values=('ex', 'gs'), types=(str,),
|
Parameter('charelx', allowed_values=('ex', 'gs'), types=(str,),
|
||||||
default='gs'),
|
default='gs'),
|
||||||
Parameter('ionzst', allowed_values=('neutral', 'ionic'),
|
Parameter('ionzst', allowed_values=('neutral', 'ionic'),
|
||||||
types=(str,), fmt='7>s', default='neutral'),
|
types=(str,), fmt='>7s', default='neutral'),
|
||||||
Parameter('eikappr', allowed_values=('yes', 'no'), types=(str,),
|
Parameter('eikappr', allowed_values=('yes', 'no'), types=(str,),
|
||||||
fmt='3>s', default='no'),
|
fmt='>3s', default='no'),
|
||||||
Parameter('db', types=(int, float), fmt='.2f', default=0.01),
|
Parameter('db', types=(int, float), fmt='.2f', default=0.01),
|
||||||
Parameter('optrsh', allowed_values=('y', 'n'), types=(str,),
|
Parameter('optrsh', allowed_values=('y', 'n'), types=(str,),
|
||||||
default='n'),
|
default='n'),
|
||||||
|
@ -885,11 +886,12 @@ class TMatrixParameters(BaseParameters):
|
||||||
def __init__(self, phagen_parameters):
|
def __init__(self, phagen_parameters):
|
||||||
parameters = (
|
parameters = (
|
||||||
Parameter('potential', types=str,
|
Parameter('potential', types=str,
|
||||||
allowed_values=('muffin_tin', 'lmto'),
|
allowed_values=('muffin_tin', 'lmto', 'spkkr', 'msf'),
|
||||||
default='muffin_tin', doc=textwrap.dedent("""
|
default='muffin_tin', doc=textwrap.dedent("""
|
||||||
This option allows to choose which kind of potential is used to compute the T-Matrix. For now,
|
This option allows to choose which kind of potential is used to compute the T-Matrix. For now,
|
||||||
only the internal *Muffin-Tin* potential is supported.
|
only the internal *Muffin-Tin* potential is supported.
|
||||||
""")),
|
""")),
|
||||||
|
Parameter('potential_file', types=(str,type(None)), default=None),
|
||||||
Parameter('exchange_correlation', types=str,
|
Parameter('exchange_correlation', types=str,
|
||||||
allowed_values=('hedin_lundqvist_real',
|
allowed_values=('hedin_lundqvist_real',
|
||||||
'hedin_lundqvist_complex',
|
'hedin_lundqvist_complex',
|
||||||
|
@ -955,8 +957,12 @@ class TMatrixParameters(BaseParameters):
|
||||||
self.freeze()
|
self.freeze()
|
||||||
|
|
||||||
def bind_potential(self, p):
|
def bind_potential(self, p):
|
||||||
mapping = {'muffin_tin': 'in', 'lmto': 'ex'}
|
mapping = {'muffin_tin': 'in', 'lmto': 'ex', 'spkkr': 'ex', 'msf': 'ex'}
|
||||||
self.phagen_parameters.potgen = mapping[p.value]
|
if p.value.lower() in ('muffin_tin'):
|
||||||
|
self.phagen_parameters.potgen = 'in'
|
||||||
|
elif p.value.lower() in ('spkkr', 'lmto', 'msf'):
|
||||||
|
self.phagen_parameters.potgen = 'ex'
|
||||||
|
self.phagen_parameters.potype = p.value.lower()
|
||||||
|
|
||||||
def bind_exchange_correlation(self, p):
|
def bind_exchange_correlation(self, p):
|
||||||
potential = self.get_parameter('potential').value
|
potential = self.get_parameter('potential').value
|
||||||
|
@ -969,8 +975,11 @@ class TMatrixParameters(BaseParameters):
|
||||||
'dirac_hara_complex': 'dhcmp'
|
'dirac_hara_complex': 'dhcmp'
|
||||||
}
|
}
|
||||||
self.phagen_parameters.potype = mapping[p.value]
|
self.phagen_parameters.potype = mapping[p.value]
|
||||||
elif potential == 'lmto':
|
else:
|
||||||
self.phagen_parameters.potype = 'lmto'
|
self.phagen_parameters.potype = potential
|
||||||
|
|
||||||
|
def bind_potential_file(self, p):
|
||||||
|
pass
|
||||||
|
|
||||||
def bind_imaginery_part(self, p):
|
def bind_imaginery_part(self, p):
|
||||||
self.phagen_parameters.gamma = p.value
|
self.phagen_parameters.gamma = p.value
|
||||||
|
|
Loading…
Reference in New Issue