From 6319e56f20be3d78f69f2ccbe60b217c350f2ef6 Mon Sep 17 00:00:00 2001 From: mikibonacci Date: Fri, 13 Dec 2024 09:35:27 +0000 Subject: [PATCH 1/4] Adding quickfix for IP spectra in yambofile parse_output --- yamboparser/yambofile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yamboparser/yambofile.py b/yamboparser/yambofile.py index 2be2f0d..08e3aa9 100644 --- a/yamboparser/yambofile.py +++ b/yamboparser/yambofile.py @@ -111,7 +111,10 @@ def parse_output(self,**parse_kwargs): zip_tags = parse_kwargs.get('zip_tags',False) #flag--default behavior is to do nothing #get the tags of the columns if self.type in YamboFile._outputs_type.keys(): #== "output_absorption": - tags = [tag.strip() for tag in re.findall('([ `0-9a-zA-Z\-\/]+)\[[0-9]\]',''.join(self.lines))] + pattern = '([ `0-9a-zA-Z\-\/]+)\[[0-9]\]' + tags = [tag.strip() for tag in re.findall(pattern,''.join(self.lines))] + lines_with_matches = [line for line in self.lines if re.search(pattern, line)] # temporary fix for IP case: E[1] [eV] Im(eps) Re(eps) + tags = [tag.strip() for tag in lines_with_matches[0].replace("#","").replace("\n","").replace("[eV]","").split()] if self.type == "output_gw": tags = [line.replace('(meV)','').replace('Sc(Eo)','Sc|Eo') for line in self.lines if all(tag in line for tag in ['K-point','Band','Eo'])][0] tags = tags[2:].strip().split() From a8319e13000778180fb8edf5ae21d64541666519 Mon Sep 17 00:00:00 2001 From: mikibonacci Date: Fri, 13 Dec 2024 10:02:37 +0000 Subject: [PATCH 2/4] quickfix for yambopyenv import errors --- tutorial/databases_qepy/iron-metal/flow-iron.py | 2 +- yambopy/__init__.py | 11 ----------- yambopy/dbs/bsekerneldb.py | 1 + yambopy/env/__init__.py | 10 ++++++++++ yambopy/flow/task.py | 2 +- yambopy/io/inputfile.py | 3 ++- yambopy/io/iofile.py | 2 +- 7 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 yambopy/env/__init__.py diff --git a/tutorial/databases_qepy/iron-metal/flow-iron.py b/tutorial/databases_qepy/iron-metal/flow-iron.py index 964433f..cfde2da 100644 --- a/tutorial/databases_qepy/iron-metal/flow-iron.py +++ b/tutorial/databases_qepy/iron-metal/flow-iron.py @@ -7,7 +7,7 @@ from yambopy.io.factories import PwNscfTasks, PwBandsTasks, PwRelaxTasks from yambopy.flow import YambopyFlow, PwTask, E2yTask, YamboTask from schedulerpy import Scheduler -from yambopy import yambopyenv +from yambopy.env import yambopyenv #sch = Scheduler.factory(scheduler="slurm",ntasks=8,walltime="10:00:00") sch = Scheduler.factory(scheduler="bash") diff --git a/yambopy/__init__.py b/yambopy/__init__.py index 9a8ad92..969d46d 100644 --- a/yambopy/__init__.py +++ b/yambopy/__init__.py @@ -37,17 +37,6 @@ """ import numpy as np -class yambopyenv(): - YAMBO = "yambo" - P2Y = "p2y" - E2Y = "e2y" - YPP = "ypp" - SCHEDULER = "bash" - YAMBO_RT = "yambo_rt" - YPP_RT = "ypp_rt" - YAMBO_NL = "yambo_nl" - YPP_NL = "ypp_nl" - #tools and units from yambopy.tools.jsonencoder import * from yambopy.units import * diff --git a/yambopy/dbs/bsekerneldb.py b/yambopy/dbs/bsekerneldb.py index 6620a2f..fc8d0da 100644 --- a/yambopy/dbs/bsekerneldb.py +++ b/yambopy/dbs/bsekerneldb.py @@ -4,6 +4,7 @@ # import os from yambopy import * +from yambopy.dbs.savedb import YamboSaveDB from yambopy.units import * from itertools import product diff --git a/yambopy/env/__init__.py b/yambopy/env/__init__.py new file mode 100644 index 0000000..b372211 --- /dev/null +++ b/yambopy/env/__init__.py @@ -0,0 +1,10 @@ +class yambopyenv(): + YAMBO = "yambo" + P2Y = "p2y" + E2Y = "e2y" + YPP = "ypp" + SCHEDULER = "bash" + YAMBO_RT = "yambo_rt" + YPP_RT = "ypp_rt" + YAMBO_NL = "yambo_nl" + YPP_NL = "ypp_nl" \ No newline at end of file diff --git a/yambopy/flow/task.py b/yambopy/flow/task.py index 638d956..7808dd6 100644 --- a/yambopy/flow/task.py +++ b/yambopy/flow/task.py @@ -34,7 +34,7 @@ from qepy.ph import PhIn from qepy.dynmat import DynmatIn from qepy import qepyenv -from yambopy import yambopyenv +from yambopy.env import yambopyenv from yambopy.tools.string import marquee from yambopy.tools.duck import isiter, isstring from yambopy.io.inputfile import YamboIn diff --git a/yambopy/io/inputfile.py b/yambopy/io/inputfile.py index a60027a..3f88053 100644 --- a/yambopy/io/inputfile.py +++ b/yambopy/io/inputfile.py @@ -7,9 +7,10 @@ import json import re from subprocess import Popen, PIPE -from yambopy import yambopyenv +#from yambopy.env import yambopyenv from yambopy.tools.duck import isstring + def issave(path): """ Check if yambo SAVE folder is present either as directory or as symlink """ if os.path.isdir(path) or os.path.islink(path): return True diff --git a/yambopy/io/iofile.py b/yambopy/io/iofile.py index 201f9f7..5921dbb 100644 --- a/yambopy/io/iofile.py +++ b/yambopy/io/iofile.py @@ -1,7 +1,7 @@ import os import re from subprocess import Popen, PIPE -from yambopy import yambopyenv +from yambopy.env import yambopyenv from yambopy.tools.duck import isstring class YamboIO(object): From a3080f6cd6947ab93b7988e4b3fdb14326b75b8b Mon Sep 17 00:00:00 2001 From: mikibonacci Date: Fri, 13 Dec 2024 10:04:57 +0000 Subject: [PATCH 3/4] Trigger the parse of loss, eps, alpha only for selected cases. --- yamboparser/yambofile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yamboparser/yambofile.py b/yamboparser/yambofile.py index 08e3aa9..f098867 100644 --- a/yamboparser/yambofile.py +++ b/yamboparser/yambofile.py @@ -113,8 +113,9 @@ def parse_output(self,**parse_kwargs): if self.type in YamboFile._outputs_type.keys(): #== "output_absorption": pattern = '([ `0-9a-zA-Z\-\/]+)\[[0-9]\]' tags = [tag.strip() for tag in re.findall(pattern,''.join(self.lines))] - lines_with_matches = [line for line in self.lines if re.search(pattern, line)] # temporary fix for IP case: E[1] [eV] Im(eps) Re(eps) - tags = [tag.strip() for tag in lines_with_matches[0].replace("#","").replace("\n","").replace("[eV]","").split()] + if len(tags) < 2 and self.type in ["output_loss", "output_abs", "output_alpha"]: # temporary fix for IP case: E[1] [eV] Im(eps) Re(eps) + lines_with_matches = [line for line in self.lines if re.search(pattern, line)] + tags = [tag.strip() for tag in lines_with_matches[0].replace("#","").replace("\n","").replace("[eV]","").split()] if self.type == "output_gw": tags = [line.replace('(meV)','').replace('Sc(Eo)','Sc|Eo') for line in self.lines if all(tag in line for tag in ['K-point','Band','Eo'])][0] tags = tags[2:].strip().split() From dbc7d3a1de2409feeca6cc0e71a8dab1409bc6a1 Mon Sep 17 00:00:00 2001 From: mikibonacci Date: Fri, 13 Dec 2024 10:06:15 +0000 Subject: [PATCH 4/4] Forgotten import in io.inputfile.py --- yambopy/io/inputfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yambopy/io/inputfile.py b/yambopy/io/inputfile.py index 3f88053..1c23c46 100644 --- a/yambopy/io/inputfile.py +++ b/yambopy/io/inputfile.py @@ -7,7 +7,7 @@ import json import re from subprocess import Popen, PIPE -#from yambopy.env import yambopyenv +from yambopy.env import yambopyenv from yambopy.tools.duck import isstring