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

Only normalize if initial state is normalized. #2427

Merged
merged 3 commits into from
May 16, 2024

Conversation

Ericgig
Copy link
Member

@Ericgig Ericgig commented May 16, 2024

Description
We had a few issues (#2415, #2426) where an initial state that has not a trace of 1 was used and the new normalization of density matrices resulted in wrong results.

This change the normalization to happen only when the initial state is already normalized, expecting that when a non-normalized initial density matrix in used in mesolve, etc., it is a conscious choice and the solver should not fight it.

Related issues or PRs
fix #2426

@coveralls
Copy link

coveralls commented May 16, 2024

Coverage Status

coverage: 86.266% (+0.006%) from 86.26%
when pulling 528200b on Ericgig:misc.solver.state0_norm
into ad05a22 on qutip:master.

@BoxiLi
Copy link
Member

BoxiLi commented May 16, 2024

I actually have a question about this automatic normalization.

Do we really need this to hide the numerical errors? Wouldn't it be better to just expose the error since it will be proportional to atol anyway (and if not, something went wrong)? Which group of users will this auto-normalization benefit?

Sometimes an unnormalised state at the ends can also indicate that there is something wrong with the Hamiltonian, e.g., it is not hermitian due to some typos.

@Ericgig
Copy link
Member Author

Ericgig commented May 16, 2024

We mostly added it to mesolve since we always had it for sesolve.
Numerical error is not well understood by all users and we can get issues that the solver are wrong because the trace, norm, populations etc. is not constant.

@Ericgig Ericgig merged commit 664f7dd into qutip:master May 16, 2024
11 checks passed
@Ericgig Ericgig deleted the misc.solver.state0_norm branch May 16, 2024 18:19
Ericgig added a commit to Ericgig/qutip that referenced this pull request May 16, 2024
Only normalize if initial state is normalized.
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.

mesolve produces unphysical result in qutip v5.0.1 (and not in v4.6)
4 participants