Skip to content

Commit

Permalink
Keeping this file
Browse files Browse the repository at this point in the history
  • Loading branch information
leespen1 committed Sep 20, 2024
2 parents 2afddae + ccd7eea commit 2bfc568
Show file tree
Hide file tree
Showing 87 changed files with 1,266 additions and 7,195 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
BSplines = "488c2830-172b-11e9-1591-253b8a7df96d"

[weakdeps]
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
Expand Down
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
[![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://leespen1.github.io/QuantumGateDesign.jl/dev/)
# QuantumGateDesign.jl
Julia package for quantum optimal control using Hermite methods.
Julia package for designing quantum gates via quantum optimal control using
high-order Hermite methods.

## Installation
`QuantumGateDesign` may be installed using the following commands:
```
julia> ]
pkg> add /~https://github.com/leespen1/QuantumGateDesign.jl.git
```

## Basic Workflow
The basic workflow consists of the steps
1. Set up a `SchrodingerProb`, which determines the Hamiltonian of the system,
as well as some other properties involved in the numerical simulation of
Schrodinger's equation.
2. Set up the controls, which determine the basis used for controlling the pulse
amplitudes used manipulate the quantum system.
3. Set up the target matrix which defines the target gate to be implemented by
this package.
4. Choose an initial guess for the control vector.
5. Optimize the control vector by calling `optimize_gate`.

For a more detailed understanding, please read the documentation.

## Current State and Future Work
QuantumGateDesign.jl is still in an early stage of development, so there are
bound to be bugs, and the API is subject to change in the future. If you have
any bug reports, feature suggestions, or questions about how this package works,
please contact Spencer Lee at leespen1@msu.edu.

# Future Features
- "Memory lean" discrete adjoint.

# Bug Fixes
- Type issues for getting gradients of control functions using automatic
differentiation.
10 changes: 0 additions & 10 deletions comparison_test.jl

This file was deleted.

119 changes: 77 additions & 42 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,52 +81,87 @@ target = vcat(real(target_complex), imag(target_complex))
ret_dict = optimize_gate(prob, control, pcof, target, order=4)
```

### 3 Qudit System with Jaynes-Cummings Coupling
### 2 Qudits in the Dispersive limit
QuantumGateDesign.jl provides convenience functions for setting up
several [`SchrodingerProb`](@ref)'s which arise frequently in quantum computing.
The code below uses the `DispersiveProblem` constructor to make a
`SchrodingerProb` representing two qubits in the dispersive limit.



```
using QuantumGateDesign
# Set up the SchrodingerProb
subsystem_sizes = (4,4)
essential_subsystem_sizes = (2,2)
transition_freqs = [4.10595, 4.81526] .* 2pi
rotation_freqs = copy(transition_freqs)
# 0.1 for artificially large fast coupling. Actual value is 1e-6
kerr_coeffs = 2pi .* [2*0.1099 0.1
0.1 2*0.1126]
tf = 50.0
nsteps = 100
sparse_rep=true
prob = DispersiveProblem(
subsystem_sizes, essential_subsystem_sizes,
transition_freqs, rotation_freqs, kerr_coeffs,
tf, nsteps;
sparse_rep=sparse_rep
)
# Set up the Controls
carrier_wave_freqs = transition_freqs .- rotation_freqs
bspline_degree = 2
N_knots = 5
D1 = 10
fa = sum(transition_freqs) / length(transition_freqs)
om1 = 2pi .* [transition_freqs[1] - rotation_freqs[1],
transition_freqs[1] - rotation_freqs[1] - kerr_coeffs[1,2],
]
om2 = 2pi .* [transition_freqs[2] - rotation_freqs[2],
transition_freqs[2] - rotation_freqs[2] - kerr_coeffs[1,2],
]
# Transition frequencies in GHz
transition_frequencies = [5.18, 5.12, 5.06]
# Rotation frequency to use in each subsystem
# (for Jaynes-Cummings, must be same in all subsystems so system Hamiltonian is time-independent)
rotation_frequency = 5.12
# The self-Kerr coefficients (we ignore cross-kerr here)
kerr_coefficients = [
0.34 0 0
0 0.34 0
0 0 0.34
]
# The cross resonance coefficients (Jayne-Cummings coupling)
cross_resonance_coefficients = [
0 5e-3 0
5e-3 0 5e-3
0 5e-3 0
]
# Number of timesteps
nsteps = 500
# Gate duration (nanoseconds)
tf = 500
# Model each qudit with 3 levels, 2 of which are used for computation
subsystem_sizes = [3, 3, 3]
essential_levels_vec = [2, 2, 2]
prob = QuantumGateDesign.JaynesCummingsProblem(
subsystem_sizes,
essential_levels_vec,
transition_frequencies,
rotation_frequency,
kerr_coefficients,
cross_resonance_coefficients,
tf,
nsteps
control1 = BSplineControl(tf, D1, om1)
control2 = BSplineControl(tf, D1, om2)
controls = [control1, control2]
N_coeff = get_number_of_control_parameters(controls)
amax = 0.04 # Keeping pulse amplitudes below 40 MHz
pcof0 = rand(N_coeff) .* 0.04 / 10
# Set up target gate
CNOT_target = create_gate(
subsystem_sizes, essential_subsystem_sizes,
[(1,0) => (1,1),
(1,1) => (1,0)]
)
# Transform target into rotating frame
rot_mat = rotation_matrix(subsystem_sizes, rotation_freqs, tf)
CNOT_target_complex = real_to_complex(CNOT_target)
CNOT_target_rotating_frame_complex = prod(rot_mat) * CNOT_target_complex
CNOT_target = complex_to_real(CNOT_target_rotating_frame_complex)
# Compare stepsize to relative error in solution history
run_convergence_test = false
if run_convergence_test
convergence_dict = QuantumGateDesign.get_histories(prob, controls, pcof0, 15, base_nsteps=100, orders=(2,4))
pl1 = QuantumGateDesign.plot_stepsize_convergence(convergence_dict)
pl2 = QuantumGateDesign.plot_timing_convergence(convergence_dict)
end
# Use step sizes based on output of above tests
nsteps_order2 = trunc(Int, tf/10.0^(-3.5))
nsteps_order4 = trunc(Int, tf/10.0^(-0.5))
#prob.nsteps = nsteps_order2
prob.nsteps = 100
return_dict_order2 = optimize_gate(prob, controls, pcof0, CNOT_target, order=2, maxIter=50, pcof_L=-amax, pcof_U=amax)
prob.nsteps = nsteps_order4
return_dict_order4 = optimize_gate(prob, controls, pcof0, CNOT_target, order=4, maxIter=50, pcof_L=-amax, pcof_U=amax)
```
35 changes: 0 additions & 35 deletions examples/2D_problem.jl

This file was deleted.

48 changes: 0 additions & 48 deletions examples/Proposal/adam.jl

This file was deleted.

Loading

0 comments on commit 2bfc568

Please sign in to comment.