Skip to content

Commit

Permalink
Merge pull request #134 from albertomercurio/dev/documentation
Browse files Browse the repository at this point in the history
Change document folder structure and make Introduction
  • Loading branch information
ytdHuang authored May 27, 2024
2 parents adc1204 + f2b9590 commit 1d5df9c
Show file tree
Hide file tree
Showing 28 changed files with 414 additions and 561 deletions.
5 changes: 4 additions & 1 deletion .JuliaFormatter.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ always_use_return=true
format_docstrings=true
indent_submodule=true
format_markdown=true
ignore = ["README.md"]
ignore = [
"README.md",
"CODE_OF_CONDUCT.md"
]
25 changes: 25 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Contributor Covenant Code of Conduct

As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.

We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
* Other unethical or unprofessional conduct

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.

This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.

This Code of Conduct is adapted from the Contributor Covenant , version 1.2.0, available at https://www.contributor-covenant.org/version/1/2/0/code-of-conduct.html

[homepage]: https://contributor-covenant.org
[version]: https://contributor-covenant.org/version/1/2/
42 changes: 25 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
MIT License
BSD 3-Clause License

Copyright (c) 2022 Alberto Mercurio
Copyright (c) 2022 to 2024 inclusive, QuTiP developers and contributors.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name = "QuantumToolbox"
uuid = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab"
authors = ["Alberto Mercurio"]
version = "0.8.2"
authors = ["Alberto Mercurio", "Luca Gravina", "Yi-Te Huang"]
version = "0.8.4"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
Expand All @@ -25,6 +26,7 @@ CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
QuantumToolboxCUDAExt = "CUDA"

[compat]
ArrayInterface = "6, 7"
CUDA = "5"
DiffEqCallbacks = "2, 3"
FFTW = "1.5"
Expand Down
118 changes: 105 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,126 @@
<!-- Logo -->
<div align="center">
<img src="./docs/src/assets/logo.png" alt="QuantumToolbox.jl logo" width="150">
</div>

# QuantumToolbox.jl

