Git Product home page Git Product logo

ott's Introduction

ott - Optical Tweezers Toolbox

DOI Documentation Status View Optical Tweezers Toolbox on File Exchange

The optical tweezers toolbox can be used to calculate optical forces and torques of particles using the T-matrix formalism in a vector spherical wave basis. The toolbox includes codes for calculating T-matrices, beams described by vector spherical wave functions, functions for calculating forces and torques, simple codes for simulating dynamics and examples.

We are currently working on documentation and we welcome feedback/suggestions/comments. Additional documentation can be found via the Matlab help command or in the source code.

Installation and usage

There are several methods for installing the toolbox. If using Matlab, the easiest method is to launch Matlab and navigate to Home -> Addons -> Get-Addons and search for "Optical Tweezers Toolbox". Then, simply click the "Add from GitHub" button to automatically download the package and add it to the path. Alternatively, you can download the toolbox directly from the GitHub repository or select a specific release; if using this method you will need to add the toolbox directory to Matlab's path using

addpath('<download-path>/ott');
help ott   % Test that ott was found, should display ott Contents page

Regardless of the method you acquired OTT with, once installed you should be able to access the toolbox functions and classes contained in the ott.* package, for example

beam = ott.BscPmGauss();

or for the graphical user interface

ott.ui.Launcher

More detailed instructions can be found in the Getting Started section of the documentation.

Dependencies

The toolbox runs on recent versions of Matlab, most functionality should work on at least R2016b but the graphical user interface might need R2018a or newer. Most functionality should work with GNU Octave, however this has not been tested recently and performance is optimised for Matlab.

Some functionality may require additional dependences including additional Matlab products. We are currently working on a full list; however, if you encounter any difficulties with missing dependencies, please let us know and we may be able to find a workaround.

Quick-start guide

The toolbox has changed a lot since previous releases, the most notable change is addition of a graphical user interface (still a work-in-progress) and moving from a folder structure to a Matlab package structure. To get started, take a look at the documentation over on read the docs. The documentation source can be found in the docs directory or you can download a PDF copy of the documentation with the latest release. Alternatively, take a look at the examples directory.

To calculate the force on a spherical particle, you need to setup a beam object, setup a particle and run the ott.forcetorque function. For example:

