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

Out-of-place functions in semiclassical solvers #405

Open
apkille opened this issue Jul 31, 2024 · 2 comments
Open

Out-of-place functions in semiclassical solvers #405

apkille opened this issue Jul 31, 2024 · 2 comments

Comments

@apkille
Copy link
Contributor

apkille commented Jul 31, 2024

According to the docs (https://docs.qojulia.org/semiclassical/), to run a semiclassical solver, say semiclassical.schroedinger_dynamic, one has to define the following functions:

function fquantum_schroedinger(t, ψ, u)
  # update H (Hamiltonian) according to dependencies on
  # classical variables u and quantum state ψ
  return H
end
function fclassical!(du, u, ψ, t)
  # update du (vector of derivatives of classical variables)
  # according to dependencies on classical variables
  # u and quantum state ψ
  # -- no return statement!
end

So we have to define an out-of-place function for the hamiltonian, and an in-place function for classical data. Is there any particular reason why fquantum_schroedinger has to be out-of-place? It is clunky that both functions cannot be in-place and less memory efficient.

@apkille
Copy link
Contributor Author

apkille commented Jul 31, 2024

Somewhat related to #404.

@david-pl
Copy link
Member

david-pl commented Aug 7, 2024

@apkille You're right. There's no reason in particular, why this is the case. Probably just because there were no nice ways to update operators in-place at the time, other than working with the .data fields directly, which can be a bit of a footgun.

To get the best performance, everything that can be in-place, should be in-place of course.

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

No branches or pull requests

2 participants