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

Update settings on change of backend #66

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/qutip_jax/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import jax.numpy as jnp
import numpy as np
from qutip import settings
from qutip import SESolver, MCSolver, MESolver

__all__ = ["use_jax_backend"]
__all__ = ["set_as_default"]

def use_jax_backend():
settings.core['numpy_backend'] = jnp
def set_as_default(*, revert=False):
if revert:
settings.core['numpy_backend'] = np
settings.core['default_dtype'] = None
SESolver.solver_options['method'] = 'adams'
MESolver.solver_options['method'] = 'adams'
MCSolver.solver_options['method'] = 'adams'
else:
settings.core['numpy_backend'] = jnp
settings.core['default_dtype'] = 'jax'
SESolver.solver_options['method'] = 'diffrax'
MESolver.solver_options['method'] = 'diffrax'
MCSolver.solver_options['method'] = 'diffrax'
Loading