q-optimize / c3

Toolset for control, calibration and characterization of physical systems
https://c3-toolset.readthedocs.io/
Apache License 2.0
69 stars 35 forks source link

Adding state propagation using RK methods #223

Closed Ashutosh-Mishra2 closed 2 years ago

Ashutosh-Mishra2 commented 2 years ago

What

Adds state propagation using RK methods for calculating the dynamics. Also adds a method to just calculate the final state using the same method which might be faster for optimizations where only the final state is required.

Why

Evolution of quantum system by calculating the superoperators can become computationally expensive very fast as the Hilbert space dimension increases. In these cases a propagation of states using RK methods can be faster.

How

Added a new method "compute_states" in experiment class which calls an ode solver to solve the required ode (Schrodinger equation/ Von Neumann equation/ Lindblad master equation). Also there are various solvers , e.g. RK4, RK5 etc. and step functions that the user can specify.

Remarks

Checklist

Please include and complete the following checklist. Your Pull Request is (in most cases) not ready for review until the following have been completed. You can create a draft PR while you are still completing the checklist. Check the Contribution Guidelines for more details. You can mark an item as complete with the - [x] prefix

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

lazyoracle commented 2 years ago

@Ashutosh-Mishra2 Can you sign the CLA by clicking on the link the comment above?

Ashutosh-Mishra2 commented 2 years ago

I have signed, it but it says the status is still pending. Does it usually take a few minutes?

codecov[bot] commented 2 years ago

Codecov Report

Merging #223 (14b9292) into dev (ee6a8ca) will increase coverage by 1.41%. The diff coverage is 87.41%.

@@            Coverage Diff             @@
##              dev     #223      +/-   ##
==========================================
+ Coverage   74.87%   76.29%   +1.41%     
==========================================
  Files          38       38              
  Lines        5549     5804     +255     
==========================================
+ Hits         4155     4428     +273     
+ Misses       1394     1376      -18     
Impacted Files Coverage Δ
c3/optimizers/optimalcontrol.py 63.15% <50.00%> (-4.29%) :arrow_down:
c3/utils/tf_utils.py 72.30% <81.25%> (+4.87%) :arrow_up:
c3/experiment.py 81.34% <90.90%> (+6.51%) :arrow_up:
c3/libraries/propagation.py 76.82% <92.00%> (+15.26%) :arrow_up:
c3/model.py 88.64% <92.59%> (+1.04%) :arrow_up:
c3/libraries/fidelities.py 36.66% <100.00%> (+2.56%) :arrow_up:
c3/optimizers/optimizer.py 80.17% <100.00%> (+0.08%) :arrow_up:
c3/signal/gates.py 94.89% <100.00%> (ø)
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

nwittler commented 2 years ago

Some of the code climate things should be easy to fix, like not using CamelCase for some function. The complaints about copy-paste code in the examples we can live with from my perspective.

lazyoracle commented 2 years ago

Agree. Anything to do with examples can be left as is, but we should try to fix the other warnings in code climate. Can we get more test coverage because that seems to have dropped with the new changes in this PR?

shaimach commented 2 years ago

RK, as a general-purpose ODE solver, has a tendency not to preserve state norms. Consider adding an assert to check it is still within epsilon of 1 (IMHO, a reasonable default would be 1e-6).