Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

64
Scilab The Free Software for Numerical Computation Dr. Claude Gomez Scilab Enterprises CEO June 2014

description

A very comprehensive set of slides presented by CEO, Scilab Enterprise, Dr Claude Gomez. TBSS-Scilab Singapore Center is the partner of Scilab Enterprise in Singapore and TBSS Khai Kinh Co. Ltd. is the partner in Vietnam. Both companies are the TBSS Group of Companies.

Transcript of Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Page 1: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilab

The Free Software for Numerical Computation

Dr. Claude GomezScilab Enterprises CEO

June 2014

Page 2: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

History

Page 3: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

1 - Scilab made by Inria

2003 – 2007: Scilab Consortium phase 1 (Inria)2008 – 2012: Scilab Consortium phase 2 (DIGITEO Foundation) 2008: Free Scilab (GPL compatible) 2009: Xcos industrialization

1980: first MATLAB1980 – 1990: BASILE software at Inria / Simulog

2010: Transfer to Scilab Enterprises Company2012: Exclusivity of trademark, development and publishing of Scilab

1990 – 2003: Open Source Scilab (Research) Scilab freely distributed on the Net in 1994

2 - Scilab industrialization

3 – Scilab Enterprises

Page 4: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilab Software

Page 5: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilab Distribution Scilab

Powerful Computation Engine

XcosDynamic Systems Modeling and Simulation

ATOMS (AuTomatic mOdules Management for Scilab)

Modules Management

Page 6: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilab: the Free and Open Source Numerical Software

High level programming language

Hundreds of mathematical functions

Advanced data structures & user-defined data types

Computation engine easy to embed into applications

Open System: extended capabilities with professional & specialized modules

Page 7: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilab: Key Scientific Features

Mathematical functions Matrix computation, sparse

matrices Polynomials and rational functions Simulation: ODE and DAE Classic and robust control, LMI

optimization Differentiable and non

differentiable optimization• Interpolation, approximation• Signal processing• Statistics• Xcos: hybrid dynamical systems

modeler and simulator

More than 2,000 functions:

Page 8: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Xcos Dynamic Systems Modeling & Simulation

A user-friendly GUI-based editor for modeling and simulating hybrid dynamical systems as block diagrams: model construction, edition and customization

Integrated Modelica Compiler

Freely Available and distributed with Scilab

Page 9: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Xcos main features

• Graphically model, compile, and simulate dynamical systems• Combine continuous and discrete-time behaviors in the same model• Select model elements from Palettes of standard blocks• Program new blocks in C, Fortran, or Scilab language

• HDF5 standard which has been chosen to guarantee data exchanges between Scilab and Xcos Editor

• Free Modelica compiler which enables the simulation of implicit diagrams• Graphical user interface based on JGraphX

Page 10: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Coselica external module for multiphysics simulation

200 acausal blocks (in Modelica language):• Analogical electrical systems.

• Mechanical systems: 1-D (translations, rotations) and 2-D planar.

• Thermic exchanges 0-D/1-D.

Page 11: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

User-friendly Environment: easy to program

Variable BrowserFile Browser

Command History

Console

Page 12: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

2-D/3-D VisualizationEditor

Embedded Help

External Modules Manager

Variable Editor

Page 13: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Graphical User Interfaces

Great number of functionalities to create Graphical User Interfaces

Accessible from Scilab

Interaction between GUI and plots

Fully integrated in OS environment

Page 14: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Latest release: Scilab 5.5.0 (April 2014)

What’s new?

Graphics: speed (Matplot), datatips, interactions, 3-D lightning

Graphical User Interface: new UI Controls

Remote file Access (sciCurl)

Scilab/MPI (Message Passing Interface)

Java Integration (JIMS)

HDF5 management

Localization of external modules

Works under Windows XP/Vista/7/8, GNU/Linuxand Mac OS X, 32 bits and 64 bits

• Mathematics and linear algebra

• Simulation

• Visualization

• Control

• Optimization

• Probabilities, statistics

• Signal processing

Page 15: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Links with other language and software

Management of C, C++, Fortran, Java, Python, .net... from Scilab: JIMS module for Java

Available as a computing engine with C, C++, Java, Python, .net API...

Links with: – Excel®, COM/DCOM® (Microsoft),

– Labview® (National Instruments),

– Isight® (Dassault Systèmes),

– Alternova® (Eurodecision),

– modeFRONTIER® (ESTECO),

– etc.

Page 16: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilab Future

