scilab model reduction toolbox documentation · pdf file · 2018-03-14those are the...

8
This documentation is made for the engineer who would like to leverage Proper Orthogonal Decomposition for his work, bringing some intelligence in the use of Scilab Model Reduction Toolbox. Introduction To fully understand the capabilities and the limits of the POD, you just have to know a few main points. The main ideas behind the POD : 1) POD is a statistical tool The POD analyses the coherent structure of a flow through your DOE snapshots. What does that mean? First of all, that the modes (eigenvectors of correlation matrix) you obtain could be real physical structures evolving with time or other parameters. That is the case, for example, if you train your model on a turbulent unsteady CFD case. Modes could then be turbulent structures. Second of all, that the energy associated to the modes (eigenvalues of correlation matrix) represents the probability for such a mode to appear in your Snapshots simulations. How to correctly use the POD tool? It’s all about setting a relevant DOE depending on your case. - If you would like to leverage a reduced basis (considering only a few modes), and if you are focusing on a particular dynamic behaviour, try to make it happen more often (more snapshots) so that the energy associated to that mode will be higher. Considering only the first more energetic modes will then be OK. - If you would like to simulate any kind of case, you have to make a DOE as bigger and random as possible. Doing so, you will have to consider all the modes, because no one will be more relevant than another (Or maybe the few firsts ones. But those won’t capture any particular dynamic.). So, if you think that your system dynamic is not well reconstructed/predicted, first of all check your modes and see if the particular dynamic is present. If it’s not, try to generate a new and more relevant DOE. 2) POD is just about mode computing What is different from other surrogate modelling method like RBF interpolation or kriging? The first step with POD is to generate a modal basis based on a relevant DOE. The idea behind POD with interpolation prediction is that you assume that your simulation can be linearly decomposed on this exact same basis. Good point: As modes correspond to coherent structures which are evolving following a parameter (One DOE snapshot for one set of parameter), it is particularly relevant to try to interpolate the behaviour of that modes in order to predict the whole system behaviour. Bad point: As said, it is a linear decomposition. So, it is hard to predict strongly non-linear behaviour (transonic shock for example) with a single POD basis. The idea could then be to generate many local relevant POD basis. 3) What about model reduction Model reduction can be considering only a few modes for your POD basis before interpolating or make a projection of your mathematical model equations on your reduced basis.

Upload: dobao

Post on 24-Mar-2018

242 views

Category:

Documents


3 download

TRANSCRIPT

This documentation is made for the engineer who would like to leverage Proper OrthogonalDecompositionforhiswork,bringingsomeintelligenceintheuseofScilabModelReductionToolbox.

IntroductionTofullyunderstandthecapabilitiesandthelimitsofthePOD,youjusthavetoknowafewmainpoints.ThemainideasbehindthePOD:

1) PODisastatisticaltoolThePODanalysesthecoherentstructureofaflowthroughyourDOEsnapshots.Whatdoesthatmean?First of all, that the modes (eigenvectors of correlation matrix) you obtain could be realphysicalstructuresevolvingwithtimeorotherparameters.Thatisthecase,forexample, ifyou train your model on a turbulent unsteady CFD case. Modes could then be turbulentstructures.Secondof all, that theenergy associated to themodes (eigenvaluesof correlationmatrix)representstheprobabilityforsuchamodetoappearinyourSnapshotssimulations.HowtocorrectlyusethePODtool?

It’sallaboutsettingarelevantDOEdependingonyourcase.

- Ifyouwouldliketoleverageareducedbasis(consideringonlyafewmodes),andifyouarefocusingonaparticulardynamicbehaviour,trytomakeithappenmoreoften(moresnapshots)sothattheenergyassociatedtothatmodewillbehigher.ConsideringonlythefirstmoreenergeticmodeswillthenbeOK.

- If youwould like to simulate any kindof case, youhave tomakeaDOEasbigger andrandomaspossible.Doingso,youwillhavetoconsiderallthemodes,becausenoonewillbemorerelevantthananother(Ormaybethefewfirstsones.Butthosewon’tcaptureanyparticulardynamic.).

So,ifyouthinkthatyoursystemdynamicisnotwellreconstructed/predicted,firstofallcheckyourmodesandseeiftheparticulardynamicispresent.Ifit’snot,trytogenerateanewandmorerelevantDOE.

2) PODisjustaboutmodecomputingWhatisdifferentfromothersurrogatemodellingmethodlikeRBFinterpolationorkriging?ThefirststepwithPODistogenerateamodalbasisbasedonarelevantDOE.TheideabehindPODwith interpolation prediction is that you assume that your simulation can be linearlydecomposedonthisexactsamebasis.Good point: As modes correspond to coherent structures which are evolving following aparameter(OneDOEsnapshotforonesetofparameter), it isparticularlyrelevanttotrytointerpolatethebehaviourofthatmodesinordertopredictthewholesystembehaviour.Badpoint:As said, it isa lineardecomposition.So, it ishard topredict stronglynon-linearbehaviour(transonicshockforexample)withasinglePODbasis.TheideacouldthenbetogeneratemanylocalrelevantPODbasis.

