├── .gitattributes ├── .github └── workflows │ └── build.yml ├── .gitignore ├── Makefile ├── QuTiP_tree_plot ├── d3_data │ ├── d3.layout.min.js │ ├── d3.min.js │ ├── qutip.json │ ├── tree-radial.js │ └── tree.css ├── qutip-structure.py └── qutip_org.html ├── README.md ├── apidoc ├── apidoc.rst ├── classes.rst └── functions.rst ├── biblio.rst ├── changelog.rst ├── conf.py ├── contrib ├── qpt.py └── sim_ent_qkd │ ├── sim_ent_qkd.html │ └── sim_ent_qkd.py ├── contributors.rst ├── development ├── contributing.rst ├── development.rst ├── docs.rst ├── ideas.rst ├── ideas │ ├── README │ ├── heom-gpu.rst │ ├── pulse-level-quantum-circuits.rst │ ├── quantum-error-mitigation.rst │ ├── qutip-interactive.rst │ └── tensorflow-data-backend.rst ├── release_distribution.rst └── roadmap.rst ├── figures ├── NumFocus_logo.png ├── about.png ├── bloch_decay.mp4 ├── citing │ ├── bibtex.png │ ├── qutip.bib │ ├── qutip2.bib │ └── us.png ├── demos.png ├── documentation │ ├── developer.png │ ├── online.png │ └── pdf.png ├── download │ ├── arrow.png │ ├── gz.png │ └── zip.png ├── favicon.ico ├── features │ ├── docs.png │ ├── dynamics.png │ ├── mc_performance.png │ ├── me_performance.png │ ├── multiprocessing.png │ ├── ninja.png │ ├── schcat.png │ └── sparse.png ├── home │ ├── multiprocessing.png │ └── visitors.png ├── inst_quant_sher.png ├── jsps.jpg ├── korea-logo.png ├── logo.png ├── nav │ ├── citing.png │ ├── citing_red.png │ ├── documentation.png │ ├── documentation_red.png │ ├── download.png │ ├── download_red.png │ ├── end_spacer.png │ ├── features.png │ ├── features_red.png │ ├── home.png │ ├── home_red.png │ ├── qutip2_header.png │ ├── qutip_header.png │ ├── spacer.png │ ├── support.png │ ├── support_red.png │ ├── updates.png │ └── updates_red.png ├── qip │ ├── illustration.png │ ├── processor-noise.png │ ├── processor-workflow.png │ ├── quantum_circuit_example.png │ ├── quantum_circuit_w_state.png │ └── workflow.png ├── qustar.png ├── qutip_logo.png ├── release_guide_after_workflow.png ├── release_guide_run_build_workflow.png ├── riken-logo.png ├── support │ ├── arrow.png │ ├── brain.png │ ├── discussion.png │ ├── issue.png │ ├── manual.png │ ├── paul.png │ └── rob.png ├── unitaryfund_logo.png ├── updates │ └── blog.png └── wide_logo.png ├── frontmatter.rst ├── gallery └── src │ ├── README.rst │ └── qip │ ├── README.txt │ ├── plot_qip_amplitude_noise.py │ ├── plot_qip_intro_processor.py │ └── plot_qip_relaxation.py ├── guide ├── doc │ └── qutip_tree.pdf ├── dynamics │ ├── dynamics-bloch-redfield.rst │ ├── dynamics-data.rst │ ├── dynamics-floquet.rst │ ├── dynamics-master.rst │ ├── dynamics-monte.rst │ ├── dynamics-options.rst │ ├── dynamics-photocurrent.rst │ ├── dynamics-piqs.rst │ ├── dynamics-stochastic.rst │ └── dynamics-time.rst ├── figures │ ├── bloch3d+data.png │ ├── bloch3d+points.png │ ├── bloch3d-blank.png │ ├── qtrl-code_object_model.png │ ├── quant_optim_ctrl.png │ └── qutip_tree.png ├── guide-basics.rst ├── guide-bloch.rst ├── guide-control.rst ├── guide-correlation.rst ├── guide-dynamics.rst ├── guide-measurement.rst ├── guide-overview.rst ├── guide-parfor.rst ├── guide-qip.rst ├── guide-random.rst ├── guide-saving.rst ├── guide-settings.rst ├── guide-states.rst ├── guide-steady.rst ├── guide-tensor.rst ├── guide-visualization.rst ├── guide.rst ├── qip │ ├── qip-basics.rst │ ├── qip-processor.rst │ ├── qip-simulator.rst │ └── w-state.qasm ├── quide-basics-qobj-box.png └── scripts │ ├── bloch_ex1.py │ ├── correlation_ex1.py │ ├── correlation_ex2.py │ ├── correlation_ex3.py │ ├── correlation_ex4.py │ ├── ex_bloch_animation.py │ ├── ex_steady.py │ ├── floquet_ex0.py │ ├── floquet_ex1.py │ ├── floquet_ex2.py │ ├── floquet_ex3.py │ └── spectrum_ex1.py ├── index.rst ├── installation.rst ├── make.bat ├── requirements.txt ├── sphinxext └── requirements.txt ├── static └── site.css └── templates └── layout.html /.gitattributes: -------------------------------------------------------------------------------- 1 | # Force Windows batch files to use \r\n. 2 | *.bat text eol=crlf 3 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build HTML documentation 2 | 3 | on: 4 | [push, pull_request] 5 | 6 | jobs: 7 | build: 8 | name: Build documentation 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v2 13 | 14 | - uses: actions/setup-python@v2 15 | name: Install Python 16 | with: 17 | python-version: '3.8' 18 | 19 | - name: Install documentation dependencies 20 | run: | 21 | python -mpip install -r requirements.txt 22 | 23 | - name: Install QuTiP from GitHub 24 | run: | 25 | python -mpip install git+git://github.com/qutip/qutip.git#egg=qutip[full] 26 | python -c 'import qutip; qutip.about()' 27 | 28 | - name: Build documentation 29 | run: | 30 | make html SPHINXOPTS="-W --keep-going -T" 31 | # Above flags are: 32 | # -W : turn warnings into errors 33 | # --keep-going : do not stop after the first error 34 | # -T : display a full traceback if a Python exception occurs 35 | 36 | - name: Upload built files 37 | uses: actions/upload-artifact@v2 38 | with: 39 | name: qutip_html_docs 40 | path: _build/html/* 41 | if-no-files-found: error 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.pyc 3 | *.pyx 4 | *.dat 5 | *.qu 6 | *.dat 7 | *~ 8 | 9 | _build 10 | _images 11 | gallery/build 12 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 16 | 17 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 18 | 19 | help: 20 | @echo "Please use \`make ' where is one of" 21 | @echo " html to make standalone HTML files" 22 | @echo " dirhtml to make HTML files named index.html in directories" 23 | @echo " singlehtml to make a single large HTML file" 24 | @echo " pickle to make pickle files" 25 | @echo " json to make JSON files" 26 | @echo " htmlhelp to make HTML files and a HTML help project" 27 | @echo " qthelp to make HTML files and a qthelp project" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 31 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 32 | @echo " text to make text files" 33 | @echo " man to make manual pages" 34 | @echo " texinfo to make Texinfo files" 35 | @echo " info to make Texinfo files and run them through makeinfo" 36 | @echo " gettext to make PO message catalogs" 37 | @echo " changes to make an overview of all changed/added/deprecated items" 38 | @echo " linkcheck to check all external links for integrity" 39 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 40 | 41 | clean: 42 | -rm -rf $(BUILDDIR)/* 43 | 44 | html: 45 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 48 | 49 | dirhtml: 50 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 51 | @echo 52 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 53 | 54 | singlehtml: 55 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 56 | @echo 57 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 58 | 59 | pickle: 60 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 61 | @echo 62 | @echo "Build finished; now you can process the pickle files." 63 | 64 | json: 65 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 66 | @echo 67 | @echo "Build finished; now you can process the JSON files." 68 | 69 | htmlhelp: 70 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 71 | @echo 72 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 73 | ".hhp project file in $(BUILDDIR)/htmlhelp." 74 | 75 | qthelp: 76 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 77 | @echo 78 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 79 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 80 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/QuTiP.qhcp" 81 | @echo "To view the help file:" 82 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/QuTiP.qhc" 83 | 84 | devhelp: 85 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 86 | @echo 87 | @echo "Build finished." 88 | @echo "To view the help file:" 89 | @echo "# mkdir -p $$HOME/.local/share/devhelp/QuTiP" 90 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/QuTiP" 91 | @echo "# devhelp" 92 | 93 | epub: 94 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 95 | @echo 96 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 97 | 98 | latex: 99 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 100 | @echo 101 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 102 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 103 | "(use \`make latexpdf' here to do that automatically)." 104 | 105 | latexpdf: 106 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 107 | @echo "Running LaTeX files through pdflatex..." 108 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 109 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 110 | 111 | text: 112 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 113 | @echo 114 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 115 | 116 | man: 117 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 118 | @echo 119 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 120 | 121 | texinfo: 122 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 123 | @echo 124 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 125 | @echo "Run \`make' in that directory to run these through makeinfo" \ 126 | "(use \`make info' here to do that automatically)." 127 | 128 | info: 129 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 130 | @echo "Running Texinfo files through makeinfo..." 131 | make -C $(BUILDDIR)/texinfo info 132 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 133 | 134 | gettext: 135 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 136 | @echo 137 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 138 | 139 | changes: 140 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 141 | @echo 142 | @echo "The overview file is in $(BUILDDIR)/changes." 143 | 144 | linkcheck: 145 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 146 | @echo 147 | @echo "Link check complete; look for any errors in the above output " \ 148 | "or in $(BUILDDIR)/linkcheck/output.txt." 149 | 150 | doctest: 151 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 152 | @echo "Testing of doctests in the sources finished, look at the " \ 153 | "results in $(BUILDDIR)/doctest/output.txt." 154 | -------------------------------------------------------------------------------- /QuTiP_tree_plot/d3_data/tree-radial.js: -------------------------------------------------------------------------------- 1 | var r = 1500; 2 | 3 | var tree = d3.layout.tree() 4 | .size([360, r - 175]) 5 | .separation(function(a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; }); 6 | 7 | var diagonal = d3.svg.diagonal.radial() 8 | .projection(function(d) { return [d.y, d.x / 180 * Math.PI]; }); 9 | 10 | var vis = d3.select("#chart").append("svg") 11 | .attr("width", r * 2 ) 12 | .attr("height", r * 2 ) 13 | .append("g") 14 | .attr("transform", "translate(" + r + "," + r + ")"); 15 | 16 | d3.json("d3_data/qutip.json", function(json) { 17 | var nodes = tree.nodes(json); 18 | 19 | var link = vis.selectAll("path.link") 20 | .data(tree.links(nodes)) 21 | .enter().append("path") 22 | .attr("class", "link") 23 | .attr("d", diagonal); 24 | 25 | var node = vis.selectAll("g.node") 26 | .data(nodes) 27 | .enter().append("g") 28 | .attr("class", "node") 29 | .attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; }) 30 | 31 | node.append("circle") 32 | .attr("r", 2.5) 33 | /*.style("fill", function(d) { return d.color; })*/ 34 | .style("stroke", function(d) { return d.color; }); 35 | 36 | node.append("text") 37 | .attr("dx", function(d) { return d.x < 180 ? 8 : -8; }) 38 | .attr("dy", ".31em") 39 | .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; }) 40 | .attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; }) 41 | .style("fill", function(d) { return d.color; }) 42 | .text(function(d) { return d.name; }); 43 | }); 44 | -------------------------------------------------------------------------------- /QuTiP_tree_plot/d3_data/tree.css: -------------------------------------------------------------------------------- 1 | .node circle { 2 | fill: #fff; 3 | stroke: mediumpurple; 4 | stroke-width: 1px; 5 | } 6 | 7 | .node { 8 | font: 10px sans-serif; 9 | } 10 | 11 | .link { 12 | fill: none; 13 | stroke: #ccc; 14 | stroke-width: 1px; 15 | } 16 | -------------------------------------------------------------------------------- /QuTiP_tree_plot/qutip-structure.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import inspect 4 | import pathlib 5 | import warnings 6 | import sys 7 | 8 | import qutip 9 | 10 | # This script currently relies on all packages being imported by the 11 | # import qutip 12 | # command. If in the future some packages are not imported, then you'll need 13 | # to add more import lines below it to make sure they're all in. We do this 14 | # rather than file-based discovery so we have more access to information 15 | # included by the import system, such as which names are meant to be public. 16 | # It also means that we can import Cythonised modules to investigate their 17 | # internals as well. 18 | 19 | root_directory = pathlib.Path(qutip.__file__).parent 20 | 21 | # This list needs to populated manually at the moment. Each element of the 22 | # list is a two-tuple (colour, modules), where the `colour` is the text colour 23 | # in the output, and `modules` is a set of module names that will be that 24 | # colour. You can also put package names into the set of modules---any 25 | # submodules of that package will inherit the same colour. You don't need to 26 | # include the "qutip." prefix to the modules. It's a list not a dictionary 27 | # because the order is important to the output. 28 | module_groups = [ 29 | # Solvers 30 | ("#0b5fa5", { 31 | "mesolve", "mcsolve", "sesolve", "stochastic", "bloch_redfield", 32 | "nonmarkov", "floquet", "essolve", "correlation", "steadystate", 33 | "rhs_generate", "propagator", "eseries", "hsolve", "rcsolve", 34 | "scattering", "piqs", "pdpsolve", 35 | }), 36 | # Options and settings 37 | ("#043c6b", {"settings", "configrc", "solver"}), 38 | # Visualisation 39 | ("#3f8fd2", { 40 | "bloch", "bloch3d", "sphereplot", "orbital", "visualization", "wigner", 41 | "distributions", "tomography", "topology", 42 | }), 43 | # Operators 44 | ("#00ae68", { 45 | "operators", "superoperator", "superop_reps", "subsystem_apply", 46 | }), 47 | # States 48 | ("#007143", { 49 | "states", "continuous_variables", "qstate", "random_objects", 50 | "three_level_atom", 51 | }), 52 | # QIP 53 | ("#36d695", {"qip", "measurement"}), 54 | # Metrics and distance measures 55 | ("#ff4500", {"entropy", "metrics", "countstat", "semidefinite"}), 56 | # Core 57 | ("#692102", { 58 | "qobj", "qobjevo", "expect", "tensor", "partial_transpose", "ptrace", 59 | "cy", "fastsparse", "interpolate", 60 | }), 61 | # Utilities 62 | ("#bf5730", { 63 | "fileio", "utilities", "ipynbtools", "sparse", "graph", "simdiag", 64 | "permute", "demos", "about", "parallel", "version", "testing", 65 | "parfor", "hardware_info", "ui", "cite", "lattice", 66 | }), 67 | ] 68 | 69 | # Set of modules that we don't want to include in the output. Any modules that 70 | # are detected inside `qutip` but are not either in this set or the 71 | # `module_groups` list will generate a warning when the script is run. 72 | modules_ignored = { 73 | "dimensions", 74 | "logging_utils", 75 | "matplotlib_utilities", 76 | "legacy", 77 | "qobjevo_codegen", 78 | "_mkl", 79 | "cy.pyxbuilder", 80 | "cy.openmp", 81 | "cy.graph_utils", 82 | "cy.inter", 83 | "cy.cqobjevo", 84 | "cy.cqobjevo_factor", 85 | "cy.codegen", 86 | "cy.br_codegen", 87 | "cy.ptrace", 88 | } 89 | 90 | 91 | def _our_tree(module, tree): 92 | """ 93 | Find the subtree corresponding to this module, creating any necessary 94 | subtrees along the way. 95 | """ 96 | our_tree = tree 97 | cur_name = "" 98 | for part in module.__name__.split(".")[1:]: 99 | cur_name = (cur_name + "." + part) if cur_name else part 100 | if cur_name in modules_ignored: 101 | return tree 102 | try: 103 | our_tree = our_tree[part] 104 | except KeyError: 105 | our_tree[part] = {} 106 | our_tree = our_tree[part] 107 | return our_tree 108 | 109 | 110 | def _ignore(module, root): 111 | if not module.__name__.startswith(root): 112 | return True 113 | name = module.__name__[len(root):] 114 | if name in modules_ignored: 115 | return True 116 | while (idx := name.rfind(".")) > 0: 117 | name = name[:idx] 118 | if name in modules_ignored: 119 | return True 120 | return False 121 | 122 | 123 | def python_object_tree(module, tree=None, seen=None, root=None, nobjects=0): 124 | """ 125 | Recursively access every accessible element of the given module, building 126 | up a complete tree structure where the keys are the parts of the module 127 | name, and the eventual leaves are public functions and classes defined in 128 | that particular module (so ignoring any names that leak in from other 129 | imports). For example, 130 | >>> import qutip 131 | >>> python_object_tree(qutip) 132 | { 133 | "mesolve" : { 134 | "mesolve": , 135 | }, 136 | "qip": { 137 | "operations": { 138 | ... 139 | }, 140 | ... 141 | }, 142 | ... 143 | } 144 | """ 145 | tree = tree if tree is not None else {} 146 | seen = seen if seen is not None else set() 147 | root = root if root is not None else (module.__name__ + ".") 148 | if module in seen: 149 | return tree, nobjects 150 | seen.add(module) 151 | our_tree = _our_tree(module, tree) 152 | for _, obj in inspect.getmembers(module): 153 | if inspect.isclass(obj) or inspect.isroutine(obj): 154 | object_module = inspect.getmodule(obj) 155 | if object_module is module: 156 | if not obj.__name__.startswith("_"): 157 | our_tree[obj.__name__] = obj 158 | nobjects += 1 159 | continue 160 | # Fall through, so we recursively comb through modules. 161 | obj = object_module 162 | if inspect.ismodule(obj) and not _ignore(obj, root): 163 | if obj.__name__.startswith(root): 164 | _, nobjects =\ 165 | python_object_tree(obj, tree, seen, root, nobjects) 166 | # Also do our parent package, if we have one. In theory it's possible to 167 | # get into a situation with packages and overzealous use of "del" in init 168 | # scripts where a submodule may be accessible but its parent isn't. 169 | parent = ".".join(module.__name__.split(".")[:-1]) 170 | if parent.startswith(root): 171 | _, nobjects =\ 172 | python_object_tree(sys.modules[parent], tree, seen, root, nobjects) 173 | return tree, nobjects 174 | 175 | 176 | def _lookup_color(basename, index, color): 177 | for i, (color_, modules) in enumerate(module_groups): 178 | if basename in modules: 179 | return i, color_ 180 | return index, color 181 | 182 | 183 | def convert_to_d3_struct(in_tree, name, index=-1, color=None, basename=None): 184 | out_struct = {} 185 | children = [] 186 | color_default = "black" 187 | index, color = _lookup_color(basename, index, color) 188 | for key, value in in_tree.items(): 189 | nextname = (basename + "." + key) if basename else key 190 | if isinstance(value, dict): 191 | out = convert_to_d3_struct(value, key, index, color, nextname) 192 | else: 193 | out = { 194 | "name": key, 195 | "color": color or color_default, 196 | "index": index, 197 | } 198 | children.append(out) 199 | if name == "QuTiP" and basename is None: 200 | # Don't warn for the base case. 201 | color = color_default 202 | if color is None: 203 | modname = "qutip" + (("." + basename) if basename else "") 204 | warnings.warn("handling unspecified module: " + modname) 205 | out_struct["name"] = name 206 | out_struct["color"] = color or color_default 207 | out_struct["index"] = index 208 | if children: 209 | out_struct["children"] = sorted(children, key=lambda x: x["index"]) 210 | return out_struct 211 | 212 | 213 | if __name__ == "__main__": 214 | import json 215 | 216 | tree, count = python_object_tree(qutip) 217 | struct = convert_to_d3_struct(tree, "QuTiP") 218 | with open("d3_data/qutip.json", "w") as f: 219 | json.dump(struct, f) 220 | print(count) 221 | -------------------------------------------------------------------------------- /QuTiP_tree_plot/qutip_org.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | QuTiP Organization 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ARCHIVED SINCE 2021-05-01 2 | ========================= 3 | 4 | **The documentation is now hosted [in the `doc` folder of the qutip/qutip repository](https://github.com/qutip/qutip/tree/master/doc).** 5 | 6 | As of May 2021, this is no longer the main repository for QuTiP documentation development, but is preserved to avoid breaking old links. 7 | Please submit all new issues and pull requests there, instead. 8 | 9 | The rest of this readme and repository are left as-is. 10 | 11 | Repository for QuTiP documentation 12 | ================================== 13 | 14 | This repository contains the source files for the QuTiP documentation. 15 | 16 | For pre-built documentation, see http://www.qutip.org/documentation.html 17 | 18 | Building 19 | -------- 20 | 21 | The main Python requirements for the documentation are `sphinx`, `sphinx-gallery`, `sphinx_rtd_theme`, `numpydoc` and `ipython`. 22 | You should build or install the version of QuTiP you want to build the documentation against in the same environment. 23 | You will also need a sensible copy of `make`, and if you want to build the LaTeX documentation then also a `pdflatex` distribution. 24 | As of 2021-04-20, the `conda` recipe for `sphinx_rtd_theme` is rather old compared to the `pip` version, so it's recommended to use a mostly `pip`-managed environment to do the documentation build. 25 | 26 | The simplest way to get a functional build environment is to use the `requirements.txt` file in this repository, which completely defines a known-good `pip` environment (tested on Python 3.8, but not necessarily limited to it). 27 | If you typically use conda, the way to do this is 28 | ```bash 29 | $ conda create -n qutip-doc-build python=3.8 30 | $ conda activate qutip-doc-build 31 | $ pip install -r /path/to/qutip-doc/requirements.txt 32 | ``` 33 | You will also need to build or install the main QuTiP library in the same environment. 34 | If you simply want to build the documentation without editing the main library, you can install a release version of QuTiP with `pip install qutip`. 35 | Otherwise, refer to [the main repository](https://github.com/qutip/qutip) for the current process to build from source. 36 | You need to have the optional QuTiP dependency `Cython` to build the documentation, but this is included in this repository's `requirements.txt` so you do not need to do anything separately. 37 | 38 | After you have done this, you can effect the build with `make`. 39 | The targets you might want are `html`, `latexpdf` and `clean`, which build the HTML pages, build the PDFs, and delete all built files respectively. 40 | For example, to build the HTML files only, use 41 | ```bash 42 | $ make html 43 | ``` 44 | 45 | *Note (2021-04-20):* the documentation build is currently broken on Windows due to incompatibilities in the main library in multiprocessing components. 46 | 47 | Writing User Guides 48 | ------------------- 49 | 50 | The user guide provides an overview of QuTiP's functionality. The guide is composed of individual reStructuredText (`.rst`) files which each get rendered as a webpage. Each page typically tackles one area of functionality. To learn more about how to write `.rst` files, it is useful to follow the [Sphinx Guide](https://www.sphinx-doc.org/en/master/usage/index.html). 51 | 52 | The documentation build also utilizes a number of [Sphinx Extensions](https://www.sphinx-doc.org/en/master/usage/extensions/index.html) including but not limited to 53 | [doctest](https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html) , [autodoc](https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html) , [sphinx gallery](https://sphinx-gallery.github.io/stable/index.html) , [plot](http://matthew-brett.github.io/nb2plots/nbplots.html#module-nb2plots.nbplots) . Additional extensions can be configured in the `conf.py` file. 54 | 55 | Tests can also be run on examples in the documentation using the doctest extension 56 | and plots are generated using the `plot` directive. For more specific 57 | guidelines on how to incorporate code examples into the guide, refer to (insert reference). 58 | -------------------------------------------------------------------------------- /apidoc/apidoc.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _apidoc: 5 | 6 | ***************** 7 | API documentation 8 | ***************** 9 | 10 | This chapter contains automatically generated API documentation, including a 11 | complete list of QuTiP's public classes and functions. 12 | 13 | .. toctree:: 14 | :maxdepth: 3 15 | 16 | classes.rst 17 | functions.rst 18 | -------------------------------------------------------------------------------- /apidoc/classes.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _classes: 5 | 6 | *************** 7 | Classes 8 | *************** 9 | 10 | .. _classes-qobj: 11 | 12 | Qobj 13 | -------------- 14 | 15 | .. autoclass:: qutip.Qobj 16 | :members: 17 | 18 | .. _classes-qobjevo: 19 | 20 | QobjEvo 21 | -------------- 22 | 23 | .. autoclass:: qutip.QobjEvo 24 | :members: 25 | 26 | .. _classes-eseries: 27 | 28 | eseries 29 | ----------------- 30 | 31 | .. autoclass:: qutip.eseries 32 | :members: 33 | 34 | .. _classes-bloch: 35 | 36 | Bloch sphere 37 | --------------- 38 | 39 | .. autoclass:: qutip.bloch.Bloch 40 | :members: 41 | 42 | 43 | Cubic Spline 44 | --------------- 45 | 46 | .. autoclass:: qutip.interpolate.Cubic_Spline 47 | :members: 48 | 49 | 50 | .. _classes-non_markov: 51 | 52 | Non-Markovian Solvers 53 | --------------------- 54 | 55 | .. autoclass:: qutip.nonmarkov.heom.HEOMSolver 56 | :members: 57 | 58 | .. autoclass:: qutip.nonmarkov.heom.HSolverDL 59 | :members: 60 | 61 | .. autoclass:: qutip.nonmarkov.memorycascade.MemoryCascade 62 | :members: 63 | 64 | .. autoclass:: qutip.nonmarkov.transfertensor.TTMSolverOptions 65 | :members: 66 | 67 | .. _classes-odeoptions: 68 | 69 | Solver Options and Results 70 | --------------------------- 71 | 72 | .. autoclass:: qutip.solver.ExpectOps 73 | :members: 74 | 75 | .. autoclass:: qutip.solver.Options 76 | :members: 77 | 78 | .. autoclass:: qutip.solver.Result 79 | :members: 80 | 81 | .. autoclass:: qutip.solver.SolverConfiguration 82 | :members: 83 | 84 | .. autoclass:: qutip.solver.Stats 85 | :members: 86 | 87 | .. autoclass:: qutip.stochastic.StochasticSolverOptions 88 | :members: 89 | 90 | .. _classes-piqs: 91 | 92 | Permutational Invariance 93 | ------------------------ 94 | 95 | .. autoclass:: qutip.piqs.Dicke 96 | :members: 97 | 98 | .. autoclass:: qutip.piqs.Pim 99 | :members: 100 | 101 | .. _classes-distributions: 102 | 103 | One-Dimensional Lattice 104 | ----------------------- 105 | 106 | .. autoclass:: qutip.lattice.Lattice1d 107 | :members: 108 | 109 | Distribution functions 110 | ---------------------------- 111 | 112 | .. autoclass:: qutip.distributions.Distribution 113 | :members: 114 | 115 | .. autoclass:: qutip.distributions.WignerDistribution 116 | :members: 117 | 118 | .. autoclass:: qutip.distributions.QDistribution 119 | :members: 120 | 121 | .. autoclass:: qutip.distributions.TwoModeQuadratureCorrelation 122 | :members: 123 | 124 | .. autoclass:: qutip.distributions.HarmonicOscillatorWaveFunction 125 | :members: 126 | 127 | .. autoclass:: qutip.distributions.HarmonicOscillatorProbabilityFunction 128 | :members: 129 | 130 | .. _classes-qip: 131 | 132 | Quantum information processing 133 | ------------------------------ 134 | 135 | .. autoclass:: qutip.qip.Gate 136 | :members: 137 | 138 | .. autoclass:: qutip.qip.circuit.Measurement 139 | :members: 140 | 141 | .. autoclass:: qutip.qip.circuit.QubitCircuit 142 | :members: 143 | 144 | .. autoclass:: qutip.qip.circuit.CircuitResult 145 | :members: 146 | 147 | .. autoclass:: qutip.qip.circuit.CircuitSimulator 148 | :members: 149 | 150 | .. autoclass:: qutip.qip.device.Processor 151 | :members: 152 | 153 | .. autoclass:: qutip.qip.device.OptPulseProcessor 154 | :members: 155 | :inherited-members: 156 | 157 | .. autoclass:: qutip.qip.device.ModelProcessor 158 | :members: 159 | :inherited-members: 160 | 161 | .. autoclass:: qutip.qip.device.SpinChain 162 | :members: 163 | :inherited-members: 164 | 165 | .. autoclass:: qutip.qip.device.LinearSpinChain 166 | :members: 167 | :inherited-members: 168 | 169 | .. autoclass:: qutip.qip.device.CircularSpinChain 170 | :members: 171 | :inherited-members: 172 | 173 | .. autoclass:: qutip.qip.device.DispersiveCavityQED 174 | :members: 175 | :inherited-members: 176 | 177 | .. autoclass:: qutip.qip.noise.Noise 178 | :members: 179 | 180 | .. autoclass:: qutip.qip.noise.DecoherenceNoise 181 | :members: 182 | :inherited-members: 183 | 184 | .. autoclass:: qutip.qip.noise.RelaxationNoise 185 | :members: 186 | :inherited-members: 187 | 188 | .. autoclass:: qutip.qip.noise.ControlAmpNoise 189 | :members: 190 | :inherited-members: 191 | 192 | .. autoclass:: qutip.qip.noise.RandomNoise 193 | :members: 194 | :inherited-members: 195 | 196 | .. autoclass:: qutip.qip.pulse.Pulse 197 | :members: 198 | 199 | .. autoclass:: qutip.qip.compiler.GateCompiler 200 | :members: 201 | 202 | .. autoclass:: qutip.qip.compiler.CavityQEDCompiler 203 | :members: 204 | :inherited-members: 205 | 206 | .. autoclass:: qutip.qip.compiler.SpinChainCompiler 207 | :members: 208 | :inherited-members: 209 | 210 | .. autoclass:: qutip.qip.compiler.Scheduler 211 | :members: 212 | 213 | .. autoclass:: qutip.qip.compiler.Instruction 214 | :members: 215 | 216 | .. _classes-control: 217 | 218 | Optimal control 219 | --------------- 220 | 221 | .. autoclass:: qutip.control.optimizer.Optimizer 222 | :members: 223 | 224 | .. autoclass:: qutip.control.optimizer.OptimizerBFGS 225 | :members: 226 | 227 | .. autoclass:: qutip.control.optimizer.OptimizerLBFGSB 228 | :members: 229 | 230 | .. autoclass:: qutip.control.optimizer.OptimizerCrab 231 | :members: 232 | 233 | .. autoclass:: qutip.control.optimizer.OptimizerCrabFmin 234 | :members: 235 | 236 | .. autoclass:: qutip.control.optimizer.OptimIterSummary 237 | :members: 238 | 239 | .. autoclass:: qutip.control.termcond.TerminationConditions 240 | :members: 241 | 242 | .. autoclass:: qutip.control.optimresult.OptimResult 243 | :members: 244 | 245 | .. autoclass:: qutip.control.dynamics.Dynamics 246 | :members: 247 | 248 | .. autoclass:: qutip.control.dynamics.DynamicsGenMat 249 | :members: 250 | 251 | .. autoclass:: qutip.control.dynamics.DynamicsUnitary 252 | :members: 253 | 254 | .. autoclass:: qutip.control.dynamics.DynamicsSymplectic 255 | :members: 256 | 257 | .. autoclass:: qutip.control.propcomp.PropagatorComputer 258 | :members: 259 | 260 | .. autoclass:: qutip.control.propcomp.PropCompApproxGrad 261 | :members: 262 | 263 | .. autoclass:: qutip.control.propcomp.PropCompDiag 264 | :members: 265 | 266 | .. autoclass:: qutip.control.propcomp.PropCompFrechet 267 | :members: 268 | 269 | .. autoclass:: qutip.control.fidcomp.FidelityComputer 270 | :members: 271 | 272 | .. autoclass:: qutip.control.fidcomp.FidCompUnitary 273 | :members: 274 | 275 | .. autoclass:: qutip.control.fidcomp.FidCompTraceDiff 276 | :members: 277 | 278 | .. autoclass:: qutip.control.fidcomp.FidCompTraceDiffApprox 279 | :members: 280 | 281 | .. autoclass:: qutip.control.tslotcomp.TimeslotComputer 282 | :members: 283 | 284 | .. autoclass:: qutip.control.tslotcomp.TSlotCompUpdateAll 285 | :members: 286 | 287 | .. autoclass:: qutip.control.pulsegen.PulseGen 288 | :members: 289 | 290 | .. autoclass:: qutip.control.pulsegen.PulseGenRandom 291 | :members: 292 | 293 | .. autoclass:: qutip.control.pulsegen.PulseGenZero 294 | :members: 295 | 296 | .. autoclass:: qutip.control.pulsegen.PulseGenLinear 297 | :members: 298 | 299 | .. autoclass:: qutip.control.pulsegen.PulseGenPeriodic 300 | :members: 301 | 302 | .. autoclass:: qutip.control.pulsegen.PulseGenSine 303 | :members: 304 | 305 | .. autoclass:: qutip.control.pulsegen.PulseGenSquare 306 | :members: 307 | 308 | .. autoclass:: qutip.control.pulsegen.PulseGenSaw 309 | :members: 310 | 311 | .. autoclass:: qutip.control.pulsegen.PulseGenTriangle 312 | :members: 313 | 314 | .. autoclass:: qutip.control.pulsegen.PulseGenGaussian 315 | :members: 316 | 317 | .. autoclass:: qutip.control.pulsegen.PulseGenGaussianEdge 318 | :members: 319 | 320 | .. autoclass:: qutip.control.pulsegen.PulseGenCrab 321 | :members: 322 | 323 | .. autoclass:: qutip.control.pulsegen.PulseGenCrabFourier 324 | :members: 325 | 326 | .. autoclass:: qutip.control.stats.Stats 327 | :members: 328 | 329 | .. autoclass:: qutip.control.dump.Dump 330 | :members: 331 | 332 | .. autoclass:: qutip.control.dump.OptimDump 333 | :members: 334 | 335 | .. autoclass:: qutip.control.dump.DynamicsDump 336 | :members: 337 | 338 | .. autoclass:: qutip.control.dump.DumpItem 339 | :members: 340 | 341 | .. autoclass:: qutip.control.dump.EvoCompDumpItem 342 | :members: 343 | 344 | .. autoclass:: qutip.control.dump.DumpSummaryItem 345 | :members: 346 | -------------------------------------------------------------------------------- /biblio.rst: -------------------------------------------------------------------------------- 1 | .. _biblo: 2 | 3 | Bibliography 4 | ============ 5 | 6 | .. [BCSZ08] 7 | W. Bruzda, V. Cappellini, H.-J. Sommers, K. Życzkowski, *Random Quantum Operations*, Phys. Lett. A **373**, 320-324 (2009). :doi:`10.1016/j.physleta.2008.11.043`. 8 | 9 | .. [Hav03] 10 | Havel, T. *Robust procedures for converting among Lindblad, Kraus and matrix representations of quantum dynamical semigroups*. Journal of Mathematical Physics **44** 2, 534 (2003). :doi:`10.1063/1.1518555`. 11 | 12 | .. [Wat13] 13 | Watrous, J. |theory-qi|_, lecture notes. 14 | 15 | .. The trick with |text|_ is to get an italic link, and is described in the 16 | Docutils FAQ at http://docutils.sourceforge.net/FAQ.html#is-nested-inline-markup-possible. 17 | 18 | .. |theory-qi| replace:: *Theory of Quantum Information* 19 | .. _theory-qi: https://cs.uwaterloo.ca/~watrous/CS766/ 20 | 21 | .. [Mez07] 22 | F. Mezzadri, *How to generate random matrices from the classical compact groups*, Notices of the AMS **54** 592-604 (2007). :arxiv:`math-ph/0609050`. 23 | 24 | .. [Moh08] 25 | M. Mohseni, A. T. Rezakhani, D. A. Lidar, *Quantum-process tomography: Resource analysis of different strategies*, Phys. Rev. A **77**, 032322 (2008). :doi:`10.1103/PhysRevA.77.032322`. 26 | 27 | .. [Gri98] 28 | M. Grifoni, P. Hänggi, *Driven quantum tunneling*, Physics Reports **304**, 299 (1998). :doi:`10.1016/S0370-1573(98)00022-2`. 29 | 30 | .. [Gar03] 31 | Gardineer and Zoller, *Quantum Noise* (Springer, 2004). 32 | 33 | .. [Bre02] 34 | H.-P. Breuer and F. Petruccione, *The Theory of Open Quantum Systems* (Oxford, 2002). 35 | 36 | .. [Coh92] 37 | C. Cohen-Tannoudji, J. Dupont-Roc, G. Grynberg, *Atom-Photon Interactions: Basic Processes and Applications*, (Wiley, 1992). 38 | 39 | .. [WBC11] 40 | C. Wood, J. Biamonte, D. G. Cory, *Tensor networks and graphical calculus for 41 | open quantum systems*. :arxiv:`1111.6950` 42 | 43 | .. [dAless08] 44 | D. d’Alessandro, *Introduction to Quantum Control and Dynamics*, (Chapman & Hall/CRC, 2008) 45 | 46 | .. [Byrd95] 47 | R. H. Byrd, P. Lu, J. Nocedal, and C. Zhu, *A Limited Memory Algorithm for Bound Constrained Optimization*, SIAM J. Sci. Comput. **16**, 1190 (1995). :doi:`10.1137/0916069` 48 | 49 | .. [Flo12] 50 | F. F. Floether, P. de Fouquieres, and S. G. Schirmer, *Robust quantum gates for open systems via optimal control: Markovian versus non-Markovian dynamics*, New J. Phys. **14**, 073023 (2012). :doi:`10.1088/1367-2630/14/7/073023` 51 | 52 | .. [Lloyd14] 53 | S. Lloyd and S. Montangero, *Information theoretical analysis of quantum optimal control*, Phys. Rev. Lett. **113**, 010502 (2014). :doi:`10.1103/PhysRevLett.113.010502` 54 | 55 | .. [Doria11] 56 | P. Doria, T. Calarco & S. Montangero, *Optimal Control Technique for Many-Body Quantum Dynamics*, Phys. Rev. Lett. **106**, 190501 (2011). :doi:`10.1103/PhysRevLett.106.190501` 57 | 58 | .. [Caneva11] 59 | T. Caneva, T. Calarco, & S. Montangero, *Chopped random-basis quantum optimization*, Phys. Rev. A **84**, 022326 (2011). :doi:`10.1103/PhysRevA.84.022326` 60 | 61 | .. [Rach15] 62 | N. Rach, M. M. Müller, T. Calarco, and S. Montangero, *Dressing the chopped-random-basis optimization: A bandwidth-limited access to the trap-free landscape*, Phys. Rev. A. **92**, 062343 (2015). :doi:`10.1103/PhysRevA.92.062343` 63 | 64 | .. [DYNAMO] 65 | S. Machnes, U. Sander, S. J. Glaser, P. De Fouquieres, A. Gruslys, S. Schirmer, and T. Schulte-Herbrueggen, *Comparing, Optimising and Benchmarking Quantum Control Algorithms in a Unifying Programming Framework*, Phys. Rev. A. **84**, 022305 (2010). :arxiv:`1011.4874` 66 | 67 | -------------------------------------------------------------------------------- /contrib/sim_ent_qkd/sim_ent_qkd.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Code for simulating secure key rate, twofolds, and quantum bit error rate 3 | Written in Python and QuTIP by Catherine Holloway (c2hollow@iqc.ca). 4 | 5 | Detector model and squashing functions by Catherine Holloway, 6 | based on code by Dr. Thomas Jennewein (tjennewe@iqc.ca). 7 | 8 | Contributed to the QuTiP project on June 06, 2012 by Catherine Holloway. 9 | ''' 10 | 11 | #imports 12 | from qutip import * 13 | from numpy import * 14 | from pylab import * 15 | import matplotlib 16 | import matplotlib.pyplot as plt 17 | 18 | 19 | def choose(n, k): 20 | """ 21 | Binomial coefficient function for the detector model. 22 | 23 | Parameters 24 | ---------- 25 | n : int 26 | Number of elements. 27 | k : int 28 | Number of subelements. 29 | 30 | Returns 31 | ------- 32 | coeff : int 33 | Binomial coefficient. 34 | 35 | """ 36 | if 0 <= k <= n: 37 | ntok = 1 38 | ktok = 1 39 | for t in xrange(1, min(k, n - k) + 1): 40 | ntok *= n 41 | ktok *= t 42 | n -= 1 43 | return ntok // ktok 44 | else: 45 | return 0 46 | 47 | 48 | def BucketDetector_realistic_detector(N,efficiency,n_factor): 49 | """ 50 | Bucket detector model based on H. Lee, U. Yurtsever, P. Kok, G. Hockney, C. Adami, S. Braunstein, 51 | and J. Dowling, "Towards photostatistics from photon-number discriminating detectors," 52 | Journal of Modern Optics, vol. 51, p. 15171528, 2004. 53 | 54 | Parameters 55 | ---------- 56 | N : int 57 | The Fock Space dimension. 58 | efficiency : float 59 | The channel efficiency. 60 | n_factor : float 61 | The average number of dark counts per detection window APD (Bucket Detector). 62 | 63 | Returns 64 | ------- 65 | [proj, un_proj] : list 66 | The projection and unprojection operators. 67 | 68 | """ 69 | proj=zeros((N,N)) 70 | #APD (Bucket Detector) un_detector (=gives probability for 0-detection) 71 | un_proj=identity(N) 72 | #n_factor = 0; 73 | for i in range(N): 74 | probs = 0; 75 | for k in range (1,100): 76 | for d in range(k+1): 77 | if k-d<=i: 78 | probs= probs+ (exp(-n_factor)*(n_factor)**(d))/factorial(d)*choose(i,k-d)*efficiency**(k-d)*(1-efficiency)**(i-k+d) 79 | 80 | proj[i,i]=probs 81 | 82 | 83 | un_proj = un_proj-proj 84 | un_proj = Qobj(un_proj) 85 | proj = Qobj(proj) 86 | return [proj,un_proj] 87 | 88 | 89 | def measure_2folds_4modes_squashing(N,psi,proj,proj2): 90 | """ 91 | Determines the 2-fold count rate on the joint state 92 | outputs for an array of double count probabilities. 93 | 94 | Parameters 95 | ---------- 96 | N : int 97 | The Fock Space dimension. 98 | psi : qobj 99 | The entangled state to analyze 100 | proj1 : qobj 101 | 1st projection operator for the Channel between Alice and 102 | the Channel between Bob. 103 | proj2 : qobj 104 | 2nd projection operator for the Channel between Alice and 105 | the Channel between Bob. 106 | 107 | Returns 108 | ------- 109 | [HH,HV,VH,VV] : list 110 | Two-fold probabilities. 111 | 112 | Notes 113 | ----- 114 | The squashing (assigning double pairs to random bases) comes from two papers: 115 | 116 | T. Moroder, O. Guhne, N. Beaudry, M. Piani, and N. Lutkenhaus, 117 | "Entanglement verication with realistic measurement devices via squashing operations," 118 | Phys. Rev. A, vol. 81, p. 052342, May 2010. 119 | 120 | N. Lutkenhaus, "Estimates for practical quantum cryptography," Phys. Rev.A, 121 | vol. 59, pp. 3301-3319, May 1999. 122 | 123 | """ 124 | ida=qeye(N) 125 | final_state=psi 126 | det_exp = zeros((2,2,2,2)) 127 | 128 | #i,j,k,l means Ha,Va,Hb,Vb, 0 means detector clicked, 1 means detector did not click 129 | for i in range(2): 130 | for j in range(2): 131 | for k in range(2): 132 | for l in range(2): 133 | #expectation values for different detector configurations 134 | det_exp[i][j][k][l] = abs(expect(tensor(proj[i],proj[j],proj2[k],proj[l]),final_state)) 135 | #two fold probabilities 136 | HH = det_exp[0][1][0][1]+0.5*(det_exp[0][0][0][1]+det_exp[0][1][0][0])+0.25*det_exp[0][0][0][0] 137 | VV = det_exp[1][0][1][0]+0.5*(det_exp[0][0][1][0]+det_exp[1][0][0][0])+0.25*det_exp[0][0][0][0] 138 | HV = det_exp[0][1][1][0]+0.5*(det_exp[0][0][1][0]+det_exp[0][1][0][0])+0.25*det_exp[0][0][0][0] 139 | VH = det_exp[1][0][0][1]+0.5*(det_exp[0][0][0][1]+det_exp[1][0][0][0])+0.25*det_exp[0][0][0][0] 140 | 141 | return [HH,HV,VH,VV] 142 | 143 | 144 | def sim_qkd_entanglement(eps,loss_a,loss_b,n_factor_a,n_factor_b,N): 145 | """ 146 | Simulate skr with an SPDC state. 147 | 148 | Parameters 149 | ---------- 150 | eps : float 151 | The squeezing factor, sort of analogous to the amount of 152 | pumping power to the spdc source, but not really. 153 | loss_a : float 154 | Efficiency of the quantum channel going to Alice. 155 | loss_b : float 156 | Efficiency of the quantum channel going to Bob. 157 | n_factor_a : float 158 | Background noise in Alice's detection. 159 | n_factor_b : float 160 | Background noise in Bob's detection. 161 | N : int 162 | Size of the fock space that we allow for the states 163 | 164 | Returns 165 | ------- 166 | qber : float 167 | The Quantum Bit Error Rate 168 | twofolds : float 169 | Probability of Alice and Bob getting a simultaneous detection 170 | of a photon pair (also referred to as coincidences) within a 171 | timing window. 172 | skr : float 173 | Probability of getting a secure key bit within a timing window, 174 | assuming error correction and privacy amplification, in the 175 | limit of many coincidences. 176 | 177 | """ 178 | #make vaccuum state 179 | vacc = basis(N,0) 180 | 181 | #make squeezing operator for SPDC 182 | H_sq = 1j*eps*(tensor(create(N),create(N))+tensor(destroy(N),destroy(N))) 183 | 184 | #exponentiate hamiltonian and apply it to vaccuum state to make an SPDC state 185 | U_sq = H_sq.expm() 186 | spdc = U_sq*tensor(vacc,vacc) 187 | psi = tensor(spdc,spdc) 188 | #since qutip doesn't have a permute function, 189 | #we have to do a couple of steps in between 190 | #1. turn psi from a sparse matrix to a full matrix 191 | out = psi.full() 192 | #2. reshape psi into a 4-D matrix 193 | out = reshape(out, (N,N,N,-1)) 194 | #3. permute the dimensions of our 4-D matrix 195 | out = transpose(out,(0,3,2,1)) 196 | #4. turn the matrix back into a 1-D array 197 | out = reshape(out,(N*N*N*N,-1)) 198 | #5. convert the matrix back into a quantum object 199 | psi = Qobj(out,dims = [[N, N, N, N], [1, 1, 1, 1]]) 200 | 201 | # model detectors 202 | a_det = BucketDetector_realistic_detector(N,loss_a,n_factor_a) 203 | b_det = BucketDetector_realistic_detector(N,loss_b,n_factor_b) 204 | 205 | #measure detection probabilities 206 | probs2f=measure_2folds_4modes_squashing(N,psi,a_det,b_det) 207 | 208 | #Rates returned are 'per pulse', so multiply by source rate 209 | twofolds=probs2f[0]+probs2f[1]+probs2f[2]+probs2f[3] 210 | #Determine QBER from returned detection probabilities 211 | qber = (probs2f[0]+probs2f[3])/twofolds 212 | 213 | #calculate the entropy of the qber 214 | if qber>0: 215 | H2=-qber*log2(qber) - (1-qber)*log2(1-qber) 216 | else: 217 | H2 = 0 218 | # estimate error correction efficiency from the CASCADE algorithm 219 | f_e = 1.16904371810274 + qber 220 | #security analysis - calculate skr in infinite key limit 221 | #See Chris Erven's PhD thesis or Xiongfeng Ma's paper 222 | #to understand where this equation comes from 223 | skr=real(twofolds*0.5*(1-(1+f_e)*H2)) 224 | return [qber, skr, twofolds] 225 | 226 | 227 | if __name__=='__main__': 228 | #Lets look at what happens to the secure key rate and 229 | #the quantum bit error rate as the loss gets worse. 230 | #Analogous to distance with fiber optic links. 231 | 232 | #define the fock space 233 | N = 7 234 | #define the squeezing paramter 235 | eps = 0.2 236 | #define the noise factor 237 | n_factor = 4.0e-5 238 | #define the length of the coincidence window (in s) 239 | coinc_window = 2.0e-9 240 | loss_db = arange(0,30) 241 | skr = zeros(30) 242 | qber = zeros(30) 243 | twofolds = zeros(30) 244 | 245 | #run calculation 246 | for i in range(30): 247 | exp_loss = 10.0**(-loss_db[i]/10.0); 248 | [qber[i], skr[i], twofolds[i]] = sim_qkd_entanglement(eps,exp_loss,exp_loss,n_factor,n_factor,N) 249 | skr = skr/coinc_window 250 | qber = qber*100 251 | 252 | #plot results 253 | fig = plt.figure() 254 | ax = fig.add_subplot(211) 255 | ax.plot(loss_db, skr,lw=2) 256 | ax.set_yscale('log') 257 | ax.set_ylabel('Secure Key Rate (bits/s)') 258 | ax.set_xlabel('Loss (dB)') 259 | ax = fig.add_subplot(212) 260 | ax.plot(loss_db, qber,lw=2) 261 | ax.set_ylabel('Quantum Bit Error Rate (%)') 262 | ax.set_ylim([0,15]) 263 | ax.set_xlabel('Loss (dB)') 264 | plt.show() 265 | 266 | -------------------------------------------------------------------------------- /contributors.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011 and later, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _developers: 5 | 6 | ************ 7 | Developers 8 | ************ 9 | 10 | 11 | .. _developers-lead: 12 | 13 | Lead Developers 14 | =============== 15 | 16 | - `Alex Pitchford `_ 17 | - `Nathan Shammah `_ 18 | - `Shahnawaz Ahmed `_ 19 | - `Neill Lambert `_ 20 | - `Eric Giguère `_ 21 | - `Boxi Li `_ 22 | - `Jake Lishman `_ 23 | - `Simon Cross `_ 24 | 25 | Past Lead Developers 26 | ==================== 27 | 28 | - `Robert Johansson `_ (RIKEN) 29 | - `Paul Nation `_ (Korea University) 30 | - `Chris Granade `_ 31 | - `Arne Grimsmo `_ 32 | 33 | 34 | .. _developers-contributors: 35 | 36 | Contributors 37 | ============ 38 | 39 | .. note:: 40 | 41 | Anyone is welcome to contribute to QuTiP. 42 | If you are interested in helping, please let us know! 43 | 44 | - Abhisek Upadhyaya 45 | - Adriaan 46 | - Alexander Pitchford 47 | - Alexios-xi 48 | - Amit 49 | - Anubhav Vardhan 50 | - Arie van Deursen 51 | - Arne Grimsmo 52 | - Arne Hamann 53 | - Asier Galicia Martinez 54 | - Ben Bartlett 55 | - Ben Criger 56 | - Ben Jones 57 | - Bo Yang 58 | - Boxi Li 59 | - Canoming 60 | - Christoph Gohlke 61 | - Christopher Granade 62 | - Craig Gidney 63 | - Denis Vasilyev 64 | - Dominic Meiser 65 | - Drew Parsons 66 | - Eric Giguère 67 | - Eric Hontz 68 | - Felipe Bivort Haiek 69 | - Florestan Ziem 70 | - Gilbert Shih 71 | - Harry Adams 72 | - Ivan Carvalho 73 | - Jake Lishman 74 | - Jevon Longdell 75 | - Johannes Feist 76 | - Jonas Hoersch 77 | - Jonas Neergaard-Nielsen 78 | - Jonathan A. Gross 79 | - Julian Iacoponi 80 | - Kevin Fischer 81 | - Laurence Stant 82 | - Louis Tessler 83 | - Lucas Verney 84 | - Marco David 85 | - Marek 86 | - Markus Baden 87 | - Martín Sande 88 | - Mateo Laguna 89 | - Matthew O'Brien 90 | - Michael Goerz 91 | - Michael V. DePalatis 92 | - Moritz Oberhauser 93 | - Nathan Shammah 94 | - Neill Lambert 95 | - Nicolas Quesada 96 | - Nikolas Tezak 97 | - Nithin Ramu 98 | - Paul Nation 99 | - Peter Kirton 100 | - Philipp Schindler 101 | - Piotr Migdal 102 | - Rajiv-B 103 | - Ray Ganardi 104 | - Reinier Heeres 105 | - Richard Brierley 106 | - Robert Johansson 107 | - Sam Griffiths 108 | - Samesh Lakhotia 109 | - Sebastian Krämer 110 | - Shahnawaz Ahmed 111 | - Sidhant Saraogi 112 | - Simon Cross 113 | - Simon Humpohl 114 | - Simon Whalen 115 | - Stefan Krastanov 116 | - Tarun Raheja 117 | - Thomas Walker 118 | - Viacheslav Ostroukh 119 | - Vlad Negnevitsky 120 | - Wojciech Rzadkowski 121 | - Xiaodong Qi 122 | - Xiaoliang Wu 123 | - Yariv Yanay 124 | - YouWei Zhao 125 | - alex 126 | - eliegenois 127 | - essence-of-waqf 128 | - fhenneke 129 | - gecrooks 130 | - jakobjakobson13 131 | - maij 132 | - sbisw002 133 | - yuri@FreeBSD 134 | - Élie Gouzien 135 | -------------------------------------------------------------------------------- /development/development.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2021, Paul D. Nation, Robert J. Johansson & other 3 | contributors. 4 | 5 | .. _development: 6 | 7 | ************************* 8 | Development Documentation 9 | ************************* 10 | 11 | This chapter covers the development of QuTiP and its subpackages, including 12 | a roadmap for upcoming releases and ideas for future improvements. 13 | 14 | .. toctree:: 15 | :maxdepth: 3 16 | 17 | contributing.rst 18 | roadmap.rst 19 | ideas.rst 20 | docs.rst 21 | release_distribution.rst 22 | -------------------------------------------------------------------------------- /development/docs.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011 and later, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _user_guide.rst: 5 | 6 | ************************************ 7 | Working with the QuTiP Documentation 8 | ************************************ 9 | 10 | 11 | The user guide provides an overview of QuTiP's functionality. 12 | The guide is composed of individual reStructuredText (``.rst``) files which each get rendered as a webpage. 13 | Each page typically tackles one area of functionality. 14 | To learn more about how to write ``.rst`` files, it is useful to follow the `sphinx guide `_. 15 | 16 | The documentation build also utilizes a number of 17 | `Sphinx Extensions `_ 18 | including but not limited to 19 | `doctest `_, 20 | `autodoc `_, 21 | `sphinx gallery `_ and 22 | `plot `_. 23 | Additional extensions can be configured in the `conf.py `_ file. 24 | 25 | .. _directives.rst: 26 | 27 | Directives 28 | ========== 29 | 30 | There are two Sphinx directives that can be used to write code examples in the user guide: 31 | 32 | - `Doctest `_ 33 | - `Plot `_ 34 | 35 | For a more comprehensive account of the usage of each directive, please refer to their individual pages. Here we outline some general guidelines on how to these directives while making a user guide. 36 | 37 | Doctest 38 | ------- 39 | 40 | The doctest directive enables tests on interactive code examples. 41 | The simplest way to do this is by specifying a prompt along with its respective output: :: 42 | 43 | .. doctest:: 44 | 45 | >>> a = 2 46 | >>> a 47 | 2 48 | 49 | This is rendered in the documentation as follows: 50 | 51 | .. doctest:: 52 | 53 | >>> a = 2 54 | >>> a 55 | 2 56 | 57 | 58 | While specifying code examples under the ``.. doctest::`` directive, either all statements must be specified by the ``>>>`` prompt or without it. 59 | For every prompt, any potential corresponding output must be specified immediately after it. 60 | This directive is ideally used when there are a number of examples that need to be checked in quick succession. 61 | 62 | A different way to specify code examples (and test them) is using the associated ``.. testcode::`` directive which is effectively a code block: :: 63 | 64 | .. testcode:: 65 | 66 | a = 2 67 | print(a) 68 | 69 | followed by its results. 70 | The result can be specified with the ``.. testoutput::`` block: :: 71 | 72 | .. testoutput:: 73 | 74 | 2 75 | 76 | The advantage of the ``testcode`` directive is that it is a lot simpler to 77 | specify and amenable to copying the code to clipboard. Usually, tests are 78 | more easily specified with this directive as the input and output are 79 | specified in different blocks. The rendering is neater too. 80 | 81 | .. note:: 82 | The ``doctest`` and ``testcode`` directives should not be assumed to 83 | have the same namespace. 84 | 85 | **Output:** 86 | 87 | .. testcode:: 88 | 89 | a = 2 90 | print(a) 91 | 92 | .. testoutput:: 93 | 94 | 2 95 | 96 | A few notes on using the doctest extension: 97 | 98 | - By default, each ``testcode`` and ``doctest`` block is run in a fresh namespace. 99 | To share a common namespace, we can specify a common group across the blocks 100 | (within a single ``.rst`` file). For example, :: 101 | 102 | .. doctest:: [group_name] 103 | 104 | >>> a = 2 105 | 106 | can be followed by some explanation followed by another code block 107 | sharing the same namespace :: 108 | 109 | .. doctest:: [group_name] 110 | 111 | >>> print(a) 112 | 2 113 | 114 | - To only print the code blocks (or the output), use the option ``+SKIP`` to 115 | specify the block without the code being tested when running ``make doctest``. 116 | 117 | - To check the result of a ``Qobj`` output, it is useful to make sure that 118 | spacing irregularities between the expected and actual output are ignored. 119 | For that, we can use the option ``+NORMALIZE_WHITESPACE``. 120 | 121 | Plot 122 | ---- 123 | 124 | Since the doctest directive cannot render matplotlib figures, we use Matplotlib's 125 | `Plot `_ 126 | directive when rendering to LaTeX or HTML. 127 | 128 | The plot directive can also be used in the doctest format. In this case, 129 | when running doctests (which is enabled by specifying all statements with the 130 | ``>>>`` prompts), tests also include those specified under the plot directive. 131 | 132 | **Example:** 133 | :: 134 | 135 | First we specify some data: 136 | 137 | .. plot:: 138 | 139 | >>> import numpy as np 140 | >>> x = np.linspace(0, 2 * np.pi, 1000) 141 | >>> x[:10] # doctest: +NORMALIZE_WHITESPACE 142 | array([ 0. , 0.00628947, 0.01257895, 0.01886842, 0.0251579 , 143 | 0.03144737, 0.03773685, 0.04402632, 0.0503158 , 0.05660527]) 144 | 145 | 146 | .. plot:: 147 | :context: 148 | 149 | >>> import matplotlib.pyplot as plt 150 | >>> plt.plot(x, np.sin(x)) 151 | [...] 152 | 153 | Note the use of the ``NORMALIZE_WHITESPACE`` option to ensure that the 154 | multiline output matches. 155 | 156 | **Render:** 157 | 158 | 159 | .. plot:: 160 | 161 | >>> import numpy as np 162 | >>> x = np.linspace(0, 2 * np.pi, 1000) 163 | >>> x[:10] # doctest: +SKIP 164 | array([ 0. , 0.00628947, 0.01257895, 0.01886842, 0.0251579 , 165 | 0.03144737, 0.03773685, 0.04402632, 0.0503158 , 0.05660527]) 166 | >>> import matplotlib.pyplot as plt 167 | >>> plt.plot(x, np.sin(x)) 168 | [...] 169 | 170 | A few notes on using the plot directive: 171 | 172 | - A useful argument to specify in plot blocks is that of ``context`` which ensures 173 | that the code is being run in the namespace of the previous plot block within the 174 | same file. 175 | 176 | - By default, each rendered figure in one plot block (when using ``:context:``) 177 | is carried over to the next block. 178 | 179 | - When the ``context`` argument is specified with the ``reset`` option 180 | as ``:context: reset``, the namespace is reset to a new one and all figures are 181 | erased. 182 | 183 | - When the ``context`` argument is specified with the ``close-figs`` option 184 | as ``:context: reset``, the namespace is reset to a new one and all figures are 185 | erased. 186 | 187 | 188 | The Plot directive cannot be used in conjunction with Doctest because they do not 189 | share the same namespace when used in the same file. 190 | Since Plot can also be used in doctest mode, in 191 | the case where code examples require both testing and rendering figures, it is 192 | easier to use the Plot directive. To learn more about each directive, it is useful 193 | to refer to their individual pages. 194 | -------------------------------------------------------------------------------- /development/ideas.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2021, Paul D. Nation, Robert J. Johansson & other 3 | contributors. 4 | 5 | .. _development_ideas: 6 | 7 | ********************************** 8 | Ideas for future QuTiP development 9 | ********************************** 10 | 11 | This chapter covers the development of QuTiP and its subpackages, including 12 | a roadmap for upcoming releases and ideas for future improvements. 13 | 14 | .. toctree:: 15 | :maxdepth: 1 16 | 17 | ideas/qutip-interactive.rst 18 | ideas/pulse-level-quantum-circuits.rst 19 | ideas/tensorflow-data-backend.rst 20 | ideas/quantum-error-mitigation.rst 21 | ideas/heom-gpu.rst 22 | -------------------------------------------------------------------------------- /development/ideas/README: -------------------------------------------------------------------------------- 1 | This folder contains ideas for future QuTiP development. Please put 2 | each project or idea in a separate file and link to them from 3 | development/ideas.rst. 4 | -------------------------------------------------------------------------------- /development/ideas/heom-gpu.rst: -------------------------------------------------------------------------------- 1 | ********************************************************** 2 | GPU implementation of the Hierarchical Equations of Motion 3 | ********************************************************** 4 | 5 | .. contents:: Contents 6 | :local: 7 | :depth: 3 8 | 9 | The Hierarchical Equations of Motion (HEOM) method is a non-perturbative 10 | approach to simulate the evolution of the density matrix of dissipative quantum 11 | systems. The underlying equations are a system of coupled ODEs which can be run 12 | on a GPU. This will allow the study of larger systems as discussed in [1]_. The 13 | goal of this project would be to extend QuTiP's HEOM method [2]_ and implement 14 | it on a GPU. 15 | 16 | Since the method is related to simulating large, coupled ODEs, it can also be 17 | quite general and extended to other solvers. 18 | 19 | Expected outcomes 20 | ================= 21 | 22 | * A version of HEOM which runs on a GPU. 23 | * Performance comparison with the CPU version. 24 | * Implement dynamic scaling. 25 | 26 | Skills 27 | ====== 28 | 29 | * Git, python and familiarity with the Python scientific computing stack 30 | * CUDA and OpenCL knowledge 31 | 32 | Difficulty 33 | ========== 34 | 35 | * Hard 36 | 37 | Mentors 38 | ======= 39 | 40 | * Neill Lambert (nwlambert@gmail.com) 41 | * Alex Pitchford (alex.pitchford@gmail.com) 42 | * Shahnawaz Ahmed (shahnawaz.ahmed95@gmail.com) 43 | * Simon Cross (hodgestar@gmail.com) 44 | 45 | References 46 | ========== 47 | 48 | .. [1] https://pubs.acs.org/doi/abs/10.1021/ct200126d?src=recsys&journalCode=jctcce 49 | .. [2] https://arxiv.org/abs/2010.10806 50 | -------------------------------------------------------------------------------- /development/ideas/pulse-level-quantum-circuits.rst: -------------------------------------------------------------------------------- 1 | ******************************************* 2 | Pulse level description of quantum circuits 3 | ******************************************* 4 | 5 | .. contents:: Contents 6 | :local: 7 | :depth: 3 8 | 9 | The aim of this proposal is to enhance QuTiP quantum-circuit compilation 10 | features with regard to quantum information processing. While QuTiP core modules 11 | deal with dynamics simulation, there is also a module for quantum circuits 12 | simulation. The two subsequent Google Summer of Code projects, in 2019 and 2020, 13 | enhanced them in capabilities and features, allowing the simulation both at the 14 | level of gates and at the level of time evolution. To connect them, a compiler 15 | is implemented to compile quantum gates into the Hamiltonian model. We would 16 | like to further enhance this feature in QuTiP and the connection with other 17 | libraries. 18 | 19 | Expected outcomes 20 | ================= 21 | 22 | * APIs to import and export pulses to other libraries. Quantum compiler is a 23 | current research topic in quantum engineering. Although QuTiP has a simple 24 | compiler, many may want to try their own compiler which is more compatible 25 | with their quantum device. Allowing importation and exportation of control 26 | pulses will make this much easier. This will include a study of existing 27 | libraries, such as `qiskit.pulse` and `OpenPulse` [1]_, comparing them with 28 | `qutip.qip.pulse` module and building a more general and comprehensive 29 | description of the pulse. 30 | 31 | * More examples of quantum system in the `qutip.qip.device` module. The circuit 32 | simulation and compilation depend strongly on the physical system. At the 33 | moment, we have two models: spin chain and cavity QED. We would like to 34 | include some other commonly used planform such as Superconducting system [2]_, 35 | Ion trap system [3]_ or silicon system. Each model will need a new set of 36 | control Hamiltonian and a compiler that finds the control pulse of a quantum 37 | gate. More involved noise models can also be added based on the physical 38 | system. This part is going to involve some physics and study of commonly used 39 | hardware platforms. The related code can be found in `qutip.qip.device` and 40 | `qutip.qip.compiler`. 41 | 42 | Skills 43 | ====== 44 | 45 | * Git, Python and familiarity with the Python scientific computing stack 46 | * quantum information processing and quantum computing (quantum circuit formalism) 47 | 48 | Difficulty 49 | ========== 50 | 51 | * Medium 52 | 53 | Mentors 54 | ======= 55 | 56 | * Boxi Li (etamin1201@gmail.com) [QuTiP GSoC 2019 graduate] 57 | * Nathan Shammah (nathan.shammah@gmail.com) 58 | * Alex Pitchford (alex.pitchford@gmail.com) 59 | 60 | References 61 | ========== 62 | 63 | .. [1] McKay D C, Alexander T, Bello L, et al. Qiskit backend specifications for openqasm and openpulse experiments[J]. arXiv preprint arXiv:1809.03452, 2018. 64 | 65 | .. [2] Häffner H, Roos C F, Blatt R, **Quantum computing with trapped ions**, Physics reports, 2008, 469(4): 155-203. 66 | 67 | .. [3] Krantz P, Kjaergaard M, Yan F, et al. **A quantum engineer's guide to superconducting qubits**, Applied Physics Reviews, 2019, 6(2): 021318. 68 | -------------------------------------------------------------------------------- /development/ideas/quantum-error-mitigation.rst: -------------------------------------------------------------------------------- 1 | ************************ 2 | Quantum Error Mitigation 3 | ************************ 4 | 5 | .. contents:: Contents 6 | :local: 7 | :depth: 3 8 | 9 | From the QuTiP 4.5 release, the qutip.qip module now contains the noisy quantum 10 | circuit simulator (which was a GSoC project) providing enhanced features for a 11 | pulse-level description of quantum circuits and noise models. A new class 12 | `Processor` and several subclasses are added to represent different platforms 13 | for quantum computing. They can transfer a quantum circuit into the 14 | corresponding control sequence and simulate the dynamics with QuTiP solvers. 15 | Different noise models can be added to `qutip.qip.noise` to simulate noise in a 16 | quantum device. 17 | 18 | This module is still young and many features can be improved, including new 19 | device models, new noise models and integration with the existing general 20 | framework for quantum circuits (`qutip.qip.circuit`). There are also possible 21 | applications such as error mitigation techniques ([1]_, [2]_, [3]_). 22 | 23 | The tutorial notebooks can be found at http://qutip.org/tutorials.html#nisq. A 24 | recent presentation on the FOSDEM conference may help you get an overview 25 | (https://fosdem.org/2020/schedule/event/quantum_qutip/). See also the Github 26 | Project page for a collection of related issues and ongoing Pull Requests. 27 | 28 | Expected outcomes 29 | ================= 30 | 31 | - Make an overview of existing libraries and features in error mitigation, 32 | similarly to a literature survey for a research article, but for a code 33 | project (starting from Refs. [4]_, [5]_). This is done in order to best 34 | integrate the features in QuTiP with existing libraries and avoid 35 | reinventing the wheel. 36 | - Features to perform error mitigation techniques in QuTiP, such as zero-noise 37 | extrapolation by pulse stretching. 38 | - Tutorials implementing basic quantum error mitigation protocols 39 | - Possible integration with Mitiq [6]_ 40 | 41 | Skills 42 | ====== 43 | 44 | * Background in quantum physics and quantum circuits. 45 | * Git, python and familiarity with the Python scientific computing stack 46 | 47 | Difficulty 48 | ========== 49 | 50 | * Medium 51 | 52 | Mentors 53 | ======= 54 | 55 | * Nathan Shammah (nathan.shammah@gmail.com) 56 | * Alex Pitchford (alex.pitchford@gmail.com) 57 | * Eric Giguère (eric.giguere@usherbrooke.ca) 58 | * Neill Lambert (nwlambert@gmail.com) 59 | * Boxi Li (etamin1201@gmail.com) [QuTiP GSoC 2019 graduate] 60 | 61 | References 62 | ========== 63 | 64 | .. [1] Kristan Temme, Sergey Bravyi, Jay M. Gambetta, **Error mitigation for short-depth quantum circuits**, Phys. Rev. Lett. 119, 180509 (2017) 65 | 66 | .. [2] Abhinav Kandala, Kristan Temme, Antonio D. Corcoles, Antonio Mezzacapo, Jerry M. Chow, Jay M. Gambetta, 67 | **Extending the computational reach of a noisy superconducting quantum processor**, Nature *567*, 491 (2019) 68 | 69 | .. [3] S. Endo, S.C. Benjamin, Y. Li, **Practical quantum error mitigation for near-future applications**, Physical Review X *8*, 031027 (2018) 70 | 71 | .. [4] Boxi Li's blog on the GSoC 2019 project on pulse-level control, https://gsoc2019-boxili.blogspot.com/ 72 | 73 | .. [5] Video of a recent talk on the GSoC 2019 project, https://fosdem.org/2020/schedule/event/quantum_qutip/ 74 | 75 | .. [6] `Mitiq `_ 76 | -------------------------------------------------------------------------------- /development/ideas/qutip-interactive.rst: -------------------------------------------------------------------------------- 1 | ***************** 2 | QuTiP Interactive 3 | ***************** 4 | 5 | .. contents:: Contents 6 | :local: 7 | :depth: 3 8 | 9 | QuTiP is pretty simple to use at an entry level for anyone with basic Python 10 | skills. However, *some* Python skills are necessary. A graphical user interface 11 | (GUI) for some parts of qutip could help make qutip more accessible. This could 12 | be particularly helpful in education, for teachers and learners. 13 | 14 | Ideally, interactive components could be embedded in web pages. Including, but 15 | not limited to, Jupyter notebooks. 16 | 17 | The scope for this is broad and flexible. Ideas including, but not limited to: 18 | 19 | Interactive Bloch sphere 20 | ------------------------ 21 | 22 | QuTiP has a Bloch sphere virtualisation for qubit states. This could be made 23 | interactive through sliders, radio buttons, cmd buttons etc. An interactive 24 | Bloch sphere could have sliders for qubit state angles. Buttons to add states, 25 | toggle state evolution path. Potential for recording animations. Matplotlib has 26 | some interactive features (sliders, radio buttons, cmd buttons) that can be used 27 | to control parameters. that could potentially be used. 28 | 29 | Interactive solvers 30 | ------------------- 31 | 32 | Options to configure dynamics generators (Lindbladian / Hamiltonian args etc) 33 | and expectation operators. Then run solver and view state evolution. 34 | 35 | Animated circuits 36 | ----------------- 37 | 38 | QIP circuits could be animated. Status lights showing evolution of states during 39 | the processing. Animated Bloch spheres for qubits. 40 | 41 | Expected outcomes 42 | ================= 43 | 44 | * Interactive graphical components for demonstrating quantum dynamics 45 | * Web pages for qutip.org or Jupyter notebooks introducing quantum dynamics 46 | using the new components 47 | 48 | Skills 49 | ====== 50 | 51 | * Git, Python and familiarity with the Python scientific computing stack 52 | * elementary understanding of quantum dynamics 53 | 54 | Difficulty 55 | ========== 56 | 57 | * Variable 58 | 59 | Mentors 60 | ======= 61 | 62 | * Nathan Shammah (nathan.shammah@gmail.com) 63 | * Alex Pitchford (alex.pitchford@gmail.com) 64 | * Simon Cross (hodgestar@gmail.com) 65 | * Boxi Li (etamin1201@gmail.com) [QuTiP GSoC 2019 graduate] 66 | -------------------------------------------------------------------------------- /development/ideas/tensorflow-data-backend.rst: -------------------------------------------------------------------------------- 1 | *********************** 2 | TensorFlow Data Backend 3 | *********************** 4 | 5 | .. contents:: Contents 6 | :local: 7 | :depth: 3 8 | 9 | QuTiP's data layer provides the mathematical operations needed to work with 10 | quantum states and operators, i.e. ``Qobj``, inside QuTiP. As part of Google 11 | Summer of Code 2020, the data layer was rewritten to allow new backends to 12 | be added more easily and for different backends to interoperate with each 13 | other. Backends using in-memory spares and dense matrices already exist, 14 | and we would like to add a backend that implements the necessary operations 15 | using TensorFlow [1]_. 16 | 17 | Why a TensorFlow backend? 18 | ------------------------- 19 | 20 | TensorFlow supports distributing matrix operations across multiple GPUs and 21 | multiple machines, and abstracts away some of the complexities of doing so 22 | efficiently. We hope that by using TensorFlow we might enable QuTiP to scale 23 | to bigger quantum systems (e.g. more qubits) and decrease the time taken to 24 | simulate them. 25 | 26 | There is particular interest in trying the new backend with the 27 | BoFiN HEOM (Hierarchical Equations of Motion) solver [2]_. 28 | 29 | Challenges 30 | ---------- 31 | 32 | TensorFlow is a very different kind of computational framework to the existing 33 | dense and sparse matrix backends. It uses flow graphs to describe operations, 34 | and to work efficiently. Ideally large graphs of operations need to be 35 | executed together in order to efficiently compute results. 36 | 37 | The QuTiP data layer might need to be adjusted to accommodate these 38 | differences, and it is possible that this will prove challenging or even 39 | that we will not find a reasonable way to achieve the desired performance. 40 | 41 | Expected outcomes 42 | ================= 43 | 44 | * Add a ``qutip.core.data.tensorflow`` data type. 45 | * Implement specialisations for some important operations (e.g. ``add``, 46 | ``mul``, ``matmul``, ``eigen``, etc). 47 | * Write a small benchmark to show how ``Qobj`` operations scale on the new 48 | backend in comparison to the existing backends. Run the benchmark both 49 | with and without using a GPU. 50 | * Implement enough for a solver to run on top of the new TensorFlow data 51 | backend and benchmark that (stretch goal). 52 | 53 | Skills 54 | ====== 55 | 56 | * Git, Python and familiarity with the Python scientific computing stack 57 | * Familiarity with TensorFlow (beneficial, but not required) 58 | * Familiarity with Cython (beneficial, but not required) 59 | 60 | Difficulty 61 | ========== 62 | 63 | * Medium 64 | 65 | Mentors 66 | ======= 67 | 68 | * Simon Cross (hodgestar@gmail.com) 69 | * Jake Lishman (jake@binhbar.com) 70 | * Alex Pitchford (alex.pitchford@gmail.com) 71 | 72 | References 73 | ========== 74 | 75 | .. [1] https://www.tensorflow.org/ 76 | .. [2] https://github.com/tehruhn/bofin 77 | -------------------------------------------------------------------------------- /figures/NumFocus_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/NumFocus_logo.png -------------------------------------------------------------------------------- /figures/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/about.png -------------------------------------------------------------------------------- /figures/bloch_decay.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/bloch_decay.mp4 -------------------------------------------------------------------------------- /figures/citing/bibtex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/citing/bibtex.png -------------------------------------------------------------------------------- /figures/citing/qutip.bib: -------------------------------------------------------------------------------- 1 | @article{Johansson20121760, 2 | title = "QuTiP: An open-source Python framework for the dynamics of open quantum systems", 3 | journal = "Computer Physics Communications", 4 | volume = "183", 5 | number = "8", 6 | pages = "1760 - 1772", 7 | year = "2012", 8 | note = "", 9 | issn = "0010-4655", 10 | doi = "10.1016/j.cpc.2012.02.021", 11 | url = "http://www.sciencedirect.com/science/article/pii/S0010465512000835", 12 | author = "J.R. Johansson and P.D. Nation and Franco Nori", 13 | keywords = "Open quantum systems", 14 | keywords = "Lindblad master equation", 15 | keywords = "Quantum Monte Carlo", 16 | keywords = "Python" 17 | } 18 | 19 | -------------------------------------------------------------------------------- /figures/citing/qutip2.bib: -------------------------------------------------------------------------------- 1 | @article{Johansson20131234, 2 | title = "QuTiP 2: A Python framework for the dynamics of open quantum systems", 3 | journal = "Computer Physics Communications", 4 | volume = "184", 5 | number = "4", 6 | pages = "1234 - 1240", 7 | year = "2013", 8 | note = "", 9 | issn = "0010-4655", 10 | doi = "10.1016/j.cpc.2012.11.019", 11 | url = "http://www.sciencedirect.com/science/article/pii/S0010465512003955", 12 | author = "J.R. Johansson and P.D. Nation and Franco Nori", 13 | keywords = "Open quantum systems", 14 | keywords = "Lindblad", 15 | keywords = "Bloch–Redfield", 16 | keywords = "Floquet–Markov", 17 | keywords = "Master equation", 18 | keywords = "Quantum Monte Carlo", 19 | keywords = "Python" 20 | } -------------------------------------------------------------------------------- /figures/citing/us.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/citing/us.png -------------------------------------------------------------------------------- /figures/demos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/demos.png -------------------------------------------------------------------------------- /figures/documentation/developer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/documentation/developer.png -------------------------------------------------------------------------------- /figures/documentation/online.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/documentation/online.png -------------------------------------------------------------------------------- /figures/documentation/pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/documentation/pdf.png -------------------------------------------------------------------------------- /figures/download/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/download/arrow.png -------------------------------------------------------------------------------- /figures/download/gz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/download/gz.png -------------------------------------------------------------------------------- /figures/download/zip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/download/zip.png -------------------------------------------------------------------------------- /figures/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/favicon.ico -------------------------------------------------------------------------------- /figures/features/docs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/features/docs.png -------------------------------------------------------------------------------- /figures/features/dynamics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/features/dynamics.png -------------------------------------------------------------------------------- /figures/features/mc_performance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/features/mc_performance.png -------------------------------------------------------------------------------- /figures/features/me_performance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/features/me_performance.png -------------------------------------------------------------------------------- /figures/features/multiprocessing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/features/multiprocessing.png -------------------------------------------------------------------------------- /figures/features/ninja.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/features/ninja.png -------------------------------------------------------------------------------- /figures/features/schcat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/features/schcat.png -------------------------------------------------------------------------------- /figures/features/sparse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/features/sparse.png -------------------------------------------------------------------------------- /figures/home/multiprocessing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/home/multiprocessing.png -------------------------------------------------------------------------------- /figures/home/visitors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/home/visitors.png -------------------------------------------------------------------------------- /figures/inst_quant_sher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/inst_quant_sher.png -------------------------------------------------------------------------------- /figures/jsps.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/jsps.jpg -------------------------------------------------------------------------------- /figures/korea-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/korea-logo.png -------------------------------------------------------------------------------- /figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/logo.png -------------------------------------------------------------------------------- /figures/nav/citing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/citing.png -------------------------------------------------------------------------------- /figures/nav/citing_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/citing_red.png -------------------------------------------------------------------------------- /figures/nav/documentation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/documentation.png -------------------------------------------------------------------------------- /figures/nav/documentation_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/documentation_red.png -------------------------------------------------------------------------------- /figures/nav/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/download.png -------------------------------------------------------------------------------- /figures/nav/download_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/download_red.png -------------------------------------------------------------------------------- /figures/nav/end_spacer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/end_spacer.png -------------------------------------------------------------------------------- /figures/nav/features.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/features.png -------------------------------------------------------------------------------- /figures/nav/features_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/features_red.png -------------------------------------------------------------------------------- /figures/nav/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/home.png -------------------------------------------------------------------------------- /figures/nav/home_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/home_red.png -------------------------------------------------------------------------------- /figures/nav/qutip2_header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/qutip2_header.png -------------------------------------------------------------------------------- /figures/nav/qutip_header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/qutip_header.png -------------------------------------------------------------------------------- /figures/nav/spacer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/spacer.png -------------------------------------------------------------------------------- /figures/nav/support.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/support.png -------------------------------------------------------------------------------- /figures/nav/support_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/support_red.png -------------------------------------------------------------------------------- /figures/nav/updates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/updates.png -------------------------------------------------------------------------------- /figures/nav/updates_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/nav/updates_red.png -------------------------------------------------------------------------------- /figures/qip/illustration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/qip/illustration.png -------------------------------------------------------------------------------- /figures/qip/processor-noise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/qip/processor-noise.png -------------------------------------------------------------------------------- /figures/qip/processor-workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/qip/processor-workflow.png -------------------------------------------------------------------------------- /figures/qip/quantum_circuit_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/qip/quantum_circuit_example.png -------------------------------------------------------------------------------- /figures/qip/quantum_circuit_w_state.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/qip/quantum_circuit_w_state.png -------------------------------------------------------------------------------- /figures/qip/workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/qip/workflow.png -------------------------------------------------------------------------------- /figures/qustar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/qustar.png -------------------------------------------------------------------------------- /figures/qutip_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/qutip_logo.png -------------------------------------------------------------------------------- /figures/release_guide_after_workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/release_guide_after_workflow.png -------------------------------------------------------------------------------- /figures/release_guide_run_build_workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/release_guide_run_build_workflow.png -------------------------------------------------------------------------------- /figures/riken-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/riken-logo.png -------------------------------------------------------------------------------- /figures/support/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/support/arrow.png -------------------------------------------------------------------------------- /figures/support/brain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/support/brain.png -------------------------------------------------------------------------------- /figures/support/discussion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/support/discussion.png -------------------------------------------------------------------------------- /figures/support/issue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/support/issue.png -------------------------------------------------------------------------------- /figures/support/manual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/support/manual.png -------------------------------------------------------------------------------- /figures/support/paul.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/support/paul.png -------------------------------------------------------------------------------- /figures/support/rob.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/support/rob.png -------------------------------------------------------------------------------- /figures/unitaryfund_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/unitaryfund_logo.png -------------------------------------------------------------------------------- /figures/updates/blog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/updates/blog.png -------------------------------------------------------------------------------- /figures/wide_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/figures/wide_logo.png -------------------------------------------------------------------------------- /frontmatter.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011 and later, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _frontmatter: 5 | 6 | ************* 7 | Frontmatter 8 | ************* 9 | 10 | .. _about-docs: 11 | 12 | About This Documentation 13 | ========================== 14 | 15 | This document contains a user guide and automatically generated API documentation for QuTiP. A PDF version of this text is available at the `documentation page `_. 16 | 17 | **For more information see the** `QuTiP project web page`_. 18 | 19 | .. _QuTiP project web page: http://www.qutip.org 20 | 21 | 22 | :Author: J.R. Johansson 23 | 24 | :Author: P.D. Nation 25 | 26 | :Author: Alexander Pitchford 27 | 28 | :Author: Arne Grimsmo 29 | 30 | :Author: Chris Grenade 31 | 32 | :Author: Nathan Shammah 33 | 34 | :Author: Shahnawaz Ahmed 35 | 36 | :Author: Neill Lambert 37 | 38 | :Author: Eric Giguere 39 | 40 | :Author: Boxi Li 41 | 42 | :Author: Jake Lishman 43 | 44 | :version: |version| 45 | 46 | :copyright: This documentation is licensed under the Creative Commons Attribution 3.0 Unported License. 47 | 48 | .. _citing-qutip: 49 | 50 | Citing This Project 51 | ========================== 52 | 53 | If you find this project useful, then please cite: 54 | 55 | .. centered:: J. R. Johansson, P.D. Nation, and F. Nori, "QuTiP 2: A Python framework for the dynamics of open quantum systems", Comp. Phys. Comm. **184**, 1234 (2013). 56 | 57 | or 58 | 59 | .. centered:: J. R. Johansson, P.D. Nation, and F. Nori, "QuTiP: An open-source Python framework for the dynamics of open quantum systems", Comp. Phys. Comm. **183**, 1760 (2012). 60 | 61 | 62 | which may also be downloaded from http://arxiv.org/abs/1211.6518 or http://arxiv.org/abs/1110.0573, respectively. 63 | 64 | .. _funding-qutip: 65 | 66 | Funding 67 | ======= 68 | QuTiP is developed under the auspice of the non-profit organizations: 69 | 70 | .. _image-numfocus: 71 | 72 | .. figure:: figures/NumFocus_logo.png 73 | :width: 3in 74 | :figclass: align-center 75 | 76 | .. _image-unitaryfund: 77 | 78 | .. figure:: figures/unitaryfund_logo.png 79 | :width: 3in 80 | :figclass: align-center 81 | 82 | QuTiP was partially supported by 83 | 84 | .. _image-jsps: 85 | 86 | .. figure:: figures/jsps.jpg 87 | :width: 2in 88 | :figclass: align-center 89 | 90 | .. _image-riken: 91 | 92 | .. figure:: figures/riken-logo.png 93 | :width: 1.5in 94 | :figclass: align-center 95 | 96 | .. _image-korea: 97 | 98 | .. figure:: figures/korea-logo.png 99 | :width: 2in 100 | :figclass: align-center 101 | 102 | .. figure:: figures/inst_quant_sher.png 103 | :width: 2in 104 | :figclass: align-center 105 | 106 | .. _about: 107 | 108 | About QuTiP 109 | =========== 110 | 111 | Every quantum system encountered in the real world is an open quantum system. For although much care is taken experimentally to eliminate the unwanted influence of external interactions, there remains, if ever so slight, a coupling between the system of interest and the external world. In addition, any measurement performed on the system necessarily involves coupling to the measuring device, therefore introducing an additional source of external influence. Consequently, developing the necessary tools, both theoretical and numerical, to account for the interactions between a system and its environment is an essential step in understanding the dynamics of practical quantum systems. 112 | 113 | In general, for all but the most basic of Hamiltonians, an analytical description of the system dynamics is not possible, and one must resort to numerical simulations of the equations of motion. In absence of a quantum computer, these simulations must be carried out using classical computing techniques, where the exponentially increasing dimensionality of the underlying Hilbert space severely limits the size of system that can be efficiently simulated. However, in many fields such as quantum optics, trapped ions, superconducting circuit devices, and most recently nanomechanical systems, it is possible to design systems using a small number of effective oscillator and spin components, excited by a limited number of quanta, that are amenable to classical simulation in a truncated Hilbert space. 114 | 115 | The Quantum Toolbox in Python, or QuTiP, is an open-source framework written in the Python programming language, designed for simulating the open quantum dynamics of systems such as those listed above. This framework distinguishes itself from other available software solutions in providing the following advantages: 116 | 117 | * QuTiP relies entirely on open-source software. You are free to modify and use it as you wish with no licensing fees or limitations. 118 | 119 | * QuTiP is based on the Python scripting language, providing easy to read, fast code generation without the need to compile after modification. 120 | 121 | * The numerics underlying QuTiP are time-tested algorithms that run at C-code speeds, thanks to the `Numpy `_, `Scipy `_, and `Cython `_ libraries, and are based on many of the same algorithms used in propriety software. 122 | 123 | * QuTiP allows for solving the dynamics of Hamiltonians with (almost) arbitrary time-dependence, including collapse operators. 124 | 125 | * Time-dependent problems can be automatically compiled into C++-code at run-time for increased performance. 126 | 127 | * Takes advantage of the multiple processing cores found in essentially all modern computers. 128 | 129 | * QuTiP was designed from the start to require a minimal learning curve for those users who have experience using the popular quantum optics toolbox by Sze M. Tan. 130 | 131 | * Includes the ability to create high-quality plots, and animations, using the excellent `Matplotlib `_ package. 132 | 133 | 134 | For detailed information about new features of each release of QuTiP, see the :ref:`changelog`. 135 | 136 | .. _plugin-qutip: 137 | 138 | QuTiP Plugins 139 | ============= 140 | 141 | Several libraries depend on QuTiP heavily making QuTiP a super-library 142 | 143 | :Matsubara: `Matsubara `_ is a plugin to study the ultrastrong coupling regime with structured baths 144 | 145 | :QNET: `QNET `_ is a computer algebra package for quantum mechanics and photonic quantum networks 146 | 147 | .. _libraries: 148 | 149 | Libraries Using QuTiP 150 | ===================== 151 | 152 | Several libraries rely on QuTiP for quantum physics or quantum information processing. Some of them are: 153 | 154 | :Krotov: `Krotov `_ focuses on the python implementation of Krotov's method for quantum optimal control 155 | 156 | :pyEPR: `pyEPR `_ interfaces classical distributed microwave analysis with that of quantum structures and hamiltonians by providing easy to use analysis function and automation for the design of quantum chips 157 | 158 | :scQubits: `scQubits `_ is a Python library which provides a convenient way to simulate superconducting qubits by providing an interface to QuTiP 159 | 160 | :SimulaQron: `SimulaQron `_ is a distributed simulation of the end nodes in a quantum internet with the specific goal to explore application development 161 | 162 | :QInfer: `QInfer `_ is a library for working with sequential Monte Carlo methods for parameter estimation in quantum information 163 | 164 | :QPtomographer: `QPtomographer `_ derive quantum error bars for quantum processes in terms of the diamond norm to a reference quantum channel 165 | 166 | :QuNetSim: `QuNetSim `_ is a quantum networking simulation framework to develop and test protocols for quantum networks 167 | 168 | :qupulse: `qupulse `_ is a toolkit to facilitate experiments involving pulse driven state manipulation of physical qubits 169 | 170 | 171 | 172 | 173 | Contributing to QuTiP 174 | ===================== 175 | 176 | We welcome anyone who is interested in helping us make QuTiP the best package for simulating quantum systems. 177 | There are :ref:`detailed instructions on how to contribute code and documentation ` in the developers' section of this guide. 178 | You can also help out our users by answering questions in the `QuTiP discussion mailing list `_, or by raising issues in `the main GitHub repository `_ if you find any bugs. 179 | Anyone who contributes code will be duly recognized. 180 | Even small contributions are noted. 181 | See :ref:`developers-contributors` for a list of people who have helped in one way or another. 182 | -------------------------------------------------------------------------------- /gallery/src/README.rst: -------------------------------------------------------------------------------- 1 | Gallery 2 | ======= 3 | 4 | This is the gallery for QuTiP examples, you can click on the image to see the source code. -------------------------------------------------------------------------------- /gallery/src/qip/README.txt: -------------------------------------------------------------------------------- 1 | Quantum Information Processing 2 | ------------------------------ 3 | -------------------------------------------------------------------------------- /gallery/src/qip/plot_qip_amplitude_noise.py: -------------------------------------------------------------------------------- 1 | """ 2 | Control Amplitude Noise 3 | ======================= 4 | 5 | This example demonstrates how to add Gaussian noise to the control pulse. 6 | """ 7 | import numpy as np 8 | import matplotlib.pyplot as plt 9 | from qutip.qip.device import Processor 10 | from qutip.qip.noise import RandomNoise 11 | from qutip.operators import sigmaz, sigmay 12 | 13 | # add control Hamiltonians 14 | processor = Processor(N=1) 15 | processor.add_control(sigmaz(), targets=0) 16 | 17 | # define pulse coefficients and tlist for all pulses 18 | processor.pulses[0].coeff = np.array([0.3, 0.5, 0. ]) 19 | processor.set_all_tlist(np.array([0., np.pi/2., 2*np.pi/2, 3*np.pi/2])) 20 | 21 | # define noise, loc and scale are keyword arguments for np.random.normal 22 | gaussnoise = RandomNoise( 23 | dt=0.01, rand_gen=np.random.normal, loc=0.00, scale=0.02) 24 | processor.add_noise(gaussnoise) 25 | 26 | # Plot the ideal pulse 27 | processor.plot_pulses(title="Original control amplitude", figsize=(5,3)) 28 | 29 | # Plot the noisy pulse 30 | qobjevo, _ = processor.get_qobjevo(noisy=True) 31 | noisy_coeff = qobjevo.to_list()[1][1] + qobjevo.to_list()[2][1] 32 | fig2, ax2 = processor.plot_pulses(title="Noisy control amplitude", figsize=(5,3)) 33 | ax2[0].step(qobjevo.tlist, noisy_coeff) 34 | -------------------------------------------------------------------------------- /gallery/src/qip/plot_qip_intro_processor.py: -------------------------------------------------------------------------------- 1 | """ 2 | Basic use of Processor 3 | ============================= 4 | 5 | This example contains the basic functions of :class:`qutip.qip.device.Processor.` We define a simulator with control Hamiltonian, pulse amplitude and time slice for each pulse. The two figures illustrate the pulse shape for two different setup: step function or continuous pulse. 6 | """ 7 | import copy 8 | import numpy as np 9 | import matplotlib.pyplot as plt 10 | pi = np.pi 11 | from qutip.qip.device import Processor 12 | from qutip.operators import sigmaz 13 | from qutip.states import basis 14 | 15 | processor = Processor(N=1) 16 | processor.add_control(sigmaz(), targets=0) 17 | 18 | tlist = np.linspace(0., 2*np.pi, 20) 19 | processor = Processor(N=1, spline_kind="step_func") 20 | processor.add_control(sigmaz(), 0) 21 | processor.pulses[0].tlist = tlist 22 | processor.pulses[0].coeff = np.array([np.sin(t) for t in tlist]) 23 | processor.plot_pulses() 24 | 25 | tlist = np.linspace(0., 2*np.pi, 20) 26 | processor = Processor(N=1, spline_kind="cubic") 27 | processor.add_control(sigmaz()) 28 | processor.pulses[0].tlist = tlist 29 | processor.pulses[0].coeff = np.array([np.sin(t) for t in tlist]) 30 | processor.plot_pulses() 31 | -------------------------------------------------------------------------------- /gallery/src/qip/plot_qip_relaxation.py: -------------------------------------------------------------------------------- 1 | """ 2 | T2 Relaxation 3 | ============= 4 | 5 | Simulating the T2 relaxation of a single qubit with :class:`qutip.qip.device.Processor`. The single qubit is driven by a rotation around z axis. We measure the population of the plus state as a function of time to see the Ramsey signal. 6 | """ 7 | import numpy as np 8 | import matplotlib.pyplot as plt 9 | from qutip.qip.device import Processor 10 | from qutip.operators import sigmaz, destroy 11 | from qutip.qip.operations import snot 12 | from qutip.states import basis 13 | 14 | a = destroy(2) 15 | Hadamard = snot() 16 | plus_state = (basis(2,1) + basis(2,0)).unit() 17 | tlist = np.arange(0.00, 20.2, 0.2) 18 | 19 | T2 = 5 20 | processor = Processor(1, t2=T2) 21 | processor.add_control(sigmaz()) 22 | processor.pulses[0].coeff = np.ones(len(tlist)) 23 | processor.pulses[0].tlist = tlist 24 | result = processor.run_state( 25 | plus_state, e_ops=[a.dag()*a, Hadamard*a.dag()*a*Hadamard]) 26 | 27 | fig, ax = plt.subplots() 28 | # detail about length of tlist needs to be fixed 29 | ax.plot(tlist[:-1], result.expect[1][:-1], '.', label="simulation") 30 | ax.plot(tlist[:-1], np.exp(-1./T2*tlist[:-1])*0.5 + 0.5, label="theory") 31 | ax.set_xlabel("t") 32 | ax.set_ylabel("Ramsey signal") 33 | ax.legend() 34 | ax.set_title("Relaxation T2=5") 35 | ax.grid() 36 | fig.tight_layout() 37 | fig.show() -------------------------------------------------------------------------------- /guide/doc/qutip_tree.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/guide/doc/qutip_tree.pdf -------------------------------------------------------------------------------- /guide/dynamics/dynamics-data.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _solver_result: 5 | 6 | ******************************************************** 7 | Dynamics Simulation Results 8 | ******************************************************** 9 | 10 | .. _solver_result-class: 11 | 12 | The solver.Result Class 13 | ======================= 14 | 15 | Before embarking on simulating the dynamics of quantum systems, we will first look at the data structure used for returning the simulation results to the user. This object is a :func:`qutip.solver.Result` class that stores all the crucial data needed for analyzing and plotting the results of a simulation. Like the :func:`qutip.Qobj` class, the ``Result`` class has a collection of properties for storing information. However, in contrast to the ``Qobj`` class, this structure contains no methods, and is therefore nothing but a container object. A generic ``Result`` object ``result`` contains the following properties for storing simulation data: 16 | 17 | .. cssclass:: table-striped 18 | 19 | +------------------------+-----------------------------------------------------------------------+ 20 | | Property | Description | 21 | +========================+=======================================================================+ 22 | | ``result.solver`` | String indicating which solver was used to generate the data. | 23 | +------------------------+-----------------------------------------------------------------------+ 24 | | ``result.times`` | List/array of times at which simulation data is calculated. | 25 | +------------------------+-----------------------------------------------------------------------+ 26 | | ``result.expect`` | List/array of expectation values, if requested. | 27 | +------------------------+-----------------------------------------------------------------------+ 28 | | ``result.states`` | List/array of state vectors/density matrices calculated at ``times``, | 29 | | | if requested. | 30 | +------------------------+-----------------------------------------------------------------------+ 31 | | ``result.num_expect`` | The number of expectation value operators in the simulation. | 32 | +------------------------+-----------------------------------------------------------------------+ 33 | | ``result.num_collapse``| The number of collapse operators in the simulation. | 34 | +------------------------+-----------------------------------------------------------------------+ 35 | | ``result.ntraj`` | Number of Monte Carlo trajectories run. | 36 | +------------------------+-----------------------------------------------------------------------+ 37 | | ``result.col_times`` | Times at which state collapse occurred. Only for Monte Carlo solver. | 38 | +------------------------+-----------------------------------------------------------------------+ 39 | | ``result.col_which`` | Which collapse operator was responsible for each collapse in | 40 | | | in ``col_times``. Only used by Monte Carlo solver. | 41 | +------------------------+-----------------------------------------------------------------------+ 42 | | ``result.seeds`` | Seeds used in generating random numbers for Monte Carlo solver. | 43 | +------------------------+-----------------------------------------------------------------------+ 44 | 45 | 46 | .. _odedata-access: 47 | 48 | Accessing Result Data 49 | ====================== 50 | 51 | To understand how to access the data in a Result object we will use an example as a guide, although we do not worry about the simulation details at this stage. Like all solvers, the Monte Carlo solver used in this example returns an Result object, here called simply ``result``. To see what is contained inside ``result`` we can use the print function: 52 | 53 | .. doctest:: 54 | :options: +SKIP 55 | 56 | >>> print(result) 57 | Result object with mcsolve data. 58 | --------------------------------- 59 | expect = True 60 | num_expect = 2, num_collapse = 2, ntraj = 500 61 | 62 | The first line tells us that this data object was generated from the Monte Carlo solver ``mcsolve`` (discussed in :ref:`monte`). The next line (not the ``---`` line of course) indicates that this object contains expectation value data. Finally, the last line gives the number of expectation value and collapse operators used in the simulation, along with the number of Monte Carlo trajectories run. Note that the number of trajectories ``ntraj`` is only displayed when using the Monte Carlo solver. 63 | 64 | Now we have all the information needed to analyze the simulation results. 65 | To access the data for the two expectation values one can do: 66 | 67 | 68 | .. testcode:: 69 | :skipif: True 70 | 71 | expt0 = result.expect[0] 72 | expt1 = result.expect[1] 73 | 74 | Recall that Python uses C-style indexing that begins with zero (i.e., [0] => 1st collapse operator data). Together with the array of times at which these expectation values are calculated: 75 | 76 | .. testcode:: 77 | :skipif: True 78 | 79 | times = result.times 80 | 81 | we can plot the resulting expectation values: 82 | 83 | .. testcode:: 84 | :skipif: True 85 | 86 | plot(times, expt0, times, expt1) 87 | show() 88 | 89 | 90 | State vectors, or density matrices, as well as ``col_times`` and ``col_which``, are accessed in a similar manner, although typically one does not need an index (i.e [0]) since there is only one list for each of these components. The one exception to this rule is if you choose to output state vectors from the Monte Carlo solver, in which case there are ``ntraj`` number of state vector arrays. 91 | 92 | .. _odedata-saving: 93 | 94 | Saving and Loading Result Objects 95 | ================================== 96 | 97 | The main advantage in using the Result class as a data storage object comes from the simplicity in which simulation data can be stored and later retrieved. The :func:`qutip.fileio.qsave` and :func:`qutip.fileio.qload` functions are designed for this task. To begin, let us save the ``data`` object from the previous section into a file called "cavity+qubit-data" in the current working directory by calling: 98 | 99 | .. testcode:: 100 | :skipif: True 101 | 102 | qsave(result, 'cavity+qubit-data') 103 | 104 | All of the data results are then stored in a single file of the same name with a ".qu" extension. Therefore, everything needed to later this data is stored in a single file. Loading the file is just as easy as saving: 105 | 106 | .. doctest:: 107 | :options: +SKIP 108 | 109 | >>> stored_result = qload('cavity+qubit-data') 110 | Loaded Result object: 111 | Result object with mcsolve data. 112 | --------------------------------- 113 | expect = True 114 | num_expect = 2, num_collapse = 2, ntraj = 500 115 | 116 | where ``stored_result`` is the new name of the Result object. We can then extract the data and plot in the same manner as before: 117 | 118 | .. testcode:: 119 | :skipif: True 120 | 121 | expt0 = stored_result.expect[0] 122 | expt1 = stored_result.expect[1] 123 | times = stored_result.times 124 | plot(times, expt0, times, expt1) 125 | show() 126 | 127 | Also see :ref:`saving` for more information on saving quantum objects, as well as arrays for use in other programs. 128 | -------------------------------------------------------------------------------- /guide/dynamics/dynamics-options.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _options: 5 | 6 | ********************************************* 7 | Setting Options for the Dynamics Solvers 8 | ********************************************* 9 | 10 | .. testsetup:: [dynamics_options] 11 | 12 | from qutip import Options 13 | 14 | import numpy as np 15 | 16 | Occasionally it is necessary to change the built in parameters of the dynamics solvers used by for example the :func:`qutip.mesolve` and :func:`qutip.mcsolve` functions. The options for all dynamics solvers may be changed by using the Options class :class:`qutip.solver.Options`. 17 | 18 | .. testcode:: [dynamics_options] 19 | 20 | options = Options() 21 | 22 | the properties and default values of this class can be view via the `print` function: 23 | 24 | .. testcode:: [dynamics_options] 25 | 26 | print(options) 27 | 28 | **Output**: 29 | 30 | .. testoutput:: [dynamics_options] 31 | :options: +NORMALIZE_WHITESPACE 32 | 33 | Options: 34 | ----------- 35 | atol: 1e-08 36 | rtol: 1e-06 37 | method: adams 38 | order: 12 39 | nsteps: 1000 40 | first_step: 0 41 | min_step: 0 42 | max_step: 0 43 | tidy: True 44 | num_cpus: 2 45 | norm_tol: 0.001 46 | norm_steps: 5 47 | rhs_filename: None 48 | rhs_reuse: False 49 | seeds: 0 50 | rhs_with_state: False 51 | average_expect: True 52 | average_states: False 53 | ntraj: 500 54 | store_states: False 55 | store_final_state: False 56 | 57 | These properties are detailed in the following table. Assuming ``options = Options()``: 58 | 59 | .. cssclass:: table-striped 60 | 61 | +-----------------------------+-----------------+----------------------------------------------------------------+ 62 | | Property | Default setting | Description | 63 | +=============================+=================+================================================================+ 64 | | options.atol | 1e-8 | Absolute tolerance | 65 | +-----------------------------+-----------------+----------------------------------------------------------------+ 66 | | options.rtol | 1e-6 | Relative tolerance | 67 | +-----------------------------+-----------------+----------------------------------------------------------------+ 68 | | options.method | 'adams' | Solver method. Can be 'adams' (non-stiff) or 'bdf' (stiff) | 69 | +-----------------------------+-----------------+----------------------------------------------------------------+ 70 | | options.order | 12 | Order of solver. Must be <=12 for 'adams' and <=5 for 'bdf' | 71 | +-----------------------------+-----------------+----------------------------------------------------------------+ 72 | | options.nsteps | 1000 | Max. number of steps to take for each interval | 73 | +-----------------------------+-----------------+----------------------------------------------------------------+ 74 | | options.first_step | 0 | Size of initial step. 0 = determined automatically by solver. | 75 | +-----------------------------+-----------------+----------------------------------------------------------------+ 76 | | options.min_step | 0 | Minimum step size. 0 = determined automatically by solver. | 77 | +-----------------------------+-----------------+----------------------------------------------------------------+ 78 | | options.max_step | 0 | Maximum step size. 0 = determined automatically by solver. | 79 | +-----------------------------+-----------------+----------------------------------------------------------------+ 80 | | options.tidy | True | Whether to run tidyup function on time-independent Hamiltonian.| 81 | +-----------------------------+-----------------+----------------------------------------------------------------+ 82 | | options.store_final_state | False | Whether or not to store the final state of the evolution. | 83 | +-----------------------------+-----------------+----------------------------------------------------------------+ 84 | | options.store_states | False | Whether or not to store the state vectors or density matrices. | 85 | +-----------------------------+-----------------+----------------------------------------------------------------+ 86 | | options.rhs_filename | None | RHS filename when using compiled time-dependent Hamiltonians. | 87 | +-----------------------------+-----------------+----------------------------------------------------------------+ 88 | | options.rhs_reuse | False | Reuse compiled RHS function. Useful for repetitive tasks. | 89 | +-----------------------------+-----------------+----------------------------------------------------------------+ 90 | | options.rhs_with_state | False | Whether or not to include the state in the Hamiltonian | 91 | | | | function callback signature. | 92 | +-----------------------------+-----------------+----------------------------------------------------------------+ 93 | | options.num_cpus | installed num | Integer number of cpus used by mcsolve. | 94 | | | of processors | | 95 | +-----------------------------+-----------------+----------------------------------------------------------------+ 96 | | options.seeds | None | Array containing random number seeds for mcsolver. | 97 | +-----------------------------+-----------------+----------------------------------------------------------------+ 98 | | options.norm_tol | 1e-6 | Tolerance used when finding wavefunction norm in mcsolve. | 99 | +-----------------------------+-----------------+----------------------------------------------------------------+ 100 | | options.norm_steps | 5 | Max. number of steps used to find wavefunction's norm to within| 101 | | | | norm_tol in mcsolve. | 102 | +-----------------------------+-----------------+----------------------------------------------------------------+ 103 | | options.steady_state_average| False | Include an estimation of the steady state in mcsolve. | 104 | +-----------------------------+-----------------+----------------------------------------------------------------+ 105 | | options.ntraj | 500 | Number of trajectories in stochastic solvers. | 106 | +-----------------------------+-----------------+----------------------------------------------------------------+ 107 | | options.average_expect | True | Average expectation values over trajectories. | 108 | +-----------------------------+-----------------+----------------------------------------------------------------+ 109 | | options.average_states | False | Average of the states over trajectories. | 110 | +-----------------------------+-----------------+----------------------------------------------------------------+ 111 | | options.openmp_threads | installed num | Number of OPENMP threads to use. | 112 | | | of processors | | 113 | +-----------------------------+-----------------+----------------------------------------------------------------+ 114 | | options.use_openmp | None | Use OPENMP for sparse matrix vector multiplication. | 115 | +-----------------------------+-----------------+----------------------------------------------------------------+ 116 | 117 | As an example, let us consider changing the number of processors used, turn the GUI off, and strengthen the absolute tolerance. There are two equivalent ways to do this using the Options class. First way, 118 | 119 | .. testcode:: [dynamics_options] 120 | 121 | options = Options() 122 | options.num_cpus = 3 123 | options.atol = 1e-10 124 | 125 | or one can use an inline method, 126 | 127 | .. testcode:: [dynamics_options] 128 | 129 | options = Options(num_cpus=4, atol=1e-10) 130 | 131 | Note that the order in which you input the options does not matter. Using either method, the resulting `options` variable is now: 132 | 133 | .. testcode:: [dynamics_options] 134 | 135 | print(options) 136 | 137 | **Output**: 138 | 139 | .. testoutput:: [dynamics_options] 140 | :options: +NORMALIZE_WHITESPACE 141 | 142 | Options: 143 | ----------- 144 | atol: 1e-10 145 | rtol: 1e-06 146 | method: adams 147 | order: 12 148 | nsteps: 1000 149 | first_step: 0 150 | min_step: 0 151 | max_step: 0 152 | tidy: True 153 | num_cpus: 4 154 | norm_tol: 0.001 155 | norm_steps: 5 156 | rhs_filename: None 157 | rhs_reuse: False 158 | seeds: 0 159 | rhs_with_state: False 160 | average_expect: True 161 | average_states: False 162 | ntraj: 500 163 | store_states: False 164 | store_final_state: False 165 | 166 | 167 | 168 | To use these new settings we can use the keyword argument ``options`` in either the func:`qutip.mesolve` and :func:`qutip.mcsolve` function. We can modify the last example as:: 169 | 170 | >>> mesolve(H0, psi0, tlist, c_op_list, [sigmaz()], options=options) 171 | >>> mesolve(hamiltonian_t, psi0, tlist, c_op_list, [sigmaz()], H_args, options=options) 172 | 173 | or:: 174 | 175 | >>> mcsolve(H0, psi0, tlist, ntraj,c_op_list, [sigmaz()], options=options) 176 | >>> mcsolve(hamiltonian_t, psi0, tlist, ntraj, c_op_list, [sigmaz()], H_args, options=options) 177 | -------------------------------------------------------------------------------- /guide/dynamics/dynamics-photocurrent.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _stochastic_photo: 5 | 6 | ******************************** 7 | Stochastic Solver - Photocurrent 8 | ******************************** 9 | 10 | .. _photocurrent-intro: 11 | 12 | Photocurrent method, like monte-carlo method, allows for simulating an 13 | individual realization of the system evolution under continuous measurement. 14 | 15 | Closed system 16 | ------------- 17 | 18 | .. photocurent_Schrodinger_equation 19 | 20 | Photocurrent evolution have the state evolve deterministically between quantum jumps. 21 | During the deterministic part, the system evolve by schrodinger equation with a 22 | non-hermitian, norm conserving effective Hamiltonian. 23 | 24 | .. math:: 25 | :label: pssesolve_heff 26 | 27 | H_{\rm eff}=H_{\rm sys}+ 28 | \frac{i\hbar}{2}\left( -\sum_{n}C^{+}_{n}C_{n}+ |C_{n} \psi |^2\right). 29 | 30 | With :math:`C_{n}`, the collapse operators. 31 | This effective Hamiltonian is equivalent to the monte-carlo effective 32 | Hamiltonian with an extra term to keep the state normalized. 33 | At each time step of :math:`\delta t`, the wave function has a probability 34 | 35 | .. math:: 36 | :label: pssesolve_jump_prob 37 | 38 | \delta p_{n} = \left<\psi(t)|C_{n}^{+}C_{n}|\psi(t)\right> \delta t 39 | 40 | of making a quantum jump. :math:`\delta t` must be chosen small enough to keep 41 | that probability small :math:`\delta p << 1`. *If multiple jumps happen at the 42 | same time step, the state become unphysical.* 43 | Each jump result in a sharp variation of the state by, 44 | 45 | .. math:: 46 | :label: pssesolve_jump 47 | 48 | \delta \psi = \left( \frac{C_n \psi} {\left| C_n \psi \right|} - \psi \right) 49 | 50 | The basic photocurrent method directly integrates these equations to the first-order. 51 | Starting from a state :math:`\left|\psi(0)\right>`, it evolves the state according to 52 | 53 | .. math:: 54 | :label: pssesolve_sde 55 | 56 | \delta \psi(t) = - i H_{\rm sys} \psi(t) \delta t + \sum_n \left( 57 | -\frac{C_n^{+} C_n}{2} \psi(t) \delta t 58 | + \frac{ \left| C_n \psi \right| ^2}{2} \delta t 59 | + \delta N_n \left( \frac{C_n \psi} 60 | {\left| C_n \psi \right|} - \psi \right)\right), 61 | 62 | for each time-step. 63 | Here :math:`\delta N = 1` with a probability of :math:`\delta \omega` and 64 | :math:`\delta N_n = 0` with a probability of :math:`1-\delta \omega`. 65 | 66 | Trajectories obtained with this algorithm are equivalent to those obtained with 67 | monte-carlo evolution (up to :math:`O(\delta t^2)`). 68 | In most cases, :func:`qutip.mcsolve` is more efficient than 69 | :func:`qutip.photocurrent_sesolve`. 70 | 71 | Open system 72 | ----------- 73 | .. photocurent_Master_equation 74 | 75 | Photocurrent approach allows to obtain trajectories for a system with 76 | both measured and dissipative interaction with the bath. 77 | The system evolves according to the master equation between jumps with a modified 78 | liouvillian 79 | 80 | .. math:: 81 | :label: master_equation 82 | 83 | L_{\rm eff}(\rho(t)) = L_{\rm sys}(\rho(t)) + 84 | \sum_{n}\left( 85 | \rm{tr} \left(C_{n}^{+}C_{n} \rho C_{n}^{+}C_{n} \right) 86 | - C_{n}^{+}C_{n} \rho C_{n}^{+}C_{n} \right), 87 | 88 | with the probability of jumps in a time step :math:`\delta t` given by 89 | 90 | .. math:: 91 | :label: psmesolve_rate 92 | 93 | \delta p = \rm{tr} \left( C \rho C^{+} \right) \delta t. 94 | 95 | After a jump, the density matrix become 96 | 97 | .. math:: 98 | 99 | \rho' = \frac{C \rho C^{+}}{\rm{tr} \left( C \rho C^{+} \right)}. 100 | 101 | The evolution of the system at each time step if thus given by 102 | 103 | .. math:: 104 | :label: psmesolve_sde 105 | 106 | \rho(t + \delta t) = \rho(t) + L_{\rm eff}(\rho) \delta t + \delta N 107 | \left(\frac{C \rho C^{+}}{\rm{tr} \left( C \rho C^{+} \right)} - \rho \right). 108 | -------------------------------------------------------------------------------- /guide/dynamics/dynamics-piqs.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _master-piqs: 5 | 6 | ********************************* 7 | Permutational Invariance 8 | ********************************* 9 | 10 | .. _master-unitary-piqs: 11 | 12 | Permutational Invariant Quantum Solver (PIQS) 13 | ============================================= 14 | The *Permutational Invariant Quantum Solver (PIQS)* is a QuTiP module that allows to study the dynamics of an open quantum system consisting of an ensemble of identical qubits that can dissipate through local and collective baths according to a Lindblad master equation. 15 | 16 | The Liouvillian of an ensemble of :math:`N` qubits, or two-level systems (TLSs), :math:`\mathcal{D}_{TLS}(\rho)`, can be built using only polynomial – instead of exponential – resources. 17 | This has many applications for the study of realistic quantum optics models of many TLSs and in general as a tool in cavity QED. 18 | 19 | Consider a system evolving according to the equation 20 | 21 | .. math:: 22 | \dot{\rho} = \mathcal{D}_\text{TLS}(\rho)=-\frac{i}{\hbar}\lbrack H,\rho \rbrack 23 | +\frac{\gamma_\text{CE}}{2}\mathcal{L}_{J_{-}}[\rho] 24 | +\frac{\gamma_\text{CD}}{2}\mathcal{L}_{J_{z}}[\rho] 25 | +\frac{\gamma_\text{CP}}{2}\mathcal{L}_{J_{+}}[\rho] 26 | 27 | +\sum_{n=1}^{N}\left( 28 | \frac{\gamma_\text{E}}{2}\mathcal{L}_{J_{-,n}}[\rho] 29 | +\frac{\gamma_\text{D}}{2}\mathcal{L}_{J_{z,n}}[\rho] 30 | +\frac{\gamma_\text{P}}{2}\mathcal{L}_{J_{+,n}}[\rho]\right) 31 | 32 | 33 | where :math:`J_{\alpha,n}=\frac{1}{2}\sigma_{\alpha,n}` are SU(2) Pauli spin operators, with :math:`{\alpha=x,y,z}` and :math:`J_{\pm,n}=\sigma_{\pm,n}`. The collective spin operators are :math:`J_{\alpha} = \sum_{n}J_{\alpha,n}` . The Lindblad super-operators are :math:`\mathcal{L}_{A} = 2A\rho A^\dagger - A^\dagger A \rho - \rho A^\dagger A`. 34 | 35 | The inclusion of local processes in the dynamics lead to using a Liouvillian space of dimension :math:`4^N`. By exploiting the permutational invariance of identical particles [2-8], the Liouvillian :math:`\mathcal{D}_\text{TLS}(\rho)` can be built as a block-diagonal matrix in the basis of Dicke states :math:`|j, m \rangle`. 36 | 37 | The system under study is defined by creating an object of the 38 | :code:`Dicke` class, e.g. simply named 39 | :code:`system`, whose first attribute is 40 | 41 | - :code:`system.N`, the number of TLSs of the system :math:`N`. 42 | 43 | The rates for collective and local processes are simply defined as 44 | 45 | - :code:`collective_emission` defines :math:`\gamma_\text{CE}`, collective (superradiant) emission 46 | - :code:`collective_dephasing` defines :math:`\gamma_\text{CD}`, collective dephasing 47 | - :code:`collective_pumping` defines :math:`\gamma_\text{CP}`, collective pumping. 48 | - :code:`emission` defines :math:`\gamma_\text{E}`, incoherent emission (losses) 49 | - :code:`dephasing` defines :math:`\gamma_\text{D}`, local dephasing 50 | - :code:`pumping` defines :math:`\gamma_\text{P}`, incoherent pumping. 51 | 52 | Then the :code:`system.lindbladian()` creates the total TLS Lindbladian superoperator matrix. Similarly, :code:`system.hamiltonian` defines the TLS hamiltonian of the system :math:`H_\text{TLS}`. 53 | 54 | The system's Liouvillian can be built using :code:`system.liouvillian()`. The properties of a Piqs object can be visualized by simply calling 55 | :code:`system`. We give two basic examples on the use of *PIQS*. In the first example the incoherent emission of N driven TLSs is considered. 56 | 57 | .. code-block:: python 58 | 59 | from piqs import Dicke 60 | from qutip import steadystate 61 | N = 10 62 | system = Dicke(N, emission = 1, pumping = 2) 63 | L = system.liouvillian() 64 | steady = steadystate(L) 65 | 66 | For more example of use, see the "Permutational Invariant Lindblad Dynamics" section in the tutorials section of the website, `http://qutip.org/tutorials.html `_. 67 | 68 | .. list-table:: Useful PIQS functions. 69 | :widths: 25 25 50 70 | :header-rows: 1 71 | 72 | * - Operators 73 | - Command 74 | - Description 75 | * - Collective spin algebra :math:`J_x,\ J_y,\ J_z` 76 | - ``jspin(N)`` 77 | - The collective spin algebra :math:`J_x,\ J_y,\ J_z` for :math:`N` TLSs 78 | * - Collective spin :math:`J_x` 79 | - ``jspin(N, "x")`` 80 | - The collective spin operator :math:`Jx`. Requires :math:`N` number of TLSs 81 | * - Collective spin :math:`J_y` 82 | - ``jspin(N, "y")`` 83 | - The collective spin operator :math:`J_y`. Requires :math:`N` number of TLSs 84 | * - Collective spin :math:`J_z` 85 | - ``jspin(N, "z")`` 86 | - The collective spin operator :math:`J_z`. Requires :math:`N` number of TLSs 87 | * - Collective spin :math:`J_+` 88 | - ``jspin(N, "+")`` 89 | - The collective spin operator :math:`J_+`. 90 | * - Collective spin :math:`J_-` 91 | - ``jspin(N, "-")`` 92 | - The collective spin operator :math:`J_-`. 93 | * - Collective spin :math:`J_z` in uncoupled basis 94 | - ``jspin(N, "z", basis='uncoupled')`` 95 | - The collective spin operator :math:`J_z` in the uncoupled basis of dimension :math:`2^N`. 96 | * - Dicke state :math:`|j,m\rangle` density matrix 97 | - ``dicke(N, j, m)`` 98 | - The density matrix for the Dicke state given by :math:`|j,m\rangle` 99 | * - Excited-state density matrix in Dicke basis 100 | - ``excited(N)`` 101 | - The excited state in the Dicke basis 102 | * - Excited-state density matrix in uncoupled basis 103 | - ``excited(N, basis="uncoupled")`` 104 | - The excited state in the uncoupled basis 105 | * - Ground-state density matrix in Dicke basis 106 | - ``ground(N)`` 107 | - The ground state in the Dicke basis 108 | * - GHZ-state density matrix in the Dicke basis 109 | - ``ghz(N)`` 110 | - The GHZ-state density matrix in the Dicke (default) basis for N number of TLS 111 | * - Collapse operators of the ensemble 112 | - ``Dicke.c_ops()`` 113 | - The collapse operators for the ensemble can be called by the `c_ops` method of the Dicke class. 114 | 115 | Note that the mathematical object representing the density matrix of the full system that is manipulated (or obtained from `steadystate`) in the Dicke-basis formalism used here is a *representative of the density matrix*. This *representative object* is of linear size N^2, whereas the full density matrix is defined over a 2^N Hilbert space. In order to calculate nonlinear functions of such density matrix, such as the Von Neumann entropy or the purity, it is necessary to take into account the degeneracy of each block of such block-diagonal density matrix. Note that as long as one calculates expected values of operators, being Tr[A*rho] a *linear* function of `rho`, the *representative density matrix* give straightforwardly the correct result. When a *nonlinear* function of the density matrix needs to be calculated, one needs to weigh each degenerate block correctly; this is taken care by the `dicke_function_trace` in `qutip.piqs`, and the user can use it to define general nonlinear functions that can be described as the trace of a Taylor expandable function. Two nonlinear functions that use `dicke_function_trace` and are already implemented are `purity_dicke`, to calculate the purity of a density matrix in the Dicke basis, and `entropy_vn_dicke`, which can be used to calculate the Von Neumann entropy. 116 | 117 | More functions relative to the `qutip.piqs` module can be found at :ref:`apidoc`. Attributes to the :class:`qutip.piqs.Dicke` and :class:`qutip.piqs.Pim` class can also be found there. 118 | -------------------------------------------------------------------------------- /guide/dynamics/dynamics-stochastic.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _stochastic: 5 | 6 | ******************************************* 7 | Stochastic Solver 8 | ******************************************* 9 | 10 | .. _stochastic-intro: 11 | 12 | Homodyne detection 13 | ================== 14 | Homodyne detection is an extension of the photocurrent method where the output 15 | is mixed with a strong external source allowing to get information about the 16 | phase of the system. With this method, the resulting detection rate depends is 17 | 18 | .. math:: 19 | :label: jump_rate 20 | 21 | \tau = \tr \left((\gamma^2 + \gamma (C+C^\dag) + C^\dag C)\rho \right) 22 | 23 | With :math:`\gamma`, the strength of the external beam and :math:`C` the collapse 24 | operator. When the beam is very strong :math:`(\gamma >> C^\dag C)`, 25 | the rate becomes a constant term plus a term proportional to the quadrature of 26 | the system. 27 | 28 | Closed system 29 | ------------- 30 | .. Stochastic Schrodinger equation 31 | 32 | In closed systems, the resulting stochastic differential equation is 33 | 34 | .. math:: 35 | :label: jump_ssesolve 36 | 37 | \delta \psi(t) = - i H \psi(t) \delta t 38 | - \sum_n \left( \frac{C_n^{+} C_n}{2} -\frac{e_n}{2} C_n 39 | + \frac{e_n^2}{8} \right) \psi \delta t 40 | + \sum_n \left( C_n - \frac{e_n}{2} \right) \psi \delta \omega 41 | 42 | with 43 | 44 | .. math:: 45 | :label: jump_matrix_element 46 | 47 | e_n = \left<\psi(t)|C_n + C_n^{+}|\psi(t)\right> 48 | 49 | Here :math:`\delta \omega` is a Wiener increment. 50 | 51 | In QuTiP, this is available with the function :func:`ssesolve`. 52 | 53 | .. plot:: 54 | :context: 55 | 56 | times = np.linspace(0.0, 10.0, 201) 57 | psi0 = tensor(fock(2, 0), fock(10, 5)) 58 | a = tensor(qeye(2), destroy(10)) 59 | sm = tensor(destroy(2), qeye(10)) 60 | 61 | H = 2*np.pi*a.dag()*a + 2*np.pi*sm.dag()*sm + 2*np.pi*0.25*(sm*a.dag() + sm.dag()*a) 62 | data = ssesolve(H, psi0, times, sc_ops=[np.sqrt(0.1) * a], e_ops=[a.dag()*a, sm.dag()*sm], method="homodyne") 63 | 64 | plt.figure() 65 | plt.plot(times, data.expect[0], times, data.expect[1]) 66 | plt.title('Homodyne time evolution') 67 | plt.xlabel('Time') 68 | plt.ylabel('Expectation values') 69 | plt.legend(("cavity photon number", "atom excitation probability")) 70 | plt.show() 71 | 72 | 73 | Open system 74 | -------------- 75 | .. Stochastic Master equation 76 | 77 | In open systems, 2 types of collapse operators are considered, :math:`S_i` 78 | represent the dissipation in the environment, :math:`C_i` are monitored operators. 79 | The deterministic part of the evolution is the liouvillian with both types of 80 | collapses 81 | 82 | .. math:: 83 | :label: liouvillian 84 | 85 | L(\rho(t)) = - i[H(t),\rho(t)] 86 | + \sum_n D(S_n, \rho) 87 | + \sum_i D(C_i, \rho), 88 | 89 | with 90 | 91 | .. math:: 92 | :label: disipator 93 | 94 | D(C, \rho) = \frac{1}{2} \left[2 C \rho(t) C^{+} 95 | - \rho(t) C^{+} C - C^{+} C \rho(t) \right]. 96 | 97 | The stochastic part is given by 98 | 99 | .. math:: 100 | :label: stochastic_smesolve 101 | 102 | d_2 = \left(C \rho(t) + \rho(t) C^{+} - \rm{tr}\left(C \times \rho 103 | + \rho \times C^{+} \right)\rho(t) \right), 104 | 105 | resulting in the stochastic differential equation 106 | 107 | .. math:: 108 | :label: sde_smesolve 109 | 110 | \delta \rho(t) = L(\rho(t)) \delta t + d_2 \delta \omega 111 | 112 | The function :func:`smesolve` covert these cases in QuTiP. 113 | 114 | Heterodyne detection 115 | -------------------- 116 | With heterodyne detection, two measurements are made in order to obtain 117 | information about 2 orthogonal quadratures at once. 118 | -------------------------------------------------------------------------------- /guide/figures/bloch3d+data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/guide/figures/bloch3d+data.png -------------------------------------------------------------------------------- /guide/figures/bloch3d+points.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/guide/figures/bloch3d+points.png -------------------------------------------------------------------------------- /guide/figures/bloch3d-blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/guide/figures/bloch3d-blank.png -------------------------------------------------------------------------------- /guide/figures/qtrl-code_object_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/guide/figures/qtrl-code_object_model.png -------------------------------------------------------------------------------- /guide/figures/quant_optim_ctrl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/guide/figures/quant_optim_ctrl.png -------------------------------------------------------------------------------- /guide/figures/qutip_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/guide/figures/qutip_tree.png -------------------------------------------------------------------------------- /guide/guide-correlation.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _correlation: 5 | 6 | ****************************** 7 | Two-time correlation functions 8 | ****************************** 9 | 10 | With the QuTiP time-evolution functions (for example :func:`qutip.mesolve` and :func:`qutip.mcsolve`), a state vector or density matrix can be evolved from an initial state at :math:`t_0` to an arbitrary time :math:`t`, :math:`\rho(t)=V(t, t_0)\left\{\rho(t_0)\right\}`, where :math:`V(t, t_0)` is the propagator defined by the equation of motion. The resulting density matrix can then be used to evaluate the expectation values of arbitrary combinations of *same-time* operators. 11 | 12 | To calculate *two-time* correlation functions on the form :math:`\left`, we can use the quantum regression theorem (see, e.g., [Gar03]_) to write 13 | 14 | .. math:: 15 | 16 | \left = {\rm Tr}\left[A V(t+\tau, t)\left\{B\rho(t)\right\}\right] 17 | = {\rm Tr}\left[A V(t+\tau, t)\left\{BV(t, 0)\left\{\rho(0)\right\}\right\}\right] 18 | 19 | We therefore first calculate :math:`\rho(t)=V(t, 0)\left\{\rho(0)\right\}` using one of the QuTiP evolution solvers with :math:`\rho(0)` as initial state, and then again use the same solver to calculate :math:`V(t+\tau, t)\left\{B\rho(t)\right\}` using :math:`B\rho(t)` as initial state. 20 | 21 | Note that if the initial state is the steady state, then :math:`\rho(t)=V(t, 0)\left\{\rho_{\rm ss}\right\}=\rho_{\rm ss}` and 22 | 23 | .. math:: 24 | 25 | \left = {\rm Tr}\left[A V(t+\tau, t)\left\{B\rho_{\rm ss}\right\}\right] 26 | = {\rm Tr}\left[A V(\tau, 0)\left\{B\rho_{\rm ss}\right\}\right] = \left, 27 | 28 | which is independent of :math:`t`, so that we only have one time coordinate :math:`\tau`. 29 | 30 | QuTiP provides a family of functions that assists in the process of calculating two-time correlation functions. The available functions and their usage is shown in the table below. Each of these functions can use one of the following evolution solvers: Master-equation, Exponential series and the Monte-Carlo. The choice of solver is defined by the optional argument ``solver``. 31 | 32 | .. cssclass:: table-striped 33 | 34 | +----------------------------------------------+--------------------------------------------------+ 35 | | QuTiP function | Correlation function | 36 | +==============================================+==================================================+ 37 | | | :math:`\left` or | 38 | | :func:`qutip.correlation.correlation_2op_2t` | :math:`\left`. | 39 | +----------------------------------------------+--------------------------------------------------+ 40 | | | :math:`\left` or | 41 | | :func:`qutip.correlation.correlation_2op_1t` | :math:`\left`. | 42 | +----------------------------------------------+--------------------------------------------------+ 43 | | :func:`qutip.correlation.correlation_3op_1t` | :math:`\left`. | 44 | +----------------------------------------------+--------------------------------------------------+ 45 | | :func:`qutip.correlation.correlation_3op_2t` | :math:`\left`. | 46 | +----------------------------------------------+--------------------------------------------------+ 47 | 48 | The most common use-case is to calculate correlation functions of the kind :math:`\left`, in which case we use the correlation function solvers that start from the steady state, e.g., the :func:`qutip.correlation.correlation_2op_1t` function. These correlation function solvers return a vector or matrix (in general complex) with the correlations as a function of the delays times. 49 | 50 | .. _correlation-steady: 51 | 52 | Steadystate correlation function 53 | ================================ 54 | 55 | The following code demonstrates how to calculate the :math:`\left` correlation for a leaky cavity with three different relaxation rates. 56 | 57 | .. plot:: 58 | :context: 59 | 60 | times = np.linspace(0,10.0,200) 61 | a = destroy(10) 62 | x = a.dag() + a 63 | H = a.dag() * a 64 | 65 | corr1 = correlation_2op_1t(H, None, times, [np.sqrt(0.5) * a], x, x) 66 | corr2 = correlation_2op_1t(H, None, times, [np.sqrt(1.0) * a], x, x) 67 | corr3 = correlation_2op_1t(H, None, times, [np.sqrt(2.0) * a], x, x) 68 | 69 | plt.figure() 70 | plt.plot(times, np.real(corr1), times, np.real(corr2), times, np.real(corr3)) 71 | plt.legend(['0.5','1.0','2.0']) 72 | plt.xlabel(r'Time $t$') 73 | plt.ylabel(r'Correlation $\left$') 74 | plt.show() 75 | 76 | 77 | Emission spectrum 78 | ================= 79 | 80 | Given a correlation function :math:`\left` we can define the corresponding power spectrum as 81 | 82 | .. math:: 83 | 84 | S(\omega) = \int_{-\infty}^{\infty} \left e^{-i\omega\tau} d\tau. 85 | 86 | In QuTiP, we can calculate :math:`S(\omega)` using either :func:`qutip.correlation.spectrum_ss`, which first calculates the correlation function using one of the time-dependent solvers and then performs the Fourier transform semi-analytically, or we can use the function :func:`qutip.correlation.spectrum_correlation_fft` to numerically calculate the Fourier transform of a given correlation data using FFT. 87 | 88 | The following example demonstrates how these two functions can be used to obtain the emission power spectrum. 89 | 90 | .. plot:: guide/scripts/spectrum_ex1.py 91 | :width: 5.0in 92 | :include-source: 93 | 94 | .. _correlation-spectrum: 95 | 96 | 97 | Non-steadystate correlation function 98 | ==================================== 99 | 100 | More generally, we can also calculate correlation functions of the kind :math:`\left`, i.e., the correlation function of a system that is not in its steadystate. In QuTiP, we can evoluate such correlation functions using the function :func:`qutip.correlation.correlation_2op_2t`. The default behavior of this function is to return a matrix with the correlations as a function of the two time coordinates (:math:`t_1` and :math:`t_2`). 101 | 102 | .. plot:: guide/scripts/correlation_ex2.py 103 | :width: 5.0in 104 | :include-source: 105 | 106 | However, in some cases we might be interested in the correlation functions on the form :math:`\left`, but only as a function of time coordinate :math:`t_2`. In this case we can also use the :func:`qutip.correlation.correlation_2op_2t` function, if we pass the density matrix at time :math:`t_1` as second argument, and `None` as third argument. The :func:`qutip.correlation.correlation_2op_2t` function then returns a vector with the correlation values corresponding to the times in `taulist` (the fourth argument). 107 | 108 | Example: first-order optical coherence function 109 | ----------------------------------------------- 110 | 111 | This example demonstrates how to calculate a correlation function on the form :math:`\left` for a non-steady initial state. Consider an oscillator that is interacting with a thermal environment. If the oscillator initially is in a coherent state, it will gradually decay to a thermal (incoherent) state. The amount of coherence can be quantified using the first-order optical coherence function :math:`g^{(1)}(\tau) = \frac{\left}{\sqrt{\left\left}}`. For a coherent state :math:`|g^{(1)}(\tau)| = 1`, and for a completely incoherent (thermal) state :math:`g^{(1)}(\tau) = 0`. The following code calculates and plots :math:`g^{(1)}(\tau)` as a function of :math:`\tau`. 112 | 113 | .. plot:: guide/scripts/correlation_ex3.py 114 | :width: 5.0in 115 | :include-source: 116 | 117 | For convenience, the steps for calculating the first-order coherence function have been collected in the function :func:`qutip.correlation.coherence_function_g1`. 118 | 119 | Example: second-order optical coherence function 120 | ------------------------------------------------ 121 | 122 | The second-order optical coherence function, with time-delay :math:`\tau`, is defined as 123 | 124 | .. math:: 125 | 126 | \displaystyle g^{(2)}(\tau) = \frac{\langle a^\dagger(0)a^\dagger(\tau)a(\tau)a(0)\rangle}{\langle a^\dagger(0)a(0)\rangle^2} 127 | 128 | For a coherent state :math:`g^{(2)}(\tau) = 1`, for a thermal state :math:`g^{(2)}(\tau=0) = 2` and it decreases as a function of time (bunched photons, they tend to appear together), and for a Fock state with :math:`n` photons :math:`g^{(2)}(\tau = 0) = n(n - 1)/n^2 < 1` and it increases with time (anti-bunched photons, more likely to arrive separated in time). 129 | 130 | To calculate this type of correlation function with QuTiP, we can use :func:`qutip.correlation.correlation_3op_1t`, which computes a correlation function on the form :math:`\left` (three operators, one delay-time vector). 131 | We first have to combine the central two operators into one single one as they are evaluated at the same time, e.g. here we do :math:`a^\dagger(\tau)a(\tau) = (a^\dagger a)(\tau)`. 132 | 133 | The following code calculates and plots :math:`g^{(2)}(\tau)` as a function of :math:`\tau` for a coherent, thermal and fock state. 134 | 135 | .. plot:: guide/scripts/correlation_ex4.py 136 | :width: 5.0in 137 | :include-source: 138 | 139 | For convenience, the steps for calculating the second-order coherence function have been collected in the function :func:`qutip.correlation.coherence_function_g2`. 140 | -------------------------------------------------------------------------------- /guide/guide-dynamics.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _dynamics: 5 | 6 | ****************************************** 7 | Time Evolution and Quantum System Dynamics 8 | ****************************************** 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | dynamics/dynamics-data.rst 14 | dynamics/dynamics-master.rst 15 | dynamics/dynamics-monte.rst 16 | dynamics/dynamics-photocurrent.rst 17 | dynamics/dynamics-stochastic.rst 18 | dynamics/dynamics-time.rst 19 | dynamics/dynamics-bloch-redfield.rst 20 | dynamics/dynamics-floquet.rst 21 | dynamics/dynamics-piqs.rst 22 | dynamics/dynamics-options.rst 23 | -------------------------------------------------------------------------------- /guide/guide-overview.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2013, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _overview: 5 | 6 | ****************** 7 | Guide Overview 8 | ****************** 9 | 10 | The goal of this guide is to introduce you to the basic structures and functions that make up QuTiP. This guide is divided up into several sections, each highlighting a specific set of functionalities. In combination with the examples that can be found on the project web page `http://qutip.org/tutorials.html `_, this guide should provide a more or less complete overview. In addition, the :ref:`apidoc` for each function is located at the end of this guide. 11 | 12 | 13 | .. _overview-org: 14 | 15 | Organization 16 | ============= 17 | 18 | QuTiP is designed to be a general framework for solving quantum mechanics problems such as systems composed of few-level quantum systems and harmonic oscillators. To this end, QuTiP is built from a large (and ever growing) library of functions and classes; from :func:`qutip.states.basis` to :func:`qutip.wigner`. The general organization of QuTiP, highlighting the important API available to the user, is shown in the figure below. 19 | 20 | 21 | .. _figure-qutip-org: 22 | 23 | .. figure:: figures/qutip_tree.png 24 | :align: center 25 | :figwidth: 100% 26 | 27 | Tree-diagram of the 468 user accessible functions and classes in QuTiP 4.6. A vector image of the code tree is in :download:`qutip_tree.pdf `. 28 | 29 | -------------------------------------------------------------------------------- /guide/guide-parfor.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _parfor: 5 | 6 | ****************************************** 7 | Parallel computation 8 | ****************************************** 9 | 10 | Parallel map and parallel for-loop 11 | ---------------------------------- 12 | 13 | Often one is interested in the output of a given function as a single-parameter is varied. For instance, we can calculate the steady-state response of our system as the driving frequency is varied. In cases such as this, where each iteration is independent of the others, we can speedup the calculation by performing the iterations in parallel. In QuTiP, parallel computations may be performed using the :func:`qutip.parallel.parallel_map` function or the :func:`qutip.parallel.parfor` (parallel-for-loop) function. 14 | 15 | To use the these functions we need to define a function of one or more variables, and the range over which one of these variables are to be evaluated. For example: 16 | 17 | 18 | .. doctest:: 19 | :skipif: not os_nt 20 | :options: +NORMALIZE_WHITESPACE 21 | 22 | >>> def func1(x): return x, x**2, x**3 23 | 24 | >>> a, b, c = parfor(func1, range(10)) 25 | 26 | >>> print(a) 27 | [0 1 2 3 4 5 6 7 8 9] 28 | 29 | >>> print(b) 30 | [ 0 1 4 9 16 25 36 49 64 81] 31 | 32 | >>> print(c) 33 | [ 0 1 8 27 64 125 216 343 512 729] 34 | 35 | or 36 | 37 | .. doctest:: 38 | :skipif: not os_nt 39 | :options: +NORMALIZE_WHITESPACE 40 | 41 | >>> result = parallel_map(func1, range(10)) 42 | 43 | >>> result_array = np.array(result) 44 | 45 | >>> print(result_array[:, 0]) # == a 46 | [0 1 2 3 4 5 6 7 8 9] 47 | 48 | >>> print(result_array[:, 1]) # == b 49 | [ 0 1 4 9 16 25 36 49 64 81] 50 | 51 | >>> print(result_array[:, 2]) # == c 52 | [ 0 1 8 27 64 125 216 343 512 729] 53 | 54 | 55 | Note that the return values are arranged differently for the :func:`qutip.parallel.parallel_map` and the :func:`qutip.parallel.parfor` functions, as illustrated below. In particular, the return value of :func:`qutip.parallel.parallel_map` is not enforced to be NumPy arrays, which can avoid unnecessary copying if all that is needed is to iterate over the resulting list: 56 | 57 | 58 | .. doctest:: 59 | :skipif: not os_nt 60 | :options: +NORMALIZE_WHITESPACE 61 | 62 | >>> result = parfor(func1, range(5)) 63 | 64 | >>> print(result) 65 | [array([0, 1, 2, 3, 4]), array([ 0, 1, 4, 9, 16]), array([ 0, 1, 8, 27, 64])] 66 | 67 | >>> result = parallel_map(func1, range(5)) 68 | 69 | >>> print(result) 70 | [(0, 0, 0), (1, 1, 1), (2, 4, 8), (3, 9, 27), (4, 16, 64)] 71 | 72 | The :func:`qutip.parallel.parallel_map` and :func:`qutip.parallel.parfor` functions are not limited to just numbers, but also works for a variety of outputs: 73 | 74 | .. doctest:: 75 | :skipif: not os_nt 76 | :options: +NORMALIZE_WHITESPACE 77 | 78 | >>> def func2(x): return x, Qobj(x), 'a' * x 79 | 80 | >>> a, b, c = parfor(func2, range(5)) 81 | 82 | >>> print(a) 83 | [0 1 2 3 4] 84 | 85 | >>> print(b) 86 | [Quantum object: dims = [[1], [1]], shape = (1, 1), type = bra 87 | Qobj data = 88 | [[0.]] 89 | Quantum object: dims = [[1], [1]], shape = (1, 1), type = bra 90 | Qobj data = 91 | [[1.]] 92 | Quantum object: dims = [[1], [1]], shape = (1, 1), type = bra 93 | Qobj data = 94 | [[2.]] 95 | Quantum object: dims = [[1], [1]], shape = (1, 1), type = bra 96 | Qobj data = 97 | [[3.]] 98 | Quantum object: dims = [[1], [1]], shape = (1, 1), type = bra 99 | Qobj data = 100 | [[4.]]] 101 | 102 | >>>print(c) 103 | ['' 'a' 'aa' 'aaa' 'aaaa'] 104 | 105 | 106 | One can also define functions with **multiple** input arguments and even keyword arguments. Here the :func:`qutip.parallel.parallel_map` and :func:`qutip.parallel.parfor` functions behaves differently: 107 | While :func:`qutip.parallel.parallel_map` only iterate over the values `arguments`, the :func:`qutip.parallel.parfor` function simultaneously iterates over all arguments: 108 | 109 | .. doctest:: 110 | :skipif: not os_nt 111 | :options: +NORMALIZE_WHITESPACE 112 | 113 | >>> def sum_diff(x, y, z=0): return x + y, x - y, z 114 | 115 | >>> parfor(sum_diff, [1, 2, 3], [4, 5, 6], z=5.0) 116 | [array([5, 7, 9]), array([-3, -3, -3]), array([5., 5., 5.])] 117 | 118 | >>> parallel_map(sum_diff, [1, 2, 3], task_args=(np.array([4, 5, 6]),), task_kwargs=dict(z=5.0)) 119 | [(array([5, 6, 7]), array([-3, -4, -5]), 5.0), 120 | (array([6, 7, 8]), array([-2, -3, -4]), 5.0), 121 | (array([7, 8, 9]), array([-1, -2, -3]), 5.0)] 122 | 123 | Note that the keyword arguments can be anything you like, but the keyword values are **not** iterated over. The keyword argument *num_cpus* is reserved as it sets the number of CPU's used by parfor. By default, this value is set to the total number of physical processors on your system. You can change this number to a lower value, however setting it higher than the number of CPU's will cause a drop in performance. In :func:`qutip.parallel.parallel_map`, keyword arguments to the task function are specified using `task_kwargs` argument, so there is no special reserved keyword arguments. 124 | 125 | The :func:`qutip.parallel.parallel_map` function also supports progressbar, using the keyword argument `progress_bar` which can be set to `True` or to an instance of :class:`qutip.ui.progressbar.BaseProgressBar`. There is a function called :func:`qutip.parallel.serial_map` that works as a non-parallel drop-in replacement for :func:`qutip.parallel.parallel_map`, which allows easy switching between serial and parallel computation. 126 | 127 | .. doctest:: 128 | :options: +SKIP 129 | 130 | >>> import time 131 | 132 | >>> def func(x): time.sleep(1) 133 | 134 | >>> result = parallel_map(func, range(50), progress_bar=True) 135 | 136 | 10.0%. Run time: 3.10s. Est. time left: 00:00:00:27 137 | 20.0%. Run time: 5.11s. Est. time left: 00:00:00:20 138 | 30.0%. Run time: 8.11s. Est. time left: 00:00:00:18 139 | 40.0%. Run time: 10.15s. Est. time left: 00:00:00:15 140 | 50.0%. Run time: 13.15s. Est. time left: 00:00:00:13 141 | 60.0%. Run time: 15.15s. Est. time left: 00:00:00:10 142 | 70.0%. Run time: 18.15s. Est. time left: 00:00:00:07 143 | 80.0%. Run time: 20.15s. Est. time left: 00:00:00:05 144 | 90.0%. Run time: 23.15s. Est. time left: 00:00:00:02 145 | 100.0%. Run time: 25.15s. Est. time left: 00:00:00:00 146 | Total run time: 28.91s 147 | 148 | Parallel processing is useful for repeated tasks such as generating plots corresponding to the dynamical evolution of your system, or simultaneously simulating different parameter configurations. 149 | 150 | 151 | IPython-based parallel_map 152 | -------------------------- 153 | 154 | When QuTiP is used with IPython interpreter, there is an alternative parallel for-loop implementation in the QuTiP module :func:`qutip.ipynbtools`, see :func:`qutip.ipynbtools.parallel_map`. The advantage of this parallel_map implementation is based on IPythons powerful framework for parallelization, so the compute processes are not confined to run on the same host as the main process. 155 | -------------------------------------------------------------------------------- /guide/guide-qip.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _qip: 5 | 6 | ****************************** 7 | Quantum Information Processing 8 | ****************************** 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | qip/qip-basics.rst 14 | qip/qip-simulator.rst 15 | qip/qip-processor.rst 16 | -------------------------------------------------------------------------------- /guide/guide-random.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _random: 5 | 6 | ******************************************** 7 | Generating Random Quantum States & Operators 8 | ******************************************** 9 | 10 | .. testsetup:: [random] 11 | 12 | from qutip import rand_herm, rand_dm, rand_super_bcsz, rand_dm_ginibre 13 | 14 | QuTiP includes a collection of random state, unitary and channel generators for simulations, Monte Carlo evaluation, theorem evaluation, and code testing. 15 | Each of these objects can be sampled from one of several different distributions including the default distributions 16 | used by QuTiP versions prior to 3.2.0. 17 | 18 | For example, a random Hermitian operator can be sampled by calling `rand_herm` function: 19 | 20 | .. doctest:: [random] 21 | :hide: 22 | 23 | >>> np.random.seed(42) 24 | 25 | .. doctest:: [random] 26 | 27 | >>> rand_herm(5) # doctest: +NORMALIZE_WHITESPACE 28 | Quantum object: dims = [[5], [5]], shape = (5, 5), type = oper, isherm = True 29 | Qobj data = 30 | [[-0.25091976+0.j 0. +0.j 0. +0.j 31 | -0.21793701+0.47037633j -0.23212846-0.61607187j] 32 | [ 0. +0.j -0.88383278+0.j 0.836086 -0.23956218j 33 | -0.09464275+0.45370863j -0.15243356+0.65392096j] 34 | [ 0. +0.j 0.836086 +0.23956218j 0.66488528+0.j 35 | -0.26290446+0.64984451j -0.52603038-0.07991553j] 36 | [-0.21793701-0.47037633j -0.09464275-0.45370863j -0.26290446-0.64984451j 37 | -0.13610996+0.j -0.34240902-0.2879303j ] 38 | [-0.23212846+0.61607187j -0.15243356-0.65392096j -0.52603038+0.07991553j 39 | -0.34240902+0.2879303j 0. +0.j ]] 40 | 41 | 42 | 43 | .. tabularcolumns:: | p{2cm} | p{3cm} | c | 44 | 45 | .. cssclass:: table-striped 46 | 47 | +-------------------------------+--------------------------------------------+------------------------------------------+ 48 | | Random Variable Type | Sampling Functions | Dimensions | 49 | +===============================+============================================+==========================================+ 50 | | State vector (``ket``) | `rand_ket`, `rand_ket_haar` | :math:`N \times 1` | 51 | +-------------------------------+--------------------------------------------+------------------------------------------+ 52 | | Hermitian operator (``oper``) | `rand_herm` | :math:`N \times 1` | 53 | +-------------------------------+--------------------------------------------+------------------------------------------+ 54 | | Density operator (``oper``) | `rand_dm`, `rand_dm_hs`, `rand_dm_ginibre` | :math:`N \times N` | 55 | +-------------------------------+--------------------------------------------+------------------------------------------+ 56 | | Unitary operator (``oper``) | `rand_unitary`, `rand_unitary_haar` | :math:`N \times N` | 57 | +-------------------------------+--------------------------------------------+------------------------------------------+ 58 | | CPTP channel (``super``) | `rand_super`, `rand_super_bcsz` | :math:`(N \times N) \times (N \times N)` | 59 | +-------------------------------+--------------------------------------------+------------------------------------------+ 60 | 61 | In all cases, these functions can be called with a single parameter :math:`N` that specifies the dimension of the relevant Hilbert space. The optional 62 | ``dims`` keyword argument allows for the dimensions of a random state, unitary or channel to be broken down into subsystems. 63 | 64 | .. doctest:: [random] 65 | 66 | >>> rand_super_bcsz(7).dims 67 | [[[7], [7]], [[7], [7]]] 68 | >>> rand_super_bcsz(6, dims=[[[2, 3], [2, 3]], [[2, 3], [2, 3]]]).dims 69 | [[[2, 3], [2, 3]], [[2, 3], [2, 3]]] 70 | 71 | Several of the distributions supported by QuTiP support additional parameters as well, namely *density* and *rank*. In particular, 72 | the `rand_herm` and `rand_dm` functions return quantum objects such that a fraction of the elements are identically equal to zero. 73 | The ratio of nonzero elements is passed as the ``density`` keyword argument. By contrast, the `rand_dm_ginibre` and 74 | `rand_super_bcsz` take as an argument the rank of the generated object, such that passing ``rank=1`` returns a random 75 | pure state or unitary channel, respectively. Passing ``rank=None`` specifies that the generated object should be 76 | full-rank for the given dimension. 77 | 78 | For example, 79 | 80 | .. doctest:: [random] 81 | :hide: 82 | 83 | >>> np.random.seed(42) 84 | 85 | .. doctest:: [random] 86 | 87 | >>> rand_dm(5, density=0.5) 88 | Quantum object: dims = [[5], [5]], shape = (5, 5), type = oper, isherm = True 89 | Qobj data = 90 | [[ 0.05157906+0.j 0.04491736+0.01043329j 0.06966148+0.00344713j 91 | 0. +0.j 0.04031493-0.01886791j] 92 | [ 0.04491736-0.01043329j 0.33632352+0.j -0.08046093+0.02954712j 93 | 0.0037455 +0.03940256j -0.05679126-0.01322392j] 94 | [ 0.06966148-0.00344713j -0.08046093-0.02954712j 0.2938209 +0.j 95 | 0.0029377 +0.04463531j 0.05318743-0.02817689j] 96 | [ 0. +0.j 0.0037455 -0.03940256j 0.0029377 -0.04463531j 97 | 0.22553181+0.j 0.01657495+0.06963845j] 98 | [ 0.04031493+0.01886791j -0.05679126+0.01322392j 0.05318743+0.02817689j 99 | 0.01657495-0.06963845j 0.09274471+0.j ]] 100 | 101 | >>> rand_dm_ginibre(5, rank=2) 102 | Quantum object: dims = [[5], [5]], shape = (5, 5), type = oper, isherm = True 103 | Qobj data = 104 | [[ 0.07318288+2.60675616e-19j 0.10426866-6.63115850e-03j 105 | -0.05377455-2.66949369e-02j -0.01623153+7.66824687e-02j 106 | -0.12255602+6.11342416e-02j] 107 | [ 0.10426866+6.63115850e-03j 0.30603789+1.44335373e-18j 108 | -0.03129486-4.16194216e-03j -0.09832531+1.74110000e-01j 109 | -0.27176358-4.84608761e-02j] 110 | [-0.05377455+2.66949369e-02j -0.03129486+4.16194216e-03j 111 | 0.07055265-8.76912454e-19j -0.0183289 -2.72720794e-02j 112 | 0.01196277-1.01037189e-01j] 113 | [-0.01623153-7.66824687e-02j -0.09832531-1.74110000e-01j 114 | -0.0183289 +2.72720794e-02j 0.14168414-1.51340961e-19j 115 | 0.07847628+2.07735199e-01j] 116 | [-0.12255602-6.11342416e-02j -0.27176358+4.84608761e-02j 117 | 0.01196277+1.01037189e-01j 0.07847628-2.07735199e-01j 118 | 0.40854244-6.75775934e-19j]] 119 | 120 | 121 | 122 | 123 | See the API documentation: :ref:`functions-rand` for details. 124 | 125 | .. warning:: 126 | 127 | When using the ``density`` keyword argument, setting the density too low may result in not enough diagonal elements to satisfy trace 128 | constraints. 129 | 130 | Random objects with a given eigen spectrum 131 | ========================================== 132 | 133 | It is also possible to generate random Hamiltonian (``rand_herm``) and densitiy matrices (``rand_dm``) with a given eigen spectrum. This is done by passing an array of eigenvalues as the first argument to either function. For example, 134 | 135 | .. doctest:: [random] 136 | :hide: 137 | 138 | >>> np.random.seed(42) 139 | 140 | .. doctest:: [random] 141 | 142 | >>> eigs = np.arange(5) 143 | 144 | >>> H = rand_herm(eigs, density=0.5) 145 | 146 | >>> H # doctest: +NORMALIZE_WHITESPACE 147 | Quantum object: dims = [[5], [5]], shape = (5, 5), type = oper, isherm = True 148 | Qobj data = 149 | [[ 2.51387054-5.55111512e-17j 0.81161447+2.02283642e-01j 150 | 0. +0.00000000e+00j 0.875 +3.35634092e-01j 151 | 0.81161447+2.02283642e-01j] 152 | [ 0.81161447-2.02283642e-01j 1.375 +0.00000000e+00j 153 | 0. +0.00000000e+00j -0.76700198+5.53011066e-01j 154 | 0.375 +0.00000000e+00j] 155 | [ 0. +0.00000000e+00j 0. +0.00000000e+00j 156 | 2. +0.00000000e+00j 0. +0.00000000e+00j 157 | 0. +0.00000000e+00j] 158 | [ 0.875 -3.35634092e-01j -0.76700198-5.53011066e-01j 159 | 0. +0.00000000e+00j 2.73612946+0.00000000e+00j 160 | -0.76700198-5.53011066e-01j] 161 | [ 0.81161447-2.02283642e-01j 0.375 +0.00000000e+00j 162 | 0. +0.00000000e+00j -0.76700198+5.53011066e-01j 163 | 1.375 +0.00000000e+00j]] 164 | 165 | 166 | >>> H.eigenenergies() # doctest: +NORMALIZE_WHITESPACE 167 | array([7.70647994e-17, 1.00000000e+00, 2.00000000e+00, 3.00000000e+00, 168 | 4.00000000e+00]) 169 | 170 | 171 | In order to generate a random object with a given spectrum QuTiP applies a series of random complex Jacobi rotations. This technique requires many steps to build the desired quantum object, and is thus suitable only for objects with Hilbert dimensionality :math:`\lesssim 1000`. 172 | 173 | 174 | 175 | Composite random objects 176 | ======================== 177 | 178 | In many cases, one is interested in generating random quantum objects that correspond to composite systems generated using the :func:`qutip.tensor.tensor` function. Specifying the tensor structure of a quantum object is done using the `dims` keyword argument in the same fashion as one would do for a :class:`qutip.Qobj` object: 179 | 180 | .. doctest:: [random] 181 | :hide: 182 | 183 | >>> np.random.seed(42) 184 | 185 | .. doctest:: [random] 186 | 187 | >>> rand_dm(4, 0.5, dims=[[2,2], [2,2]]) # doctest: +NORMALIZE_WHITESPACE 188 | Quantum object: dims = [[2, 2], [2, 2]], shape = (4, 4), type = oper, isherm = True 189 | Qobj data = 190 | [[ 0.13622928+0.j 0. +0.j 0.01180807-0.01739166j 191 | 0. +0.j ] 192 | [ 0. +0.j 0.14600238+0.j 0.10335328+0.21790786j 193 | -0.00426027-0.02193627j] 194 | [ 0.01180807+0.01739166j 0.10335328-0.21790786j 0.57566072+0.j 195 | -0.0670631 +0.04124094j] 196 | [ 0. +0.j -0.00426027+0.02193627j -0.0670631 -0.04124094j 197 | 0.14210761+0.j ]] 198 | -------------------------------------------------------------------------------- /guide/guide-saving.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _saving: 5 | 6 | ********************************** 7 | Saving QuTiP Objects and Data Sets 8 | ********************************** 9 | 10 | 11 | With time-consuming calculations it is often necessary to store the results to files on disk, so it can be post-processed and archived. In QuTiP there are two facilities for storing data: Quantum objects can be stored to files and later read back as python pickles, and numerical data (vectors and matrices) can be exported as plain text files in for example CSV (comma-separated values), TSV (tab-separated values), etc. The former method is preferred when further calculations will be performed with the data, and the latter when the calculations are completed and data is to be imported into a post-processing tool (e.g. for generating figures). 12 | 13 | Storing and loading QuTiP objects 14 | ================================= 15 | 16 | To store and load arbitrary QuTiP related objects (:class:`qutip.Qobj`, :class:`qutip.solver.Result`, etc.) there are two functions: :func:`qutip.fileio.qsave` and :func:`qutip.fileio.qload`. The function :func:`qutip.fileio.qsave` takes an arbitrary object as first parameter and an optional filename as second parameter (default filename is `qutip_data.qu`). The filename extension is always `.qu`. The function :func:`qutip.fileio.qload` takes a mandatory filename as first argument and loads and returns the objects in the file. 17 | 18 | To illustrate how these functions can be used, consider a simple calculation of the steadystate of the harmonic oscillator :: 19 | 20 | >>> a = destroy(10); H = a.dag() * a 21 | >>> c_ops = [np.sqrt(0.5) * a, np.sqrt(0.25) * a.dag()] 22 | >>> rho_ss = steadystate(H, c_ops) 23 | 24 | The steadystate density matrix `rho_ss` is an instance of :class:`qutip.Qobj`. It can be stored to a file `steadystate.qu` using :: 25 | 26 | >>> qsave(rho_ss, 'steadystate') 27 | >>> !ls *.qu 28 | density_matrix_vs_time.qu steadystate.qu 29 | 30 | and it can later be loaded again, and used in further calculations :: 31 | 32 | >>> rho_ss_loaded = qload('steadystate') 33 | Loaded Qobj object: 34 | Quantum object: dims = [[10], [10]], shape = (10, 10), type = oper, isHerm = True 35 | >>> a = destroy(10) 36 | >>> np.testing.assert_almost_equal(expect(a.dag() * a, rho_ss_loaded), 0.9902248289345061) 37 | 38 | The nice thing about the :func:`qutip.fileio.qsave` and :func:`qutip.fileio.qload` functions is that almost any object can be stored and load again later on. We can for example store a list of density matrices as returned by :func:`qutip.mesolve` :: 39 | 40 | >>> a = destroy(10); H = a.dag() * a ; c_ops = [np.sqrt(0.5) * a, np.sqrt(0.25) * a.dag()] 41 | >>> psi0 = rand_ket(10) 42 | >>> times = np.linspace(0, 10, 10) 43 | >>> dm_list = mesolve(H, psi0, times, c_ops, []) 44 | >>> qsave(dm_list, 'density_matrix_vs_time') 45 | 46 | And it can then be loaded and used again, for example in an other program :: 47 | 48 | >>> dm_list_loaded = qload('density_matrix_vs_time') 49 | Loaded Result object: 50 | Result object with mesolve data. 51 | -------------------------------- 52 | states = True 53 | num_collapse = 0 54 | >>> a = destroy(10) 55 | >>> expect(a.dag() * a, dm_list_loaded.states) # doctest: +SKIP 56 | array([4.63317086, 3.59150315, 2.90590183, 2.41306641, 2.05120716, 57 | 1.78312503, 1.58357995, 1.4346382 , 1.32327398, 1.23991233]) 58 | 59 | 60 | Storing and loading datasets 61 | ============================ 62 | 63 | The :func:`qutip.fileio.qsave` and :func:`qutip.fileio.qload` are great, but the file format used is only understood by QuTiP (python) programs. When data must be exported to other programs the preferred method is to store the data in the commonly used plain-text file formats. With the QuTiP functions :func:`qutip.fileio.file_data_store` and :func:`qutip.fileio.file_data_read` we can store and load **numpy** arrays and matrices to files on disk using a deliminator-separated value format (for example comma-separated values CSV). Almost any program can handle this file format. 64 | 65 | The :func:`qutip.fileio.file_data_store` takes two mandatory and three optional arguments: 66 | 67 | >>> file_data_store(filename, data, numtype="complex", numformat="decimal", sep=",") # doctest: +SKIP 68 | 69 | where `filename` is the name of the file, `data` is the data to be written to the file (must be a *numpy* array), `numtype` (optional) is a flag indicating numerical type that can take values `complex` or `real`, `numformat` (optional) specifies the numerical format that can take the values `exp` for the format `1.0e1` and `decimal` for the format `10.0`, and `sep` (optional) is an arbitrary single-character field separator (usually a tab, space, comma, semicolon, etc.). 70 | 71 | A common use for the :func:`qutip.fileio.file_data_store` function is to store the expectation values of a set of operators for a sequence of times, e.g., as returned by the :func:`qutip.mesolve` function, which is what the following example does 72 | 73 | .. plot:: 74 | :context: 75 | 76 | >>> a = destroy(10); H = a.dag() * a ; c_ops = [np.sqrt(0.5) * a, np.sqrt(0.25) * a.dag()] 77 | >>> psi0 = rand_ket(10) 78 | >>> times = np.linspace(0, 100, 100) 79 | >>> medata = mesolve(H, psi0, times, c_ops, [a.dag() * a, a + a.dag(), -1j * (a - a.dag())]) 80 | >>> np.shape(medata.expect) 81 | (3, 100) 82 | >>> times.shape 83 | (100,) 84 | >>> output_data = np.vstack((times, medata.expect)) # join time and expt data 85 | >>> file_data_store('expect.dat', output_data.T) # Note the .T for transpose! 86 | >>> with open("expect.dat", "r") as f: 87 | ... print('\n'.join(f.readlines()[:10])) 88 | # Generated by QuTiP: 100x4 complex matrix in decimal format [',' separated values]. 89 | 0.0000000000+0.0000000000j,3.2109553666+0.0000000000j,0.3689771549+0.0000000000j,0.0185002867+0.0000000000j 90 | 1.0101010101+0.0000000000j,2.6754598872+0.0000000000j,0.1298251132+0.0000000000j,-0.3303672956+0.0000000000j 91 | 2.0202020202+0.0000000000j,2.2743186810+0.0000000000j,-0.2106241300+0.0000000000j,-0.2623894277+0.0000000000j 92 | 3.0303030303+0.0000000000j,1.9726633457+0.0000000000j,-0.3037311621+0.0000000000j,0.0397330921+0.0000000000j 93 | 4.0404040404+0.0000000000j,1.7435892209+0.0000000000j,-0.1126550232+0.0000000000j,0.2497182058+0.0000000000j 94 | 5.0505050505+0.0000000000j,1.5687324121+0.0000000000j,0.1351622725+0.0000000000j,0.2018398581+0.0000000000j 95 | 6.0606060606+0.0000000000j,1.4348632045+0.0000000000j,0.2143080535+0.0000000000j,-0.0067820038+0.0000000000j 96 | 7.0707070707+0.0000000000j,1.3321818015+0.0000000000j,0.0950352763+0.0000000000j,-0.1630920429+0.0000000000j 97 | 8.0808080808+0.0000000000j,1.2533244850+0.0000000000j,-0.0771210981+0.0000000000j,-0.1468923919+0.0000000000j 98 | 99 | 100 | In this case we didn't really need to store both the real and imaginary parts, so instead we could use the ``numtype="real"`` option 101 | 102 | .. plot:: 103 | :context: 104 | 105 | >>> file_data_store('expect.dat', output_data.T, numtype="real") 106 | >>> with open("expect.dat", "r") as f: 107 | ... print('\n'.join(f.readlines()[:5])) 108 | # Generated by QuTiP: 100x4 real matrix in decimal format [',' separated values]. 109 | 0.0000000000,3.2109553666,0.3689771549,0.0185002867 110 | 1.0101010101,2.6754598872,0.1298251132,-0.3303672956 111 | 2.0202020202,2.2743186810,-0.2106241300,-0.2623894277 112 | 3.0303030303,1.9726633457,-0.3037311621,0.0397330921 113 | 114 | and if we prefer scientific notation we can request that using the ``numformat="exp"`` option 115 | 116 | .. plot:: 117 | :context: 118 | 119 | >>> file_data_store('expect.dat', output_data.T, numtype="real", numformat="exp") 120 | 121 | Loading data previously stored using :func:`qutip.fileio.file_data_store` (or some other software) is a even easier. Regardless of which deliminator was used, if data was stored as complex or real numbers, if it is in decimal or exponential form, the data can be loaded using the :func:`qutip.fileio.file_data_read`, which only takes the filename as mandatory argument. 122 | 123 | .. plot:: 124 | :context: 125 | 126 | input_data = file_data_read('expect.dat') 127 | plt.plot(input_data[:,0], input_data[:,1]); # plot the data 128 | 129 | 130 | (If a particularly obscure choice of deliminator was used it might be necessary to use the optional second argument, for example ``sep="_"`` if ``_`` is the deliminator). 131 | -------------------------------------------------------------------------------- /guide/guide-settings.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _settings: 5 | 6 | ********************************* 7 | Modifying Internal QuTiP Settings 8 | ********************************* 9 | 10 | .. _settings-params: 11 | 12 | User Accessible Parameters 13 | ========================== 14 | 15 | In this section we show how to modify a few of the internal parameters used by QuTiP. The settings that can be modified are given in the following table: 16 | 17 | .. tabularcolumns:: | p{3cm} | p{5cm} | p{5cm} | 18 | 19 | .. cssclass:: table-striped 20 | 21 | +-------------------------------+-------------------------------------------+-----------------------------+ 22 | | Setting | Description | Options | 23 | +===============================+===========================================+=============================+ 24 | | `auto_herm` | Automatically calculate the hermicity of | True / False | 25 | | | quantum objects. | | 26 | +-------------------------------+-------------------------------------------+-----------------------------+ 27 | | `auto_tidyup` | Automatically tidyup quantum objects. | True / False | 28 | +-------------------------------+-------------------------------------------+-----------------------------+ 29 | | `auto_tidyup_atol` | Tolerance used by tidyup | any `float` value > 0 | 30 | +-------------------------------+-------------------------------------------+-----------------------------+ 31 | | `atol` | General tolerance | any `float` value > 0 | 32 | +-------------------------------+-------------------------------------------+-----------------------------+ 33 | | `num_cpus` | Number of CPU's used for multiprocessing. | `int` between 1 and # cpu's | 34 | +-------------------------------+-------------------------------------------+-----------------------------+ 35 | | `debug` | Show debug printouts. | True / False | 36 | +-------------------------------+-------------------------------------------+-----------------------------+ 37 | | `openmp_thresh` | NNZ matrix must have for OPENMP. | Int | 38 | +-------------------------------+-------------------------------------------+-----------------------------+ 39 | 40 | .. _settings-usage: 41 | 42 | Example: Changing Settings 43 | ========================== 44 | 45 | The two most important settings are ``auto_tidyup`` and ``auto_tidyup_atol`` as they control whether the small elements of a quantum object should be removed, and what number should be considered as the cut-off tolerance. Modifying these, or any other parameters, is quite simple:: 46 | 47 | >>> qutip.settings.auto_tidyup = False 48 | 49 | These settings will be used for the current QuTiP session only and will need to be modified again when restarting QuTiP. If running QuTiP from a script file, then place the `qutip.setings.xxxx` commands immediately after `from qutip import *` at the top of the script file. If you want to reset the parameters back to their default values then call the reset command:: 50 | 51 | >>> qutip.settings.reset() 52 | 53 | Persistent Settings 54 | =================== 55 | 56 | When QuTiP is imported, it looks for a file named ``qutiprc`` in a folder called ``.qutip`` user's home directory. If this file is found, it will be loaded and overwrite the QuTiP default settings, which allows for persistent changes in the QuTiP settings to be made. A sample ``qutiprc`` file is show below. The syntax is a simple key-value format, where the keys and possible values are described in the table above:: 57 | 58 | [qutip] 59 | auto_tidyup=True 60 | auto_herm=True 61 | auto_tidyup_atol=1e-12 62 | num_cpus=4 63 | debug=False 64 | 65 | Note that the ``openmp_thresh`` value is automatically generatd by QuTiP. It is also possible to set a specific compiler for QuTiP to use when generating runtime Cython code for time-dependent problems. For example, the following section in the ``qutiprc`` file will set the compiler to be ``clang-3.9``:: 66 | 67 | [compiler] 68 | cc = clang-3.9 69 | cxx = clang-3.9 70 | 71 | 72 | -------------------------------------------------------------------------------- /guide/guide-steady.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _steady: 5 | 6 | ************************************* 7 | Solving for Steady-State Solutions 8 | ************************************* 9 | 10 | .. _steady-intro: 11 | 12 | Introduction 13 | ============ 14 | 15 | For time-independent open quantum systems with decay rates larger than the corresponding excitation rates, the system will tend toward a steady state as :math:`t\rightarrow\infty` that satisfies the equation 16 | 17 | .. math:: 18 | \frac{d\hat{\rho}_{ss}}{dt}=\mathcal{L}\hat{\rho}_{ss}=0. 19 | 20 | Although the requirement for time-independence seems quite resitrictive, one can often employ a transformation to the interaction picture that yields a time-independent Hamiltonian. For many these systems, solving for the asymptotic density matrix :math:`\hat{\rho}_{ss}` can be achieved using direct or iterative solution methods faster than using master equation or Monte Carlo simulations. Although the steady state equation has a simple mathematical form, the properties of the Liouvillian operator are such that the solutions to this equation are anything but straightforward to find. 21 | 22 | Steady State solvers in QuTiP 23 | ============================= 24 | 25 | In QuTiP, the steady-state solution for a system Hamiltonian or Liouvillian is given by :func:`qutip.steadystate.steadystate`. This function implements a number of different methods for finding the steady state, each with their own pros and cons, where the method used can be chosen using the ``method`` keyword argument. 26 | 27 | .. cssclass:: table-striped 28 | 29 | .. list-table:: 30 | :widths: 10 15 30 31 | :header-rows: 1 32 | 33 | * - Method 34 | - Keyword 35 | - Description 36 | * - Direct (default) 37 | - 'direct' 38 | - Direct solution solving :math:`Ax=b` via sparse LU decomposition. 39 | * - Eigenvalue 40 | - 'eigen' 41 | - Iteratively find the zero eigenvalue of :math:`\mathcal{L}`. 42 | * - Inverse-Power 43 | - 'power' 44 | - Solve using the inverse-power method. 45 | * - GMRES 46 | - 'iterative-gmres' 47 | - Solve using the GMRES method and optional preconditioner. 48 | * - LGMRES 49 | - 'iterative-lgmres' 50 | - Solve using the LGMRES method and optional preconditioner. 51 | * - BICGSTAB 52 | - 'iterative-bicgstab' 53 | - Solve using the BICGSTAB method and optional preconditioner. 54 | * - SVD 55 | - 'svd' 56 | - Steady-state solution via the **dense** SVD of the Liouvillian. 57 | 58 | 59 | The function :func:`qutip.steadystate.steadystate` can take either a Hamiltonian and a list of collapse operators as input, generating internally the corresponding Liouvillian super operator in Lindblad form, or alternatively, a Liouvillian passed by the user. When possible, we recommend passing the Hamiltonian and collapse operators to :func:`qutip.steadystate.steadystate`, and letting the function automatically build the Liouvillian (in Lindblad form) for the system. 60 | 61 | As of QuTiP 3.2, the ``direct`` and ``power`` methods can take advantage of the Intel Pardiso LU solver in the Intel Math Kernel library that comes with the Anacoda (2.5+) and Intel Python distributions. This gives a substantial increase in performance compared with the standard SuperLU method used by SciPy. To verify that QuTiP can find the necessary libraries, one can check for ``INTEL MKL Ext: True`` in the QuTiP about box (:func:`qutip.about`). 62 | 63 | 64 | .. _steady-usage: 65 | 66 | Using the Steadystate Solver 67 | ============================= 68 | 69 | Solving for the steady state solution to the Lindblad master equation for a general system with :func:`qutip.steadystate.steadystate` can be accomplished using:: 70 | 71 | >>> rho_ss = steadystate(H, c_ops) 72 | 73 | where ``H`` is a quantum object representing the system Hamiltonian, and ``c_ops`` is a list of quantum objects for the system collapse operators. The output, labeled as ``rho_ss``, is the steady-state solution for the systems. If no other keywords are passed to the solver, the default 'direct' method is used, generating a solution that is exact to machine precision at the expense of a large memory requirement. The large amount of memory need for the direct LU decomposition method stems from the large bandwidth of the system Liouvillian and the correspondingly large fill-in (extra nonzero elements) generated in the LU factors. This fill-in can be reduced by using bandwidth minimization algorithms such as those discussed in :ref:`steady-args`. However, in most cases, the default fill-in reducing algorithm is nearly optimal. Additional parameters may be used by calling the steady-state solver as: 74 | 75 | .. code-block:: python 76 | 77 | rho_ss = steadystate(H, c_ops, method='power', use_rcm=True) 78 | 79 | where ``method='power'`` indicates that we are using the inverse-power solution method, and ``use_rcm=True`` turns on a bandwidth minimization routine. 80 | 81 | 82 | Although it is not obvious, the ``'direct'``, ``eigen``, and ``'power'`` methods all use an LU decomposition internally and thus suffer from a large memory overhead. In contrast, iterative methods such as the ``'iterative-gmres'``, ``'iterative-lgmres'``, and ``'iterative-bicgstab'`` methods do not factor the matrix and thus take less memory than these previous methods and allowing, in principle, for extremely large system sizes. The downside is that these methods can take much longer than the direct method as the condition number of the Liouvillian matrix is large, indicating that these iterative methods require a large number of iterations for convergence. To overcome this, one can use a preconditioner :math:`M` that solves for an approximate inverse for the (modified) Liouvillian, thus better conditioning the problem, leading to faster convergence. The use of a preconditioner can actually make these iterative methods faster than the other solution methods. The problem with precondioning is that it is only well defined for Hermitian matrices. Since the Liouvillian is non-Hermitian, the ability to find a good preconditioner is not guaranteed. And moreover, if a preconditioner is found, it is not guaranteed to have a good condition number. QuTiP can make use of an incomplete LU preconditioner when using the iterative ``'gmres'``, ``'lgmres'``, and ``'bicgstab'`` solvers by setting ``use_precond=True``. The preconditioner optionally makes use of a combination of symmetric and anti-symmetric matrix permutations that attempt to improve the preconditioning process. These features are discussed in the :ref:`steady-args` section. Even with these state-of-the-art permutations, the generation of a successful preconditoner for non-symmetric matrices is currently a trial-and-error process due to the lack of mathematical work done in this area. It is always recommended to begin with the direct solver with no additional arguments before selecting a different method. 83 | 84 | Finding the steady-state solution is not limited to the Lindblad form of the master equation. Any time-independent Liouvillian constructed from a Hamiltonian and collapse operators can be used as an input:: 85 | 86 | >>> rho_ss = steadystate(L) 87 | 88 | where ``L`` is the Louvillian. All of the additional arguments can also be used in this case. 89 | 90 | 91 | .. _steady-args: 92 | 93 | Additional Solver Arguments 94 | ============================= 95 | 96 | The following additional solver arguments are available for the steady-state solver: 97 | 98 | .. cssclass:: table-striped 99 | 100 | .. list-table:: 101 | :widths: 10 30 60 102 | :header-rows: 1 103 | 104 | * - Keyword 105 | - Options (default listed first) 106 | - Description 107 | * - method 108 | - 'direct', 'eigen', 'power', 'iterative-gmres','iterative-lgmres', 'svd' 109 | - Method used for solving for the steady-state density matrix. 110 | * - sparse 111 | - True, False 112 | - Use sparse version of direct solver. 113 | * - weight 114 | - None 115 | - Allows the user to define the weighting factor used in the ``'direct'``, ``'GMRES'``, and ``'LGMRES'`` solvers. 116 | * - permc_spec 117 | - 'COLAMD', 'NATURAL' 118 | - Column ordering used in the sparse LU decomposition. 119 | * - use_rcm 120 | - False, True 121 | - Use a Reverse Cuthill-Mckee reordering to minimize the bandwidth of the modified Liouvillian used in the LU decomposition. If ``use_rcm=True`` then the column ordering is set to ``'Natural'`` automatically unless explicitly set. 122 | * - use_precond 123 | - False, True 124 | - Attempt to generate a preconditioner when using the ``'iterative-gmres'`` and ``'iterative-lgmres'`` methods. 125 | * - M 126 | - None, sparse_matrix, LinearOperator 127 | - A user defined preconditioner, if any. 128 | * - use_wbm 129 | - False, True 130 | - Use a Weighted Bipartite Matching algorithm to attempt to make the modified Liouvillian more diagonally dominate, and thus for favorable for preconditioning. Set to ``True`` automatically when using a iterative method, unless explicitly set. 131 | * - tol 132 | - 1e-9 133 | - Tolerance used in finding the solution for all methods expect ``'direct'`` and ``'svd'``. 134 | * - maxiter 135 | - 10000 136 | - Maximum number of iterations to perform for all methods expect ``'direct'`` and ``'svd'``. 137 | * - fill_factor 138 | - 10 139 | - Upper-bound on the allowed fill-in for the approximate inverse preconditioner. This value may need to be set much higher than this in some cases. 140 | * - drop_tol 141 | - 1e-3 142 | - Sets the threshold for the relative magnitude of preconditioner elements that should be dropped. A lower number yields a more accurate approximate inverse at the expense of fill-in and increased runtime. 143 | * - diag_pivot_thresh 144 | - None 145 | - Sets the threshold between :math:`[0,1]` for which diagonal elements are considered acceptable pivot points when using a preconditioner. 146 | * - ILU_MILU 147 | - 'smilu_2' 148 | - Selects the incomplete LU decomposition method algorithm used. 149 | 150 | Further information can be found in the :func:`qutip.steadystate.steadystate` docstrings. 151 | 152 | 153 | .. _steady-example: 154 | 155 | Example: Harmonic Oscillator in Thermal Bath 156 | ============================================ 157 | 158 | A simple example of a system that reaches a steady state is a harmonic oscillator coupled to a thermal environment. Below we consider a harmonic oscillator, initially in the :math:`\left|10\right>` number state, and weakly coupled to a thermal environment characterized by an average particle expectation value of :math:`\left=2`. We calculate the evolution via master equation and Monte Carlo methods, and see that they converge to the steady-state solution. Here we choose to perform only a few Monte Carlo trajectories so we can distinguish this evolution from the master-equation solution. 159 | 160 | .. plot:: guide/scripts/ex_steady.py 161 | :include-source: 162 | -------------------------------------------------------------------------------- /guide/guide.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011-2012, Paul D. Nation & Robert J. Johansson 3 | 4 | .. _guide: 5 | 6 | ******************* 7 | Users Guide 8 | ******************* 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | guide-overview.rst 14 | guide-basics.rst 15 | guide-states.rst 16 | guide-tensor.rst 17 | guide-dynamics.rst 18 | guide-steady.rst 19 | guide-correlation.rst 20 | guide-control.rst 21 | guide-bloch.rst 22 | guide-visualization.rst 23 | guide-parfor.rst 24 | guide-saving.rst 25 | guide-random.rst 26 | guide-settings.rst 27 | guide-qip.rst 28 | guide-measurement.rst 29 | -------------------------------------------------------------------------------- /guide/qip/w-state.qasm: -------------------------------------------------------------------------------- 1 | 2 | // Name of Experiment: W-state v1 3 | 4 | OPENQASM 2.0; 5 | include "qelib1.inc"; 6 | 7 | 8 | qreg q[3]; 9 | creg c[3]; 10 | gate cH a,b { 11 | h b; 12 | sdg b; 13 | cx a,b; 14 | h b; 15 | t b; 16 | cx a,b; 17 | t b; 18 | h b; 19 | s b; 20 | x b; 21 | s a; 22 | } 23 | 24 | ry(1.91063) q[0]; 25 | cH q[0],q[1]; 26 | ccx q[0],q[1],q[2]; 27 | x q[0]; 28 | x q[1]; 29 | cx q[0],q[1]; 30 | -------------------------------------------------------------------------------- /guide/quide-basics-qobj-box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qutip/qutip-doc/fa21a11e70a543c3c3c4344d21f16c96b2892c7d/guide/quide-basics-qobj-box.png -------------------------------------------------------------------------------- /guide/scripts/bloch_ex1.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import qutip 3 | 4 | b = qutip.Bloch() 5 | th = np.linspace(0, 2*np.pi, 20) 6 | 7 | xp = np.cos(th) 8 | yp = np.sin(th) 9 | zp = np.zeros(20) 10 | 11 | xz = np.zeros(20) 12 | yz = np.sin(th) 13 | zz = np.cos(th) 14 | 15 | b.add_points([xp, yp, zp]) 16 | b.add_points([xz, yz, zz]) 17 | b.show() 18 | -------------------------------------------------------------------------------- /guide/scripts/correlation_ex1.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import qutip 4 | 5 | times = np.linspace(0, 10, 200) 6 | a = qutip.destroy(10) 7 | x = a.dag() + a 8 | H = a.dag() * a 9 | 10 | corr1 = qutip.correlation_2op_1t(H, None, times, [np.sqrt(0.5) * a], x, x) 11 | corr2 = qutip.correlation_2op_1t(H, None, times, [np.sqrt(1.0) * a], x, x) 12 | corr3 = qutip.correlation_2op_1t(H, None, times, [np.sqrt(2.0) * a], x, x) 13 | 14 | plt.plot(times, np.real(corr1), times, np.real(corr2), times, np.real(corr3)) 15 | plt.xlabel(r'Time $t$') 16 | plt.ylabel(r'Correlation $\left$') 17 | plt.show() 18 | -------------------------------------------------------------------------------- /guide/scripts/correlation_ex2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import qutip 4 | 5 | times = np.linspace(0, 10.0, 200) 6 | a = qutip.destroy(10) 7 | x = a.dag() + a 8 | H = a.dag() * a 9 | alpha = 2.5 10 | rho0 = qutip.coherent_dm(10, alpha) 11 | corr = qutip.correlation_2op_2t(H, rho0, times, times, [np.sqrt(0.25) * a], x, x) 12 | 13 | plt.pcolor(np.real(corr)) 14 | plt.xlabel(r'Time $t_2$') 15 | plt.ylabel(r'Time $t_1$') 16 | plt.title(r'Correlation $\left$') 17 | plt.show() 18 | -------------------------------------------------------------------------------- /guide/scripts/correlation_ex3.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import qutip 4 | 5 | N = 15 6 | taus = np.linspace(0,10.0,200) 7 | a = qutip.destroy(N) 8 | H = 2 * np.pi * a.dag() * a 9 | 10 | # collapse operator 11 | G1 = 0.75 12 | n_th = 2.00 # bath temperature in terms of excitation number 13 | c_ops = [np.sqrt(G1 * (1 + n_th)) * a, np.sqrt(G1 * n_th) * a.dag()] 14 | 15 | # start with a coherent state 16 | rho0 = qutip.coherent_dm(N, 2.0) 17 | 18 | # first calculate the occupation number as a function of time 19 | n = qutip.mesolve(H, rho0, taus, c_ops, [a.dag() * a]).expect[0] 20 | 21 | # calculate the correlation function G1 and normalize with n to obtain g1 22 | G1 = qutip.correlation_2op_2t(H, rho0, None, taus, c_ops, a.dag(), a) 23 | g1 = G1 / np.sqrt(n[0] * n) 24 | 25 | plt.plot(taus, np.real(g1), 'b', lw=2) 26 | plt.plot(taus, n, 'r', lw=2) 27 | plt.title('Decay of a coherent state to an incoherent (thermal) state') 28 | plt.xlabel(r'$\tau$') 29 | plt.legend([ 30 | r'First-order coherence function $g^{(1)}(\tau)$', 31 | r'Occupation number $n(\tau)$', 32 | ]) 33 | plt.show() 34 | -------------------------------------------------------------------------------- /guide/scripts/correlation_ex4.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import qutip 4 | 5 | N = 25 6 | taus = np.linspace(0, 25.0, 200) 7 | a = qutip.destroy(N) 8 | H = 2 * np.pi * a.dag() * a 9 | 10 | kappa = 0.25 11 | n_th = 2.0 # bath temperature in terms of excitation number 12 | c_ops = [np.sqrt(kappa * (1 + n_th)) * a, np.sqrt(kappa * n_th) * a.dag()] 13 | 14 | states = [ 15 | {'state': qutip.coherent_dm(N, np.sqrt(2)), 'label': "coherent state"}, 16 | {'state': qutip.thermal_dm(N, 2), 'label': "thermal state"}, 17 | {'state': qutip.fock_dm(N, 2), 'label': "Fock state"}, 18 | ] 19 | 20 | fig, ax = plt.subplots(1, 1) 21 | 22 | for state in states: 23 | rho0 = state['state'] 24 | 25 | # first calculate the occupation number as a function of time 26 | n = qutip.mesolve(H, rho0, taus, c_ops, [a.dag() * a]).expect[0] 27 | 28 | # calculate the correlation function G2 and normalize with n(0)n(t) to 29 | # obtain g2 30 | G2 = qutip.correlation_3op_1t(H, rho0, taus, c_ops, a.dag(), a.dag()*a, a) 31 | g2 = G2 / (n[0] * n) 32 | 33 | ax.plot(taus, np.real(g2), label=state['label'], lw=2) 34 | 35 | ax.legend(loc=0) 36 | ax.set_xlabel(r'$\tau$') 37 | ax.set_ylabel(r'$g^{(2)}(\tau)$') 38 | plt.show() 39 | -------------------------------------------------------------------------------- /guide/scripts/ex_bloch_animation.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import qutip 3 | 4 | def qubit_integrate(w, theta, gamma1, gamma2, psi0, tlist): 5 | # operators and the hamiltonian 6 | sx = qutip.sigmax() 7 | sy = qutip.sigmay() 8 | sz = qutip.sigmaz() 9 | sm = qutip.sigmam() 10 | H = w * (np.cos(theta) * sz + np.sin(theta) * sx) 11 | # collapse operators 12 | c_op_list = [] 13 | n_th = 0.5 # temperature 14 | rate = gamma1 * (n_th + 1) 15 | if rate > 0.0: c_op_list.append(np.sqrt(rate) * sm) 16 | rate = gamma1 * n_th 17 | if rate > 0.0: c_op_list.append(np.sqrt(rate) * sm.dag()) 18 | rate = gamma2 19 | if rate > 0.0: c_op_list.append(np.sqrt(rate) * sz) 20 | # evolve and calculate expectation values 21 | output = qutip.mesolve(H, psi0, tlist, c_op_list, [sx, sy, sz]) 22 | return output.expect[0], output.expect[1], output.expect[2] 23 | 24 | ## calculate the dynamics 25 | w = 1.0 * 2 * np.pi # qubit angular frequency 26 | theta = 0.2 * np.pi # qubit angle from sigma_z axis (toward sigma_x axis) 27 | gamma1 = 0.5 # qubit relaxation rate 28 | gamma2 = 0.2 # qubit dephasing rate 29 | # initial state 30 | a = 1.0 31 | psi0 = (a*qutip.basis(2, 0) + (1-a)*qutip.basis(2, 1))/np.sqrt(a**2 + (1-a)**2) 32 | tlist = np.linspace(0, 4, 250) 33 | #expectation values for ploting 34 | sx, sy, sz = qubit_integrate(w, theta, gamma1, gamma2, psi0, tlist) 35 | -------------------------------------------------------------------------------- /guide/scripts/ex_steady.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | 4 | import qutip 5 | 6 | # Define paramters 7 | N = 20 # number of basis states to consider 8 | a = qutip.destroy(N) 9 | H = a.dag() * a 10 | psi0 = qutip.basis(N, 10) # initial state 11 | kappa = 0.1 # coupling to oscillator 12 | 13 | # collapse operators 14 | c_op_list = [] 15 | n_th_a = 2 # temperature with average of 2 excitations 16 | rate = kappa * (1 + n_th_a) 17 | if rate > 0.0: 18 | c_op_list.append(np.sqrt(rate) * a) # decay operators 19 | rate = kappa * n_th_a 20 | if rate > 0.0: 21 | c_op_list.append(np.sqrt(rate) * a.dag()) # excitation operators 22 | 23 | # find steady-state solution 24 | final_state = qutip.steadystate(H, c_op_list) 25 | # find expectation value for particle number in steady state 26 | fexpt = qutip.expect(a.dag() * a, final_state) 27 | 28 | tlist = np.linspace(0, 50, 100) 29 | # monte-carlo 30 | mcdata = qutip.mcsolve(H, psi0, tlist, c_op_list, [a.dag() * a], ntraj=100) 31 | # master eq. 32 | medata = qutip.mesolve(H, psi0, tlist, c_op_list, [a.dag() * a]) 33 | 34 | plt.plot(tlist, mcdata.expect[0], tlist, medata.expect[0], lw=2) 35 | # plot steady-state expt. value as horizontal line (should be = 2) 36 | plt.axhline(y=fexpt, color='r', lw=1.5) 37 | plt.ylim([0, 10]) 38 | plt.xlabel('Time', fontsize=14) 39 | plt.ylabel('Number of excitations', fontsize=14) 40 | plt.legend(('Monte-Carlo', 'Master Equation', 'Steady State')) 41 | plt.title( 42 | r'Decay of Fock state $\left|10\rangle\right.$' 43 | r' in a thermal environment with $\langle n\rangle=2$' 44 | ) 45 | plt.show() 46 | -------------------------------------------------------------------------------- /guide/scripts/floquet_ex0.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from matplotlib import pyplot 3 | import qutip 4 | 5 | delta = 0.2 * 2*np.pi 6 | eps0 = 0.0 * 2*np.pi 7 | omega = 1.0 * 2*np.pi 8 | A_vec = np.linspace(0, 10, 100) * omega 9 | T = 2*np.pi/omega 10 | tlist = np.linspace(0.0, 10 * T, 101) 11 | psi0 = qutip.basis(2, 0) 12 | 13 | q_energies = np.zeros((len(A_vec), 2)) 14 | 15 | H0 = delta/2.0 * qutip.sigmaz() - eps0/2.0 * qutip.sigmax() 16 | args = omega 17 | for idx, A in enumerate(A_vec): 18 | H1 = A/2.0 * qutip.sigmax() 19 | H = [H0, [H1, lambda t, w: np.sin(w*t)]] 20 | f_modes,f_energies = qutip.floquet_modes(H, T, args, True) 21 | q_energies[idx,:] = f_energies 22 | 23 | # plot the results 24 | pyplot.plot( 25 | A_vec/omega, np.real(q_energies[:, 0]) / delta, 'b', 26 | A_vec/omega, np.real(q_energies[:, 1]) / delta, 'r', 27 | ) 28 | pyplot.xlabel(r'$A/\omega$') 29 | pyplot.ylabel(r'Quasienergy / $\Delta$') 30 | pyplot.title(r'Floquet quasienergies') 31 | pyplot.show() 32 | -------------------------------------------------------------------------------- /guide/scripts/floquet_ex1.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from matplotlib import pyplot 3 | 4 | import qutip 5 | 6 | delta = 0.2 * 2*np.pi 7 | eps0 = 1.0 * 2*np.pi 8 | A = 0.5 * 2*np.pi 9 | omega = 1.0 * 2*np.pi 10 | T = (2*np.pi)/omega 11 | tlist = np.linspace(0.0, 10 * T, 101) 12 | psi0 = qutip.basis(2, 0) 13 | 14 | H0 = - delta/2.0 * qutip.sigmax() - eps0/2.0 * qutip.sigmaz() 15 | H1 = A/2.0 * qutip.sigmaz() 16 | args = {'w': omega} 17 | H = [H0, [H1, lambda t,args: np.sin(args['w'] * t)]] 18 | 19 | # find the floquet modes for the time-dependent hamiltonian 20 | f_modes_0,f_energies = qutip.floquet_modes(H, T, args) 21 | 22 | # decompose the inital state in the floquet modes 23 | f_coeff = qutip.floquet_state_decomposition(f_modes_0, f_energies, psi0) 24 | 25 | # calculate the wavefunctions using the from the floquet modes 26 | p_ex = np.zeros(len(tlist)) 27 | for n, t in enumerate(tlist): 28 | psi_t = qutip.floquet_wavefunction_t(f_modes_0, f_energies, f_coeff, t, H, T, args) 29 | p_ex[n] = qutip.expect(qutip.num(2), psi_t) 30 | 31 | # For reference: calculate the same thing with mesolve 32 | p_ex_ref = qutip.mesolve(H, psi0, tlist, [], [qutip.num(2)], args).expect[0] 33 | 34 | # plot the results 35 | pyplot.plot(tlist, np.real(p_ex), 'ro', tlist, 1-np.real(p_ex), 'bo') 36 | pyplot.plot(tlist, np.real(p_ex_ref), 'r', tlist, 1-np.real(p_ex_ref), 'b') 37 | pyplot.xlabel('Time') 38 | pyplot.ylabel('Occupation probability') 39 | pyplot.legend(("Floquet $P_1$", "Floquet $P_0$", "Lindblad $P_1$", "Lindblad $P_0$")) 40 | pyplot.show() 41 | -------------------------------------------------------------------------------- /guide/scripts/floquet_ex2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from matplotlib import pyplot 3 | import qutip 4 | 5 | delta = 0.0 * 2*np.pi 6 | eps0 = 1.0 * 2*np.pi 7 | A = 0.25 * 2*np.pi 8 | omega = 1.0 * 2*np.pi 9 | T = 2*np.pi / omega 10 | tlist = np.linspace(0.0, 10 * T, 101) 11 | psi0 = qutip.basis(2,0) 12 | 13 | H0 = - delta/2.0 * qutip.sigmax() - eps0/2.0 * qutip.sigmaz() 14 | H1 = A/2.0 * qutip.sigmax() 15 | args = {'w': omega} 16 | H = [H0, [H1, lambda t, args: np.sin(args['w'] * t)]] 17 | 18 | # find the floquet modes for the time-dependent hamiltonian 19 | f_modes_0,f_energies = qutip.floquet_modes(H, T, args) 20 | 21 | # decompose the inital state in the floquet modes 22 | f_coeff = qutip.floquet_state_decomposition(f_modes_0, f_energies, psi0) 23 | 24 | # calculate the wavefunctions using the from the floquet modes 25 | f_modes_table_t = qutip.floquet_modes_table(f_modes_0, f_energies, tlist, H, T, args) 26 | p_ex = np.zeros(len(tlist)) 27 | for n, t in enumerate(tlist): 28 | f_modes_t = qutip.floquet_modes_t_lookup(f_modes_table_t, t, T) 29 | psi_t = qutip.floquet_wavefunction(f_modes_t, f_energies, f_coeff, t) 30 | p_ex[n] = qutip.expect(qutip.num(2), psi_t) 31 | 32 | # For reference: calculate the same thing with mesolve 33 | p_ex_ref = qutip.mesolve(H, psi0, tlist, [], [qutip.num(2)], args).expect[0] 34 | 35 | # plot the results 36 | pyplot.plot(tlist, np.real(p_ex), 'ro', tlist, 1-np.real(p_ex), 'bo') 37 | pyplot.plot(tlist, np.real(p_ex_ref), 'r', tlist, 1-np.real(p_ex_ref), 'b') 38 | pyplot.xlabel('Time') 39 | pyplot.ylabel('Occupation probability') 40 | pyplot.legend(("Floquet $P_1$", "Floquet $P_0$", "Lindblad $P_1$", "Lindblad $P_0$")) 41 | pyplot.show() 42 | -------------------------------------------------------------------------------- /guide/scripts/floquet_ex3.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from matplotlib import pyplot 3 | import qutip 4 | 5 | delta = 0.0 * 2*np.pi 6 | eps0 = 1.0 * 2*np.pi 7 | A = 0.25 * 2*np.pi 8 | omega = 1.0 * 2*np.pi 9 | T = 2*np.pi / omega 10 | tlist = np.linspace(0.0, 20 * T, 101) 11 | psi0 = qutip.basis(2,0) 12 | 13 | H0 = - delta/2.0 * qutip.sigmax() - eps0/2.0 * qutip.sigmaz() 14 | H1 = A/2.0 * qutip.sigmax() 15 | args = {'w': omega} 16 | H = [H0, [H1, lambda t,args: np.sin(args['w'] * t)]] 17 | 18 | # noise power spectrum 19 | gamma1 = 0.1 20 | def noise_spectrum(omega): 21 | return 0.5 * gamma1 * omega/(2*np.pi) 22 | 23 | # find the floquet modes for the time-dependent hamiltonian 24 | f_modes_0, f_energies = qutip.floquet_modes(H, T, args) 25 | 26 | # precalculate mode table 27 | f_modes_table_t = qutip.floquet_modes_table( 28 | f_modes_0, f_energies, np.linspace(0, T, 500 + 1), H, T, args, 29 | ) 30 | 31 | # solve the floquet-markov master equation 32 | output = qutip.fmmesolve(H, psi0, tlist, [qutip.sigmax()], [], [noise_spectrum], T, args) 33 | 34 | # calculate expectation values in the computational basis 35 | p_ex = np.zeros(tlist.shape, dtype=np.complex128) 36 | for idx, t in enumerate(tlist): 37 | f_modes_t = qutip.floquet_modes_t_lookup(f_modes_table_t, t, T) 38 | p_ex[idx] = qutip.expect(qutip.num(2), output.states[idx].transform(f_modes_t, True)) 39 | 40 | # For reference: calculate the same thing with mesolve 41 | output = qutip.mesolve(H, psi0, tlist, 42 | [np.sqrt(gamma1) * qutip.sigmax()], [qutip.num(2)], 43 | args) 44 | p_ex_ref = output.expect[0] 45 | 46 | # plot the results 47 | pyplot.plot(tlist, np.real(p_ex), 'r--', tlist, 1-np.real(p_ex), 'b--') 48 | pyplot.plot(tlist, np.real(p_ex_ref), 'r', tlist, 1-np.real(p_ex_ref), 'b') 49 | pyplot.xlabel('Time') 50 | pyplot.ylabel('Occupation probability') 51 | pyplot.legend(("Floquet $P_1$", "Floquet $P_0$", "Lindblad $P_1$", "Lindblad $P_0$")) 52 | pyplot.show() 53 | -------------------------------------------------------------------------------- /guide/scripts/spectrum_ex1.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from matplotlib import pyplot 3 | import qutip 4 | 5 | N = 4 # number of cavity fock states 6 | wc = wa = 1.0 * 2 * np.pi # cavity and atom frequency 7 | g = 0.1 * 2 * np.pi # coupling strength 8 | kappa = 0.75 # cavity dissipation rate 9 | gamma = 0.25 # atom dissipation rate 10 | 11 | # Jaynes-Cummings Hamiltonian 12 | a = qutip.tensor(qutip.destroy(N), qutip.qeye(2)) 13 | sm = qutip.tensor(qutip.qeye(N), qutip.destroy(2)) 14 | H = wc*a.dag()*a + wa*sm.dag()*sm + g*(a.dag()*sm + a*sm.dag()) 15 | 16 | # collapse operators 17 | n_th = 0.25 18 | c_ops = [ 19 | np.sqrt(kappa * (1 + n_th)) * a, 20 | np.sqrt(kappa * n_th) * a.dag(), 21 | np.sqrt(gamma) * sm, 22 | ] 23 | 24 | # calculate the correlation function using the mesolve solver, and then fft to 25 | # obtain the spectrum. Here we need to make sure to evaluate the correlation 26 | # function for a sufficient long time and sufficiently high sampling rate so 27 | # that the discrete Fourier transform (FFT) captures all the features in the 28 | # resulting spectrum. 29 | tlist = np.linspace(0, 100, 5000) 30 | corr = qutip.correlation_2op_1t(H, None, tlist, c_ops, a.dag(), a) 31 | wlist1, spec1 = qutip.spectrum_correlation_fft(tlist, corr) 32 | 33 | 34 | # calculate the power spectrum using spectrum, which internally uses essolve 35 | # to solve for the dynamics (by default) 36 | wlist2 = np.linspace(0.25, 1.75, 200) * 2 * np.pi 37 | spec2 = qutip.spectrum(H, wlist2, c_ops, a.dag(), a) 38 | 39 | # plot the spectra 40 | fig, ax = pyplot.subplots(1, 1) 41 | ax.plot(wlist1 / (2 * np.pi), spec1, 'b', lw=2, label='eseries method') 42 | ax.plot(wlist2 / (2 * np.pi), spec2, 'r--', lw=2, label='me+fft method') 43 | ax.legend() 44 | ax.set_xlabel('Frequency') 45 | ax.set_ylabel('Power spectrum') 46 | ax.set_title('Vacuum Rabi splitting') 47 | ax.set_xlim(wlist2[0]/(2*np.pi), wlist2[-1]/(2*np.pi)) 48 | plt.show() 49 | -------------------------------------------------------------------------------- /index.rst: -------------------------------------------------------------------------------- 1 | .. QuTiP 2 | Copyright (C) 2011 and later, Paul D. Nation & Robert J. Johansson 3 | 4 | .. figure:: figures/logo.png 5 | :align: center 6 | :width: 7in 7 | 8 | 9 | QuTiP: Quantum Toolbox in Python 10 | ================================ 11 | 12 | .. toctree:: 13 | :maxdepth: 3 14 | 15 | frontmatter.rst 16 | installation.rst 17 | guide/guide.rst 18 | gallery/build/index.rst 19 | apidoc/apidoc.rst 20 | 21 | changelog.rst 22 | contributors.rst 23 | development/development.rst 24 | biblio.rst 25 | 26 | 27 | Indices and tables 28 | ==================== 29 | 30 | * :ref:`genindex` 31 | * :ref:`modindex` 32 | * :ref:`search` 33 | -------------------------------------------------------------------------------- /make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set TEXIFY=texify 10 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | ) 14 | 15 | if "%1" == "" goto help 16 | 17 | if "%1" == "help" ( 18 | :help 19 | echo.Please use `make ^` where ^ is one of 20 | echo. html to make standalone HTML files 21 | echo. dirhtml to make HTML files named index.html in directories 22 | echo. singlehtml to make a single large HTML file 23 | echo. pickle to make pickle files 24 | echo. json to make JSON files 25 | echo. htmlhelp to make HTML files and a HTML help project 26 | echo. qthelp to make HTML files and a qthelp project 27 | echo. devhelp to make HTML files and a Devhelp project 28 | echo. epub to make an epub 29 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 30 | echo. text to make text files 31 | echo. man to make manual pages 32 | echo. changes to make an overview over all changed/added/deprecated items 33 | echo. linkcheck to check all external links for integrity 34 | echo. doctest to run all doctests embedded in the documentation if enabled 35 | goto end 36 | ) 37 | 38 | if "%1" == "clean" ( 39 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 40 | del /q /s %BUILDDIR%\* 41 | goto end 42 | ) 43 | 44 | if "%1" == "html" ( 45 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 46 | if errorlevel 1 exit /b 1 47 | echo. 48 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 49 | goto end 50 | ) 51 | 52 | if "%1" == "dirhtml" ( 53 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 54 | if errorlevel 1 exit /b 1 55 | echo. 56 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 57 | goto end 58 | ) 59 | 60 | if "%1" == "singlehtml" ( 61 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 62 | if errorlevel 1 exit /b 1 63 | echo. 64 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 65 | goto end 66 | ) 67 | 68 | if "%1" == "pickle" ( 69 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 70 | if errorlevel 1 exit /b 1 71 | echo. 72 | echo.Build finished; now you can process the pickle files. 73 | goto end 74 | ) 75 | 76 | if "%1" == "json" ( 77 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 78 | if errorlevel 1 exit /b 1 79 | echo. 80 | echo.Build finished; now you can process the JSON files. 81 | goto end 82 | ) 83 | 84 | if "%1" == "htmlhelp" ( 85 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 86 | if errorlevel 1 exit /b 1 87 | echo. 88 | echo.Build finished; now you can run HTML Help Workshop with the ^ 89 | .hhp project file in %BUILDDIR%/htmlhelp. 90 | goto end 91 | ) 92 | 93 | if "%1" == "qthelp" ( 94 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 95 | if errorlevel 1 exit /b 1 96 | echo. 97 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 98 | .qhcp project file in %BUILDDIR%/qthelp, like this: 99 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\QInfer.qhcp 100 | echo.To view the help file: 101 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\QInfer.ghc 102 | goto end 103 | ) 104 | 105 | if "%1" == "devhelp" ( 106 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 107 | if errorlevel 1 exit /b 1 108 | echo. 109 | echo.Build finished. 110 | goto end 111 | ) 112 | 113 | if "%1" == "epub" ( 114 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 115 | if errorlevel 1 exit /b 1 116 | echo. 117 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 118 | goto end 119 | ) 120 | 121 | if "%1" == "latex" ( 122 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 123 | if errorlevel 1 exit /b 1 124 | echo. 125 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 126 | goto end 127 | ) 128 | 129 | if "%1" == "latexpdf" ( 130 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 131 | @echo "Running LaTeX files through texify..." 132 | cd %BUILDDIR%/latex 133 | $(TEXIFY) -b --pdf 134 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 135 | ) 136 | 137 | if "%1" == "text" ( 138 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 139 | if errorlevel 1 exit /b 1 140 | echo. 141 | echo.Build finished. The text files are in %BUILDDIR%/text. 142 | goto end 143 | ) 144 | 145 | if "%1" == "man" ( 146 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 147 | if errorlevel 1 exit /b 1 148 | echo. 149 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 150 | goto end 151 | ) 152 | 153 | if "%1" == "changes" ( 154 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 155 | if errorlevel 1 exit /b 1 156 | echo. 157 | echo.The overview file is in %BUILDDIR%/changes. 158 | goto end 159 | ) 160 | 161 | if "%1" == "linkcheck" ( 162 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 163 | if errorlevel 1 exit /b 1 164 | echo. 165 | echo.Link check complete; look for any errors in the above output ^ 166 | or in %BUILDDIR%/linkcheck/output.txt. 167 | goto end 168 | ) 169 | 170 | if "%1" == "doctest" ( 171 | %SPHINXBUILD% -b doctest -t nomock %ALLSPHINXOPTS% %BUILDDIR%/doctest 172 | if errorlevel 1 exit /b 1 173 | echo. 174 | echo.Testing of doctests in the sources finished, look at the ^ 175 | results in %BUILDDIR%/doctest/output.txt. 176 | goto end 177 | ) 178 | 179 | :end 180 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | alabaster==0.7.12 2 | appnope==0.1.2 3 | Babel==2.9.0 4 | backcall==0.2.0 5 | certifi==2020.12.5 6 | chardet==4.0.0 7 | cycler==0.10.0 8 | Cython==0.29.23 9 | decorator==5.0.7 10 | docutils==0.16 11 | idna==2.10 12 | imagesize==1.2.0 13 | ipython==7.22.0 14 | ipython-genutils==0.2.0 15 | jedi==0.18.0 16 | Jinja2==2.11.3 17 | kiwisolver==1.3.1 18 | MarkupSafe==1.1.1 19 | matplotlib==3.3.4 20 | numpy==1.19.5 21 | numpydoc==1.1.0 22 | packaging==20.9 23 | parso==0.8.2 24 | pexpect==4.8.0 25 | pickleshare==0.7.5 26 | Pillow==8.2.0 27 | prompt-toolkit==3.0.18 28 | ptyprocess==0.7.0 29 | Pygments==2.8.1 30 | pyparsing==2.4.7 31 | python-dateutil==2.8.1 32 | pytz==2021.1 33 | requests==2.25.1 34 | scipy==1.6.2 35 | six==1.15.0 36 | snowballstemmer==2.1.0 37 | Sphinx==3.5.4 38 | sphinx-gallery==0.8.2 39 | sphinx-rtd-theme==0.5.2 40 | sphinxcontrib-applehelp==1.0.2 41 | sphinxcontrib-devhelp==1.0.2 42 | sphinxcontrib-htmlhelp==1.0.3 43 | sphinxcontrib-jsmath==1.0.1 44 | sphinxcontrib-qthelp==1.0.3 45 | sphinxcontrib-serializinghtml==1.1.4 46 | traitlets==5.0.5 47 | urllib3==1.26.4 48 | wcwidth==0.2.5 49 | -------------------------------------------------------------------------------- /sphinxext/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy 2 | -e git+http://github.com/qutip/qutip.git#egg=qutip 3 | -------------------------------------------------------------------------------- /static/site.css: -------------------------------------------------------------------------------- 1 | @import url('http://fonts.googleapis.com/css?family=Source+Code+Pro'); 2 | 3 | 4 | .navbar-text { 5 | color: #e8e8e8 !important; 6 | } 7 | 8 | a { 9 | color: #599AD3; 10 | text-decoration: none; 11 | } 12 | 13 | a:hover, 14 | a:focus { 15 | color: #8C0028; 16 | text-decoration: underline; 17 | } 18 | 19 | a:focus { 20 | outline: thin dotted #333; 21 | outline: 5px auto -webkit-focus-ring-color; 22 | outline-offset: -2px; 23 | } 24 | 25 | code, 26 | pre { 27 | padding: 0 3px 2px; 28 | font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace; 29 | font-size: 12px; 30 | color: #333333; 31 | -webkit-border-radius: 3px; 32 | -moz-border-radius: 3px; 33 | border-radius: 3px; 34 | } 35 | 36 | .alert { 37 | border-width: 2px; 38 | color: #09224F; 39 | font-weight: bold; 40 | -webkit-border-radius: 3px; 41 | -moz-border-radius: 3px; 42 | border-radius: 3px; 43 | } 44 | 45 | .alert-success { 46 | background-color: #B9E0B0; 47 | border-color: #79C36A; 48 | } 49 | 50 | 51 | .alert-info { 52 | background-color: #A6CBE9; 53 | border-color: #599AD3; 54 | } 55 | 56 | .alert-warning { 57 | background-color: #FBD1A7; 58 | border-color: #F9A65A; 59 | } 60 | 61 | .alert-danger { 62 | background-color: #F7A7AA; 63 | border-color: #F1595F; 64 | } 65 | -------------------------------------------------------------------------------- /templates/layout.html: -------------------------------------------------------------------------------- 1 | {# Import the theme's layout. #} 2 | {% extends "!layout.html" %} 3 | 4 | {# Custom CSS overrides #} 5 | {% set bootswatch_css_custom = ['_static/site.css'] %} --------------------------------------------------------------------------------