Page 17: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilab: Main Development Axis

Covering strategic fields

From HPC to multicore:Scilab 6 with new kernel

Embedded systems:C code generation with Xcos

Extending Scilab & Xcos

Interface with main simulation software

Dedicated sectorial modules

Page 18: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

New kernel ready for:• HPC: multithreading, parallelism

detection,…

• Code generation

• Debugging

Scilab for the Future: Scilab 6

Language: ascendant compatibility ensured

Memory:• Scilab memory is only limited by hardware

• Dynamic memory allocation

New parser:• Native multi dimensional types and lists

• Error management

Page 19: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilab Community

Page 20: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilab in the World

About 100,000 monthly downloads from 150 countries on www.scilab.org

Page 21: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilab in Vietnamese

Page 22: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)
Page 23: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Main French Scilab Users

Main industrial sectors Aerospace: Airbus Group, CNES, Safran,

Dassault Aviation Transportation: Renault, LEONI, Siemens,

Alstom, Faurecia Mechanical: ArcelorMittal, Aperam Energy: EDF, RTE, CEA, Total, IFP Defence: DGA, THALES Health: SANOFI Telecom: Orange Earth Science: BRGM, Eramet

Academics, education High schools Engineering schools Universities

In red: Scilab Enterprises customers

Page 24: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Organization

Page 25: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Company created in June 2010 from Inria The official structure resulting of the Scilab

Consortium which had developed Scilab since 2003

Jacques DhellemmesPresident

Claude GomezCEO

Christian SaguezVice President

Denis RanqueBoard Administrator

A high level team who has extensive knowledge of Scilab software and its environment and benefits directly from the Scilab developers expertise.

Scilab Enterprises relies on the historical and technical knowledge of the Scilab Consortium which develops Scilab software since 2003.

Scilab Enterprises

Page 26: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Activities

Scilab = Free software

funding

Scilab Enterprises

• Services:

– Consulting

– Migrations to Scilab

– Specific in-house versions

– Development and optimization of applications

• Products:

– Training and support

– Scilab LTS (« Long Term Support »)

– External commercial modules

development

publishing

Page 27: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

International Partnership Committee

President: Gérard Poirier (Dassault Aviation)

The International Scilab User’s Group

Role

• Management of Scilab users and developers• Promotion of Scilab• Roadmap and external modules proposals• All kinds of exchanges around Scilab

Creation of regional groups

Page 28: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Extending Scilab

Page 29: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

What does “free” means

Scilab Enterprises Commitment

Mission given by InriaThe Scilab distribution is and will

remain Free and Open Source

The Scilab distribution = what isdownloaded from “www.scilab.org”

• Mathematical functions• Language• Graphics, GUI• Xcos• ATOMS

Scilab license: CeCILL, GPL compatible

Scilab includes GPL code

=

Page 30: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

External modules: Open Source or not Free or commercial

EM

EM

Scilab distribution: Free and Open Source

...

Page 31: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Graphics

GUI Fortran and C code

(800,000 lines)

Scilab code(150,000 lines)

Computation libraries

Parser

Interpreter

API

Docu

men

tatio

nScilab

internals

User

External Module

External Module

External

Module

700 functions

1300 functions XML

JAVA

External

Module

Page 32: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Make a complete application using the good language

Fortran, C, C++

Scilab Code (including UI

Control)

Java

Scilab API:create a C gateway

JIMS = Java Interaction Mechanism in Scilab

You can use your own existing code without modifying it

Page 33: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

External modules

EM

EM

Scilab

ATOMSsystem

ATOMS: the external module manager

Advantages of ATOMS modules:

Independent of Scilab releases issues: easy update

Works on all architectures (Fortran, C or C++ code compiled on Windows, Mac OS X, Linux)

Handling of dependencies between modules

...

Page 34: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

User implementation

Organize the Scilab module according to instructions: http://atoms.scilab.org

The module can include:Scilab, Fortran, C, C++, Fortran code, XML help files

Upload source of Scilab module to ATOMS Scilab site Module available from Scilab

“ATOMIZATION” by Scilab Enterprises

For Companies: an internal ATOMS server can be installed

Fast deployment and easy maintenance

Page 35: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

ATOMS modules are loaded and installed interactively from Scilab from the “Applications” menu

Page 36: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Why Using Scilab?

Page 37: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilab Advantages

Scilab is free software

– Easy to install everywhere

– Large community of users

But freedom is not enoughA friendly software with a lot of functionalities

– Included toolboxes for most of applied mathematics

