% [H,gE]=CalcMagField(d)
%
% Calculates the magnetic field strength H and normal force (actually
% acceleration due to gravity and magnetic field) gE acting on droplet at
% given distance from magnet surface.
%
% d = distance between the magnet surface and the bottom of 10 mul droplet.
% (mm)
%
% H = Magnetic field (Oe)
% gE = Acceleration due to gravity and magnetic field (g)
%
% H is given in Oersteds, a unit used in CGS (centimetre–gram–second)
% system of units. Oersted is often more convenient to use than ampere per
% meter used in the SI system. gE is given relative to the gravitational
% acceleration (thus the unit is g).
function [H,gE]=CalcMagField(d)
% d is the distance between magnet surface and the bottom of the droplet.
% We are interested in the mean field droplet experiences. Thus we need to
% take into account the size of the droplet and calculate the field
% strength in the middle of the droplet. For 10 mul droplet the center is
% approximately 1 mm from the bottom of the droplet.
z = d + 1;
% The field strength along the axis of the main magnet was measured with
% gaussmeter. Data was fitted with theoretical model with 3 coefficients,
% R, L, M. These coefficients and the model can be used to calculate field
% strength H and field gradient dH (in vertical direction, i.e. dH/dz.)
R=10.168458546157993;
L=43;
M=1.301974338420206e+04;
H=M./2.*((L+z)./sqrt(R.^2+(L+z).^2)-z./sqrt(R.^2+z.^2));
dH=-M./2.*R.^2.*((R.^2+(L+z).^2).^(-3/2)-(R.^2+z.^2).^(-3/2));
% Next we need to calculate the effective magnetization ME of the fluid at
% this field. It is used in calculation of the magnetic forces. The fluid
% magnetization M was measured with SQUID magnetometer and the data was
% fitted with a smoothing spline.
% ME = M + H (dM/dH)
magfit=importdata('Ferrofluid magnetization fit.mat');
ME=feval(magfit,H)+(feval(magfit,H*1.001)-feval(magfit,H*0.999))./(1.001-0.999);
% Normal force is the sum of gravitational and magnetic forces. The sum of
% these forces is here examined relative to gravitational force. Actually
% we are working with effective gravitational acceleration gE, unit of
% which is g (the gravitational acceleration of Earth, 9.82 m/s^2). If
% there is no magnetic forces, gE = 1 g. If the magnetic force is as large
% as gravitational force, gE = 2 g and so on. This makes it easy to
% understand the magnitude of the forces.
% F = m*gE = m*g + V*ME*dH/dz
% gE = g + V/m*ME*dH/dz = g + 1/rho*ME*dH/dz
% Here we are still using CGS units: g = 982 cm/s^2. rho is the fluid
% density, 1.0069 g/cm^3. dH was calculated earlier, its unit is Oe/mm.
% Thus we need to multiply it by 10 to get to Oe/cm.
gE=(982+ME./1.0069.*dH*10); %in CGS units
gE=gE/982; %the unit is now g.