Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

before embedding check that the destination basis matches the operator basis #246

Merged
merged 7 commits into from
Mar 26, 2019

Conversation

atombear
Copy link
Contributor

closes #240

@david-pl
Copy link
Member

I changed the syntax as discussed in #240. I'm sure things could be more elegant, but at least everything seems to work properly like this. Let me know if you have any suggestions before I merge this.

@coveralls
Copy link

coveralls commented Mar 21, 2019

Coverage Status

Coverage decreased (-0.02%) to 96.677% when pulling 82daf53 on atombear:bug/embed_checks_bases into 40d0231 on qojulia:master.

@codecov
Copy link

codecov bot commented Mar 21, 2019

Codecov Report

Merging #246 into master will increase coverage by 3.24%.
The diff coverage is 96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #246      +/-   ##
==========================================
+ Coverage    93.4%   96.65%   +3.24%     
==========================================
  Files          36       36              
  Lines        2973     2897      -76     
==========================================
+ Hits         2777     2800      +23     
+ Misses        196       97      -99
Impacted Files Coverage Δ
src/operators_sparse.jl 84.52% <0%> (-3.14%) ⬇️
src/operators.jl 97.72% <100%> (+2.15%) ⬆️
src/operators_lazysum.jl 89.74% <0%> (-7.48%) ⬇️
src/bases.jl 94.66% <0%> (-1.28%) ⬇️
src/fock.jl 100% <0%> (ø) ⬆️
src/manybody.jl 100% <0%> (+0.9%) ⬆️
src/operators_lazytensor.jl 100% <0%> (+1.12%) ⬆️
src/stochastic_schroedinger.jl 100% <0%> (+2.17%) ⬆️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 07db21f...60321e0. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 21, 2019

Codecov Report

Merging #246 into master will decrease coverage by 0.01%.
The diff coverage is 97.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #246      +/-   ##
==========================================
- Coverage   96.69%   96.67%   -0.02%     
==========================================
  Files          36       36              
  Lines        2874     2919      +45     
