Skip to content

Commit

Permalink
Various fixes and modifs for atomate2 development (#283)
Browse files Browse the repository at this point in the history
* Read SHG AR contrib

* test spinat

* modif set_autospinat

* modif for atomate2

* fix EventParser for RelaxConvergenceWarning + quick fix wrapper as_dict pmg_serialize

* remove VT
  • Loading branch information
VicTrqt authored Jan 19, 2024
1 parent 5a23a23 commit af4186a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion abipy/abio/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ def set_autospinat(self, default=0.6) -> dict:
for site in self.structure:
if hasattr(site, 'magmom'):
spinat.append((0., 0., site.magmom))
elif hasattr(site.specie, 'spin'):
elif hasattr(site.specie, 'spin') and site.specie.spin:
spinat.append((0., 0., site.specie.spin))
elif str(site.specie) in magmom_mp_conf:
spinat.append((0., 0., magmom_mp_conf.get(str(site.specie))))
Expand Down
8 changes: 7 additions & 1 deletion abipy/abio/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,13 @@ def pop_stack():
if dtidx is None:
vars_global[key] = value
else:
vars_dataset[dtidx][key] = value
try:
vars_dataset[dtidx][key] = value
except KeyError:
if dtidx==0:
vars_global[key] = value
else:
raise Exception("dataset index != 0 but still not found in vars_dataset")

for line in lines:
if not line: continue
Expand Down
5 changes: 4 additions & 1 deletion abipy/electrons/optic.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
"longname": "Second Harmonic Generation",
"rank": 3,
"terms": ["shg_inter2w", "shg_inter1w", "shg_intra2w",
"shg_intra1w", "shg_intra1wS", "shg_chi2tot"],
"shg_intra1w", "shg_intra1wS", "shg_chi2tot",
"shg_inter2w_AR", "shg_inter1w_AR", "shg_intra2w_AR",
"shg_intra1w_AR", "shg_intra1wS_AR", "shg_chi2tot_AR",
"shg_chi2full"],
}
#"latex": r"\chi(-2\omega, \omega, \omega)"
),
Expand Down
1 change: 1 addition & 0 deletions abipy/flowtk/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ def parse(self, filename: str, verbose: int = 0) -> EventReport:
if w.match(doc.tag):
#print("got doc.tag", doc.tag,"--")
try:
doc.text = doc.text.replace('\n \n', '\n')
#print(doc.text)
event = yaml.load(doc.text) # Can't use ruamel safe_load!
# FIXME: This new (recommend) API does not reproduce yaml.load behavior. bug in ruamel?
Expand Down
2 changes: 1 addition & 1 deletion abipy/flowtk/qadapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def __init__(self, **kwargs):

# Convert memory to megabytes.
m = str(kwargs.pop("mem_per_node"))
self.mem_per_node = int(Memory.from_str(m).to("Mb"))
self.mem_per_node = int(Memory.from_string(m).to("Mb"))

if self.mem_per_node <= 0 or self.sockets_per_node <= 0 or self.cores_per_socket <= 0:
raise ValueError("invalid parameters: %s" % kwargs)
Expand Down
2 changes: 2 additions & 0 deletions abipy/tools/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def pmg_serialize(method):

@functools.wraps(method)
def wrapper(*args, **kwargs):
if not args:
return None
self = args[0]
d = method(*args, **kwargs)
# Add @module and @class
Expand Down

0 comments on commit af4186a

Please sign in to comment.