-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08333e9
commit f08750b
Showing
5 changed files
with
227 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from aiida import orm, load_profile\n", | ||
"load_profile()\n", | ||
"\n", | ||
"import pathlib\n", | ||
"import tempfile\n", | ||
"from aiida.plugins import DataFactory\n", | ||
"SingleFileData = DataFactory('core.singlefile')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"wann_block = orm.load_node(7955)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "AttributeError", | ||
"evalue": "'str' object has no attribute 'readlines'", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", | ||
"Cell \u001b[0;32mIn[12], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m u_file \u001b[38;5;241m=\u001b[39m wann_block\u001b[38;5;241m.\u001b[39moutputs\u001b[38;5;241m.\u001b[39mretrieved\u001b[38;5;241m.\u001b[39mget_object_content(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124maiida\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m_u.mat\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m----> 2\u001b[0m u_text \u001b[38;5;241m=\u001b[39m \u001b[43mu_file\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreadlines\u001b[49m()\n", | ||
"\u001b[0;31mAttributeError\u001b[0m: 'str' object has no attribute 'readlines'" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"u_file = wann_block.outputs.retrieved.get_object_content('aiida' + '_u.mat')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 13, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"temp_file = \"/home/jovyan/work/blitz/prova.mat\"\n", | ||
"with open(temp_file, 'w') as fd:\n", | ||
" fd.write(''.join(u_file))\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "blitz_shell_koopmans", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pathlib | ||
import tempfile | ||
from aiida.plugins import DataFactory | ||
SingleFileData = DataFactory('core.singlefile') | ||
|
||
def generate_singlefiledata(filename, flines): | ||
with tempfile.TemporaryDirectory() as dirpath: | ||
# Open the output file from the AiiDA storage and copy content to the temporary file | ||
temp_file = pathlib.Path(dirpath) / filename | ||
with open(temp_file, 'w') as fd: | ||
fd.write(''.join(flines)) | ||
|
||
file = SingleFileData(temp_file) | ||
|
||
return file | ||
|
||
def produce_wannier90_files(wannierize_workflow,merge_directory_name): | ||
"""producing the wannier90 files in the case of just one occ and/or one emp blocks. | ||
Args: | ||
wannierize_workflow (WannierizeWorkflow): WannierizeWorkflow which is doing the splitted wannierization. | ||
merge_directory_name (str): "occ" or "emp", as obtained in the WannierizeWorkflow | ||
Returns: | ||
dict: dictionary containing SingleFileData of the files: hr, u and centres for occ and emp, then u_dis if dfpt. | ||
""" | ||
hr_file = wannierize_workflow.w90_wchains[merge_directory_name][0].outputs.wannier90.retrieved.get_object_content('aiida' + '_hr.dat') | ||
u_file = wannierize_workflow.w90_wchains[merge_directory_name][0].outputs.wannier90.retrieved.get_object_content('aiida' + '_u.mat') | ||
centres_file = wannierize_workflow.w90_wchains[merge_directory_name][0].outputs.wannier90.retrieved.get_object_content('aiida' + '_centres.xyz') | ||
|
||
hr_singlefile = generate_singlefiledata('aiida' + '_hr.dat', hr_file) | ||
u_singlefile = generate_singlefiledata('aiida' + '_u.mat', u_file) | ||
centres_singlefile = generate_singlefiledata('aiida' + '_centres.xyz', centres_file) | ||
|
||
standard_dictionary = {'hr_dat':hr_singlefile, "u_mat": u_singlefile, "centres_xyz": centres_singlefile} | ||
|
||
if wannierize_workflow.parameters.method == 'dfpt' and merge_directory_name == "emp": | ||
u_dis_file = wannierize_workflow.w90_wchains[merge_directory_name][0].outputs.wannier90.retrieved.get_object_content('aiida' + '_u_dis.mat') | ||
u_dis_singlefile = generate_singlefiledata('aiida' + '_u_dis.mat', u_dis_file) | ||
standard_dictionary["u_dis_mat"] = u_dis_singlefile | ||
|
||
return standard_dictionary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters