<filename>src/scripts/ComputeNorms.py
"""The WaveBlocks Project

Calculate the norms of the different wave packets as well as the sum of all norms.

@author: <NAME>
@copyright: Copyright (C) 2010, 2011 <NAME>
@license: Modified BSD License
"""

import sys

from WaveBlocks import IOManager


if __name__ == "__main__":

    iom = IOManager()

    # Read file with simulation data
    try:
        iom.open_file(filename=sys.argv[1])
    except IndexError:
        iom.open_file()

    # Iterate over all blocks
    for blockid in iom.get_block_ids():
        print("Computing the norms in data block '"+str(blockid)+"'")

        if iom.has_norm(blockid=blockid):
            print("Datablock '"+str(blockid)+"' already contains norm data, silent skip.")
            continue

        # See if we have an inhomogeneous wavepacket in the current data block
        if iom.has_inhomogwavepacket(blockid=blockid):
            import NormWavepacketInhomog
            NormWavepacketInhomog.compute_norm(iom, blockid=blockid)
        # If not, we test for a homogeneous wavepacket next
        elif iom.has_wavepacket(blockid=blockid):
            import NormWavepacket
            NormWavepacket.compute_norm(iom, blockid=blockid)
        # If we have no wavepacket, then we try for a wavefunction
        elif iom.has_wavefunction(blockid=blockid):
            import NormWavefunction
            NormWavefunction.compute_norm(iom, blockid=blockid)
        # If there is also no wavefunction, then there is nothing to compute the norm
        else:
            print("Warning: Not computing any norm in block '"+str(blockid)+"'!")

    iom.finalize()

<filename>src/scripts/ComputeNorms.py
"""The WaveBlocks Project

Calculate the norms of the different wave packets as well as the sum of all norms.

@author: <NAME>
@copyright: Copyright (C) 2010, 2011 <NAME>
@license: Modified BSD License
"""

import sys

from WaveBlocks import IOManager


if __name__ == "__main__":

    iom = IOManager()

    # Read file with simulation data
    try:
        iom.open_file(filename=sys.argv[1])
    except IndexError:
        iom.open_file()

    # Iterate over all blocks
    for blockid in iom.get_block_ids():
        print("Computing the norms in data block '"+str(blockid)+"'")

        if iom.has_norm(blockid=blockid):
            print("Datablock '"+str(blockid)+"' already contains norm data, silent skip.")
            continue

        # See if we have an inhomogeneous wavepacket in the current data block
        if iom.has_inhomogwavepacket(blockid=blockid):
            import NormWavepacketInhomog
            NormWavepacketInhomog.compute_norm(iom, blockid=blockid)
        # If not, we test for a homogeneous wavepacket next
        elif iom.has_wavepacket(blockid=blockid):
            import NormWavepacket
            NormWavepacket.compute_norm(iom, blockid=blockid)
        # If we have no wavepacket, then we try for a wavefunction
        elif iom.has_wavefunction(blockid=blockid):
            import NormWavefunction
            NormWavefunction.compute_norm(iom, blockid=blockid)
        # If there is also no wavefunction, then there is nothing to compute the norm
        else:
            print("Warning: Not computing any norm in block '"+str(blockid)+"'!")

    iom.finalize()

The WaveBlocks Project  Calculate the norms of the different wave packets as well as the sum of all norms.  @author: <NAME> @copyright: Copyright (C) 2010, 2011 <NAME> @license: Modified BSD License # Read file with simulation data # Iterate over all blocks # See if we have an inhomogeneous wavepacket in the current data block # If not, we test for a homogeneous wavepacket next # If we have no wavepacket, then we try for a wavefunction # If there is also no wavefunction, then there is nothing to compute the norm