==========================================
+ Hits         2779     2822      +43     
- Misses         95       97       +2
Impacted Files Coverage Δ
src/operators_sparse.jl 84.52% <0%> (-1.02%) ⬇️
src/sortedindices.jl 100% <100%> (ø) ⬆️
src/operators.jl 97.94% <100%> (-0.24%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40d0231...82daf53. Read the comment docs.

@atombear atombear force-pushed the bug/embed_checks_bases branch 2 times, most recently from fd0dcd5 to b5c83c4 Compare March 21, 2019 16:05
@atombear
Copy link
Contributor Author

i added a method that performs the index wrangling to embed an operator in a joint hilbert space as defined by a subset of the bases. i'm not sure if this is redundant with the change you added, but i'll work to understand it better.

@atombear atombear force-pushed the bug/embed_checks_bases branch from b5c83c4 to 2a0e0b3 Compare March 21, 2019 20:56
@david-pl
Copy link
Member

I didn't go through your code in detail, so correct me if I'm wrong, but it seems like your function handles the case of a single (composite) operator being embedded in a product basis only. This case is covered by the method I wrote as well. So yes, I think this is a bit redundant.

@atombear
Copy link
Contributor Author

atombear commented Mar 22, 2019

Yes, my method handles the case of one operator being embedded in any subspace of a composite hilbert space. so, for 8 qubits, D=2^8, and a CNOT will be embedded appropriately in any 4d supspace, meaning in any 2 indices. I think your method does not distinguish between an operator acting an different, but equivalent, sub-bases. for example, for a 5x3 operator being embedded in a space that is 5x3x3, your method gives the same output whether the indices are [1, 2] or [1, 3], but those should yield different operators.

@atombear
Copy link
Contributor Author

so i think my position is as follows: the original code (indices, ops) tried to match every op to an index, but had the problem that the matching would not bother checking that the op matched the basis corresponding to the index in which it was being inserted.

the new method (indices, ops) tries to do two things:

  • assert that the size of the basis matches, thereby fixing the bug
  • try to account for composite spaces by index counting

however, there is an oversight in that it assumes operators in composite spaces correspond to consecutive basis indices. i think it is impossible to correct for this without the index wrangling. Additionally, it assumes the following syntax: [1,2,3], [op12, op3] to place a composite operator op12 in the space [1,2], and a third operator op3 in space 3. perhaps the syntax [[1,2],3], [op12, op3] would be clearer?

the new (indices, op) method generically embeds an operator in a composite hilbert space in an even larger hilbert space, by doing the appropriate index wrangling.

i think it is true that the more general and bug-free (indices, ops) method can be written in terms of the new (indices, op) method, allowing for non-consecutive indices. my proposal is to do this, and i am glad to take on the task if that makes sense to you. additionally, i am happy with any syntax, though the second i think is clearer, eg: [[1,3],2], [op13, op2].

@atombear atombear force-pushed the bug/embed_checks_bases branch from c97c568 to 2b2e37a Compare March 23, 2019 16:37
@atombear atombear force-pushed the bug/embed_checks_bases branch from 2b2e37a to d61d107 Compare March 23, 2019 16:41
@atombear
Copy link
Contributor Author

i think i have pushed a test-passing working version of what i described. there are a few more tests i'd like to add, but i think the code is at least correct (finally). a review would be much appreciated at this point.

@atombear atombear force-pushed the bug/embed_checks_bases branch from ff9f6d8 to c41ced9 Compare March 24, 2019 20:51
@david-pl david-pl closed this Mar 25, 2019
@david-pl david-pl reopened this Mar 25, 2019
@david-pl
Copy link
Member

I appreciate all your work. The changes look good and I agree with the new syntax, which makes a lot more sense especially in the case that I oversaw (embedding composite operators on bases such as e.g. [1,3]). I'm also not sure why the tests are failing. Hopefully it was just a hick-up, so I triggered them by closing/re-opening.

src/operators.jl Outdated Show resolved Hide resolved
src/operators.jl Outdated Show resolved Hide resolved
src/operators.jl Outdated Show resolved Hide resolved
@atombear atombear force-pushed the bug/embed_checks_bases branch from e98773e to a514ee7 Compare March 25, 2019 22:48
@david-pl david-pl merged commit fff4db5 into qojulia:master Mar 26, 2019
karolpezet added a commit to karolpezet/QuantumOptics.jl that referenced this pull request Feb 12, 2020
* fix ishermitian for dense and sparse operator

* Fix manybody deprecated syntax

* Change steady state sorting (qojulia#231)

* Sort by absolute value of real part

* Move normalization and sort by absolute value

* Update checking and error message

* Fix steady eig docstring formatting

* Bump REQUIRE to v0.7-beta2 (qojulia#230)

* Bump REQUIRE to v0.7-beta2

* Fix deprecations

* Fix deprecations

* Remove Compat imports

* Change WignerSymbols version

* First successful build

* Fock tests pass

* Some more tests pass

* All tests except printing pass

* Replace Complex128 with ComplexF64 in tests

* Rename Complex128 to ComplexF64

* Add FFTW requirement

* Update printing

* Add Arpack requirement

* Add rounding to printing

* Update tests to use 0.7

* Fix compilation deprecation warnings

* Fix printing

* Fix deprecations

* Rename full to dense

* Fix some more deprecations

* More deprecations

* Fix operator deprecations

* Fix particle deprecations

* Fix all deprecations occurring in tests

* Update REQUIRE

* Update appveyor

* Fix a bug in subspace; export norm

* Fix silly bug in subspace

* v0.7 compatibility

* Implement macros to skip checks

commit f221430
Author: david-pl <[email protected]>
Date:   Fri Aug 17 11:16:22 2018 +0200

    Update macro docstrings

commit 62f10e8
Author: David Plankensteiner <[email protected]>
Date:   Tue Aug 14 21:17:58 2018 +0200

    Fix stochastic checks

commit 5c9eff5
Author: David Plankensteiner <[email protected]>
Date:   Tue Aug 14 20:45:51 2018 +0200

    Rename macros

commit f78cf33
Author: david-pl <[email protected]>
Date:   Tue Aug 14 16:01:36 2018 +0200

    Start renaming stuff

commit c5f8bd6
Author: David Plankensteiner <[email protected]>
Date:   Mon Aug 13 20:25:58 2018 +0200

    Implement macros to skip checks

* Define ' on Operator as dagger (qojulia#235)

* fix typo

* Enable v1.0 testing

* Implement parametric types (qojulia#238)

* Start parametric typing for Ket/Bra

* Fix tensor vararg for StateVector

* Fix subspacebasis field parameters

* Fix semiclassical state for kets

* Update testing scripts

* Fix typo in appveyor

* Fix semiclassical_stochastic ket typing

* Fix travis 1.0 testing

* Parametric typing for CompositeBasis

* Rename Operator to AbstractOperator

* Proper parametric type for CompositeBasis

* Parametric typing for operators

* Parametrize basis dimensions

* Revert "Parametrize basis dimensions"

This reverts commit b451987.

* Update basis checks for states

* Update basis checks for dense operators

* Update basis checks for sparse operators

* Update LazyProduct implementation

* Update LazySum implementation

* Update LazyTensor implementation

* Add non-type parameters where needed to ensure correct basis dispatch

* Update basis checks for schroedinger

* Update basis checks for metrics

* Update basis checks for phasespace

* Update basis checks for master

* Update basis checks for mcwf

* Update basis checks for semiclassical

* Update superoperators and steadystate

* Update basis checks for stochastic solvers

* Update timecorrelations basis checks

* Added parameter to FFToperators so the gemv! is type stable

* Add basis checks to FFT in-place multiplication

* Implement transpose forsparse/dense operators

* Proper recasting in mcwf

* Add some missing basis checks

* Fix silly copy-paste error

* Less strict typing for liouvillian

* Mention gitter in readme text

* Some dots for states and operators
Squashed commit of the following:

commit abc523b
Author: david-pl <[email protected]>
Date:   Fri Jan 11 10:28:33 2019 +0100

    Broadcasting for states, operators and superoperators

commit 838f717
Author: David Plankensteiner <[email protected]>
Date:   Sat Dec 8 12:59:47 2018 +0100

    Use custom broadcasting styles

commit bedef6e
Author: David Plankensteiner <[email protected]>
Date:   Fri Dec 7 11:49:40 2018 +0100

    Broadcasting for sparse and dense operators

* Fix typo in macro export

* Fix @warn and implement adjoint(StateVector)

* Update tests to newer Julia versions

* Fix documentation of gaussianstate

* Patch failing tests

* created coherentstate! for inplace operations

* Fix bug in MCWF display_afterevent

* before embedding check that the destination basis matches the operator basis (qojulia#246)

* before embedding check that the destination basis matches the operator basis

* Change embed to handle composite operators

* perform embedding of an operator in a joint hilbert space

* functional embedding with new syntax

* more tests for composite bases

* code review and a few more tests

* Change Int64 to Int in type checks for x86

* remove intersect and union from sortedindices, as there are appropriate methods in Base

* Fix default choice of noise for stochastics

* Add Bloch-Redfield master equation (qojulia#250)

* Added bloch_redfield_master submodule

Added the option for a Bloch-Redfield master equation in the timeevolution module

* Add files via upload

* Delete bloch_redfield_master.jl

* Delete QuantumOptics.jl

* Update bloch_redfield_master.jl

* Cleaned up and commented new bloch_redfield_master submodule

* Delete bloch_redfield_master.jl

* Moved bloch_redfield_master to correct location...

* Re-added coherentstate! (inplace)

* Add simple test

* Include new test file

* Replace vec2mat_index by CartesianIndices

* Use timeevolution_base for BR master

* Added docstrings and renamed c_ops kwarg to J

Changed c_ops kwarg in bloch_redfield_tensor to J to be consistent with Linblad ME implementation

* Fix a bug and better saving

* Type-stable fout

* Fixed docstring typos in bloch_redfield_master

* Update README.md

* Switch to Project.toml

* Update Project.toml

* Abstractions for quantum information on qubits (qojulia#251)

* created abstractions for quantum information on qubits

* changed how equality is handled and added tests

* code review

* cleanup on types and added tests

* code review and composition for chi and ptm

* better caching

* code review for isapprox vs ==

* Move windows tests to travis

* Improve in-place multiplication for lazy types

* Patch bug in mcwf_dynamic

* Make entropy_vn type-stable

* Update Project.toml

* Restrict broadcasting of functions on states and operators

* Make bases immutable

* use ARPACKException from Arpack.jl

* Semiclassical MCWF (qojulia#255)

* MCWF jump times and indices (qojulia#257)

* semicl mcwf

* semicl mcwf läuft

* semiclassical mcfw

* Change MCWF interface to display jumps

* Semiclassical mcwf with display event

* Add display_which and display_t to semiclassical mcwf

* Clean up integrate_mcwf

* Clean up semiclassical mcwf

* Add docstrings

* Add docstrings in semiclassical.mcwf

* Fix tests

* Update Project.toml

* Remove QuantumOpticsBase functionality (qojulia#259)

* Remove QuantumOpticsBase functionality

* Re-add changes to mcwf interface lost during deletion

* Update semiclassical mcwf docstrings

* Fix precompilation

* Add superoperator tests that cannot run in Base

* Re-add spectralanalysis

* Separate stochastic base functionality from timeevolution

* Update Project.toml

* Type-stable bloch_redfield_tensor (qojulia#262)

* Made bloch_redfield_tensor function type-stable

* Quick patch failing tests

* Install TagBot as a GitHub Action

* Update Project.toml

Co-authored-by: goropikari <[email protected]>
Co-authored-by: David Plankensteiner <[email protected]>
Co-authored-by: David Nadlinger <[email protected]>
Co-authored-by: Louis Ponet <[email protected]>
Co-authored-by: wolfgang-n <[email protected]>
Co-authored-by: alexander papageorge <[email protected]>
Co-authored-by: sd109 <[email protected]>
Co-authored-by: Kristoffer Carlsson <[email protected]>
Co-authored-by: Julia TagBot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

embed with false indexing overwrites sub-basis
3 participants