[![Release](https://img.shields.io/github/release/albertomercurio/QuantumToolbox.jl.svg)](https://github.com/albertomercurio/QuantumToolbox.jl/releases)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11096277.svg)](https://doi.org/10.5281/zenodo.11096277)
[![Downloads](https://img.shields.io/badge/dynamic/json?url=http%3A%2F%2Fjuliapkgstats.com%2Fapi%2Fv1%2Fmonthly_downloads%2FQuantumToolbox&query=total_requests&suffix=%2Fmonth&label=Downloads)](https://juliapkgstats.com/pkg/QuantumToolbox)
[![Build Status](https://github.com/albertomercurio/QuantumToolbox.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/albertomercurio/QuantumToolbox.jl/actions/workflows/CI.yml?query=branch%3Amain)
<!-- Current admin team (in chronological order) -->
[A. Mercurio](https://github.com/albertomercurio),
[L. Gravina](https://github.com/lgravina1997),
and [Y.-T. Huang](https://github.com/ytdHuang).

<!-- Badges -->
[![Release](https://img.shields.io/github/release/qutip/QuantumToolbox.jl.svg)](https://github.com/qutip/QuantumToolbox.jl/releases)
[![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10822816.svg)](https://doi.org/10.5281/zenodo.10822816)
[![Downloads](https://img.shields.io/badge/dynamic/json?url=http%3A%2F%2Fjuliapkgstats.com%2Fapi%2Fv1%2Ftotal_downloads%2FQuantumToolbox&query=total_requests&label=Downloads)](https://juliapkgstats.com/pkg/QuantumToolbox)
[![Build Status](https://github.com/qutip/QuantumToolbox.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/qutip/QuantumToolbox.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
[![Coverage](https://codecov.io/gh/albertomercurio/QuantumToolbox.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/albertomercurio/QuantumToolbox.jl)
[![Doc-Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://albertomercurio.github.io/QuantumToolbox.jl/stable)
[![Doc-Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://albertomercurio.github.io/QuantumToolbox.jl/dev)
[![Coverage](https://codecov.io/gh/qutip/QuantumToolbox.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/qutip/QuantumToolbox.jl)
[![Doc-Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://qutip.github.io/QuantumToolbox.jl/stable)
[![Doc-Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://qutip.github.io/QuantumToolbox.jl/dev)

## Introduction

[QuantumToolbox.jl](https://github.com/albertomercurio/QuantumToolbox.jl) is a cutting-edge Julia package designed for quantum physics simulations, closely emulating the popular Python [QuTiP](https://github.com/qutip/qutip) package. It uniquely combines the simplicity and power of Julia with advanced features like GPU acceleration and distributed computing, making simulation of quantum systems more accessible and efficient.
[QuantumToolbox.jl](https://github.com/qutip/QuantumToolbox.jl) is a cutting-edge Julia package designed for quantum physics simulations, closely emulating the popular Python [QuTiP](https://github.com/qutip/qutip) package. It uniquely combines the simplicity and power of Julia with advanced features like GPU acceleration and distributed computing, making simulation of quantum systems more accessible and efficient.

*With this package, moving from Python to Julia for quantum physics simulations has never been easier*, due to the similar syntax and functionalities.

## Features

QuantumToolbox.jl is equipped with a robust set of features:

- **Quantum State and Operator Manipulation:** Easily handle quantum states and operators with a rich set of tools.
- **Dynamical Evolution:** Advanced solvers for time evolution of quantum systems.
- **Measurement and Statistics:** Comprehensive quantum measurement simulation and analysis.
- **GPU and Distributed Computing:** Leverage GPU and distributed resources for high-performance computing.
- **Quantum State and Operator Manipulation:** Easily handle quantum states and operators with a rich set of tools, with the same functionalities as QuTiP.
- **Dynamical Evolution:** Advanced solvers for time evolution of quantum systems, thanks to the powerful [DifferentialEquations.jl](https://github.com/SciML/DifferentialEquations.jl) package.
- **GPU Computing:** Leverage GPU resources for high-performance computing. For example, you run the master equation direclty on the GPU with the same syntax as the CPU case.
- **Distributed Computing:** Distribute the computation over multiple nodes (e.g., a cluster). For example, you can run undreds of quantum trajectories in parallel on a cluster, with, again, the same syntax as the simple case.
- **Easy Extension:** Easily extend the package, taking advantage of the Julia language features, like multiple dispatch and metaprogramming.

## Installation
## Brief example

We now provide a brief example to demonstrate the similarity between [QuantumToolbox.jl](https://github.com/qutip/QuantumToolbox.jl) and [QuTiP](https://github.com/qutip/qutip).

Let's consider a quantum harmonic oscillator with a Hamiltonian given by:

$$
\hat{H} = \omega \hat{a}^\dagger \hat{a}
$$

where $\hat{a}$ and $\hat{a}^\dagger$ are the annihilation and creation operators, respectively. We can define the Hamiltonian as follows:

```julia
using QuantumToolbox

N = 20 # cutoff of the Hilbert space dimension
ω = 1.0 # frequency of the harmonic oscillator

a = destroy(N) # annohilation operator

H = ω * a' * a
```

We now introduce some losses in a thermal environment, described by the Lindblad master equation:

$$
\frac{d \hat{\rho}}{dt} = -i [\hat{H}, \hat{\rho}] + \gamma \mathcal{D}[\hat{a}] \hat{\rho}
$$

where $\hat{\rho}$ is the density matrix, $\gamma$ is the damping rate, and $\mathcal{D}[\hat{a}]$ is the Lindblad dissipator, defined as:

$$
\mathcal{D}[\hat{a}]\hat{\rho} = \hat{a}\hat{\rho}\hat{a}^\dagger - \frac{1}{2}\hat{a}^\dagger\hat{a}\hat{\rho} - \frac{1}{2}\hat{\rho}\hat{a}^\dagger\hat{a}
$$

We now compute the time evolution of the system using the [`mesolve`](@ref) function, starting from the initial state $\ket{\psi (0)} = \ket{3}$:

```julia
γ = 0.1 # damping rate

ψ0 = fock(N, 3) # initial state

tlist = range(0, 10, 100) # time list

c_ops = [sqrt(γ) * a]
e_ops = [a' * a]

sol = mesolve(H, ψ0, tlist, c_ops, e_ops=e_ops)
```

We can extract the expectation value of the number operator $\hat{a}^\dagger \hat{a}$ with the command `sol.expect`, and the states with the command `sol.states`.

### Passing in the GPU

We can easily pass the computation to the GPU, by simply passing all the `Qobj`s to the GPU:

```julia
using CUDA

a_gpu = cu(destroy(N)) # The only difference in the code is the cu() function

H_gpu = ω * a_gpu' * a_gpu

ψ0_gpu = cu(fock(N, 3))

c_ops = [sqrt(γ) * a_gpu]
e_ops = [a_gpu' * a_gpu]

sol = mesolve(H_gpi, ψ0_gpu, tlist, c_ops, e_ops=e_ops)
```

## Installation
`QuantumToolbox.jl` requires `Julia 1.7+`. To install it, run the following commands inside Julia's interactive session (also known as REPL):
```julia
using Pkg
Pkg.add("QuantumToolbox")
```
Alternatively, this can also be done in Julia's [Pkg REPL](https://julialang.github.io/Pkg.jl/v1/getting-started/) by pressing the key `]` in the REPL to use the package mode, and then type the following command:
```julia-REPL
(1.7) pkg> add QuantumToolbox
```
To load the package and check the version information, use either `versioninfo()` or `about()`, namely
```julia
using QuantumToolbox
QuantumToolbox.versioninfo()
QuantumToolbox.about()
```
59 changes: 30 additions & 29 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,43 @@ using Documenter

DocMeta.setdocmeta!(QuantumToolbox, :DocTestSetup, :(using QuantumToolbox); recursive = true)

const PAGES = Any[
"Front Matter" => Any[
const PAGES = [
"Front Matter" => [
"Introduction" => "index.md",
"Installation" => "install.md",
"Key differences from QuTiP" => "qutip_differences.md",
# "Cite QuantumToolbox.jl" => "cite.md",
],
"Users Guide" => Any[
"Basic Operations on Quantum Objects" => Any[
"Qobj.md",
"Qobj_functions.md",
"Users Guide" => [
"Basic Operations on Quantum Objects" => [
"users_guide/QuantumObject/QuantumObject.md",
"users_guide/QuantumObject/QuantumObject_functions.md",
],
"Manipulating States and Operators" => Any[
"state_vectors.md",
"density_matrices.md",
"qubit_systems.md",
"expectation_values.md",
"superoperators.md",
"Manipulating States and Operators" => [
"users_guide/states_and_operators/state_vectors.md",
"users_guide/states_and_operators/density_matrices.md",
"users_guide/states_and_operators/qubit_systems.md",
"users_guide/states_and_operators/expectation_values.md",
"users_guide/states_and_operators/superoperators.md",
],
"Tensor Products and Partial Traces" => Any[
"tensor.md",
"partial_trace.md",
"Tensor Products and Partial Traces" => [
"users_guide/tensor_product/tensor.md",
"users_guide/tensor_product/partial_trace.md",
],
"Time Evolution and Dynamics" => Any[
"time_evolution/intro.md"
"Time Evolution and Dynamics" => [
"users_guide/time_evolution/intro.md"
],
"Solving for Steady-State Solutions" => Any[],
"Two-time correlation functions" => Any[],
"Extensions" => Any[
"extensions/cuda.md",
"Solving for Steady-State Solutions" => [],
"Two-time correlation functions" => [],
"Extensions" => [
"users_guide/extensions/cuda.md",
],
],
"Tutorials" => Any[
"Time Evolution" => Any[
"Tutorials" => [
"Time Evolution" => [
"Low Rank Master Equation" => "tutorials/lowrank.md",
],
"Miscellaneous Tutorials" => Any[
"Miscellaneous Tutorials" => [
"tutorials/logo.md",
],
],
Expand All @@ -49,15 +50,15 @@ const PAGES = Any[

makedocs(;
modules = [QuantumToolbox],
authors = "Alberto Mercurio",
repo = Remotes.GitHub("albertomercurio", "QuantumToolbox.jl"),
authors = "Alberto Mercurio, Luca Gravina and Yi-Te Huang",
repo = Remotes.GitHub("qutip", "QuantumToolbox.jl"),
sitename = "QuantumToolbox.jl",
pages = PAGES,
format = Documenter.HTML(;
prettyurls = get(ENV, "CI", "false") == "true",
canonical = "https://albertomercurio.github.io/QuantumToolbox.jl",
canonical = "https://qutip.github.io/QuantumToolbox.jl",
edit_link = "main",
assets = String[],
assets = ["assets/favicon.ico"],
mathengine = MathJax3(
Dict(
:loader => Dict("load" => ["[tex]/physics"]),
Expand All @@ -71,4 +72,4 @@ makedocs(;
)
)

deploydocs(; repo = "github.com/albertomercurio/QuantumToolbox.jl", devbranch = "main")
deploydocs(; repo = "github.com/qutip/QuantumToolbox.jl", devbranch = "main")
2 changes: 2 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ issuper
size
eltype
length
sqrtm
LinearAlgebra.tr
LinearAlgebra.svdvals
LinearAlgebra.norm
Expand All @@ -61,6 +62,7 @@ negativity
entropy_vn
entanglement
expect
fidelity
wigner
get_coherence
n_th
Expand Down
6 changes: 2 additions & 4 deletions docs/src/benchmarks/benchmark_history.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
```@raw html
<iframe id="myIframe" src="https://albertomercurio.github.io/QuantumToolbox.jl/benchmarks/" style="width:100%; border:none; overflow:hidden;"></iframe>
<iframe id="myIframe" src="https://qutip.github.io/QuantumToolbox.jl/benchmarks/" style="width:100%; border:none; overflow:hidden;"></iframe>
<script>
// Function to adjust the iframe height
function adjustIframeHeight(event) {
const iframe = document.getElementById('myIframe');
if (event.origin === 'https://albertomercurio.github.io') { // Ensure this matches the iframe origin
iframe.style.height = event.data + 'px';
}
iframe.style.height = event.data + 'px';
}
// Listen for messages from the iframe
Expand Down
Loading

0 comments on commit 1d5df9c

Please sign in to comment.