Coder Social home page Coder Social logo

juliaquantumcontrol / krotov.jl Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 2.0 17.42 MB

Julia implementation of Krotov's method for quantum optimal control

Home Page: https://juliaquantumcontrol.github.io/Krotov.jl

License: MIT License

Makefile 4.14% Julia 95.86%
julia krotov numerical-methods optimal-control quantum

krotov.jl's Introduction

JuliaQuantumControl Dev Environment

The packages within the JuliaQuantumControl organization are tightly coupled. Development on any package should happen in conjunction with all other packages.

When developing on a Unix system (WSL is recommended on Windows), you should use this repository to set up a development environment:

git clone [email protected]:JuliaQuantumControl/JuliaQuantumControl.git
cd JuliaQuantumControl
make clone

This will clone all the active project repos within the JuliaQuantumControl organization into a subfolder of JuliaQuantumControl. You may then navigate into any of the project folders for development, e.g.

cd QuantumControlBase.jl
make test
make devrepl

The Makefile for each project is set up such that testing happens automatically against the current state of all sibling folders (the entire organization). Run just make within each project for available make-targets.

Org-level Makefile

You may also perform some development tasks across the entire organization by using make within the parent JuliaQuantumControl folder. E.g.,

make pull

will pull the current state of all org projects from Github,

make status

will show the state of all checkouts, and

make distclean testall

will run a complete set of tests for the entire organization.

You can also run

make devrepl

for a Julia REPL with the dev-version of all projects available. Note that this is in addition to the development REPL available for each individual project (make devrepl in the project folder), which also has access to the sibling projects.

Making Releases

If releases need to be made for multiple packages across the organization, they must be made in the order listed in the package table

For each package, for a release X.Y.Z, e.g. 1.0.0, do the following from the master branch:

  • git checkout -b release-1.0.0
  • Modify Project.toml to bump to the new version number, set compat for all dependencies in the JuliaQuantumControl org to the latest release (removing any >= specification)
  • Make a commit with message "Release 1.0.0"
  • git push -u origin release-1.0.0
  • Create a pull request
  • Apply the "no changelog" label
  • Wait for continuous integration to finish
  • Go to the main Github profile for the package
  • Select the release-1.0.0 branch in the top left
  • Click on the commit ID of the release commit in the table title row
  • Comment @JuliaRegistrator register on the commit
  • Wait for JuliaRegistrator and Tagbot to make and tag a release, wait for all CI to finish
  • In the terminal, switch to the master branch
  • git merge --no-ff --no-commit release-1.0.0
  • Edit Project.toml to append +dev to the version number (e.g., 1.0.0+dev), prepend >= to the compat specification of all dependencies in the JuliaQuantumControl organization.
  • git commit to make a merge commit, use "Bump version to 1.0.0+dev" as the commit message
  • git push to push the master

The QuantumControlRegistry

Working with unregistered packages in Julia is tricky.. Therefore, we have a QuantumControlRegistry to register any packages within the JuliaQuantumControl organization that should not be or are not ready yet for the Julia General Registry. Packages must be registered either in QuantumControlRegistry or in General: when a package gets added to General, it should be removed from QuantumControlRegistry.

To add the QuantumControlRegistry to your julia installation, run

pkg> registry add https://github.com/JuliaQuantumControl/QuantumControlRegistry.git

To add packages to QuantumControlRegistry, or create new releases for previously added packages, use the LocalRegistry.register command in the org-level REPL (make devrepl), e.g.,

using LocalRegistry
register("./GRAPELinesearchAnalysis.jl/", registry="QuantumControlRegistry")

See

help?> register

or the LocalRegistry documentation for details.

krotov.jl's People

Contributors

github-actions[bot] avatar goerz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

krotov.jl's Issues

`optimize` mutates guess pulses

When the guess controls are actually pulses (vectors defined on the midpoint of the time grid), the optimization will mutate the original objective.generator. This happens because currently, disretize_on_midpoints simply returns the input vector instead of a copy of the input vector.

using Test
using QuantumControl
using LinearAlgebra
using StableRNGs
using QuantumControlTestUtils.DummyOptimization: dummy_control_problem
using QuantumControl.Controls: get_controls, discretize_on_midpoints
using QuantumControl.Functionals: J_T_re

rng = StableRNG(1244561944)

# The problem occurs when the controls are actually pulses (on the midpoints of
# the time grid), so that the optimization does not have to call
# `discretize_on_midpoints` internally
problem = dummy_control_problem(; pulses_as_controls=true)
nt = length(problem.tlist)
guess_pulse = QuantumControl.Controls.get_controls(problem.objectives)[1]
@test length(guess_pulse) == nt - 1
guess_pulse_copy = copy(QuantumControl.Controls.get_controls(problem.objectives)[1])

# Optimizing this should not modify the original generator in any way
res = optimize(problem; method=:krotov, J_T=J_T_re, iter_stop=2)
opt_control = res.optimized_controls[1]
@test length(opt_control) == nt  # optimized_controls are always *on* tlist
opt_pulse = discretize_on_midpoints(opt_control, problem.tlist)
post_pulse = QuantumControl.Controls.get_controls(problem.objectives)[1]

# * The generator should still have the exact same objects as controls
@test guess_pulse  post_pulse
# * These objects should not have been modified
@test norm(guess_pulse_copy - guess_pulse)  0.0  # FAILS
# * But the values of the optimized pulse should differ from the pulse in the
#   generator
@test norm(post_pulse - opt_pulse) > 0.1  # FAILS

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Releases

This is an ongoing issue to trigger package registration

Time integrated functional

I am trying to optimise the control pulse to empty an optical resonator as fast as possible by, e.g switching off a driving field and controlling its detuning from the resonance frequency.

The initial state is therefore a coherent state, and the final one, the vacuum. To maximise the speed at which the cavity is empty the cost function to minimise would be, e.g, the photon number integrated cross the dynamics. Is there a way to set this as the optimisation functional?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.