-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/SOF-7776 WFN #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/SOF-7784
Are you sure you want to change the base?
Changes from all commits
84d1d45
df48f40
39e00e9
fb8a57a
e0cbcf9
03af085
9c4c7dc
66a9995
61f6635
75da86a
3ee158b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| &INPUTPP | ||
| outdir = {% raw %}'{{ JOB_WORK_DIR }}/outdir'{% endraw %} | ||
| prefix = '__prefix__' | ||
| plot_num = 7, | ||
| kpoint = 1, | ||
| kband = {% raw %}{{ KBAND_VALUE }}{% endraw %}, | ||
| lsign = .true., | ||
| !spin_component = 1 | ||
| / | ||
| &PLOT | ||
| iflag = 1, ! 1D line (not 2D plane) | ||
| fileout = 'wf_r.dat', | ||
| output_format = 0, ! gnuplot 1D | ||
| x0(1)=0.0, x0(2)=0.0, x0(3)=0.0, ! line origin (alat units) | ||
| e1(1)=0.0, e1(2)=0.0, e1(3)=1.0, ! direction along z (alat units) | ||
| nx = 200 ! samples along the line | ||
| / | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # ---------------------------------------------------------------- # | ||
| # Extract band indices near Fermi energy from band_structure # | ||
| # This script expects fermi_energy and band_structure results # | ||
| # ---------------------------------------------------------------- # | ||
| import json | ||
|
|
||
| from munch import Munch | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's explain why this is needed and put a task to remove the use of it |
||
|
|
||
| # Data From Context | ||
| # ----------------- | ||
| # fermi_energy: float (in eV) - from pw_scf result | ||
| # band_structure: Munch object with band energies - from pw_bands result | ||
|
|
||
| {% raw %}fermi_energy_value = {{ fermi_energy }}{% endraw %} | ||
| {% raw %}band_structure_data = {{ band_structure }}{% endraw %} | ||
|
|
||
| # Extract band energies at Gamma point (first k-point) | ||
| # band_structure format from QE parser: | ||
| # { | ||
| # "name": "band_structure", | ||
| # "xDataArray": [[kx, ky, kz], ...], # k-points | ||
| # "yDataSeries": [[e1_k1, e1_k2, ...], [e2_k1, e2_k2, ...], ...] # energies per band | ||
| # } | ||
| # yDataSeries[band_index][kpoint_index] = energy | ||
|
|
||
| # Get energies at first k-point (Gamma, index 0) for all bands | ||
| y_data = band_structure_data.get('yDataSeries', []) | ||
| band_energies = [band_data[0] for band_data in y_data] if y_data else [] | ||
|
|
||
| # Find bands near Fermi energy (1-based indices as QE expects) | ||
| valence_bands = [(i + 1, e) for i, e in enumerate(band_energies) if e <= fermi_energy_value] | ||
| conduction_bands = [(i + 1, e) for i, e in enumerate(band_energies) if e > fermi_energy_value] | ||
|
|
||
| if valence_bands: | ||
| valence_index, valence_energy = max(valence_bands, key=lambda x: x[1]) | ||
| else: | ||
| valence_index = 1 | ||
| valence_energy = band_energies[0] if band_energies else 0.0 | ||
|
|
||
| if conduction_bands: | ||
| conduction_index, conduction_energy = min(conduction_bands, key=lambda x: x[1]) | ||
| else: | ||
| conduction_index = len(band_energies) | ||
| conduction_energy = band_energies[-1] if band_energies else 0.0 | ||
|
|
||
| result = { | ||
| "band_below_fermi": valence_index, | ||
| "band_above_fermi": conduction_index, | ||
| "fermi_energy": fermi_energy_value, | ||
| "valence_energy": valence_energy, | ||
| "conduction_energy": conduction_energy, | ||
| "total_bands": len(band_energies) | ||
| } | ||
|
|
||
| # Print to STDOUT for subsequent assignment unit | ||
| print(json.dumps(result, indent=4)) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # ---------------------------------------------------------------- # | ||
| # Generate wavefunction plot from pp.x output # | ||
| # Outputs potential_profile JSON to STDOUT for platform rendering # | ||
| # Also saves static PNG as fallback # | ||
| # ---------------------------------------------------------------- # | ||
|
|
||
| import json | ||
|
|
||
| import matplotlib | ||
| import numpy as np | ||
|
|
||
| matplotlib.use('Agg') # Non-interactive backend | ||
| import matplotlib.pyplot as plt | ||
|
|
||
| # Load wavefunction data from pp.x output | ||
| data = np.loadtxt('wf_r.dat') | ||
| z = data[:, 0] | ||
| psi_r = data[:, 1] | ||
|
|
||
| # Calculate wavefunction amplitude | ||
| psi_amplitude = np.abs(psi_r) | ||
|
|
||
| # Create static PNG plot | ||
| fig, ax = plt.subplots(figsize=(10, 6)) | ||
| ax.plot(z, psi_amplitude, 'b-', linewidth=2) | ||
| ax.set_xlabel('Position z (Å)', fontsize=12) | ||
| ax.set_ylabel('Wavefunction amplitude |ψ| (a.u.)', fontsize=12) | ||
| ax.set_title('Wavefunction along z-axis', fontsize=14) | ||
| ax.grid(True, alpha=0.3) | ||
| plt.tight_layout() | ||
| plt.savefig('wf_r.png', dpi=150, bbox_inches='tight') | ||
| plt.close() | ||
|
|
||
| # Create potential_profile JSON for platform rendering | ||
| wavefunction_data = { | ||
| "name": "potential_profile", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wavefunction_amplitude |
||
| "xAxis": { | ||
| "label": "Position", | ||
| "units": "angstrom" | ||
| }, | ||
| "xDataArray": z.tolist(), | ||
| "yAxis": { | ||
| "label": "Wavefunction Amplitude", | ||
| "units": "a.u." | ||
| }, | ||
| "yDataSeries": [psi_amplitude.tolist()] | ||
| } | ||
|
|
||
| # Print JSON to STDOUT (will be captured as potential_profile result) | ||
| print(json.dumps(wavefunction_data, indent=2)) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # ------------------------------------------------------------------ # | ||
| # # | ||
| # Python package requirements for extract_bands_fermi unit # | ||
| # # | ||
| # ------------------------------------------------------------------ # | ||
|
|
||
| munch==2.5.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # ------------------------------------------------------------------ # | ||
| # # | ||
| # Python package requirements for plot_wavefunction unit # | ||
| # # | ||
| # ------------------------------------------------------------------ # | ||
|
|
||
| numpy<2 | ||
| matplotlib |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Note: This subworkflow extracts band indices near Fermi energy | ||
| # Expects fermi_energy and band_structure to be passed via unitConfigs | ||
| # Outputs: KBAND_VALUE_BELOW_EF, KBAND_VALUE_ABOVE_EF, and KBAND_VALUE (selected) | ||
| application: | ||
| name: python | ||
| version: 3.10.13 | ||
| method: | ||
| name: UnknownMethod | ||
| model: | ||
| name: UnknownModel | ||
| name: Extract Bands Near Fermi | ||
| units: | ||
| - config: | ||
| execName: python | ||
| flavorName: extract_bands_fermi | ||
| name: extract_bands_fermi | ||
| flowchartId: extract-band-fermi | ||
| type: executionBuilder | ||
| - config: | ||
| name: Store Band Below EF | ||
| operand: KBAND_VALUE_BELOW_EF | ||
| value: "json.loads(STDOUT)['band_below_fermi']" | ||
| input: | ||
| - name: STDOUT | ||
| scope: extract-band-fermi | ||
| type: assignment | ||
| - config: | ||
| name: Store Band Above EF | ||
| operand: KBAND_VALUE_ABOVE_EF | ||
| value: "json.loads(STDOUT)['band_above_fermi']" | ||
| input: | ||
| - name: STDOUT | ||
| scope: extract-band-fermi | ||
| type: assignment | ||
| - config: | ||
| name: Select Band | ||
| operand: KBAND_VALUE | ||
| value: "KBAND_VALUE_BELOW_EF" | ||
| type: assignment |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| application: | ||
| name: python | ||
| version: 3.10.13 | ||
| method: | ||
| name: UnknownMethod | ||
| model: | ||
| name: UnknownModel | ||
| name: Plot Wavefunction | ||
| properties: | ||
| - potential_profile | ||
| - file_content | ||
| units: | ||
| - config: | ||
| execName: python | ||
| flavorName: plot_wavefunction | ||
| name: plot WFN | ||
| results: | ||
| - name: potential_profile | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
| - name: file_content | ||
| basename: wf_r.png | ||
| filetype: image | ||
| type: executionBuilder | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check formatting for other pp files and match