Skip to content

Commit

Permalink
Merge pull request mala-project#574 from timcallow/ldos_align
Browse files Browse the repository at this point in the history
Align LDOS vectors to a reference
  • Loading branch information
RandomDefaultUser authored Oct 7, 2024
2 parents 96e983d + 7be0287 commit 7a36d31
Show file tree
Hide file tree
Showing 4 changed files with 399 additions and 0 deletions.
32 changes: 32 additions & 0 deletions examples/advanced/ex09_align_ldos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os

import mala

from mala.datahandling.data_repo import data_path

"""
Shows how to align the energy spaces of different LDOS vectors to a reference.
This is useful when the band energy spectrum starts at different values, e.g.
when MALA is trained for snapshots of different mass densities.
Note that this example is only a proof-of-principle, because the alignment
algorithm has no effect on the Be test snapshots (apart from truncation).
"""


parameters = mala.Parameters()
parameters.targets.ldos_gridoffset_ev = -5
parameters.targets.ldos_gridsize = 11
parameters.targets.ldos_gridspacing_ev = 2.5

# initialize and add snapshots to workflow
ldos_aligner = mala.LDOSAligner(parameters)
ldos_aligner.clear_data()
ldos_aligner.add_snapshot("Be_snapshot0.out.npy", data_path)
ldos_aligner.add_snapshot("Be_snapshot1.out.npy", data_path)
ldos_aligner.add_snapshot("Be_snapshot2.out.npy", data_path)

# align and cut the snapshots from the left and right-hand sides
ldos_aligner.align_ldos_to_ref(
left_truncate=True, right_truncate_value=11, number_of_electrons=4
)
1 change: 1 addition & 0 deletions mala/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
DataConverter,
Snapshot,
DataShuffler,
LDOSAligner,
)
from .network import (
Network,
Expand Down
1 change: 1 addition & 0 deletions mala/datahandling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from .data_converter import DataConverter
from .snapshot import Snapshot
from .data_shuffler import DataShuffler
from .ldos_aligner import LDOSAligner
Loading

0 comments on commit 7a36d31

Please sign in to comment.