Skip to content

Commit

Permalink
Fixed documentation and tests for polarisability functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ilent2 committed Apr 6, 2020
1 parent 6eaf524 commit b6aef2b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 25 deletions.
13 changes: 4 additions & 9 deletions +ott/+utils/+polarizability/CM.m
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
function alpha_CM = polarizability_CM(d, index)
function alpha_CM = CM(spacing, index)
% Clausius-Mossoti Polarizability
%
% Usage
% alpha = polarizability_LDR(spacing, index)
% alpha = CM(spacing, index)
% Calculates a Nx1 element vector containing the isotropic
% polarisabilities for N dipoles.
%
% alpha = polarizability_LDR(spacing, index, kvec, E0)
% As above but specifies the polarisability information for use
% with plane wave illumination.
%
% Parameters
% - spacing (numeric scalar) -- lattice spacing parameter
% - index (Nx1 numeric) -- Relative refractive indices for N dipoles.
% - kvec (1x3 numeric) -- Wave vector [kx, ky, kz]
% - E0 (1x3 numeric) -- E-field polarisation [Ex, Ey, Ez]

% Based on the script by Vincent Loke.
% This file is part of the optical tweezers toolbox.
% See LICENSE.md for information about using/distributing this file.

msqr = index(:).^2;
dcube = d^3;
dcube = spacing^3;

alpha_CM = 3*dcube/(4*pi)*(msqr - 1)./(msqr + 2); % Clausius-Mossotti

6 changes: 3 additions & 3 deletions +ott/+utils/+polarizability/Contents.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% +OTT/+UTILS/+POLARIZABILITY Polarizability calculation methods for DDA
%
% polarizability_CM - Clausius-Mossoti Polarizability
% polarizability_FCD - Filtered coupled dipole polarizability
% polarizability_LDR - Lattice dispersion relation polarizablity
% CM - Clausius-Mossoti Polarizability
% FCD - Filtered coupled dipole polarizability
% LDR - Lattice dispersion relation polarizablity
6 changes: 3 additions & 3 deletions +ott/+utils/+polarizability/FCD.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function alpha_FCD = polarizability_FCD(spacing, index, varargin)
function alpha_FCD = FCD(spacing, index, varargin)
% Filtered coupled dipole polarizability
%
% Usage
% alpha = polarizability_FCD(spacing, index)
% alpha = FCD(spacing, index)
% Calculates a Nx1 element vector containing the isotropic
% polarisabilities for N dipoles.
% polarizabilities for N dipoles.
%
% Parameters
% - spacing (numeric scalar) -- lattice spacing parameter
Expand Down
6 changes: 3 additions & 3 deletions +ott/+utils/+polarizability/LDR.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function alpha_LDR = polarizability_LDR(spacing,index,varargin)
function alpha_LDR = LDR(spacing,index,varargin)
% Lattice dispersion relation polarizablity
%
% Polarizability calculation based on
Expand All @@ -8,11 +8,11 @@
% The Astrophysical Journal, 405:685-697, 1993 March 10
%
% Usage
% alpha = polarizability_LDR(spacing, index, ...)
% alpha = LDR(spacing, index, ...)
% Calculates a Nx1 element vector containing the isotropic
% polarisabilities for N dipoles.
%
% alpha = polarizability_LDR(spacing, index, kvec, E0, ...)
% alpha = LDR(spacing, index, kvec, E0, ...)
% As above but specifies the polarisability information for use
% with plane wave illumination.
%
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/testPolarizabilityCm.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function testAlphaValues(testCase)
spacing = 1.0;
index = [1, 2];

alpha = ott.utils.polarizability_CM(spacing,index);
alpha = ott.utils.polarizability.CM(spacing,index);

targetAlpha = [0; 0.119366207318922];

Expand Down
2 changes: 1 addition & 1 deletion tests/utils/testPolarizabilityFcd.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function testAlphaValues(testCase)
spacing = 1.0;
index = [1, 2];

alpha = ott.utils.polarizability_FCD(spacing,index);
alpha = ott.utils.polarizability.FCD(spacing,index);

targetAlpha = [0; 0.000029131505380 - 0.003023300651752i];

Expand Down
10 changes: 5 additions & 5 deletions tests/utils/testPolarizabilityLdr.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ function testArgumentCount(testCase)
kvec = [0, 0, 1];
E0 = [1, 0, 0];

alpha = ott.utils.polarizability_LDR(spacing,index,kvec,E0);
alpha = ott.utils.polarizability.LDR(spacing,index,kvec,E0);

alpha = ott.utils.polarizability_LDR(spacing,index,kvec,E0, 'k0', 2*pi);
alpha = ott.utils.polarizability.LDR(spacing,index,kvec,E0, 'k0', 2*pi);

alpha = ott.utils.polarizability_LDR(spacing,index);
alpha = ott.utils.polarizability.LDR(spacing,index);

alpha = ott.utils.polarizability_LDR(spacing,index, 'k0', 2*pi);
alpha = ott.utils.polarizability.LDR(spacing,index, 'k0', 2*pi);

end

Expand All @@ -28,7 +28,7 @@ function testAlphaValues(testCase)
spacing = 1.0;
index = [1, 2];

alpha = ott.utils.polarizability_LDR(spacing,index);
alpha = ott.utils.polarizability.LDR(spacing,index);

targetAlpha = [0; -0.002627924391542 + 0.004518926661470i];

Expand Down

0 comments on commit b6aef2b

Please sign in to comment.