Giter Club home page Giter Club logo

qutip-tutorials's Introduction

QuTiP: Quantum Toolbox in Python

A. Pitchford, C. Granade, A. Grimsmo, N. Shammah, S. Ahmed, N. Lambert, E. Giguère, B. Li, J. Lishman, S. Cross, A. Galicia, P. Menczel, P. Hopf, P. D. Nation, and J. R. Johansson

Build Status Coverage Status Maintainability license PyPi Downloads Conda-Forge Downloads

QuTiP is open-source software for simulating the dynamics of closed and open quantum systems. It uses the excellent Numpy, Scipy, and Cython packages as numerical backends, and graphical output is provided by Matplotlib. QuTiP aims to provide user-friendly and efficient numerical simulations of a wide variety of quantum mechanical problems, including those with Hamiltonians and/or collapse operators with arbitrary time-dependence, commonly found in a wide range of physics applications. QuTiP is freely available for use and/or modification, and it can be used on all Unix-based platforms and on Windows. Being free of any licensing fees, QuTiP is ideal for exploring quantum mechanics in research as well as in the classroom.

Support

Unitary Fund Powered by NumFOCUS

We are proud to be affiliated with Unitary Fund and numFOCUS.

We are grateful for Nori's lab at RIKEN and Blais' lab at the Institut Quantique for providing developer positions to work on QuTiP.

We also thank Google for supporting us by financing GSoC students to work on the QuTiP as well as other supporting organizations that have been supporting QuTiP over the years.

Installation

Pip Package Conda-Forge Package

QuTiP is available on both pip and conda (the latter in the conda-forge channel). You can install QuTiP from pip by doing

pip install qutip

to get the minimal installation. You can instead use the target qutip[full] to install QuTiP with all its optional dependencies. For more details, including instructions on how to build from source, see the detailed installation guide in the documentation.

All back releases are also available for download in the releases section of this repository, where you can also find per-version changelogs. For the most complete set of release notes and changelogs for historic versions, see the changelog section in the documentation.

The pre-release of QuTiP 5.0 is available on PyPI and can be installed using pip:

pip install --pre qutip

This version breaks compatibility with QuTiP 4.7 in many small ways. Please see the changelog for a list of changes, new features and deprecations. This version should be fully working. If you find any bugs, confusing documentation or missing features, please create a GitHub issue.

Documentation

Documentation Status - Latest

The documentation for the latest stable release and the master branch is available for reading on Read The Docs.

The documentation for official releases, in HTML and PDF formats, can be found in the documentation section of the QuTiP website.

The latest development documentation is available in this repository in the doc folder.

A selection of demonstration notebooks is available, which demonstrate some of the many features of QuTiP. These are stored in the qutip/qutip-tutorials repository here on GitHub.

Contribute

You are most welcome to contribute to QuTiP development by forking this repository and sending pull requests, or filing bug reports at the issues page. You can also help out with users' questions, or discuss proposed changes in the QuTiP discussion group. All code contributions are acknowledged in the contributors section in the documentation.

For more information, including technical advice, please see the "contributing to QuTiP development" section of the documentation.

Citing QuTiP

If you use QuTiP in your research, please cite the original QuTiP papers that are available here.

qutip-tutorials's People

Contributors

arturdomingues avatar christian512 avatar ericgig avatar hodgestar avatar marcogobbo avatar nwlambert avatar obliviateandsurrender avatar pmenczel avatar rochisha0 avatar tamakoshi2001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qutip-tutorials's Issues

Update dependencies

The current dependencies in the test_environment.yml are rather old. Update them to more recent versions.
Furthermore, we need a environment.yml which includes the current releases of qutip and qutip-qip for a user installation.

Add a notebook that shows how to adjust the max_step when using solvers with time-dependent Hamiltonians.

When using time-dependent Hamiltonians where the Hamiltonian is constant for large periods of time, it is possible for the adaption solvers to take very large time-steps that completely step over the small time-dependent part. Periodically our users are very confused by this, so it would be nice to have a notebook that shows the problem and how to fix it.

Related issues:

Qutip.qip error

I am new to QuTip and I am blown away by your amazing library and relevant examples. I am using QuTip 5.0 and I ran into problems with Lecture 2A, no module named 'qutip_qip' is found. Have phasegate changed location to a new module?

Upgrade lectures for QuTiP 5

Take the notebooks from /tutorials-v4/lectures/ and modify them to work with QuTiP 5 (i.e. the version of QuTiP in the branch dev.major).

Refactored the tutorial notebook "Reproduce: Stabalizing Feedback Controls for quantum systems" for qutip version 4.6.2

