def test_roothaan_method(n, m, Z, grid, N=2): start = time.process_time() ret = roothaan.roothaan(N, n, m, Z, verbose=True, return_progress=True) wavefunc = ret['eigenfunction'] print(f"Time to run: {time.process_time() - start}") print(units.atomic_to_ev(wavefunc.E)) print(wavefunc.C) plotting.plot_wavefunction(wavefunc, grid, None, 'roothaan') plotting.plot_iterative_method_convergance(ret, None, 'roothaan', 'Roothaan', KNOWN_HE_GROUND_STATE_EV)
def run_hartree_fock(plot_folder, plot_name_prefix, Z=2, L=5, m=128, verbose=0): grid = Grid(m, L) wf = roothaan.roothaan(2, 3, 2, Z, convergance=1e-6, max_iter=50, verbose=True) plotting.plot_wavefunction(wf, grid, plot_folder, plot_name_prefix)
def f(mode, fname): wavef = lambda x: wavefs[mode-1](x, 0) (fig, reax, imax) = plotting.setup_figure_topbottom(title=u'Wavefunction for n=%i mode' % mode, #fig, reax) = plotting.setup_figure_standard(title=u'Wavefunction for n=%i mode' % mode, xlabel=u'Distance accross waveguide (m)', ylabel=u'Wavefunction (arbitrary units)') d = plotting.plot_wavefunction(reax, imax, wavef, waveguide.slab_gap) plotting.save_figure(fig, fname) sio.savemat(fname + '.mat', d)
def sp_plot_wavefunction(waveguide, wavelength, angle, out_file, verbose=False): """ This method produces a wavefunction hitting the waveguide at angle, and splits it into the guided modes of the waveguide. The resultant wavefunction is plotted @param waveguide: The waveguide being illuminated @type waveguide: PlanarWaveguide @param wavelength: The wavelength of light illuminating the waveguide @type wavelength: float @param angle: The angle of the plane waves striking the waveguide, in radian @type angle: float @param out_file: The filename to write output to @type out_file: str @param verbose: Whether or not to give verbose output @type verbose: bool @return: None """ solver = modesolvers.ExpLossySolver(waveguide, wavelength) kxs = solver.solve_transcendental(verbose=verbose) wavefs = solver.get_wavefunctions(kxs, verbose=verbose) k = 2*np.pi/wavelength inkx = k*np.sin(angle) inwave = lambda x: np.exp(1j*inkx*x) splitter = splitters.ModeSplitter(inwave, wavefs) cm = splitter.get_coupling_constants() wffull = splitter.get_wavefunction(cm) wf = functools.partial(lambda z,x: wffull(x,z), 0.005) if verbose: print 'Coupling coefficients: ' for (i,c) in enumerate(cm): print '\t %i: Magnitude: %f, Phase: %f, Square: %f' % (i+1, np.abs(c), np.angle(c), np.abs(c)**2) (fig, reax, imax) = plotting.setup_figure_topbottom(title=ur'Wavefunction for incidence angle $\theta=%f$ rad' % angle, xlabel=u'Distance accross waveguide (m)', ylabel=u'Wavefunction (arbitrary units)') #plotting.plot_intensity(reax, wf, waveguide.slab_gap) #phasef = lambda x: np.angle(wf(x)) plotting.plot_wavefunction(reax, imax, wf, waveguide.slab_gap) plotting.save_figure(fig, unicode(out_file))