Skip to content

mbudisic/mesochronic-analysis

Repository files navigation

** Mesochronic Analysis Toolbox ** 

This is a Matlab toolbox intented to demonstrate the principles behind
2d mesochronic analyses for incompressible dynamical systems. The
toolbox has been tested with Matlab 2012b and newer. It will not run
correctly on Matlab 2011b and earlier.

I would appreciate your feedback sent to
mbudisic@engr.ucsb.edu 

Additionally, if you happen to publish results based on mesochronic
analysis using this code, please send me and 
Igor Mezic mezic@engineering.ucsb.edu
an e-mail with a reference.

Written by 
Marko Budisic, 
Dept. of Mechanical Engineering, UC Santa Barbara
supported by ONR MURI N00014-11-1-0087

** Installation: **

On Matlab 2012b and newer, if faster execution is desired (highly
recommended), run

   deploytool -build mcjacobian.prj

before using the code for the first time and wait until "Build
finished" message. This will convert mcjacobian.m to C-code and
compile it into mcjacobian_mat MEX. Function evaluateJ_ode.m detects
whether the MEX file exists and uses MEX or .mat file appropriately.

For compilation problems, please consult Matlab Coder (not Compiler!)
compatibility chart: http://www.mathworks.com/support/compilers

The code is written so it can be run in parallel on Matlab with
Parallel Toolbox licenses. To open several "workers" to compute code
in parallel, issue command

matlabpool open N

where N is the number of processing cores on your computer (laptops
typically have 1-4 nowadays). You can also omit 'N' altogether and
issue just

matlabpool open

to have Matlab autodetect the number of cores. Note that they
sometimes under-estimate the number of cores available. Setting N to
anything larger than number of cores may lead to slowdown of
performance. Here's an article by Cleve Moler on this issue, if you
want to know more:

http://www.mathworks.com/company/newsletters/articles/parallel-matlab-multiple-processors-and-multiple-cores.html

There is a well known case of a bug, appearing on Mac OS X with newer
versions of Java. You can see how it manifests and how to fix it on

http://www.mathworks.com/support/bugreports/919688


** Test (demo) system ** 

This is a simple planar, time-dependent flow, used as the first
example in Mezic, Loire, et al. Science (2010). The function
fourgyre.m was written with intention of being mimicked by other
researchers in their researcn, not as being the optimally written
harness for others to use.p

Demo: fourgyre.m

****

% open parallel jobs (in serial, the code takes a few minutes to run)
matlabpool open; % 

% computes mesochronic analysis
% and store results in mcan_fourgyre_ode_fwdT_1.5_N_00900.mat
N = 30; % grid resolution
Ts = [0.5, 1, 1.5]; % three different integration times
direction = 1; % positive time arrow direction
R = fourgyre([], Ts, N, direction)

% visualize output for T=1
fourgyre(R, 1, N, direction) 

****

The demonstration is a sample short-time run, just to evaluate that
the code runs validly and to familiarize the user with inputs and
output. Once you are comfortable with the structure, you could

a) replace the vector field vf_fourgyre passed in fourgyre.m to
meh_simulation.m with an alternative vector field. As a practice
field, the file vf_shaddengyre can be used.

b) Mimic the structure of fourgyre.m to produce your own code, e.g.,
replacing meh_simulation.m (which computes mesochronic Jacobians
data), with another, perhaps more precise, computational code, or even
experimental data, and just applying meh_analysis.m to that data.

*** File functionality ***

* Main files *

  meh_simulation.m -- Simulation harness: this is the main file that
  performs simulation of an arbitrary system specified as a function
  handle and computes mesochronic Jacobian for a specific set of
  initial conditions and integration times.

  This is performed in parallel for initial conditions.

  meh_analysis.m -- Analysis harness: this is the file that 
  runs mesochronic analysis on mesochronic Jacobians, e.g., those
  computed by meh_simulation.

  This is performed in parallel for initial conditions.
  
  meh2d.m -- Analysis at a single point. Takes several Jacobians,
  all corresponding to the same initial condition, but different
  integration lengths, and computes their mesochronic analysis.

* Computational aides *

  vf_fourgyre.m and vf_shaddengyre.m -- Two simple 2d incompressible
  vector fields.

  evaluateJ_ode.m -- Evaluates the mesochronic Jacobian at a given
  state point and time of a flow specified by a function handle.

  mcjacobian.m -- Computes a mesochronic Jacobian from evaluations of
  instantaneous Jacobian along trajectory (run by evaluateJ_ode.m)

  ftle.m -- Computes FTLE from mesochronic Jacobian (run by
  meh2d).

  jacobian_fd.m -- Computes instantaneous Jacobiaian using central
  difference method on a vector field.

  mindist.m -- Computes the smallest difference of elements of a
  vector.

* Visualization aides *

  mehcolor.m -- Creates a colormap for visualization of 2d mesochronic
  classes using values of determinant.

  diverging_map.m -- Creates a diverging colormap between 2 colors. 
Written by Andy Stein based on Kenneth Moreland's (Sandia) paper: 
http://www.sandia.gov/~kmorel/documents/ColorMaps/ 
doi:10.1007/978-3-642-10520-3_9

* Additional files *

  mcjacobian.prj -- Matlab Coder Project file, used to compile 
mcjacobian.m into a fast compiled code.

Copyright (c) 2013, Regents of the University of California All rights
reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.  Redistributions
in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.  Neither the name of
the University of California, Santa Barbara nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.  THIS
SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

About

Two-dimensional mesochronic analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published