3) WhataboutmodelreductionModelreductioncanbeconsideringonlyafewmodesforyourPODbasisbeforeinterpolatingormakeaprojectionofyourmathematicalmodelequationsonyourreducedbasis.

ScilabModelReductionToolboxEvenifallthefeaturesarenotavailableyet,everythinghasbeenimplementedinordertoconsider2D/3D,3/4nodescells,steady/unsteadycases.Notethatfor3DcasesyouwillhavetousetheEuclidianinnerproductandvisualizationwon’tbeavailable.Moreoveronlythesnapshotsmethodisavailable.

DataformatTosetupthelearningphase,youwillfirstneedtosetupyourmeshinScilab.TodosoyouwillneedtwotextfilesthatyoucantransformintoarrayinScilabusingthefscanfMatfunction.Thefirstonegathers X, Y, Z nodes coordinates, one column for each. The second one is the cell description(connectivity)ofyourmesh.Thisisanarraywherethenth lineiscomposedofthepositionofeachnodes(regardingthefirstcoordinatesfile)composingthenthcell(Yourfirstindexhavetobe1).

Intheexampleontheleft,wecanseethetheX and Y coordinates on the left on twocolumns. Beside lies the connectivity file,wherewecanseethatthemeshcomposedof quad cells (4 columns) and that the firstcell is composed of the 6219th, 6218th,

6294th,6295thnodesinthecoordinateslist.

Nowimportyourfielddata.Todoso,gatherthenodalvaluesforalltime/parametersimulations(onesnapshotpercolumn)andfollowthesameprocessasabove.

CreatemeshandsimulationIt’stimetoseeifalltheimportphase(mesh+data)wentright.Todoso,youwillneedtocreateaMeshandaSimulation.ThosearethetwomainobjectsoftheScilabPODtoolbox.

• Create_mesh

This functionwill allowyou tocreateameshobject,dependingon thenodescoordinatesandcelldescriptionyoupreviouslyimported.TheBooleaninputargumentcompute_datajustgivesyourmeshmoreproperties.Itismandatoryformathematicalmodelreduction.(Setcompute_dataas%ffor3Dcasesbecauseitrequires3Dintegralcomputation).

Mesh object properties: node_coords / nb_nodes / cell_type / elements / nb_elements /border_edges/border_normal_vectors/element_x/element_y/element_area

• Create_simulation

This functionwill allow you to create a simulation object, depending on themeshobject you justcreatedandthenodalvaluesofyourfield.Yournodalvalueisalistobjectcontainingarrayvaluesforunsteady simulation for each set of parameters. If you areworkingwith steady simulation, everyelementofyourlistwillthenbeasimplecolumnvector.Thepropertynb_samplesisthenarowarraycontainingthenumberoftimestepsforeachlistelement.

Simulationobjectproperties:_mesh/nb_case/nb_samples/values

• Show_simulation

Tryitandvalidatetheresultwiththeshow_simulationfunction.Youjusthavetoinsertyoursimulationobject(simulation)youjustcreatedanditwillplotyourfield.Dependingonthenumberofsnapshotsyouhave,youcandisplayasingleframeoracompleteanimation.Ifyousetvararginto%t,itwillsaveyoualltheframeas.gifimages.(Notavailablefor3Dcasesbecausefecisonly2D).

GeneratemodalbasisIfyouaredoingmathematicalmodelreduction,youwillhavetobecarefulaboutthelimitconditions.It’sforexamplemandatoryforthePODtoworkwithhomogeneouslimitconditions.Todosoyoucanusethefollowingfunction(It’squitelimitedthough).

• Prepare_limit_conditions

Limit_conditions(generatedbytheprepare_limit_conditionsfunction)isalsoanobjectinthistoolboxgathering this only two properties: homogeneous (Boolean) and time_invariant (Boolean). This is

