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

Adding Bloch-Redfield master equation #250

Merged
merged 17 commits into from
May 31, 2019
Merged

Adding Bloch-Redfield master equation #250

merged 17 commits into from
May 31, 2019

Conversation

sd109
Copy link
Contributor

@sd109 sd109 commented May 27, 2019

I've added the bloch_redfield_master file which contains a function for calculating the Bloch-Redfield tensor (Liouvillian) and the corresponding time dynamics. I didn't fully understand how the ODE solving was implemented in timeevolution_base so I have just written my own simple ODE solving function (bloch_redfield_dynamics) but maybe it would be better to keep this consistent with the rest of QO.jl?

@david-pl
Copy link
Member

In principle the integrate function in timeevolution_base just takes the function that is later passed to DiffEq (in your case ρ_dot) and creates an in-place ODEProblem. Rewriting your code to do this should be rather straightforward and I can do it.

Since I'm not so familiar with the Bloch-Redfield formalism: do you have an example, where the result is known, so we can test the implementation?

@sd109
Copy link
Contributor Author

sd109 commented May 27, 2019

I have checked that the Julia function gives the same numerical results for the Bloch-Redfield tensor and the dynamics as the QuTiP version. So if by "known" you mean that it has been calculated numerically elsewhere then I guess this example from the QuTiP documentation is something that I can easily recreate as a test (or any of the other tests from the QuTiP github I guess).

If you would prefer a test case that can be checked against an analytical calculation then I would have to think about this some more as I don't know of any off the top of my head but it should be possible to come up with one in principle.

@david-pl
Copy link
Member

Thanks for pointing out the example. Actually, we don't have to recreate the entire thing, but can just check against the numerical values of the tensor and states after some dynamics.

@sd109
Copy link
Contributor Author

sd109 commented May 27, 2019

I've still not got round to learning about testing etc. in Julia so don't know how to add the tests myself but here is the Julia version of the QuTiP example which reproduces the same numerical values for the tensor:

using QuantumOptics

Δ = 0.2 * 2*π
ϵ0 = 1.0 * 2*π
γ1 = 0.5

b = SpinBasis(1//2)
sx = sigmax(b)
sz = sigmaz(b)

H = -Δ/2.0 * sx - ϵ0/2.0 * sz

function ohmic_spectrum(ω)
    ω == 0.0 ? (return γ1) : (return γ1/2 */ (2*π)) *> 0.0))
end

R, ekets = timeevolution.bloch_redfield_tensor(H, [[sx, ohmic_spectrum]])

dense(R).data

@david-pl
Copy link
Member

Alright, I changed the function so it now uses the internal integration routine. There is still some stuff to do. For one, the saving seems to be type-unstable in the current implementation. Also, the back-transformation from the eigenspace of H can be more efficient. I will look into that.
We should also include some proper doc-strings as documentation.

Could you check if the changes I made didn't break anything? Are the dynamics the same as before? Note that I also renamed the function for the dynamics to more closely resemble the other routines in the timeevolution module.

Changed c_ops kwarg in bloch_redfield_tensor to J to be consistent with Linblad ME implementation
@sd109
Copy link
Contributor Author

sd109 commented May 29, 2019

I've checked that your changes didn't break anything and that the tensor and dynamics are the same as before. I've also added docstrings for the tensor and dynamics functions and included a reference to the QuTiP docs since this implementation is based on theirs.

@david-pl
Copy link
Member

Ok great, thanks! The tests will fail, but that's unrelated and already fixed on master.
I'll see when I can get around to improving the saving and then we're ready to go here.

@coveralls
Copy link

coveralls commented May 30, 2019

Coverage Status

Coverage decreased (-0.09%) to 96.526% when pulling 1a56b92 on sd109:master into bbe6777 on qojulia:master.

@codecov
Copy link

codecov bot commented May 30, 2019

Codecov Report

Merging #250 into master will decrease coverage by 0.09%.
The diff coverage is 93.18%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #250     +/-   ##
=========================================
- Coverage   96.61%   96.51%   -0.1%     
=========================================
  Files          36       37      +1     
  Lines        2869     2959     +90     
=========================================
+ Hits         2772     2856     +84     
- Misses         97      103      +6
Impacted Files Coverage Δ
src/QuantumOptics.jl 100% <ø> (ø) ⬆️
src/bloch_redfield_master.jl 93.18% <93.18%> (ø)
src/timeevolution_base.jl 100% <0%> (ø) ⬆️

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 bbe6777...0fd67cd. Read the comment docs.

@codecov
Copy link

codecov bot commented May 30, 2019

Codecov Report

Merging #250 into master will decrease coverage by 0.09%.
The diff coverage is 93.61%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #250     +/-   ##
=========================================
- Coverage   96.61%   96.52%   -0.1%     
=========================================
  Files          36       37      +1     
  Lines        2869     2965     +96     
=========================================
+ Hits         2772     2862     +90     
- Misses         97      103      +6
Impacted Files Coverage Δ
src/QuantumOptics.jl 100% <ø> (ø) ⬆️
src/bloch_redfield_master.jl 93.61% <93.61%> (ø)
src/timeevolution_base.jl 100% <0%> (ø) ⬆️

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 bbe6777...1a56b92. Read the comment docs.

@david-pl
Copy link
Member

Could you have one last look at this and let me know if everything's okay from your side? I'll merge then.

@sd109
Copy link
Contributor Author

sd109 commented May 31, 2019

All looks good to me now, thanks for your help!

@david-pl david-pl merged commit 4c367c4 into qojulia:master May 31, 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 <david.plankensteiner@gmx.at>
Date:   Fri Aug 17 11:16:22 2018 +0200

    Update macro docstrings

commit 62f10e8
Author: David Plankensteiner <david.plankensteiner@uibk.ac.at>
Date:   Tue Aug 14 21:17:58 2018 +0200

    Fix stochastic checks

commit 5c9eff5
Author: David Plankensteiner <david.plankensteiner@uibk.ac.at>
Date:   Tue Aug 14 20:45:51 2018 +0200

    Rename macros

commit f78cf33
Author: david-pl <david.plankensteiner@gmx.at>
Date:   Tue Aug 14 16:01:36 2018 +0200

    Start renaming stuff

commit c5f8bd6
Author: David Plankensteiner <david.plankensteiner@uibk.ac.at>
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 <david.plankensteiner@gmx.at>
Date:   Fri Jan 11 10:28:33 2019 +0100

    Broadcasting for states, operators and superoperators

commit 838f717
Author: David Plankensteiner <david.plankensteiner@uibk.ac.at>
Date:   Sat Dec 8 12:59:47 2018 +0100

    Use custom broadcasting styles

commit bedef6e
Author: David Plankensteiner <david.plankensteiner@uibk.ac.at>
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 <goropikari56@gmail.com>
Co-authored-by: David Plankensteiner <david-pl@users.noreply.github.com>
Co-authored-by: David Nadlinger <code@klickverbot.at>
Co-authored-by: Louis Ponet <louisponet@gmail.com>
Co-authored-by: wolfgang-n <33723682+wolfgang-n@users.noreply.github.com>
Co-authored-by: alexander papageorge <atpapag@gmail.com>
Co-authored-by: sd109 <49713135+sd109@users.noreply.github.com>
Co-authored-by: Kristoffer Carlsson <kristoffer.carlsson@chalmers.se>
Co-authored-by: Julia TagBot <50554310+JuliaTagBot@users.noreply.github.com>
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.

3 participants