%% Physical constants
PlanckConstant                   = 6.62607015E-34;
PlanckConstantReduced            = 6.62607015E-34/(2*pi);
FineStructureConstant            = 7.2973525698E-3;
ElectronMass                     = 9.10938291E-31;
GravitationalConstant            = 6.67384E-11;
ProtonMass                       = 1.672621777E-27;
AtomicMassUnit                   = 1.660539066E-27; 
BohrRadius                       = 5.2917721067E-11; 
BohrMagneton                     = 9.274009994E-24; 
BoltzmannConstant                = 1.38064852E-23;
StandardGravityAcceleration      = 9.80665;
SpeedOfLight                     = 299792458;
StefanBoltzmannConstant          = 5.670373E-8;
ElectronCharge                   = 1.602176634E-19;
VacuumPermeability               = 1.25663706212E-6; 
DielectricConstant               = 8.8541878128E-12;
ElectronGyromagneticFactor       = -2.00231930436153;
AvogadroConstant                 = 6.02214076E23;
ZeroKelvin                       = 273.15;
GravitationalAcceleration        = 9.80553;
VacuumPermittivity               = 1 / (SpeedOfLight^2 * VacuumPermeability);
HartreeEnergy                    = ElectronCharge^2 / (4 * pi * VacuumPermittivity * BohrRadius);
AtomicUnitOfPolarizability       = (ElectronCharge^2 * BohrRadius^2) / HartreeEnergy; % Or simply 4*pi*VacuumPermittivity*BohrRadius^3

% Dy specific constants
Dy164Mass                        = 163.929174751*AtomicMassUnit;
Dy164IsotopicAbundance           = 0.2826;
DyMagneticMoment                 = 9.93*BohrMagneton;

%% Parameters
options = struct;

options.Axis                     = 3;           % axis referenced to the beam along which you want the dipole trap potential
options.Extent                   = 1E2;         % range of spatial coordinates in one direction to calculate trap potential over
options.Crossed                  = false;       % angle between arms in degrees
options.Delta                    = 70;
options.Modulation               = false;       % required aspect ratio of modulated arm
options.ModulationFunction       = 'arccos';
options.ModulationAmplitude      = 2.16;
options.AspectRatio              = 4;
options.Gravity                  = false;
options.TiltGravity              = false;
options.Theta                    = 0.75;        % gravity tilt angle in degrees
options.TiltAxis                 = [1, 0, 0];   % lab space coordinates are rotated about x-axis in reference frame of beam
options.Astigmatism              = false;
options.DisplacementFoci         = 2.5 * 1e-3;  % difference in position of the foci along the propagation direction in meters
options.ExtractTrapFrequencies   = false;
options.Mass                     = Dy164Mass;
options.MagneticMoment           = DyMagneticMoment;

options.Power                    = 40;
options.w_x                      = 30 * 1e-6; % Beam waist in X direction in meters
options.w_z                      = 30 * 1e-6; % Beam waist in Z direction in meters
options.Polarizability           = 180;
options.Wavelength               = 1064E-9;

% Initialize variables

ComputedPotentials               = {};
Params                           = {};

% Call the function to compute trap potential
[Positions, IdealTrappingPotential, ...
 TrappingPotential, TrapDepthsInKelvin, ...
 ExtractedTrapFrequencies]       = Calculator.computeTrapPotential(options);

% Store computed potentials and parameters
ComputedPotentials{end+1}        = IdealTrappingPotential;
ComputedPotentials{end+1}        = TrappingPotential;
Params{end+1}                    = {TrapDepthsInKelvin, ExtractedTrapFrequencies};

% Call plot function to visualize the potentials
Plotter.plotPotential(Positions, ComputedPotentials, options, Params, [], false);