– Own dedicated OpenGL graphics

– Xcos comparable to Simulink

– Easy to add interactively external module

A comprehensive organization takes care of Scilab

– Scilab developed professionally by Scilab Enterprises

– Supports and services

– IPC Scilab Users Group with important Companies

Page 38: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Matlab … Scilab

Scilab is not a clone of Matlab

• Very similar languages• Same simple graphics functions: plot, bar, mesh, pie, surf

• But different syntax and semantics for many functions:- Syntax example: “eigen” vs. “spec”- Semantics example: “max” function- Different management of source files

Matlab / Scilab dictionary available in the Scilab help

Page 39: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

How Using Scilab?

Page 40: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilab as a Powerful Graphical Calculator

Matrix computations:A=rand(1000,1000); b=rand(1000,1);x=A\b; norm(A*x-b)vp=spec(A);

2D plots:plot(real(vp),imag(vp),"*r");x=linspace(-%pi,%pi,1000);clf; plot(x,sin(x),"r",x,cos(x),"g");

3D curve:k=tan(%pi/27);t=linspace(-40,40,1000);x=cos(t)./cosh(k*t); y=sin(t)./cosh(k*t); z=tanh(k*t);clf; param3d(x,y,z);

Page 41: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

3D beautiful surface: 90,000 pointsfunction z=f(x,y) // function defining the surface z=exp(exp(-x^2-y^2)*(exp(cos(x^2+y^2)^20)+.. 8*sin(x^2+y^2)^20+2*sin(2*(x^2+y^2))^8));endfunctionx=linspace(-1.5,1.5,300); y=linspace(-1.5,1.5,300); z=feval(x,y,f);f=scf(0); f.color_map=rainbowcolormap(32);surf(x,y,z); // plot the surfacee=gce(); e.color_mode=-1;a=gca(); a.box="off";a.axes_visible=["off","off","off"];a.x_label.visible="off";a.y_label.visible="off";a.z_label.visible="off";

Page 42: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Example: we want to plot data in 2D with color according to the value of the points, modify data and plot again

Data are given in text file mandel.txt (2 million points, 19 Mb).1. Put data into Scilab matrix M:

M=fscanfMat("mandel.txt");2. Open graphics window, choose beautiful colormap and plot points

according to its value:f=scf(1); f.color_map = rainbowcolormap(256);Matplot(M);

3. Discard points with value between 50 and 210 and plot in another window:M(find(50<M & M<210))=1;f=scf(2); f.color_map = rainbowcolormap(256);Matplot(M);

A very usual use: 1. Get data. 2. Plot Data. 3. Modify data and plot again.

Page 43: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

First plot Second plot

Plotting is instantaneous:

Page 44: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

To read text file takes time:M=fscanfMat("mandel.txt"); // 5 seconds

1. Save matrix into binary SOD (Scilab Open Data) based on HDF5 standard:save("mandel.sod","M"); // 0.04 second

2. Loading into Scilab is now very fast:load("mandel.sod"); // 0.1 second

Page 45: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Programming in Scilab

Friendly editor, powerful mathematical language close to natural language:

function u=Newton(f,fprim,u0,eps) u=u0; while abs(f(u))>eps then fp=fprim(u); if abs(fp)<=%eps then error("singularity") end u=u-f(u)/fp endendfunction

About 1,300 Scilab functions are written in Scilab

Page 46: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

function x=Gauss(A,b,eps) n=size(b,"*"); x=b; for k=1:n-1 // when the diagonal term is close to 0 // searching for a non zero element in the column if abs(A(k,k))<eps then kk=find(abs(A(k:n,k))>eps); if kk==[] then disp(“Non invertible Matrix"); return; end // exchanging lines k and kk in A and in b kk=kk(1); lignek=A(k,:); A(k,:)=A(kk,:); A(kk,:)=lignek; lignek=b(k); b(k)=b(kk); b(kk)=lignek; end // Gauss algorithm for l=k+1:n p=A(l,k)/A(k,k); for m=k:n A(l,m)=A(l,m)-A(k,m)*p; end x(l)=x(l)-x(k)*p; end end if abs(A(n,n))<eps then disp("Non invertible Matrix "); return; end // compute x x(n)=x(n)/A(n,n); for i=n-1:-1:1 s=0; for j=i+1:n s=s+A(i,j)*x(j); end x(i)=(x(i)-s)/A(i,i); endendfunction

Gaussian elimination with partial pivoting:

Scilab vectorized syntax