beam = ott.BscPmGauss();
tmatrix = ott.TmatrixMie(0.5, 'k_medium', 2*pi, 'k_particle', 2*pi*1.3);
fz = ott.forcetorque(beam, tmatrix, 'position', [0;0;1].*linspace(-8, 8));
figure(), plot(fz.')

This example assumes everything is in units of the wavelength, and creates a Gaussian beam with the default parameters.

Recent changes

There have been many changes since the previous release, mainly the switch to object orientated programming. Beams and T-matrices are now represented by objects, we have added shape objects and moved everything into packages.

T-matrices are represented by Tmatrix objects. For simple shapes, the Tmatrix.simple method can be used to construct T-matrices for a variety of common objects. More complex T-matrices can be generated by inheriting the T-matrix class, for an example, take a look at TmatrixMie and TmatrixPm.

Beams are represented by a Bsc objects. A beam can be multiplied by T-matrices or other matrix/scalar values to generate new beams. For Gaussian type beams, including Hermite-Gauss, Ince-Gauss, and Laguarre-Gaussian beams, the BscPmGauss class provides the equivalent of bsc_pointmatch_farfield in the previous release.

The new implementation hides Nmax, most routines have a default choice of Nmax based on the beam/particle size. Nmax can still be accessed and changed manually, but in most cases the automatic choice of Nmax should be fine. Beams can T-matrices can be multiplied without needing to worry about the having equal Nmax, the beam/T-matrix will be expanded to match the maximum Nmax. If repeated calculations are being done, it may be faster to first ensure the Nmax of the beam and T-matrix match, this is done in forcetorque when the position or rotation arguments are used.

Upcoming release

  • Version 2 will introduces a focus on simulating particles in optical traps rather than just focussing on calculating optical forces and torques. The plan is also to introduce geometric optics and other methods not requiring a T-matrix. The toolbox will be more automated and include a graphical user interface.
  • Version 1.6 we may move Beams and Tmatrices to a beams and tmatrix sub-package. We might also add drag calculation codes.

Licence

Except where otherwise noted, this toolbox is made available under the Creative Commons Attribution-NonCommercial 4.0 License. For full details see LICENSE.md. For use outside the conditions of the license, please contact us. The toolbox includes some third-party components, information about these components can be found in the documentation and corresponding file in the thirdparty directory.

This version of the toolbox can be referenced by citing the following paper

T. A. Nieminen, V. L. Y. Loke, A. B. Stilgoe, G. Knöner, A. M. Branczyk, N. R. Heckenberg, and H. Rubinsztein-Dunlop, "Optical tweezers computational toolbox", Journal of Optics A 9, S196-S203 (2007)

or by directly citing the toolbox

I. C. D. Lenton, T. A. Nieminen, V. L. Y. Loke, A. B. Stilgoe, Y. Hu, G. Knöner, A. M. Branczyk, N. R. Heckenberg, and H. Rubinsztein-Dunlop, "Optical tweezers toolbox", https://github.com/ilent2/ott

and the respective Bibtex entry

@misc{Lenton2020,
  author = {Lenton, Isaac C. D. and Nieminen, Timo A. and Loke, Vincent L. Y. and Stilgoe, Alexander B. and Y. Hu and Kn{\ifmmode\ddot{o}\else\"{o}\fi}ner, Gregor and Bra{\ifmmode\acute{n}\else\'{n}\fi}czyk, Agata M. and Heckenberg, Norman R. and Rubinsztein-Dunlop, Halina},
  title = {Optical Tweezers Toolbox},
  year = {2020},
  publisher = {GitHub},
  howpublished = {\url{https://github.com/ilent2/ott}},
  commit = {A specific commit or version (optional)}
}

Contact us

The best person to contact for inquiries about the toolbox or lincensing is Isaac Lenton

File listing

README.md     - Overview of the toolbox (this file)
LICENSE.md    - License information for OTSLM original code
AUTHORS.md    - List of contributors (pre-GitHub)
CHANGES.md    - Overview of changes to the toolbox
TODO.md       - Changes that may be made to the toolbox
thirdparty/   - Third party licenses (multiple files)
examples/     - Example files showing different toolbox features
tests/        - Unit tests to verify toolbox features function correctly
docs/         - Sphinx documentation for the project
+ott/         - The toolbox

The +ott package, as well as tests/ and examples/ directories and sub-directories contain Contents.m files which list the files and packages in each directory. These files can be viewed in Matlab by typing help ott or help ott.subpackage.

ott's People

Contributors

ilent2 avatar jagangthejust avatar manfedmanfrito 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ott's Issues

About "Warning: Ignoring fz<0 entries at start of vector " may be a bug

"Ignoring fz<0 entries at start of vector" is warned when I run modified example_sphere.m file, but when I open the find_equilibrium.m file to find the corresponding 39 lines, run find(fz<0,1) is not equal to 1, but to 3, so the program should not run warning('Ignoring fz<0 entries at start of vector'), but the result is to continue executing the program below "if zeroindex ==1". The results are shown in the following charts.
I changed 4 things, 1 is n_medium=1.53 and n_particle=1.33; 2 is NA=0.8; 3 is radius=10e-6; 4 is linspace(-4,4,80)->linspace(-30,30,300).
image
image
image
image
Thank you Dr. Lenton for your patient answer earlier. I am currently writing a simulation paper on vortex optical tweezers, and I need to use your optical tweezers kit for simulation, but I still don't know enough about some parts of the program. Thank you for your help, and I can include you as the author when the paper is published. What do you think?

TmatrixPm with 4-th order rotational symmetry

I'm unsure what to do with the file ott/+ott/tmatrix_pm_cube.m in version 1.4

In version 1.4 I've added a TmatrixPm class with a static method for constructing simple T-matrices using the point matching method.

Should I create a subclass of TmatrixPm -> TmatrixPmCube or should I modify the simple() static method to use tmatrix_pm_cube instead? What is the purpose of tmatrix_pm_cube? Are there additional optimisations? What are Nmax_particle and Nmax_medium for?

Move utility functions to +utils sub package

It would be nice to move the utility functions to a +utils sub package. We could then also drop the backwards compatibility requirement on the utility functions (say they are for internal use and users should use them at their own risk).

Functions I think should be included in the +utils directory, there may be others...

  • angulargrid.m
  • spharm.m
  • vsh.m
  • iseven.m
  • rtp2xyz.m
  • vswf.m
  • isodd.m
  • rtpv2xyzv.m
  • wigner_rotation_matrix.m
  • sbesselh1.m
  • xyz2rtp.m
  • laguerre.m
  • sbesselh2.m
  • xyzv2rtpv.m
  • legendrerow.m
  • sbesselh.m
  • z_rotation_matrix.m
  • sbesselj.m

Octave and warnings

Octave is not happy about the ott_warning.m function:

error: invalid assignment to cs-list outside multiple assignment

error: invalid empty index list

error: invalid dimension inquiry of a non-existent value

A few options there of what to do, but I'll leave it to you to decide. One way is to make it detect matlab, another way is to leave it out for now? another way is to be very strict with lists and parameters so that it doesn't output "this is not defined" type error.

EDIT: Another option is to release an octave version without warnings.

Extinction coefficient

Dear Dr. Lenton
When I read the program and the corresponding documents, I didn't find the effect of the extinction coefficient of the captured particles on the radiation pressure, whether I didn't notice this. If we calculate the radiation pressure of graphite and metal particles, how should we define the absorption coefficient or extinction coefficient

BscPlane translations as phase shifts

It would be nice (and useful) to have an option to translate plane waves by applying a phase shift to the beam.

Important: need to make sure that the same translation rule isn't applied to beams once they have been scattered by another particle (or check that they are still compatible).

Optimisations for beam.translate

  • Add A,B matrices as output to all translate functions
  • Add option for output Nmax
  • Modify translate_z to output non-square matrices
  • Updates examples and maybe forcetorque to use optimisation

BscPmParaxial.m

RE: Our previous conversation, can you add the ability to override he fit points. This will be helpful for people calculating simple SLM beams which may not need many fit points.

GUI commands

It would be useful to add (maybe optionally) a printout to the command line of the code used in GUI. E.g. when I press Generate button in any gui window, I want to see which command was executed, so I can use it later in m-files. Also, it might be useful for those trying the toolbox for the first time.

Consistent T-matrix and beam set type methods

Replace toScattered, toTotal, and similar functions with a single set type function. For the matrix, use a set.type for default behaviour and a expand function for additional behaviour.

Add unit tests for this

Check other functions that could be simplified or replaced with a get.set interface

Make the toolbox a package

It would be good to make the toolbox into a package, this will reduce namespace pollution. The functions can be used individually, such as

ott.force_z(...)

or all the functions can be imported

import ott.*

This will require adding the above import to all toolbox functions that use other toolbox functions and changing the directory ott-toolbox to +ott, however this change breaks backwards comparability.

1.3.1 versus 1.4

I'm thinking that 1.3.1 shouldn't have the GUI as it appears to be a big deal. Suggest putting it in 1.4.

The refractive index of a medium varies with the laser of different wavelength

Does the program take into account the effect of different laser wavelengths on the refractive index of the medium (such as water)? Since the refractive index of most media is corresponding to the refractive index of D-light (589.3nm), while optical tweezers are commonly used for 1064nm laser, the corresponding refractive index of media will decrease somewhat at 1064nm band, resulting in slightly different results.
Thank you, Dr. Lenton

Multiple beams in BSC class

Add append method
Plane wave beam with multiple angles
Translate to multiple beams
Scatter for multiple beams

Absorption calculations?

I think this is a feature request but I may be overlooking a way to do what I want with the existing code so... please bear with me. I am interested in computing not only the scattering of fields from particles but also their absorption. Now, the SMARTIES code base constructs T-matrices using a formulation that looks like: T = -P*inv(Q) but the OTT just calculates T directly without that factorization. This works like: E_incident~(a;b), E_scattered~(p;q), and E_internal~(c;d) where my lowercase letters represent the coefficients of the basis functions, etc. Then (p;q) = T(a;b) tells the scattered from the incident using the T-matrix. But also we can do (p;q) = -P(c;d) and (a;b) = Q(c;d) or (c;d) = inv(Q)(a;b). It is this last bit that I think I need since only if I have the coefficients for the internal field components can I figure out the dissipated power?

As a note, the SMARTIES function that does this is called: "sphCalculatePQ" which says, "Calculates P,Q matrices for a spheroid using the algorithm of [JQSRT 123, 153 (2013)]" [here is the article: https://www.sciencedirect.com/science/article/pii/S0022407313000423 ]

Add Upgrading section to readme

Version 1.4 will be installed differently and have depreciated functionality. We should add a updating section to the readme for version 1.4.

At this stage, upgrading will consist of:

  1. Download the latest release of v1.3 (probably 1.3.1), run your scripts and look for depreciation warnings. Follow the instructions in the depreciation warnings to use the new functions.

  2. Download the new toolbox and include the package path. Remove the old toolbox from the path.

  3. Add import ott.* to all scripts using toolbox functions or prefix all toolbox functions with ott..

Unsure what to do with functions

Unsure what to do with:

  • axial_equilibrium.m
  • trapping_landscape.m
  • forcetorque.m
  • force_z.m

Perhaps other files in +utils package.

Unit tests for all components

Write a unit test file for each class/component. Check that it at least constructs/runs. We can add more tests latter.

Smarties method does not work

Attempting to use either the GUI for "Geometric Shape T-matrix" or the command line "ott.Tmatrix.simple" fails when the user attempts to use the documented optional parameter 'method' with the value 'smarties'. The error is thrown by the ott.TmatrixSmarties function on line 123 indicating that method is not a recognized parameter. This seems like the parameter is getting passed down from the ott.Tmatrix.simple function to the subsidiary ott.TmatrixSmarties function when it shouldn't be but I am unfamiliar with the object oriented programming approach in Matlab so I may be wrong here. It is also possible this errror is somehow due to smarties not being installed but, if so, the error does not seem to alert the user to that effect. (I did, in fact, install smarties and used the initpath function to add it to my path prior to running ott.) This error was seen using Matlab R2019b on Mac OS Catalina.

transform from center-of-mass frame to lab frame

Hi Dr. Issac Lenton,

I'm trying to do some scattering calculations with OTT in MATLAB. I'm able to follow the beam_visualization.m example and calculate the scattered fields when the trap beam (a gaussian beam) is offset from the particle. As I understand it, everything is in the particle's center-of-mass frame. I want to transform the far-field solutions back into the lab frame after the scattering calculation. Could you advise how I should proceed? Currently, translation in Y (using .translateXyz) seems to also cause some tilt in the far-field solutions without applying any scattering matrix. I attached a plot to show how the beam profile in blue in the translated Y dimension looks skewed in the particle's COM frame in the far field regime. I want to be in a rest frame of this incoming trap beam, where I think the beam profiles in any XY planes would look translated and not skewed. Any suggestions are appreciated.

backscatteredCOM

Thanks,
Yuqi

Issue with bsc_pointmatch_farfield normalisation

rw = (k * w0)^2 * tan(theta).^2 / 2;

Hi Alex,
There seems to be an issue with the power normalisation for bsc_pointmatch_farfield. Around line 175, rw is calculated from tan(theta).^2, where theta is in the range ((1:ntheta)-0.5)/ntheta*pi which will sometimes be approximately pi/2. Even when it is not exactly pi/2, nearby values still cause a problem since rw is later used in exp(rw/2 + ...) which quickly becomes too large.
Could you take a look at this.
Cheers,
Isaac

Check documentation on all files

  • Make usage consistent across all files
  • Function names should be in bold
  • Class names should match class declaration
  • Classes should have list of methods and properties
  • PACKAGE_INFO should be replaced by the following text

% This file is part of the optical tweezers toolbox. % See LICENSE.md for information about using/distributing this file.

Warnings

The Warning messages are obtrusive in 1.3.1. It is possible to change a particular warning state (using the tag) to only display a warning once.

Setting the T-matrix of particle with other shape in GUI

Hi Issac, how can I set the T-matrix of particle with cylinder shape in GUI? I set the radius and height with 1e-7 and 3e-6 respectively. But system went worry and told me haven't defined the 'mtimes' function. My MATLAB version is 21b and using toolbox version 1(available in github).

emFieldXyz: E-field units

Dear Dr. Lenton,

I have a small question regarding the units for E-field plotted via emFieldXyz method. I couldn't find the info about the units for electric field, so, I wonder whether emFieldXyz returns fields in SI (i.e., V/m for E-field), or they somehow inherit the normalization from beam.power = 1 (as was suggested in the documentation). So, should I convert the obtained fields by hands? I found how to convert forces from normalized units to SI, but the same trick with E-field is not so clear for me.

Thank you in advance.

Best regards,
Gleb Fedorovich

Optimise examples

The examples are running really slowly. We should be able to optimise them to run at a speed comparable to the previous release.

Filling factor

Is there a predefined filling factor (ratio between beam waist and aperture radius)? I couldn't find a method to change either the aperture size or the beam waist so I assume there must be one. However, in one of the additional papers to this toolbox (Multipole expansion of strongly focussed laser beams) I've read that one can define the truncation of the beam by the aperture. Could someone explain to me what I am missing?

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.