-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
6 changed files
with
133 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from shutil import copy | ||
|
||
|
||
def extract(filename_in, filename_out, start=0, end=None, heading=None): | ||
with open(filename_in) as fd: | ||
flines = fd.readlines() | ||
|
||
# If heading is provided, find the line number of the heading | ||
if heading: | ||
for i, line in enumerate(flines): | ||
if heading in line: | ||
start = i | ||
break | ||
else: | ||
raise ValueError(f'Heading {heading} not found in file {filename_in}') | ||
|
||
indent = len(flines[start]) - len(flines[start].lstrip()) | ||
|
||
for i in range(start + 1, len(flines)): | ||
line = flines[i] | ||
if not line.startswith(' ' * (indent + 1)): | ||
end = i | ||
break | ||
|
||
if end is None: | ||
raise ValueError(f'Could not find the end of the {heading} block') | ||
|
||
flines = flines[start:end] | ||
|
||
# Find the shortest leading whitespace and strip this from all lines (as otherwise the markdown will be rendered as a code block) | ||
min_indent = min(len(line) - len(line.lstrip()) for line in flines) | ||
flines = [line[min_indent:] for line in flines] | ||
|
||
# Manual conversion of double spaces to / | ||
flines = [line[:-2] + '\ \n' if (line.endswith(' \n') | ||
and not line.strip().startswith('-')) else line for line in flines] | ||
|
||
with open(filename_out, 'w') as fd: | ||
fd.writelines(flines) | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
# Tutorial 3 | ||
extract('../../../tutorials/tutorial_3/01-ki/zno.md', | ||
'tutorial_3/md_excerpts/zno_wannierize_section.md', heading='Wannierize') | ||
extract('../../../tutorials/tutorial_3/01-ki/zno.md', 'tutorial_3/md_excerpts/zno_w2kc.md', -4, -3) | ||
extract('../../../tutorials/tutorial_3/01-ki/zno.md', 'tutorial_3/md_excerpts/zno_ham.md', -3, -2) | ||
copy('../../../tutorials/tutorial_3/01-ki/01-koopmans-dfpt/Koopmans_DFPT_bandstructure.png', 'tutorial_3/') |
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 @@ | ||
- ✅ `03-kc_ham` completed |
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 @@ | ||
- ✅ `02-wann2kc` completed |
28 changes: 28 additions & 0 deletions
28
docs/_static/tutorials/tutorial_3/md_excerpts/zno_wannierize_section.md
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,28 @@ | ||
- **Wannierize** | ||
- ✅ `01-scf` completed | ||
- ✅ `02-nscf` completed | ||
- **Wannierize Block 1** | ||
- ✅ `01-wannier90_preproc` completed | ||
- ✅ `02-pw2wannier90` completed | ||
- ✅ `03-wannier90` completed | ||
- **Wannierize Block 2** | ||
- ✅ `01-wannier90_preproc` completed | ||
- ✅ `02-pw2wannier90` completed | ||
- ✅ `03-wannier90` completed | ||
- **Wannierize Block 3** | ||
- ✅ `01-wannier90_preproc` completed | ||
- ✅ `02-pw2wannier90` completed | ||
- ✅ `03-wannier90` completed | ||
- **Wannierize Block 4** | ||
- ✅ `01-wannier90_preproc` completed | ||
- ✅ `02-pw2wannier90` completed | ||
- ✅ `03-wannier90` completed | ||
- **Wannierize Block 5** | ||
- ✅ `01-wannier90_preproc` completed | ||
- ✅ `02-pw2wannier90` completed | ||
- ✅ `03-wannier90` completed | ||
- ✅ `08-merge_occ_wannier_hamiltonian` completed | ||
- ✅ `09-merge_occ_wannier_u` completed | ||
- ✅ `10-merge_occ_wannier_centers` completed | ||
- ✅ `11-bands` completed | ||
- ✅ `12-projwfc` completed |
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