Page 47: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Save and load GUI as XML files : Save GUI with:

saveGui(f,"mygui.xml"); Load GUI with:

f=loadGui("mygui.xml");

Making easy Scilab GUI with Scilab 5.5.0

New components, speed, default look and feel of the OS

Page 48: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Migration from Matlab to Scilab: fast ROI

Migration from Excel to Scilab: GUI, faster computations, easy deployment and maintenance, easy evolution

BRGM Example 1

Scilab as a computation engine for other software: LabVIEW, iSight, ModFRONTIER,…

Make complete application as Scilab modules:– Used on site for production: ARCELORMITTAL, SANOFI, SNECMA,…– For internal use: AIRBUS GROUP, BRGM, CNES, DASSAULT AVIATION, EDF…– For scientific domains:

• Space mechanics: CelestLab by CNES Example 2• Optimization platform: SOP with DASSAULT AVIATION Example 3

For Industry

Page 49: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Example 1: from Excel to Scilab, BRGM

Page 50: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Example 2: CelestLab

ATOMS module for space mechanics and flight dynamics made by CNES

Freely available and Open Source Used by CNES and ESA for mission analysis Library of Scilab code: functions easily re-used for

making new programs

Page 51: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

CelestLab: A free and open source Scilab library for flight dynamics

CelestLab topics

Topics Contents

Coordinates and Frames - Change of coordinates- Dates manipulation- Change of reference frames- Orbital element transformations- Rotations and quaternions

Geometry and Events - Orbital events computation- Orbital geometry

Interplanetary - Interplanetary transfer- Three body analysis

Models Earth motion, density models

Orbit properties - Keplerian formulas- Orbit characteristics (sun synchronism, repeat orbits, frozen

orbits)

Relative motion Chlohessy-Wiltshire formalism

Trajectory and manoeuvres

- Orbit propagation (analytical)- Manoeuvre computation- Dispersion analysis

Utilities - Various support functions including graphics

Page 52: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

CelestLab: A free and open source Scilab library for flight dynamics 52

CelestLab and mission analysis practices

■Coding Scilab scripts using CelestLab is easy. This encourages people to develop their own scripts.

■CelestLab is developed by people in charge of mission analysis. It is a shared product.

■When an analysis is completed, there is an assessment on whether a part can be incorporated in CelestLab.

■CelestLab demos are a efficient solution for answering recurrent questions and can easily modified if needed.

■CelestLab is well documented and is more and more used as a source of information on a laptop.

Page 53: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

CelestLab: A free and open source Scilab library for flight dynamics 53

Examples of computation made with CelestLab:

1 - Sun elevation from any location on Earth

Page 54: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

CelestLab: A free and open source Scilab library for flight dynamics 54

2 - Sun reflection point (glint)

Page 55: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

CelestLab: A free and open source Scilab library for flight dynamics 55

3 - Ground stations visibility

Page 56: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Example 3: SOP

Optimization platform made with DASSAULT AVIATIONOMD2 and CSDL French funded R & D projects

Open Source and freely available: ATOMS module in the future Comprehensive application with GUI Library of C and Scilab code

Typical example of a complete Scilab industrial application:– Friendly interactive user interface masking the complexity to the final user– Possibility to try various algorithms, to make comparisons– Possibility to add its own functions and algorithms– Visualization and interaction with graphics

Page 57: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Interactive Graphics User Interface

Three modules: Data management Modeling Optimization

Project management: Saving and loading

Visualization and graphical interaction at each level

Page 58: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Data management

Load and generate existing DOE (iSight,…) : possibility to add its own DOE generator

Response simulation using external tools (openFOAM, CATIA, CCM+,…) or Scilab functions

2D visualization of factors and responses

Page 59: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Modeling

Selection among various modelers: DACE, LOLIMOT,… Parameter configuration Multiple model management with best model

selection

Possibility to select points:– Learning point– Validation or points– Bad points (simulation issues,…)

Page 60: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Modeling: execution and 2D visualization

Response: all factors, two factors Correlation

Page 61: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Optimization

Responses coefficients setting Optimizer:

– Selection between various algorithms: optim, fmincon, genetic,…

– Possibility to add its own algorithm– Interactive configuration

Visualization:– Optimal point– Pareto frontier– Robustness

Page 62: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Conclusion

Page 63: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)

Scilabis

The Professional Free Software for Numerical Computation

Industry, Education and Research

Page 64: Scilab Technical Talk at NTU, TP and HCMUT (Dr Claude Gomez)