Skip to content

Commit 7951b92

Browse files
authored
Merge pull request #98 from Exabyte-io/feature/SOF-7776
Feature/SOF-7776 WFN
2 parents cdd4d6c + 757f336 commit 7951b92

File tree

29 files changed

+1232
-9
lines changed

29 files changed

+1232
-9
lines changed

assets/applications/executables/espresso/pp.x.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,13 @@ flavors:
1919
- standard_output
2020
applicationName: espresso
2121
executableName: pp.x
22+
23+
pp_wfn:
24+
input:
25+
- name: pp_wfn.in
26+
results:
27+
- wavefunction_amplitude
28+
monitors:
29+
- standard_output
30+
applicationName: espresso
31+
executableName: pp.x

assets/applications/executables/python/python.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ flavors:
3434
applicationName: python
3535
executableName: python
3636

37+
plot_wavefunction:
38+
input:
39+
- name: script.py
40+
templateName: plot_wavefunction.py
41+
- name: requirements.txt
42+
templateName: requirements_plot_wavefunction.txt
43+
results:
44+
- name: file_content
45+
filetype: image
46+
basename: "wf_r.png"
47+
monitors:
48+
- standard_output
49+
applicationName: python
50+
executableName: python
51+
3752
'generic:post_processing:plot:matplotlib':
3853
input:
3954
- name: plot.py
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
&INPUTPP
2+
outdir = {% raw %}'{{ JOB_WORK_DIR }}/outdir'{% endraw %}
3+
prefix = '__prefix__'
4+
plot_num = 7
5+
kpoint = 1
6+
kband = {% raw %}{{ KBAND_VALUE | default(1) }}{% endraw %}
7+
lsign = .true.
8+
/
9+
&PLOT
10+
iflag = 1
11+
fileout = 'wf_r.dat'
12+
output_format = 0
13+
x0(1) = 0.0, x0(2) = 0.0, x0(3) = 0.0
14+
e1(1) = 0.0, e1(2) = 0.0, e1(3) = {{material.lattice.c/material.lattice.a}}
15+
nx = 200
16+
/
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# ---------------------------------------------------------------- #
2+
# Generate wavefunction plot from pp.x output #
3+
# And saves static #
4+
# ---------------------------------------------------------------- #
5+
6+
import matplotlib
7+
import numpy as np
8+
9+
matplotlib.use('Agg') # Non-interactive backend
10+
import matplotlib.pyplot as plt
11+
12+
# Load wavefunction data from pp.x output
13+
data = np.loadtxt('wf_r.dat')
14+
z = data[:, 0]
15+
psi_r = data[:, 1]
16+
17+
# Calculate wavefunction amplitude
18+
psi_amplitude = np.abs(psi_r)
19+
20+
# Create static PNG plot
21+
fig, ax = plt.subplots(figsize=(10, 6))
22+
ax.plot(z, psi_amplitude, 'b-', linewidth=2)
23+
ax.set_xlabel('Position z (alat)', fontsize=12)
24+
ax.set_ylabel('Wavefunction amplitude |ψ| (a.u.)', fontsize=12)
25+
ax.set_title('Wavefunction along z-axis', fontsize=14)
26+
ax.grid(True, alpha=0.3)
27+
plt.tight_layout()
28+
plt.savefig('wf_r.png', dpi=150, bbox_inches='tight')
29+
plt.close()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# ------------------------------------------------------------------ #
2+
# #
3+
# Python package requirements for plot_wavefunction unit #
4+
# #
5+
# ------------------------------------------------------------------ #
6+
7+
numpy<2
8+
matplotlib
9+

assets/applications/templates/espresso/pp.x.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@
99
contextProviders: []
1010
applicationName: espresso
1111
executableName: pp.x
12+
13+
- content: !readFile 'input_files_templates/espresso/pp_wfn.j2.in'
14+
name: pp_wfn.in
15+
contextProviders: []
16+
applicationName: espresso
17+
executableName: pp.x

assets/applications/templates/python/python.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@
2828
applicationName: python
2929
executableName: python
3030

31+
- content: !readFile 'input_files_templates/python/plot_wavefunction.pyi'
32+
name: plot_wavefunction.py
33+
contextProviders: []
34+
applicationName: python
35+
executableName: python
36+
37+
- content: !readFile 'input_files_templates/python/requirements_plot_wavefunction.j2.txt'
38+
name: requirements_plot_wavefunction.txt
39+
contextProviders: []
40+
applicationName: python
41+
executableName: python
42+
3143
- content: !readFile 'input_files_templates/python/espresso_extract_kpoints.pyi'
3244
name: espresso_extract_kpoints.py
3345
contextProviders: []

