POST-PROCESSING for linear Stability analysis of the wake of a cylinder
this scripts demonstrates how to use the data-mining features of the StabFem software for post-processing after generation of a large number of data.
It is designed to be used as a tutorial. For this, you should have previously run the script CYLINDER_LINEAR.m, which has generated a number of data (baseflows, eigenmodes, eigenvalues) and stored them in a directory './WORK/'.
First we restart StabFem specifying as 'workdir ' the directory '/WORK/' which has been used in the previous script.
if SF_core_getopt('SF_PUBLISH') CYLINDER_LINEAR; % trick for correct execution by the the gitlab runner generating the html page end close all; addpath([fileparts(fileparts(pwd)), '/SOURCES_MATLAB']); SF_Start('verbosity',3,'ffdatadir','./WORK/');
NOTICE - Initialization already done WARNING - Folder ./WORK/MESHBF not found : creating it ! ev = 0.0471 - 0.7447i em = struct with fields: mesh: [] filename: './WORK/EIGENMODES//FFDATA_000001.txt' DataDescription: 'Eigenmode for a 2D-incompressible problem ' datatype: 'EigenModeA' datastoragemode: 'CxP2P2P1' datadescriptors: 'ux,uy,p' meshfilename: './WORK/MESHES/FFMESH_000003.msh' baseflowfilename: './WORK/BASEFLOWS/FFDATA_000004.txt' lambda: 0.0471 - 0.7447i INDEXING: [1x1 struct] sym: -1 ux: [] uy: [] p: [] status: 'unloaded' type: 'D' mkdir: impossible de créer le répertoire «FIGURES»: Le fichier existe autorun.m Newton_2D_simple.edp CYLINDER_LINEAR.m Param_Adaptmesh.idp CYLINDER_LINEAR_SFLAUNCH.m Param_Mapping.edp CYLINDER_MESHTESTS.m POSTPROCESS_LINEAR_CYLINDER.m CYLINDER_NONLINEAR.m SCRIPT_CYLINDER_ALLFIGURES.m DEMO_DataBase_Management.m SCRIPT_CYLINDER_Short.m DEMO_NEWOPTIONSFORNEWTON_CYLINDER.m SF_AutoInclude.idp ErrorCatching.m SF_Custom.idp FIGURES SF_Geom.edp freefem++.pref SmartMesh_Cylinder.m html WORK literature_data WORK_DEBUG Mesh_Cylinder.edp ################################################################################ ... SUMMARY OF YOUR DATABASE FOLDER : ./WORK/ ################################################################################# .... CONTENT OF DIRECTORY ./WORK/MESHES : (list of meshes previously created/adapted ; couples of .msh/.ff2m files ) Index | Name | generation mode | Date | Nv | H 1 | FFMESH_000001.msh | initial | 23-mars-2023 01:33:18 | 2192 | 40 2 | FFMESH_000002.msh | adapted | 23-mars-2023 01:33:32 | 825 | 40 3 | FFMESH_000003.msh | adapted | 23-mars-2023 01:33:44 | 1540 | 40 4 | FFMESH_000004.msh | adapted | 23-mars-2023 01:33:56 | 3480 | 40 5 | FFMESH_000005.msh | adapted | 23-mars-2023 01:34:22 | 4550 | 40 ################################################################################# ################################################################################# .... CONTENT OF DIRECTORY ./WORK/BASEFLOWS (couples of .txt/.ff2m files ) Index | Name | Type | Date | Mesh file | Re | Fx 1 | FFDATA_000001.txt | BaseFlow | 23-mars-2023 01:33:29 | FFMESH_000001.msh | 1 | 5.5507 2 | FFDATA_000002.txt | BaseFlow | 23-mars-2023 01:33:37 | FFMESH_000002.msh | 10 | 1.3936 3 | FFDATA_000003.txt | BaseFlow | 23-mars-2023 01:33:41 | FFMESH_000002.msh | 60 | 0.64084 4 | FFDATA_000004.txt | BaseFlow | 23-mars-2023 01:33:50 | FFMESH_000003.msh | 60 | 0.64317 5 | FFDATA_000005.txt | BaseFlow | 23-mars-2023 01:34:08 | FFMESH_000004.msh | 60 | 0.64396 6 | FFDATA_000006.txt | BaseFlow | 23-mars-2023 01:34:41 | FFMESH_000005.msh | 60 | 0.6441 7 | FFDATA_000007.txt | BaseFlow | 23-mars-2023 01:36:26 | FFMESH_000005.msh | 40 | 0.75419 8 | FFDATA_000008.txt | BaseFlow | 23-mars-2023 01:36:43 | FFMESH_000005.msh | 40 | 0.75419 9 | FFDATA_000009.txt | BaseFlow | 23-mars-2023 01:37:09 | FFMESH_000005.msh | 42.5 | 0.73625 10 | FFDATA_000010.txt | BaseFlow | 23-mars-2023 01:37:36 | FFMESH_000005.msh | 45 | 0.71985 11 | FFDATA_000011.txt | BaseFlow | 23-mars-2023 01:38:01 | FFMESH_000005.msh | 47.5 | 0.70477 12 | FFDATA_000012.txt | BaseFlow | 23-mars-2023 01:38:27 | FFMESH_000005.msh | 50 | 0.69084 13 | FFDATA_000013.txt | BaseFlow | 23-mars-2023 01:38:58 | FFMESH_000005.msh | 52.5 | 0.67792 14 | FFDATA_000014.txt | BaseFlow | 23-mars-2023 01:39:24 | FFMESH_000005.msh | 55 | 0.66589 15 | FFDATA_000015.txt | BaseFlow | 23-mars-2023 01:39:51 | FFMESH_000005.msh | 57.5 | 0.65464 16 | FFDATA_000016.txt | BaseFlow | 23-mars-2023 01:40:18 | FFMESH_000005.msh | 60 | 0.6441 17 | FFDATA_000017.txt | BaseFlow | 23-mars-2023 01:40:45 | FFMESH_000005.msh | 62.5 | 0.63419 18 | FFDATA_000018.txt | BaseFlow | 23-mars-2023 01:41:12 | FFMESH_000005.msh | 65 | 0.62485 19 | FFDATA_000019.txt | BaseFlow | 23-mars-2023 01:41:36 | FFMESH_000005.msh | 67.5 | 0.61603 20 | FFDATA_000020.txt | BaseFlow | 23-mars-2023 01:42:01 | FFMESH_000005.msh | 70 | 0.60767 21 | FFDATA_000021.txt | BaseFlow | 23-mars-2023 01:42:24 | FFMESH_000005.msh | 72.5 | 0.59974 22 | FFDATA_000022.txt | BaseFlow | 23-mars-2023 01:42:46 | FFMESH_000005.msh | 75 | 0.5922 23 | FFDATA_000023.txt | BaseFlow | 23-mars-2023 01:43:11 | FFMESH_000005.msh | 77.5 | 0.58502 24 | FFDATA_000024.txt | BaseFlow | 23-mars-2023 01:43:38 | FFMESH_000005.msh | 80 | 0.57816 ################################################################################# .... CONTENT OF DIRECTORY ./WORK/EIGENMODES (couples of .txt/.ff2m files ) Index | Name | Type | Date | BaseFlow file | lambda | sym 1 | FFDATA_000001.txt | EigenModeA | 23-mars-2023 01:33:54 | ./WORK/BASEFLOWS/FFDATA_000004.txt | 0.047057-0.74471i | -1 2 | FFDATA_000002.txt | EigenModeA | 23-mars-2023 01:34:14 | ./WORK/BASEFLOWS/FFDATA_000005.txt | 0.047093-0.74496i | -1 3 | FFDATA_000003.txt | EigenMode | 23-mars-2023 01:34:59 | ./WORK/BASEFLOWS/FFDATA_000006.txt | 0.047102+0.74488i | -1 4 | FFDATA_000004.txt | EigenModeA | 23-mars-2023 01:35:06 | ./WORK/BASEFLOWS/FFDATA_000006.txt | 0.047102-0.74488i | -1 5 | FFDATA_000005.txt | EigenMode | 23-mars-2023 01:35:50 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.047013+0.74317i | -1 6 | FFDATA_000006.txt | EigenMode | 23-mars-2023 01:35:51 | ./WORK/BASEFLOWS/FFDATA_000006.txt | 0.047102+0.74488i | -1 7 | FFDATA_000007.txt | EigenMode | 23-mars-2023 01:35:51 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.047217+0.7478i | -1 8 | FFDATA_000008.txt | EigenMode | 23-mars-2023 01:35:51 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.049829+0.73609i | -1 9 | FFDATA_000009.txt | EigenMode | 23-mars-2023 01:35:51 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.049031+0.72546i | -1 10 | FFDATA_000010.txt | EigenMode | 23-mars-2023 01:35:51 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.05433+0.74503i | -1 11 | FFDATA_000011.txt | EigenMode | 23-mars-2023 01:35:52 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.052625+0.75474i | -1 12 | FFDATA_000012.txt | EigenMode | 23-mars-2023 01:35:52 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.054777+0.73205i | -1 13 | FFDATA_000013.txt | EigenMode | 23-mars-2023 01:35:52 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.051487+0.76121i | -1 14 | FFDATA_000014.txt | EigenMode | 23-mars-2023 01:35:52 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.051291+0.71741i | -1 15 | FFDATA_000015.txt | EigenMode | 23-mars-2023 01:35:53 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.056443+0.73421i | -1 16 | FFDATA_000016.txt | EigenMode | 23-mars-2023 01:35:53 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.050788+0.71357i | -1 17 | FFDATA_000017.txt | EigenMode | 23-mars-2023 01:35:53 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.050714+0.76884i | -1 18 | FFDATA_000018.txt | EigenMode | 23-mars-2023 01:35:53 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.054759+0.76128i | -1 19 | FFDATA_000019.txt | EigenMode | 23-mars-2023 01:35:53 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.050221+0.77174i | -1 20 | FFDATA_000020.txt | EigenMode | 23-mars-2023 01:35:54 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.048911+0.69954i | -1 21 | FFDATA_000021.txt | EigenMode | 23-mars-2023 01:35:54 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.04566+0.69467i | -1 22 | FFDATA_000022.txt | EigenMode | 23-mars-2023 01:35:54 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.056405+0.70905i | -1 23 | FFDATA_000023.txt | EigenMode | 23-mars-2023 01:35:54 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.064952+0.73754i | -1 24 | FFDATA_000024.txt | EigenMode | 23-mars-2023 01:35:55 | ./WORK/BASEFLOWS/FFDATA_000006.txt | -0.064872+0.72878i | -1 25 | FFDATA_000025.txt | EigenMode | 23-mars-2023 01:36:34 | ./WORK/BASEFLOWS/FFDATA_000007.txt | -0.030424+0.72009i | -1 You have previously computed 25 eigenvalues in this session The full list will be available as field 'EIGENVALUES' of this function's result ################################################################################# .... CONTENT OF DIRECTORY ./WORK/MESHBF (couples of .txt/.ff2m files ) Index | Name | Type | Date | Mesh file | Re | Fx 1 | FFDATA_000001.txt | BaseFlow | 23-mars-2023 01:33:29 | FFMESH_000001.msh | 1 | 5.5507 ################################################################################# .... CONTENT OF DIRECTORY ./WORK/MISC (couples of .txt/.ff2m files ) NB this directory may contain various secondary files produced by StabFem, such as flowfields projected after adaptation but not recomputed, adaptation masks, etc... Index | Name | Type | Date | (no bf or mesh indication) | Re | eigenvalue 1 | FFDATA_000001.txt | BaseFlow | 23-mars-2023 01:33:33 | (unknown) | 1 | ??? 2 | FFDATA_000002.txt | BaseFlow | 23-mars-2023 01:33:45 | (unknown) | 60 | ??? 3 | FFDATA_000003.txt | BaseFlow | 23-mars-2023 01:33:59 | (unknown) | 60 | ??? 4 | FFDATA_000004.txt | MASK | 23-mars-2023 01:34:18 | (unknown) 5 | FFDATA_000005.txt | BaseFlow | 23-mars-2023 01:34:26 | (unknown) | 60 | ??? 6 | FFDATA_000006.txt | Sensitivity | 23-mars-2023 01:35:10 | (unknown) | 60 | 0.047102 ################################################################################# sfs = struct with fields: MESHES: [1x5 struct] BASEFLOWS: [1x24 struct] EIGENMODES: [1x25 struct] EIGENVALUES: [1x1 struct] MESHBF: [1x1 struct] MISC: [1x6 struct] BFS = 1x24 struct array with fields: filename Re Fx meshfilename H EVS = struct with fields: mesh: [] lambda: [25x1 double] sym: [25x1 double] shift: [25x1 double] isadj: [25x1 double] Re: [25x1 double] Fx: [25x1 double] H: [25x1 double] status: 'loaded'
Unrecognized field name "THRESHOLDS". Error in CYLINDER_LINEAR (line 321) plot(EVS.Re(26:end),real(EVS.lambda(26:end)),'b+-',sfs.THRESHOLDS.Re,0,'ro'); Error in POSTPROCESS_LINEAR_CYLINDER (line 21) CYLINDER_LINEAR; % trick for correct execution by the the gitlab runner generating the html page
Then we use the SF_Status.m data-mining wizard to generate a structure allowing to access the whole content of this directory :
sf = SF_Status('ALL')
We can see that we have previously created 5 meshes (during the mesh-adaptation process), stored 18 baseflows computed with the current mesh, and 6 eigenmodes.
Let us first have a look at the contents of the 'BASEFLOWS' object:
sf.BASEFLOWS
You can see that there are 18 baseflows indexed with Re and Fx. You may wonder how StabFem knows how to do the indexing ? This is thanks to "metatada" written in the .ff2m files. This is controlled by the macro SFwriteBaseFlow. In the present case this macro is in the file SF_Custom.idp in the working directory. Have a look in this file to understand how it works !
If we want to import any of the available datafiles (baseflows or eigenmodes), we can use the function SF_Load.m. For instance here is how to import the latest baseflow and plot it:
bf = SF_Load('BASEFLOWS','last') figure(15); SF_Plot(bf,'vort','xlim',[-1.5 4.5],'ylim',[0 3],'cbtitle','\omega_z','colormap','redblue','colorrange',[-2 2]); hold on;SF_Plot(bf,'psi','contour','only','clevels',[-.02 0 .2 1 2 5],'xlim',[-1.5 4.5],'ylim',[0 3]); box on; set(gca,'FontSize', 18);hold off;
SF_Status also returns a structure 'EIGENVALUES' containing all the computed eigenvalues. Let us see what is available here:
sf.EIGENVALUES
We can see that there have been 11 eigenvalue computations, and that metadata 'Re', 'Fx', 'm' and 'k' have been generated. Here 'Re' is the Reynolds number ; 'k' is the transverse wavenumber and 'm' is the symmetry condition (-1 for antisymmetric modes and +1 for symmetric modes). (here only antisymmetric 2D modes have been computed, hence m=-1 and k=0 for all)
The structure 'EIGENMODES' contains info only on the Eigenmodes for which a datafile has been stored (they have been processed as [ev,em] = SF_Stability(...) instead of ev = SF_Stability(...) ). Let us see what is in this structure :
sf.EIGENMODES
If we now wish to re-generate the plot of the real and imaginary part of the eigenvalue of the leading eigenmode, simply do this :
figureformat='png'; figure(20);subplot(2,1,1); plot(sf.EIGENVALUES.Re,real(sf.EIGENVALUES.lambda),'b+'); xlabel('Re');ylabel('$\sigma$','Interpreter','latex'); box on; set(gca,'FontSize', 18); saveas(gca,'FIGURES/Cylinder_Sigma_Re',figureformat); figure(20);subplot(2,1,2); plot(sf.EIGENVALUES.Re,imag(sf.EIGENVALUES.lambda)/(2*pi),'b+'); xlabel('Re');ylabel('St'); box on; set(gca,'FontSize', 18); saveas(gca,'FIGURES/Cylinder_Strouhal_Re',figureformat); pause(0.1); % [[PUBLISH]] (this tag is to enable automatic publication as html ; don't touch it !) % fclose(fopen('POSTPROCESS_LINEAR_CYLINDER.success','w+'));