Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuTiPv5 Paper Notebook: new Solver class and various applications of mesolve, brsolve and heom #111

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Langhaarzombie
Copy link
Contributor

@Langhaarzombie Langhaarzombie commented Nov 13, 2024

This notebook includes the examples in the qutip v5 paper that are found in section 3.2 up until (and including) 3.3.4.
The PR remains as a draft for now as much of the code needed to generate the last few plots that are connected to the HEOM environment. See PR #2534 in the main qutip repo.

Therefore the things left to do are:

  • Complete examples of section 3.2.4 once PR #2534 is completed
  • Testing methods according to examples
  • Add authors
  • Include references and format like this

- added simple sesolver
- added mesolver for local dissipation
- added mesolver for global version
- added comparison to brsolver
- everything supported by text from the paper
- collapse list is now created by a function and for specific
  hamiltonians
- fixed variable names to fit 80 char width
- fixed typos
@Langhaarzombie Langhaarzombie changed the title Adds notebook for new Solver class and various applications of mesolve, brsolve and heom QuTiPv5 Paper Notebook: new Solver class and various applications of mesolve, brsolve and heom Nov 14, 2024
Copy link
Member

@nwlambert nwlambert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Langhaarzombie this looks great. Left a few comments and suggestions.

tutorials-v5/time-evolution/023_v5_paper-mesolve.md Outdated Show resolved Hide resolved
tutorials-v5/time-evolution/023_v5_paper-mesolve.md Outdated Show resolved Hide resolved
tutorials-v5/time-evolution/023_v5_paper-mesolve.md Outdated Show resolved Hide resolved
tutorials-v5/time-evolution/023_v5_paper-mesolve.md Outdated Show resolved Hide resolved
tutorials-v5/time-evolution/023_v5_paper-mesolve.md Outdated Show resolved Hide resolved
tutorials-v5/time-evolution/023_v5_paper-mesolve.md Outdated Show resolved Hide resolved
tutorials-v5/time-evolution/023_v5_paper-mesolve.md Outdated Show resolved Hide resolved
tutorials-v5/time-evolution/023_v5_paper-mesolve.md Outdated Show resolved Hide resolved
## Testing

```python
# test sesolve gives the same result as SESolver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess checking long-time limit of global ME is close to ground state, and that global and brmesolve produce similar results in that example, is enough?

Comment on lines +102 to +111
```python
t = 0
dt = 40 / 100
se_solver2 = SESolver(H)
se_solver2.start(psi0, t)
while t < 40:
t = t + dt
psi = se_solver2.step(t)
# process the result psi and calculate next time step
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example is a bit meh to be honest (it is from me 🙂), and it doesn't really show the args stuff that the text above it discusses... Not sure what to do about it

tutorials-v5/time-evolution/023_v5_paper-mesolve.md Outdated Show resolved Hide resolved
Comment on lines +349 to +356
```python
plt.plot(tlist_fine, me_local_res.expect[0], label="i=1")
plt.plot(tlist_fine, me_local_res.expect[1], label="i=2")
plt.xlabel("Time")
plt.ylabel(r"$\langle \sigma_z^{(i)} \rangle$")
plt.legend()
plt.show()
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this plot something with manual_res?

Comment on lines 537 to 548
```python
plt.plot(tlist, adi_me_res.expect[0], "-", label="mesolve")
plt.plot(tlist, np.real(results_corr_fit.expect[0]), '--', label=r'heomsolve')
plt.plot(tlist, brme_result.expect[0], ":", linewidth=6,
label="brmesolve non-flat")
plt.plot(tlist, brme_result2.expect[0], ":", linewidth=6, label="brmesolve")

plt.xlabel(r"$t\, /\, \Delta^{-1}$", fontsize=18)
plt.ylabel(r"$\langle \sigma_z \rangle$", fontsize=18)
plt.legend()
plt.show()
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is maybe not obvious how to do that, I have added the HEOM part using the new environment module. However, I am confused that the plot looks a bit different from the one in the paper... I must have missed some parameter, but couldn't immediately find what I am missing

```

```python
# HEOM
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the parameter gamma is slightly changed we need to refit the heom bath here, i.e., have again:

max_depth = 4  # number of hierarchy levels

wsamp = 2 * np.pi
w0 = 5 * 2 * np.pi
gamma_heom = 1.9 * w0

lambd = np.sqrt(
    0.5 * gamma / (gamma_heom * wsamp)
    * ((w0**2 - wsamp**2) ** 2 + (gamma_heom**2) * ((wsamp) ** 2))
)
# Create Environment
bath = UnderDampedEnvironment(lam=lambd, w0=w0, gamma=gamma_heom, T=1e-10)
fit_times = np.linspace(0, 5, 1000)  # range for correlation function fit

# Fit correlation function with exponentials
exp_bath, fit_info = bath.approx_by_cf_fit(fit_times, Ni_max=1, Nr_max=2, target_rsme=None)
print(fit_info["summary"])

- adjusted formatting acc. to repo specs
- added Paul as author
- streamlined equation formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants