Difference between revisions of "MATLAB: Estimating viscoelastic spectrum using Mason's method"

From Course Wiki
Jump to: navigation, search
 
(3 intermediate revisions by one user not shown)
Line 7: Line 7:
  
 
==Function implementation==
 
==Function implementation==
<tt>CalculateViscoelasticSpectrumMason</tt> computes G*, G', and G'' from a vector of MSD values. The function smoothes the MSD data with a sliding boxcar average. An optional parameter specifies the width of the averaging window.  
+
<tt>CalculateViscoelasticSpectrumMason</tt> computes G*, G', and <nowiki>G''</nowiki> from a vector of MSD values. The function smoothes the MSD data with a sliding boxcar average. An optional parameter specifies the width of the averaging window.  
  
 
<pre>
 
<pre>
function [Gstar, GPrime, GDoublePrime, Tau ] = CalculateViscoelasticSpectrumMason(MsdValues, SamplingFrequency, ParticleRadius, Temperature, Smoothing)
+
function [Gstar, GPrime, GDoublePrime, Tau ] = CalculateViscoelasticSpectrumMason( ...
 +
        MsdValues, SamplingFrequency, ParticleRadius, Temperature, Smoothing)
 +
 
 
     Tau = (1:length(MsdValues))' / SamplingFrequency;
 
     Tau = (1:length(MsdValues))' / SamplingFrequency;
  
Line 23: Line 25:
 
     end
 
     end
  
     smoothLogMsdValues log(smooth(MsdValues, Smoothing));
+
     smoothMsdValues =  smooth(MsdValues, Smoothing);
 +
    smoothLogMsdValues = log(smoothMsdValues);
 
     smoothTimeInterval = Tau;
 
     smoothTimeInterval = Tau;
  
 
     % create a time interval axis to match diff(MSD)
 
     % create a time interval axis to match diff(MSD)
 
     Tau = (smoothTimeInterval(1:(end-1)) + smoothTimeInterval(2:end)) / 2;
 
     Tau = (smoothTimeInterval(1:(end-1)) + smoothTimeInterval(2:end)) / 2;
     shiftedMsd = (smoothLogMsdValues(1:(end-1)) + smoothLogMsdValues(2:end)) / 2;
+
     shiftedMsd = (smoothMsdValues(1:(end-1)) + smoothMsdValues(2:end)) / 2;
  
 
     % compute G*, G' and G'' by Mason method
 
     % compute G*, G' and G'' by Mason method
Line 64: Line 67:
  
 
% compute MSD versus time interval vector and G*, G', G''
 
% compute MSD versus time interval vector and G*, G', G''
[gStarFree, gPrimeFree, gDoublePrimeFree, outputTau] = CalculateGStarGPrimeGDoublePrime(msdFree, sampleRate, particleRadius);
+
[gStarFree, gPrimeFree, gDoublePrimeFree, outputTau] = CalculateViscoelasticSpectrumMason(msdFree, sampleRate, particleRadius);
  
 
% now simulate a confined microsphere (see Mason equation 4)
 
% now simulate a confined microsphere (see Mason equation 4)
Line 72: Line 75:
  
 
% compute MSD versus time interval vector and G*, G', G''
 
% compute MSD versus time interval vector and G*, G', G''
[gStarConfined, gPrimeConfined, gDoublePrimeConfined, outputTau] = CalculateGStarGPrimeGDoublePrime(msdConfined, sampleRate, particleRadius);
+
[gStarConfined, gPrimeConfined, gDoublePrimeConfined, outputTau] = CalculateViscoelasticSpectrumMason(msdConfined, sampleRate, particleRadius);
  
 
figure;
 
figure;
Line 78: Line 81:
 
legend( 'G'' Free', 'G'''' Free', 'G'' Confined', 'G'''' Confined');
 
legend( 'G'' Free', 'G'''' Free', 'G'' Confined', 'G'''' Confined');
 
</pre>
 
</pre>
 +
 +
<references />
 
{{Template:20.309 bottom}}
 
{{Template:20.309 bottom}}

Latest revision as of 18:32, 17 October 2013

20.309: Biological Instrumentation and Measurement

ImageBar 774.jpg


This page demonstrates how to compute the viscoelastic modulus of a complex fluid from a vector of MSD values using the method of Mason, et al.[1] .

Function implementation

CalculateViscoelasticSpectrumMason computes G*, G', and G'' from a vector of MSD values. The function smoothes the MSD data with a sliding boxcar average. An optional parameter specifies the width of the averaging window.

function [Gstar, GPrime, GDoublePrime, Tau ] = CalculateViscoelasticSpectrumMason( ...
        MsdValues, SamplingFrequency, ParticleRadius, Temperature, Smoothing)

    Tau = (1:length(MsdValues))' / SamplingFrequency;

    kB   = 1.38e-23;            % Boltzmann constant

    if(nargin < 5)
        Smoothing = 3;
    end

    if(nargin < 4)
        Temperature = 293;
    end

    smoothMsdValues =  smooth(MsdValues, Smoothing);
    smoothLogMsdValues = log(smoothMsdValues);
    smoothTimeInterval = Tau;

    % create a time interval axis to match diff(MSD)
    Tau = (smoothTimeInterval(1:(end-1)) + smoothTimeInterval(2:end)) / 2;
    shiftedMsd = (smoothMsdValues(1:(end-1)) + smoothMsdValues(2:end)) / 2;

    % compute G*, G' and G'' by Mason method
    alpha = diff(smoothLogMsdValues) ./ diff(log(smoothTimeInterval));
    gammaOfAlpha = 0.457 * (1 + alpha).^2 - 1.36 * (1 + alpha) +1.9; % approimation value from Mason
    %gammaOfAlpha = gamma(1 + alpha);

    Gstar = abs(2 * kB * Temperature ./ (3 * pi * ParticleRadius * shiftedMsd .* gammaOfAlpha));
    GPrime = Gstar .* cos(pi * alpha / 2);
    GDoublePrime = Gstar .* sin(pi * alpha / 2);

end

Testing the function

The following code generates synthetic MSD vectors for testing CalculateViscoelasticSpectrumMason.

% this code tests the CalculateGStarGPrimeGDoublePrime function by
% simulating MSDs for two extreme cases: a particle on a spring and a
% freely diffusing particle

close all

numberOfFrames = 1800;
numberOfMsds = 1799;
sampleRate = 10;
particleRadius = 0.5e-6;
tau = (1:numberOfMsds) / sampleRate;

% generate synthetic MSD versus tau curve for a freely diffusing particle
diffusionCoefficient = 1e-15;
msdFree = diffusionCoefficient * tau;

% compute MSD versus time interval vector and G*, G', G''
[gStarFree, gPrimeFree, gDoublePrimeFree, outputTau] = CalculateViscoelasticSpectrumMason(msdFree, sampleRate, particleRadius);

% now simulate a confined microsphere (see Mason equation 4)
saturationMsd = sqrt(.01e-15);
diffusionTimeConstant = 1 / 3;
msdConfined = saturationMsd ^ 2 * (1 - exp(-tau / diffusionTimeConstant));

% compute MSD versus time interval vector and G*, G', G''
[gStarConfined, gPrimeConfined, gDoublePrimeConfined, outputTau] = CalculateViscoelasticSpectrumMason(msdConfined, sampleRate, particleRadius);

figure;
loglog( outputTau, gPrimeFree, outputTau, gDoublePrimeFree, outputTau, gPrimeConfined, outputTau, gDoublePrimeConfined );
legend( 'G'' Free', 'G'''' Free', 'G'' Confined', 'G'''' Confined');
  1. T. G. Mason, "Estimating the viscoelastic moduli of complex fluids using the generalized Stokes-Einstein equation" Rheol. Acta, 39, pp. 371-378 (2000).