I am new to qutip and want to contribute to the project. I have opened this issue to discuss the refactoring of the notebook titled "Reproduce: Stabalizing Feedback Controls for quantum systems" written by Robert Johansson to work with qutip version 4.6.2. The same issue is raised here in the google group as well. I have made changes to the code cells of the notebook and it seems to me to be working well. Kindly review it and finally guide me on how to add this tutorial to this repository as do not want to violate any rules here unwittingly.

PS: Below is the .md version of the notebook.
Reproduce_ Stabilizing Feedback Controls for quantum systems.md

Port "Steady-State: Time-dependent (periodic) quantum system" tutorial to QuTiP 5.

The Steady-State: Time-dependent (periodic) quantum system tutorial is currently only available for QuTiP 4. It needs to be ported to QuTiP 5.

Steps:

  • Copy the Markdown notebook into the appropriate folder under tutorials-v5.
  • Update the notebook to work with QuTiP 5.
  • Make any small improvements needed to the notebook.
  • Add some assertions to the end of the notebook to ensure it ran correctly (e.g. check some results).
  • Check that the notebook is included in the website build scripts.

Port Stochastic Solver notebooks to v5

The stochastic solver was not updated for QuTiP 5 yet. Port the tutorials addressing this solver ( available in tutorials-v4) to QuTiP 5, once the solver was updated.

Generate index notebook

We currently generate an index HTML page, but it would be great to also generate an index notebook. This would allow us to provide an nbviewer, Binder or try-qutip link to the index notebook, which would be a nice way for users to explore the full set of tutorials.

Run flake8 on notebook code

I had another idea -- we can add a CI check that converts the notebooks to Python scripts (using Jupytext) and then runs flake8 on those scripts.

qutip-jax and MESolve incompatibility

I was porting the 020_homodyned-Jaynes-Cummings-emission.md file to the tutorial-v5 and run into a CI build problem with a file I didn't even changed which was the JAX-backend.md file, the CI build error was

=================================== FAILURES ===================================
_ /home/runner/work/qutip-tutorials/qutip-tutorials/notebooks/miscellaneous/JAX_backend.ipynb _
---------------------------------------------------------------------------
@jax.jit
def fp(t, w):
    return jax.numpy.exp(1j * t * w)
@jax.jit
def fm(t, w):
    return jax.numpy.exp(-1j * t * w)
@jax.jit
def cte(t, A):
    return A
with qutip.CoreOptions(default_dtype="jax"):
    H = qutip.num(10)
    c_ops = [qutip.QobjEvo([qutip.destroy(10), fm], args={"w": 1.0})]
H.isherm  # Precomputing the `isherm` flag
solver = qutip.MESolver(
    H, c_ops, options={"method": "diffrax", "normalize_output": False}
)
def final_expect(solver, rho0, t, w):
    result = solver.run(rho0, [0, t], args={"w": w}, e_ops=H)
    return result.e_data[0][-1].real
dfinal_expect_dt = jax.jit(
    jax.grad(final_expect, argnums=[2]), static_argnames=["solver"]
)
dfinal_expect_dt(solver, qutip.basis(10, 8, dtype="jax"), 0.1, 1.0)
---------------------------------------------------------------------------
TracerArrayConversionError                Traceback (most recent call last)
Cell In[6], line 35
     29     return result.e_data[0][-1].real
     32 dfinal_expect_dt = jax.jit(
     33     jax.grad(final_expect, argnums=[2]), static_argnames=["solver"]
     34 )
---> 35 dfinal_expect_dt(solver,qutip.basis(10,8,dtype="jax"),0.1,1.0)
    [... skipping hidden 21 frame]
Cell In[6], line 28, in final_expect(solver, rho0, t, w)
     27 def final_expect(solver, rho0, t, w):
---> 28     result = solver.run(rho0,[0,t],args={"w":w},e_ops=H)
     29     return result.e_data[0][-1].real
File /usr/share/miniconda3/envs/test-environment/lib/python3.10/site-packages/qutip/solver/solver_base.py:176, in Solver.run(self, state0, tlist, e_ops, args)
    142 """
    143 Do the evolution of the Quantum system.
    144 
   (...)
    173     can control the saved data in the options.
    174 """
    175 _time_start = time()
--> 176 _data0 = self._prepare_state(state0)
    177 self._integrator.set_state(tlist[0], _data0)
    178 self._argument(args)
