danielelinaro / BAL

Bifurcation Analysis Library
MIT License
1 stars 0 forks source link

Help to plot 2 param bifurcation #1

Open guitorri opened 10 years ago

guitorri commented 10 years ago

Hi, thank your for sharing this tool.

I tried to contact you on SourceForge. Maybe my message did not reach you. I am dealing with non-smooth MEMS devices an I was hoping to use your tool to draw 2 parameter bifurcations plots (similar to the ones on your thesis for the HR model). So far I managed to build and run the Python examples from the 0.9.5 tarball on my Mac [1].

Do you have an example that does the plotting of the resulting h5 files (bifdiag.py for instance)?

Which is the main repository? Here or SourceForge?

Best regards, Guilherme

[1] https://github.com/guitorri/homebrew-tap/blob/master/Bal.rb

danielelinaro commented 10 years ago

Hi Guilherme,

I saw your message on Sourceforge, but I haven't had time to reply.

I am presently working on some major changes to BAL, so the version that you find on the develop branch here on GitHub is not functional.

Anyway, what does your system look like? Have you been able to compute a bifurcation diagram and your problem now concerns only plotting, or do you have to implement a C++ class that models your system?

Best, Daniele

guitorri commented 10 years ago

Hi,

The basic lumped model looks like a parallel-plate capacitor. One plane is moving like a spring-mass-system and the other if fixed. As the plate moves there is a position dependent switch that does the relaxation and sustains the oscillation [1]. In general it is capacitive switch, maybe a impact oscillator.

I have yet to write the C++ classes (rather, port one of the versions I already have coded in Python and Modelica). I can do already 1 param brute force bifurcations with my own code (I just started with AUTO, but I have to find a way around the non-smoothness of my model).

At this moment I just want to know how to plot the resulting 2 param bifurcation. Should I plot the 'labels'? But they are all have different lengths, how to map the long term into the color codes? Maybe I overlooked some detail on your thesis. I appreciate if you could help.

Regards, Guilherme

[1] http://dx.doi.org/10.1109/MEMSYS.2014.6765614

guitorri commented 10 years ago

For plotting, I guess I should be looking at the H5ReadAndClassify.m script is that right?

danielelinaro commented 10 years ago

H5ReadAndClassify is a Matlab function that reads the data generated when performing the integration and classifies the trajectories based on the number of distinct crossings, during the integration, of the Poincare' sections.

The easiest way to accomplish what you want to do is to use the SaveSummaryData method of the BifurcationDiagram class: this saves a text file where each line contains a set of parameters and the corresponding number of intersections with the Poincare' section. To plot this data, you simply need to use the number of intersections as the index in a colormap, and the bifurcation parameters as a pair of (x,y) coordinates. If you have high numbers of intersections, for example in a chaotic attractor, set a maximum number of turns and display everything above that number as black.

See if the following code helps:

data = load('some_file.classified'); p1 = unique(data(:,1)); p2 = unique(data(:,2)); nturns = reshape(data(:,end), [length(p1), length(p2)]); imagesc(p1,p2,nturns); colormap(hot(32)); colorbar;

I haven't run it, so there might be some bugs.