mandatorytosetamathematicalbasedmodelreduction.Butbecareful,youwillloseaccuracyusingthehomogeneouspropertybecauseitcomputesthePODonlyontheperturbedflow(𝑢" = 𝑢 −𝑢).

• Compute_pod_basis

Hereisthefunctionthatgeneratesyourmodalbasisbasedonyourlearningsimulations,andtheinnerproductyouwant.SetEuclidto%tifyouwanttousetheEuclidianinnerproduct(meshindependency)and%fifyouwanttousetheinnerproductonL2.Notethatthebasisgenerationcouldtakeabittimebecauseofthecomputation/diagonalizationofahugecorrelationmatrix.Fornow,a100.000nodesmesh,1000frames/snapshotscomputationtakes12minonScilab6togetthepod_basis.

Pod_basisobjectproperties:u_m(meanfield)/u_s(varyingfield)/phi(modes)/lambda(associatedeigenvalues)

• Reduce_pod_basis

Now that you get your pod_basis, you can reduce it keeping only themost energeticmodes andvisualizethem(modesandassociatedenergy)bysettingvisuto%t.

Becareful!Assaidearlier,thepodbasisistheoreticallyanorthonormalbasis,meaningthatkeepingthefullbasiswillgiveyoutheexactsolutionyouwouldhavesimulated.But,duetosomenumericalerror, taking toomuchmodes intoaccount increases the reconstruction/predictionerror.Take thetimetolookfortheoptimalnumberofmodesregardingaccuracyvscomputingtime.

Reduced_basisobjectproperties:n_pod(numberofselectedmodes)/phi(n_podfirstmodes)/u_m

Datacompression&reconstructionThedatacompressionphasecorrespondstothereducedbasisgeneration.Actuallywithyourreducedbasisandasetofcoefficientyoucanreconstructthemainpartofyourinitialsimulation.

• Reconstruct_simulation

Reconstruct_simulationisasimplesimulationobjectbasedonasimpleoneframeprojectiononyourreducedbasis. Besidesmaking theprojection, the reconstruct_simulation functionwill display then_podprojectioncoefficients.Justusetheshow_simulationfunctioninordertoseethesimulationreconstruction.

• Compute_rel_error

Thecompute_rel_errorfunctionreturnsthenormalizedrootmeansquaredeviationbetweenanexpectedandpredicted/reconstructedfield.

ParametricpredictionWhatyougetfromnow:Amesh,alearningsimulation,areducedpodbasis.

1) Steadyparametricinterpolation

This function will first compute the projection coefficients on the reduced basis of your learningsimulationsandwillinterpolatethecoefficientsthenewparameterwithRadialBasisFunction.Todoso,youjustneedtosetyourentireDOEcomposedofyourparametersvaluesforeachsimulationcase,one parameter per column. Two different kernels are available: Gaussian andMultiquadric. If thesystemisill-conditioned,youcanaddrelaxationpolynomialswithorthogonalitycondition.Notethatthe choice of the interpolationmethoddepends on the physical field to predict. It is an empiricalprocess.

2) Unsteadymono-parametricinterpolationUnsteadysimulationsaremorecomplextopredictbecausewecan’tmakeasimpleinterpolationonthecoefficients,consideringthatthosearetime-andparameter-dependent.SoyouwillhavetomakeasecondPODonthereducedbasisyougot,usingn2_podfunction.Butfirst,makesurethatallyourunsteadysimulationshavethesamenumbersnapshots(=timesteps).

• N2_pod

Givingthenumberof learningparameters,thefirstreduced_basisandthe learningsimulation,thisfunctionreturnsanewPODbasisandtheassociatedcoefficients.Thosecoefficientsareusedfortheinterpolationinthefollowingfunction:

• One_parameter_interpolation

JustasRBF_interpolation,thisfunctionwillreturntheinterpolatedcoefficientsforthenewvalueofparameter,given theDOE (DOE–have tobe linevector), thenumberofmodesn_pod in the firstreducedbasisandthecoefficientsgivenbythen2_podfunction.

3) PredictionWhatyougetfromnow:Amesh,learningsimulation,reducedpodbasisandinterpolatedcoefficientsNewPInterp.

• Predict_simulation

The predict_simulation function creates the predicted simulation associated to the interpolatedcoefficients.Ifyouhaveusedthen2_podfunctiontogetinterpolatedcoefficientsforyourunsteadysimulation, setn2 inputargument to%tandadd thesecondPODbasispodi generatedbyn2_podfunction.

VisualizationSome visualization functions are already used in themain functions, but it may be interesting toleveragesomeofthemwithoutgeneratingafullPODbasis,again.

• Plot_basis_coefficients

• Show_pod_modes

• Show_simulation

ConclusionWe saw themain functions needed to set a classical POD processwith the Scilab tool. There areobviouslymorefeaturesthatareusedwithinthemainfunctions.Andyoualsogotsomemorefeaturesforequationsbasedmodelreduction.

ReferencesCasduCylindre–Bertincase

[1]Cordier,L.,Bergmann,M.,RéductiondedynamiqueparDécompositionOrthogonaleauxValeursPropres(POD),LEMTA,UMR7563(CNRS–INPL–UHP),Mars2006.

Prédictionparinterpolationpourcasstationnaireetinstationnaire

[2]WaltonS.,HassanO.,MorganK.,Reducedordermodelling forunsteady fluid flowusingproperorthogonal decomposition and radial basis functions, College of Engineering, Swansea University,2013.

Différentesmethodesd’interpolationRBF

[3] Dolci V., and Arina R.,Proper Orthogonal Decomposition as SurrogateModel for AerodynamicOptimization,DIMEAS,PolitecnicodiTorino,2016.