Ejemplo n.º 1
0
def test_energy(direc):
    """Read data for energy from reference files and outputfiles, and
    compare them with each other.

    Args:
        direc: directory of the outputfiles and reference files

    Returns:

    """

    # import values for energy from the solver
    energy = solver(direc)[1]

    # open reference data for the energy
    fileener = open(os.path.join(direc, 'ref_energies.dat'), "r")
    linesener = fileener.readlines()
    fileener.close()

    # create array for reference energies to compare with calculated energies
    refenergies = np.zeros((int(len(energy)), ))
    for ii in range(0, len(energy)):
        refenergies[ii] = float(linesener[ii].split()[0])

    # checks whether reference and calculated values are the same
    assert np.all(np.abs(refenergies - energy) < 1e-2)
Ejemplo n.º 2
0
def test_potential(direc):
    """Read data for potential from reference files and outputfiles, and
    compare them with each other.

    Args:
        direc: directory of the outputfiles and reference files

    Returns:

    """
    # import values for potential from the solver
    xypotential = solver(direc)[0]

    # open reference data for the potential
    filepot = open(os.path.join(direc, 'ref_potential.dat'), "r")
    linespot = filepot.readlines()
    filepot.close()

    # create array for reference potential to compare with calculated potential
    refpotential = np.zeros((int(len(xypotential)), 2))
    for ii in range(0, len(xypotential)):
        refpotential[ii, 0] = float(linespot[ii].split()[0])
        refpotential[ii, 1] = float(linespot[ii].split()[1])

    # checks whether reference and calculated values are the same
    assert np.all(np.abs(refpotential - xypotential) < 1e-10)
Ejemplo n.º 3
0
def test_function(direc):
    """test interpolated discretised potential and energies"""
    # import values for potential and energy from the solver
    xypotential, energy = solver(direc)

    # open reference data for the potential
    filepot = open(os.path.join(direc, 'ref_potential.dat'), "r")
    linespot = filepot.readlines()
    filepot.close()

    # create array for reference potential to compare with calculated potential
    refpotential = np.zeros((int(len(xypotential)), 2))
    for ii in range(0, len(xypotential)):
        refpotential[ii, 0] = float(linespot[ii].split()[0])
        refpotential[ii, 1] = float(linespot[ii].split()[1])

    # checks whether reference and calculated values are the same
    assert np.all(np.abs(refpotential - xypotential) < 1e-10)

    # open reference data for the energy
    fileener = open(os.path.join(direc, 'ref_energies.dat'), "r")
    linesener = fileener.readlines()
    fileener.close()

    # create array for reference energies to compare with calculated energies
    refenergies = np.zeros((int(len(energy)), ))
    for ii in range(0, len(energy)):
        refenergies[ii] = float(linesener[ii].split()[0])

    # checks whether reference and calculated values are the same
    assert np.all(np.abs(refenergies - energy) < 1e-10)
Ejemplo n.º 4
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Executable file which contains solver and visualizer"""

import schroed_solver
import schroed_visualize

# enter the directory of the problem
direc = "inputdata/asym_potential_well"

# set options for a better illustration of the solutions
bulge_factor = 0.2
lim_x = 0.5
lim_y = 0.2

# execute solver and visualizer
schroed_solver.solver(direc)
schroed_visualize.visualize(direc, bulge_factor, lim_x, lim_y)
Ejemplo n.º 5
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Executable file which contains solver and visualizer"""

import argparse
from schroed_solver import solver

PARSER = argparse.ArgumentParser(description='Executes solver for the\
                                              Schroedinger equation')

MSG = 'Set directory of the figures\
    (default value: ./inputdata/potential_well)'

PARSER.add_argument('-d',
                    '--directory',
                    default='./inputdata/potential_well',
                    help=MSG)

ARGS = PARSER.parse_args()
print("Directory: {}".format(ARGS.directory))

solver(ARGS.directory)