def test_asym_well(): """ Tests eigenvalues and potential for the example of a asymetric well """ file = "tests/asym_well/schroedinger.inp" x_min, x_max, n_point, ev_first, ev_last, interp_type, potential_decl, alpha = sd.read_inp( file) potential_dat = sd.potential_discret(x_min, x_max, n_point, interp_type, potential_decl) eigenvektors, eigenvalues = sd.solve_wavefuncs(n_point, ev_first, ev_last, potential_dat, alpha) sd.solve_expvalues(ev_first, ev_last, potential_dat, eigenvektors) potential_exp = np.loadtxt("tests/asym_well/potential.exp") eigenvalues_exp = np.loadtxt("tests/asym_well/eigenvalues.exp") assert np.all(eigenvalues - eigenvalues_exp < 1e-10) assert np.all(potential_dat - potential_exp < 1e-10)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Main script, which uses the functions provided by the sglpackage to read in the information from the input file and calculates the discretized potential, eigenfunctions, eigenvalues and expectation values for the x-coordinate.""" import argparse import sglpackage.solver_definitions as sd _DESCRIPTION = 'View the user documentation for more information' _PARSER = argparse.ArgumentParser(description=_DESCRIPTION) _MSG = 'Directory (default: same as the scripts directory)' _PARSER.add_argument('-d', '--directory', default='', help=_MSG) ARGS = _PARSER.parse_args() FNAME = ARGS.directory + 'schroedinger.inp' X_MIN, X_MAX, N_POINT, EV_FIRST, EV_LAST, INTERP_TYPE, POTENTIAL_DECL, ALPHA = sd.read_inp( FNAME) POTENTIAL_DAT = sd.potential_discret(X_MIN, X_MAX, N_POINT, INTERP_TYPE, POTENTIAL_DECL) EIGENVEKTORS, EIGENVALUES = sd.solve_wavefuncs(N_POINT, EV_FIRST, EV_LAST, POTENTIAL_DAT, ALPHA) sd.solve_expvalues(EV_FIRST, EV_LAST, POTENTIAL_DAT, EIGENVEKTORS)