File /usr/share/miniconda3/envs/test-environment/lib/python3.10/site-packages/qutip/solver/solver_base.py:107, in Solver._prepare_state(self, state)
    [104](https://github.com/ArturDomingues/qutip-tutorials/actions/runs/9343341432/job/25712773213#step:13:105)     norm = state.norm()
    [105](https://github.com/ArturDomingues/qutip-tutorials/actions/runs/9343341432/job/25712773213#step:13:106) # Use the settings atol instead of the solver one since the second
    [106](https://github.com/ArturDomingues/qutip-tutorials/actions/runs/9343341432/job/25712773213#step:13:107) # refer to the ODE tolerance and some integrator do not use it.
--> [107](https://github.com/ArturDomingues/qutip-tutorials/actions/runs/9343341432/job/25712773213#step:13:108) self._normalized = np.abs(norm-1) <= settings.core["atol"]
    [108](https://github.com/ArturDomingues/qutip-tutorials/actions/runs/9343341432/job/25712773213#step:13:109) if self.rhs.dims[1] == state.dims:
    [109](https://github.com/ArturDomingues/qutip-tutorials/actions/runs/9343341432/job/25712773213#step:13:110)     return stack_columns(state.data)
File /usr/share/miniconda3/envs/test-environment/lib/python3.10/site-packages/jax/_src/core.py:650, in Tracer.__array__(self, *args, **kw)
    649 def __array__(self, *args, **kw):
--> 650   raise TracerArrayConversionError(self)
TracerArrayConversionError: The numpy.ndarray conversion method __array__() was called on traced array with shape float64[].
The error occurred while tracing the function final_expect at /tmp/ipykernel_7480/401557022.py:27 for jit. This value became a tracer due to JAX operations on these lines:
  operation a:f64[] = convert_element_type[new_dtype=float64 weak_type=False] b
    from line /tmp/ipykernel_7480/401557022.py:28 (final_expect)
See https://jax.readthedocs.io/en/latest/errors.html#jax.errors.TracerArrayConversionError
=========================== short test summary info ============================
FAILED miscellaneous/JAX_backend.ipynb:: - See https://jax.readthedocs.io/en/...
================== 1 failed, 74 passed in 2407.87s (0:40:07) ===================
Error: Process completed with exit code 1.

After converting the file to a notebook and running locally I realized that it wasn't possible to execute the line

final_expect(solver,qutip.basis(10, 8, dtype="jax"),0.1,1.0)

it raised the following error

---------------------------------------------------------------------------
TracerArrayConversionError                Traceback (most recent call last)
Cell In[22], [line 37](vscode-notebook-cell:?execution_count=22&line=37)
     [35](vscode-notebook-cell:?execution_count=22&line=35) get_ipython().run_line_magic('timeit', 'final_expect(solver,qutip.basis(10, 8, dtype="jax"),0.1,1.0)')
     [36](vscode-notebook-cell:?execution_count=22&line=36) get_ipython().run_line_magic('timeit', 'jax.grad(final_expect, argnums=[2])(solver, qutip.basis(10, 8, dtype="jax"), 0.1, 1.0)')
---> [37](vscode-notebook-cell:?execution_count=22&line=37) dfinal_expect_dt(solver, qutip.basis(10, 8, dtype="jax"), 0.1, 1.0)
     [38](vscode-notebook-cell:?execution_count=22&line=38) get_ipython().run_line_magic('timeit', 'dfinal_expect_dt(solver, qutip.basis(10, 8, dtype="jax"), 0.1, 1.0)')

    [... skipping hidden 21 frame]

Cell In[22], [line 27](vscode-notebook-cell:?execution_count=22&line=27)
     [26](vscode-notebook-cell:?execution_count=22&line=26) def final_expect(solver, rho0, t, w):
---> [27](vscode-notebook-cell:?execution_count=22&line=27)     result = solver.run(rho0, [0, t], args={"w": w}, e_ops=H)
     [28](vscode-notebook-cell:?execution_count=22&line=28)     return result.e_data[0][-1].real

File c:\Users\artur\anaconda3\envs\qutip-tutorials\lib\site-packages\qutip\solver\solver_base.py:163, in Solver.run(self, state0, tlist, args, e_ops)
    [129](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:129) """
    [130](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:130) Do the evolution of the Quantum system.
    [131](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:131) 
   (...)
    [160](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:160)     can control the saved data in the options.
    [161](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:161) """
    [162](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:162) _time_start = time()
--> [163](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:163) _data0 = self._prepare_state(state0)
    [164](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:164) self._integrator.set_state(tlist[0], _data0)
    [165](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:165) self._argument(args)

File c:\Users\artur\anaconda3\envs\qutip-tutorials\lib\site-packages\qutip\solver\solver_base.py:101, in Solver._prepare_state(self, state)
     [98](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:98)     norm = state.norm()
     [99](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:99) # Use the settings atol instead of the solver one since the second
    [100](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:100) # refer to the ODE tolerance and some integrator do not use it.
--> [101](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:101) self._normalized = np.abs(norm - 1) <= settings.core["atol"]
    [102](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:102) if self.rhs.dims[1] == state.dims:
    [103](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/qutip/solver/solver_base.py:103)     return stack_columns(state.data)

File c:\Users\artur\anaconda3\envs\qutip-tutorials\lib\site-packages\jax\_src\core.py:650, in Tracer.__array__(self, *args, **kw)
    [649](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/jax/_src/core.py:649) def __array__(self, *args, **kw):
--> [650](file:///C:/Users/artur/anaconda3/envs/qutip-tutorials/lib/site-packages/jax/_src/core.py:650)   raise TracerArrayConversionError(self)

TracerArrayConversionError: The numpy.ndarray conversion method __array__() was called on traced array with shape float64[].
The error occurred while tracing the function final_expect at C:\Users\artur\AppData\Local\Temp\ipykernel_4980\3189065131.py:26 for jit. This value became a tracer due to JAX operations on these lines:

  operation a:f64[] = convert_element_type[new_dtype=float64 weak_type=False] b
    from line C:\Users\artur\AppData\Local\Temp\ipykernel_4980\3189065131.py:27 (final_expect)
See https://jax.readthedocs.io/en/latest/errors.html#jax.errors.TracerArrayConversionError

i couldn't find a fix other than running the line as

jax.grad(final_expect, argnums=[2])(solver, qutip.basis(10, 8, dtype="jax"), 0.1, 1.0)

since this modification made everything work fine, I made the pull request with this file altered as well, in the following way

# When qutip-jax is fixed, uncomment the line bellow and deleted the line after it
# dfinal_expect_dt(solver, qutip.basis(10, 8, dtype="jax"), 0.1, 1.0)
jax.grad(final_expect, argnums=[2])(solver, qutip.basis(10, 8, dtype="jax"), 0.1, 1.0)

Even though this fixes the problem, it is just a work around since the previous version was working correctly before, there should be an alert to qutip-jax to fix this problem

Windows does not have imagemagick on conda

Following the installation guide, one will get on Windows

ResolvePackageNotFound:
  - imagemagick==7.1.0_36

On windows, one needs to install it from a binary an excutable file. This is fine. But the whole workflow of creating a conda environment is interrupted because of this. Is there a way to make it optional?

Make the tutorial index more beautiful

It would be awesome to make the tutorial index more pretty and user friendly so that we can link to it directly from the qutip.org website. Some ideas for things to include:

  • Links to Nbviewer (for viewing the notebook as-is with output)
  • A links to MyBinder (with an environment.yml file, for trying the notebooks out)
  • Some headings (maybe this can be derived from folder names initially, or something?)
  • Some CSS styling that matches the qutip.org site somewhat.

Update docs on formatting notebooks

The instructions of nbQA show that it is also possible to format notebooks in the .md format (by JupyText). We should include these instructions in the Readme of this repository.

Port "Steady-State: Homodyned Jaynes-Cummings emission" tutorial to QuTiP 5.

The Homodyned Jaynes-Cummings emission tutorial is currently only available for QuTiP 4. It needs to be ported to QuTiP 5.

Steps:

  • Copy the Markdown notebook into the appropriate folder under tutorials-v5.
  • Update the notebook to work with QuTiP 5.
  • Make any small improvements needed to the notebook.
  • Add some assertions to the end of the notebook to ensure it ran correctly (e.g. check some results).
  • Check that the notebook is included in the website build scripts.

Port "Steady-State: Optomechanical System in the Single-Photon Strong-Coupling Regime" tutorial to QuTiP 5.

The Steady-State: Optomechanical System tutorial is currently only available for QuTiP 4. It needs to be ported to QuTiP 5.

Steps:

  • Copy the Markdown notebook into the appropriate folder under tutorials-v5.
  • Update the notebook to work with QuTiP 5.
  • Make any small improvements needed to the notebook.
  • Add some assertions to the end of the notebook to ensure it ran correctly (e.g. check some results).
  • Check that the notebook is included in the website build scripts.

Add test for empty code cells in notebooks

After the execution with Jupyter Notebooks the notebooks can contain an empty code cell at the end. It would be good to have a test whether such an empty code cell exists. We don't need these empty cells.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.