@@ -34,10 +34,11 @@ In this notebook we will consider several examples illustrating the usage of the
3434``` python
3535import matplotlib.pyplot as plt
3636import numpy as np
37- from qutip import (SESolver, about, basis, brmesolve, fidelity, mesolve, qeye,
38- sigmam, sigmax, sigmaz, spost, spre, sprepost)
37+ from qutip import (QobjEvo, SESolver, UnderDampedEnvironment,
38+ about, basis, brmesolve, fidelity, mesolve,
39+ qeye, sigmam, sigmax, sigmaz, spost, spre, sprepost)
3940
40- # from qutip.solver.heom import HEOMSolver, BosonicBath
41+ from qutip.solver.heom import HEOMSolver
4142
4243% matplotlib inline
4344```
@@ -442,26 +443,32 @@ driv_br_res = brmesolve(H, psi0, tlist, a_ops, sec_cutoff=-1, e_ops=e_ops)
442443### With ` HEOMSolver `
443444
444445``` python
446+ max_depth = 4 # number of hierarchy levels
447+
445448wsamp = 2 * np.pi
446449w0 = 5 * 2 * np.pi
447-
448450gamma_heom = 1.9 * w0
449451
450-
451452lambd = np.sqrt(
452- 0.5
453- * gamma
453+ 0.5 * gamma / (gamma_heom * wsamp)
454454 * ((w0** 2 - wsamp** 2 ) ** 2 + (gamma_heom** 2 ) * ((wsamp) ** 2 ))
455- / (gamma_heom * wsamp)
456455)
457456```
458457
459458``` python
460- # TODO UnderDampedEnvironment is in a big separate on Overleaf, how to handle?
461-
462459# Create Environment
463- # bath = UnderDampedEnvironment(lam=lambd, w0=w0, gamma=gamma_heom, T=1e-30 )
460+ bath = UnderDampedEnvironment(lam = lambd, w0 = w0, gamma = gamma_heom, T = 1e-10 )
464461fit_times = np.linspace(0 , 5 , 1000 ) # range for correlation function fit
462+
463+ # Fit correlation function with exponentials
464+ exp_bath, fit_info = bath.approx_by_cf_fit(fit_times, Ni_max = 1 , Nr_max = 2 , target_rsme = None )
465+ print (fit_info[" summary" ])
466+ ```
467+
468+ ``` python
469+ HEOM_corr_fit = HEOMSolver(QobjEvo(H), (exp_bath, sigmax()), max_depth = max_depth,
470+ options = {' nsteps' : 15000 , ' rtol' : 1e-12 , ' atol' : 1e-12 })
471+ results_corr_fit = HEOM_corr_fit .run(psi0 * psi0.dag(), tlist, e_ops = e_ops)
465472```
466473
467474### Comparison of Solver Results
@@ -471,7 +478,7 @@ plt.figure()
471478
472479plt.plot(tlist, driv_res.expect[0 ], " -" , label = " mesolve (time-dep)" )
473480plt.plot(tlist, driv_RWA_res.expect[0 ], " -." , label = " mesolve (rwa)" )
474- # plt.plot(tlist, results_corr_fit.expect[0], '--', label=r'heomsolve')
481+ plt.plot(tlist, np.real( results_corr_fit.expect[0 ]) , ' --' , label = r ' heomsolve' )
475482plt.plot(tlist, driv_br_res.expect[0 ], " :" , linewidth = 3 , label = " brmesolve" )
476483
477484plt.xlabel(r " $ t\, /\, \D elta^ {-1}$ " )
@@ -494,61 +501,50 @@ If the drive is slow enough, we expect the bath to respond to this change and tr
494501omega_d = 0.05 * Delta # drive frequency
495502A = Delta # drive amplitude
496503H_adi = [[A / 2.0 * sigmaz(), f]]
497- # H = [H0]
498504
499505# Bath parameters
500506gamma = 0.05 * Delta / (2 * np.pi)
501507
502508# Simulation parameters
509+ T = 2 * np.pi / omega_d # period length
503510tlist = np.linspace(0 , 2 * T, 400 )
504511```
505512
506513``` python
507514# Simple mesolve
515+ c_ops_me = [np.sqrt(gamma) * sigmam()]
508516adi_me_res = mesolve(H_adi, psi0, tlist, c_ops = c_ops_me, e_ops = e_ops)
509517```
510518
511519``` python
512- # bath = UnderDampedEnvironment(lam=lambd, w0=w0, gamma=gamma_heom, T=1e-30)
513- # fit_times = np.linspace(0, 5, 1000) # range for correlation function fit
514-
515- # cfit, fit_info = bath.approx_by_cf_fit(fit_times,
516- # Ni_max=1, Nr_max=2, target_rsme=None)
517- # print(fit_info["summary"])
518- # Convert to a HEOM bath
519- # heombath = cfit.to_bath(sigmax())
520-
521-
522- # HEOM_corr_fit = HEOMSolver(
523- # qt.QobjEvo(H),
524- # heombath,
525- # max_depth=max_depth,
526- # options={"nsteps": 15000, "rtol": 1e-12, "atol": 1e-12},
527- # )
528- # results_corr_fit = HEOM_corr_fit.run(psi0 * psi0.dag(), tlist, e_ops=e_ops)
520+ # HEOM
521+ HEOM_corr_fit = HEOMSolver(QobjEvo(H_adi), (exp_bath, sigmax()), max_depth = max_depth,
522+ options = {" nsteps" : 15000 , " rtol" : 1e-12 , " atol" : 1e-12 })
523+ results_corr_fit = HEOM_corr_fit .run(psi0 * psi0.dag(), tlist, e_ops = e_ops)
529524```
530525
531526``` python
532527# BRSolve
533- brme_result2 = brmesolve(H , psi0, tlist, a_ops = a_ops, e_ops = e_ops)
528+ brme_result2 = brmesolve(H_adi , psi0, tlist, a_ops = a_ops, e_ops = e_ops)
534529```
535530
536531``` python
537532# BRSolve non-flat power spectrum
538- # a_ops_non_flat = [[sigmax(), lambda w: cfit .power_spectrum(w).item( )]]
539- # brme_result = brmesolve(H , psi0, tlist, a_ops=a_ops_non_flat, e_ops=e_ops)
533+ a_ops_non_flat = [[sigmax(), lambda w : exp_bath .power_spectrum(w)]]
534+ brme_result = brmesolve(H_adi , psi0, tlist, a_ops = a_ops_non_flat, e_ops = e_ops)
540535```
541536
542537``` python
543538plt.plot(tlist, adi_me_res.expect[0 ], " -" , label = " mesolve" )
544- # plt.plot(tlist, results_corr_fit.expect[0], '--', label=r'heomsolve')
545- # plt.plot(tlist, brme_result.expect[0], ":", linewidth=6,
546- # label="brmesolve non-flat")
539+ plt.plot(tlist, np.real( results_corr_fit.expect[0 ]) , ' --' , label = r ' heomsolve' )
540+ plt.plot(tlist, brme_result.expect[0 ], " :" , linewidth = 6 ,
541+ label = " brmesolve non-flat" )
547542plt.plot(tlist, brme_result2.expect[0 ], " :" , linewidth = 6 , label = " brmesolve" )
548543
549544plt.xlabel(r " $ t\, /\, \D elta^ {-1}$ " , fontsize = 18 )
550545plt.ylabel(r " $ \l angle \s igma_z \r angle$ " , fontsize = 18 )
551546plt.legend()
547+ plt.show()
552548```
553549
554550## References
0 commit comments