assets/workflows/subworkflows/categories.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ categories:
2121
- total_energy_contributions
2222
- total_force
2323
- valence_band_offset
24+
- wavefunction_amplitude
2425
- workflow:pyml_predict
2526
- zero_point_energy
2627
tags:
@@ -30,6 +31,8 @@ categories:
3031
- remove-all-results
3132
- set-io-unit-filenames
3233
- variable-cell_relaxation
34+
- wfn
35+
- wfn_plot
3336
application:
3437
- espresso
3538
- nwchem
@@ -303,6 +306,11 @@ entities:
303306
- espresso
304307
- phonon_dispersions
305308
- phonon_dos
309+
- filename: espresso/plot_wavefunction.json
310+
categories:
311+
- espresso
312+
- file_content
313+
- python
306314
- filename: espresso/post_processor.json
307315
categories:
308316
- espresso
@@ -362,6 +370,20 @@ entities:
362370
- total_energy
363371
- total_force
364372
- variable-cell_relaxation
373+
- filename: espresso/wavefunction_amplitude.json
374+
categories:
375+
- atomic_forces
376+
- band_structure
377+
- espresso
378+
- fermi_energy
379+
- pressure
380+
- stress_tensor
381+
- total_energy
382+
- total_energy_contributions
383+
- total_force
384+
- wavefunction_amplitude
385+
- wfn
386+
- wfn_plot
365387
- filename: espresso/zero_point_energy.json
366388
categories:
367389
- atomic_forces
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
application:
2+
name: python
3+
version: 3.10.13
4+
method:
5+
name: UnknownMethod
6+
model:
7+
name: UnknownModel
8+
name: Plot Wavefunction
9+
properties:
10+
- file_content
11+
units:
12+
- attributes:
13+
results:
14+
- name: file_content
15+
basename: "wf_r.png"
16+
filetype: "image"
17+
config:
18+
execName: python
19+
flavorName: plot_wavefunction
20+
name: plot WFN
21+
type: executionBuilder
22+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
application:
2+
name: espresso
3+
version: '6.3'
4+
method:
5+
name: PseudopotentialMethod
6+
model:
7+
name: DFTModel
8+
name: Wavefunction Amplitude
9+
properties:
10+
- atomic_forces
11+
- fermi_energy
12+
- pressure
13+
- stress_tensor
14+
- total_energy
15+
- total_energy_contributions
16+
- total_force
17+
- band_structure
18+
- wavefunction_amplitude
19+
units:
20+
- config:
21+
execName: pw.x
22+
flavorName: pw_scf
23+
name: pw_scf
24+
flowchartId: pw-scf
25+
functions:
26+
head: true
27+
type: executionBuilder
28+
attributes:
29+
results:
30+
- name: atomic_forces
31+
- name: band_structure
32+
- name: fermi_energy
33+
- name: pressure
34+
- name: stress_tensor
35+
- name: total_energy
36+
- name: total_energy_contributions
37+
- name: total_force
38+
- config:
39+
name: Extract Band Energies
40+
operand: band_energies
41+
value: >-
42+
[band_data[0] for band_data in (band_structure['yDataSeries'] if (band_structure and
43+
'yDataSeries' in band_structure) else [])]
44+
flowchartId: extract-band-energies
45+
input:
46+
- name: band_structure
47+
scope: pw-scf
48+
type: assignment
49+
- config:
50+
name: Find Indices Below Fermi
51+
operand: indices_below_fermi
52+
value: "[i for i in range(len(band_energies)) if band_energies[i] <= fermi_energy]"
53+
flowchartId: indices-below-fermi
54+
input:
55+
- name: fermi_energy
56+
scope: pw-scf
57+
type: assignment
58+
- config:
59+
name: Store Band Below EF
60+
operand: KBAND_VALUE_BELOW_EF
61+
value: "indices_below_fermi[-1] + 1 if len(indices_below_fermi) > 0 else 1"
62+
type: assignment
63+
- config:
64+
name: Select Band
65+
operand: KBAND_VALUE
66+
value: "KBAND_VALUE_BELOW_EF"
67+
type: assignment
68+
- config:
69+
execName: pp.x
70+
flavorName: pp_wfn
71+
name: pp_wfn
72+
flowchartId: pp-wfn
73+
input:
74+
- name: KBAND_VALUE
75+
type: executionBuilder
76+
attributes:
77+
results:
78+
- name: wavefunction_amplitude
79+
tags:
80+
- wfn
81+
- wfn_plot
82+

0 commit comments

Comments
 (0)