Skip to content

Commit 05cec9e

Browse files
committed
add radius edge to struct2fdmnes + fix output naming webapp
1 parent 321203f commit 05cec9e

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

larixite/fdmnes.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ class FdmnesXasInput:
6161
struct_type: Union[str, None] = None #: type of the structure
6262
vmax: Union[float, None] = None #: maximum potential value for molecules
6363
erange: str = "-20.0 0.1 70.0 1.0 100.0" #: energy range
64-
fileout_prefix: str = "job" #: prefix of the output filename for the FDMNES job (extension: .inp)
64+
fileout_prefix: str = (
65+
"job" #: prefix of the output filename for the FDMNES job (extension: .inp)
66+
)
6567
tmplpath: Union[str, Path, None] = None #: path to the FDMNES input template
6668
params: Union[dict[str, bool], None] = None #: enable/disable parameters for FDMNES
67-
spacer : str = " " #: spacer for the FDMNES input text
69+
spacer: str = " " #: spacer for the FDMNES input text
6870

6971
def __post_init__(self):
7072
"""Validate and optimize attributes"""
@@ -320,7 +322,8 @@ def get_input(self, comment: str = "", struct_type: str = None) -> str:
320322
return strict_ascii(template.format(**conf))
321323

322324
def write_input(
323-
self, inputtext: Union[str, None] = None, outdir: Union[str, Path, None] = None) -> Path:
325+
self, inputtext: Union[str, None] = None, outdir: Union[str, Path, None] = None
326+
) -> Path:
324327
"""Write the FDMNES input text to disk and return the output directory"""
325328
if inputtext is None:
326329
inputtext = self.get_input()
@@ -351,6 +354,8 @@ def struct2fdmnes(
351354
frame: int = 0,
352355
format: str = "cif",
353356
filename: Union[None, str] = None,
357+
radius: float = 7,
358+
edge: str | None = None,
354359
) -> dict:
355360
"""convert CIF/XYZ into a dictionary of {name: text} for FDMNES output files
356361
@@ -388,8 +393,14 @@ def struct2fdmnes(
388393
structs = get_structure_from_text(
389394
inp, absorber, frame=frame, format=format, filename=filename
390395
)
391-
fout_name = f"{filename.replace('.', '_')}_{absorber.symbol}"
392-
fdm = FdmnesXasInput(structs, absorber=absorber, fileout_prefix=fout_name)
393-
return {"fdmfile.txt": f"1\n{fout_name}.inp\n", fout_name: fdm.get_input()}
394-
395-
396+
fout_prefix = f"{filename.replace('.', '_')}_{absorber.symbol}"
397+
fout_name = f"{fout_prefix}.inp"
398+
fdm = FdmnesXasInput(
399+
structs,
400+
absorber=absorber,
401+
frame=frame,
402+
edge=edge,
403+
radius=radius,
404+
fileout_prefix=fout_prefix,
405+
)
406+
return {"fdmfile.txt": f"1\n{fout_name}\n", fout_name: fdm.get_input()}

larixite/webapp/webapp.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ def cifs(cifid=None):
217217
absorber, edge, cluster_size, with_h, 'fdmnes')
218218
config['out_links'] = {}
219219
out = struct2fdmnes(config['ciftext'], absorber=absorber,
220-
filename=ciffile)
220+
radius=float(cluster_size), edge=edge,
221+
filename=ciffile)
221222
for slabel, text in out.items():
222223
link = f'fdmnes_{slabel}'
223224
config['out_links'][slabel] = (slabel, cifid, absorber, edge, 0,
@@ -284,7 +285,8 @@ def zipfile(cifid=None, absorber=None, edge='K', cluster_size=7.0,
284285
zfile.writestr(oname, result)
285286
elif form == 'fdmnes':
286287
out = struct2fdmnes(config['ciftext'], absorber=absorber,
287-
filename=f'AMSCD_{cifid}.cif')
288+
radius=float(cluster_size), edge=edge,
289+
filename=f'AMSCD_{cifid}.cif')
288290
for key, val in out.items():
289291
zfile.writestr(key, val)
290292
zfile.close()
@@ -318,9 +320,10 @@ def output(cifid=None, absorber=None, site=1, edge='K', cluster_size=7.0,
318320
with_h=with_h, absorber_site=int(site))
319321
elif form == 'fdmnes':
320322
xcifid = cifid.replace('.', '_')
321-
oname = f'AMSCD_{xcifid}_{absorber}'
323+
oname = f'AMSCD_{xcifid}.cif'
322324
out = struct2fdmnes(config['ciftext'], absorber=absorber,
323-
filename=f'AMSCD_{xcifid}')
325+
radius=float(cluster_size), edge=edge,
326+
filename=oname)
324327
if fname == 'fdmfile.txt':
325328
result = out.get(fname, None)
326329
else:

0 commit comments

Comments
 (0)