Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions larixite/fdmnes.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ class FdmnesXasInput:
struct_type: Union[str, None] = None #: type of the structure
vmax: Union[float, None] = None #: maximum potential value for molecules
erange: str = "-20.0 0.1 70.0 1.0 100.0" #: energy range
fileout_prefix: str = "job" #: prefix of the output filename for the FDMNES job (extension: .inp)
fileout_prefix: str = (
"job" #: prefix of the output filename for the FDMNES job (extension: .inp)
)
tmplpath: Union[str, Path, None] = None #: path to the FDMNES input template
params: Union[dict[str, bool], None] = None #: enable/disable parameters for FDMNES
spacer : str = " " #: spacer for the FDMNES input text
spacer: str = " " #: spacer for the FDMNES input text

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

def write_input(
self, inputtext: Union[str, None] = None, outdir: Union[str, Path, None] = None) -> Path:
self, inputtext: Union[str, None] = None, outdir: Union[str, Path, None] = None
) -> Path:
"""Write the FDMNES input text to disk and return the output directory"""
if inputtext is None:
inputtext = self.get_input()
Expand Down Expand Up @@ -351,6 +354,8 @@ def struct2fdmnes(
frame: int = 0,
format: str = "cif",
filename: Union[None, str] = None,
radius: float = 7,
edge: str | None = None,
) -> dict:
"""convert CIF/XYZ into a dictionary of {name: text} for FDMNES output files

Expand Down Expand Up @@ -388,8 +393,14 @@ def struct2fdmnes(
structs = get_structure_from_text(
inp, absorber, frame=frame, format=format, filename=filename
)
fout_name = f"{filename.replace('.', '_')}_{absorber.symbol}"
fdm = FdmnesXasInput(structs, absorber=absorber, fileout_prefix=fout_name)
return {"fdmfile.txt": f"1\n{fout_name}.inp\n", fout_name: fdm.get_input()}


fout_prefix = f"{filename.replace('.', '_')}_{absorber.symbol}"
fout_name = f"{fout_prefix}.inp"
fdm = FdmnesXasInput(
structs,
absorber=absorber,
frame=frame,
edge=edge,
radius=radius,
fileout_prefix=fout_prefix,
)
return {"fdmfile.txt": f"1\n{fout_name}\n", fout_name: fdm.get_input()}
11 changes: 7 additions & 4 deletions larixite/webapp/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def cifs(cifid=None):
absorber, edge, cluster_size, with_h, 'fdmnes')
config['out_links'] = {}
out = struct2fdmnes(config['ciftext'], absorber=absorber,
filename=ciffile)
radius=float(cluster_size), edge=edge,
filename=ciffile)
for slabel, text in out.items():
link = f'fdmnes_{slabel}'
config['out_links'][slabel] = (slabel, cifid, absorber, edge, 0,
Expand Down Expand Up @@ -284,7 +285,8 @@ def zipfile(cifid=None, absorber=None, edge='K', cluster_size=7.0,
zfile.writestr(oname, result)
elif form == 'fdmnes':
out = struct2fdmnes(config['ciftext'], absorber=absorber,
filename=f'AMSCD_{cifid}.cif')
radius=float(cluster_size), edge=edge,
filename=f'AMSCD_{cifid}.cif')
for key, val in out.items():
zfile.writestr(key, val)
zfile.close()
Expand Down Expand Up @@ -318,9 +320,10 @@ def output(cifid=None, absorber=None, site=1, edge='K', cluster_size=7.0,
with_h=with_h, absorber_site=int(site))
elif form == 'fdmnes':
xcifid = cifid.replace('.', '_')
oname = f'AMSCD_{xcifid}_{absorber}'
oname = f'AMSCD_{xcifid}.cif'
out = struct2fdmnes(config['ciftext'], absorber=absorber,
filename=f'AMSCD_{xcifid}')
radius=float(cluster_size), edge=edge,
filename=oname)
if fname == 'fdmfile.txt':
result = out.get(fname, None)
else:
Expand Down
Loading