def main(argv): if len(argv) > 1: raise app.UsageError('Too many command-line arguments.') logging.info( 'Solve Poschl-Teller potential with lambda=%f, scaling=%f', FLAGS.lam, FLAGS.scaling) logging.info( 'Number of electrons: %d', FLAGS.num_electrons) logging.info( 'Grids: linspace(%f, %f, %d)', FLAGS.grid_lower, FLAGS.grid_upper, FLAGS.num_grids) exact_energy = single_electron.poschl_teller_eigen_energy( level=FLAGS.num_electrons, lam=FLAGS.lam) logging.info('Exact energy: %f', exact_energy) logging.info('Solve with solver: %s', FLAGS.solver) solver = getattr(single_electron, FLAGS.solver)( grids=np.linspace(FLAGS.grid_lower, FLAGS.grid_upper, FLAGS.num_grids), potential_fn=functools.partial( single_electron.poschl_teller, lam=FLAGS.lam), num_electrons=FLAGS.num_electrons) solver.solve_ground_state() logging.info('Numerical solution: %f', solver.total_energy) logging.info('Difference: %e', solver.total_energy - exact_energy)
def test_poschl_teller_eigen_energy_float_lambda(self, level, lam, expected_energy): # NOTE(leeley): I calculated some eigen energy for float lambda by the # expression in Phys. Rev. B 95, 115115 self.assertAlmostEqual( single_electron.poschl_teller_eigen_energy(level, lam), expected_energy)
def test_poschl_teller_eigen_energy_int_lambda(self, level, lam, expected_energy): # For integer value of lambda, the eigen energy is # E = -\mu^2 / 2 # \mu = \lambda, \lambda - 1, ..., 1 # https://en.wikipedia.org/wiki/P%C3%B6schl%E2%80%93Teller_potential self.assertAlmostEqual( single_electron.poschl_teller_eigen_energy(level, lam), expected_energy)