Coder Social home page Coder Social logo

tpogden / maxwellbloch Goto Github PK

View Code? Open in Web Editor NEW
31.0 4.0 12.0 33.05 MB

A Python package for solving the coupled Maxwell-Bloch equations describing the nonlinear propagation of near-resonant light through thermal quantised systems such as atomic vapours.

License: MIT License

Python 98.63% Shell 0.81% Makefile 0.57%
quantum-optics quantum-information quantum-mechanics optics photonics

maxwellbloch's Introduction

MaxwellBloch

Build Status Documentation Status Coverage Status PyPI

MaxwellBloch is a Python package for solving the coupled Maxwell-Bloch equations describing the nonlinear propagation of near-resonant light through thermal quantised systems such as atomic vapours.

Above is an example solution for the propagation of a 4π pulse through a dense atomic vapour. The pulse immediately breaks up on entering the medium and the resultant pulses form two optical solitons each with a pulse area of 2π.

Documentation

Docs for the project are at maxwellbloch.readthedocs.io.

Install

I recommend using Conda environments.

You can create and activate an environment named mb with all the required dependencies for MaxwellBloch with

conda create --name mb -c conda-forge python=3 numpy=1 scipy=1 qutip=4
conda activate mb

The MaxwellBloch package can then be installed from PyPI using

pip install maxwellbloch

More detailed installation instructions can be found in the docs along with many example problems.

Attribution

If you use MaxwellBloch for research, please use the following citation:

@misc{ogden2020maxwellbloch,
  author = {Ogden, Thomas P.},
  title = {{MaxwellBloch}: a Python package for solving the coupled 
    Maxwell-Bloch equations describing the nonlinear propagation of 
    near-resonant light through thermal quantised systems such as atomic 
    vapors.},
  year = {2020},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/tpogden/maxwellbloch}}
}

Changelog

See CHANGELOG.md.

License

MIT License. See LICENSE.txt.

maxwellbloch's People

Contributors

amcdawes avatar tpogden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

maxwellbloch's Issues

Fix bug: Rabi frequencies wrong for multiple coupled levels

This looks to me to be a serious bug:

    ...
        for f in self.fields:
            
            H_Omega = qu.Qobj(np.zeros([self.num_states, self.num_states]))
            
            for c in f.coupled_levels:
                H_Omega += self.sigma(c[0],c[1]) + self.sigma(c[1],c[0])
                H_Omega *= pi*f.rabi_freq # 2π*rabi_freq/2
    ...

The H_Omega *= pi*f.rabi_freq # 2π*rabi_freq/2 line should be happening in the fields loop, not the coupled_levels loop. This will result in the value being multiplied too many times in the case of multiple coupled levels -- we've probably not hit this so far

https://github.com/tommyogden/maxwellbloch/blob/master/maxwellbloch/ob_atom.py#L140

Add OBAtom.build() method

This should build the Atom operators (H_0, H_Delta, H_Omega) or more usefully rebuild in the case that we've changed something post-init in the fields, like supplying a custom t_func.

  • build_H_0() should take no arguments, just like build_H_Delta() and build_H_Omega(). So should build_c_ops().

Add ability to shift to a fixed frame of reference

The problem is solved in the frame of reference moving at the speed of light. To convert into the fixed (lab) frame of reference, we need to skew the field results along the time axis, as well providing a fixed frame tlist.

This requires two methods on MBSolve:

  • tlist_fixed_frame(speed_of_light)
  • Omegas_fixed_frame(speed_of_light)

Write tests for Field.build_rabi_freq_t_func method

Motivation

Test coverage for this method.

Tasks

The following cases should be covered:

  • The t_func argument is None (i.e. no time dependence)
  • The t_func argument is a correct string (e.g. 'square_1', 'ramp_onoff_2')
  • The t_func argument is an incorrect string (e.g. 'foo_1')

Allow t_funcs to be set without field number

I want the fields to be defined without the field number, i.e. rabi_freq_t_func: gaussian instead of rabi_freq_t_func: gaussian_1.

I could do this in OBAtom.build_fields. Take each dict and append the number there.

Omegas_fixed_frame uses real rather than abs values

  • We cannot interpolate complex values so the Omegas_fixed_frame method currently takes the real part. But in most cases we are using the abs values.
  • We should name the method Omegas_abs_fixed_frame and possibly also include a Omegas_real_fixed_frame, Omegas_angle_fixed_frame in case we want them.
  • Can't it also use vectorised values ofthe new arrays rather than loop?

Unnest the mbsolve loop

Problem

Moving through the z steps is currently done with nested loops, with the outer loop representing those steps in which we want to save the result. We have both z_step and z_step_inner.

I.e. if we need 200 steps for numerical stability, but we only want to record the result at 50 points, we would set z_step: 50 and z_step_inner: 4.

Solution

It will be simpler to have a single loop, and just save when we need to. It will introduce additional comparisons in the loop which brings some cost, but this should be negligible. It should also simplify things when we want to bring in different behaviour on the first and second steps.

Remove MBSolve.insert_first_inner_z_step

  • If z_steps_inner == 1 then we end up with z_list[1] == z_list[2].
  • This means that z_list is not strictly increasing. It is reasonable to expect that both z_list and t_list are strictly increasing lists.
  • It is now my opinion that the small first Euler step is more trouble than it is worth. While it prevents large error being introduced in the first step, in nearly every case we start at a z_0 before any atoms are present. This means that for either an Euler or AB step, nothing happens to the field anyway.
  • I've already found one problem I think is due to z_list not strictly increasing -- the 2D interpolation to shift back to a fixed frame is unstable.

Fix bug: Save function calls OBSolve save on each step

The save method added to MBSolve in #28 caused the OBSolve save method to be called each step. This is not what we want.

Move the OBSolve save functionality back to OBBase and stop the MBSolve solver from calling it each z-step.

Fix Field to_from_json_str test

The test doesn't work because it expects the t_func to be passed to the json_dict as a string, e.g. 'square_1', but it's actually passing the function, square_1.

Fix time functions

There's a few problems with the time functions in t_funcs.py that need fixing.

  • The gaussian_fwhm_[1] functions should just be called gaussian_[1] as this is how we're defining Gaussians.
  • The ramp_on_[1] functions are to use fwhm_[1] and on_[1] insteady of width_[1] and centre_[1] for clarity.
  • Same for ramp_off_[1] and ramp_onoff_[1].
  • The ramp_onoff_[1] functions are defined incorrectly and will not work as expected for amplitudes other than 1.0. Fix this.

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.