49
Matematisk modelering og Matematisk modelering og simulering simulering Hans Hans Petter Langtangen Petter Langtangen Simula Research Laboratory Simula Research Laboratory Dept. of Informatics, Univ. of Dept. of Informatics, Univ. of Oslo Oslo

Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Embed Size (px)

Citation preview

Page 1: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Matematisk modelering og Matematisk modelering og simuleringsimulering

HansHans Petter Langtangen Petter Langtangen

Simula Research LaboratorySimula Research LaboratoryDept. of Informatics, Univ. of OsloDept. of Informatics, Univ. of Oslo

Page 2: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Questions I will addressQuestions I will address

• What is What is mathematical modeling and mathematical modeling and simulationsimulation, or , or computational sciencecomputational science??

• Why is it so important?Why is it so important?• When/where is it useful?When/where is it useful?• What kind of competence and knowledge is What kind of competence and knowledge is

needed?needed?

Page 3: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

The story of the The story of the success of simulation success of simulation

is a story about is a story about making mathematics making mathematics

much more usefulmuch more useful

Page 4: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

The role of mathematics The role of mathematics cannot be cannot be underestimatedunderestimated

• For the last 300 years, mathematics has been a For the last 300 years, mathematics has been a key tool in the development of science and key tool in the development of science and technologytechnology

• Result: dramatically higher living standardsResult: dramatically higher living standards• Mathematics will be dramatically more useful in Mathematics will be dramatically more useful in

the futurethe future• Why? Because of fast computersWhy? Because of fast computers• This fact will accelerate science and technologyThis fact will accelerate science and technology

Page 5: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Why computers make Why computers make mathematics more usefulmathematics more useful

• We have equations (mathematical models) for We have equations (mathematical models) for how nature workshow nature works

• Nature = weather, climate, oil production, Nature = weather, climate, oil production, airplane manufacturing, space exploration, airplane manufacturing, space exploration, epidemics, wireless communication, …epidemics, wireless communication, …

• The difficulty is to solve the equationsThe difficulty is to solve the equations• Before the computerBefore the computer: specialized methods with : specialized methods with

pen & paper for a few problemspen & paper for a few problems• After modern, fast computersAfter modern, fast computers: general and : general and

widely applicable solution methodswidely applicable solution methods

Page 6: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

It is impossible to exaggerate the extent to which modern applied mathematics has been shaped and fuelled by the general availability of fast computers with large memories. Their impact on mathematics,both applied and pure, is comparable to the role of telescopes in astronomy and microscopes in biology... I am on the safest ground in surmissing that computing will play en even bigger role in the next century than today.

P. D. Lax, SIAM Review 1989

Page 7: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

All modern weather All modern weather forecasts are based on forecasts are based on extensive simulationextensive simulation

Page 8: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Weather forecast in Norway

Horizontal resolution: 4 km

300 x 500 x 38 grid points

Time step: 1 min

Simulation period: 60 h

Determines parameters

in 20.5 billion points

Roar Skålin,

IT manager, met.no

Page 9: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

The computer becomes The computer becomes a lab a lab • We need to make a program to do We need to make a program to do

mathematics on a computermathematics on a computer• Complicated mathematical models and Complicated mathematical models and

solution methods can be packed in user-solution methods can be packed in user-friendly software and ”hidden”friendly software and ”hidden”

• With such software, the computer becomes a With such software, the computer becomes a cheap laboratory for experimentation!cheap laboratory for experimentation!

• Using the computer as a lab is often called Using the computer as a lab is often called simulationsimulation

• Here we look at simulation based on Here we look at simulation based on mathematical modelsmathematical models

Page 10: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Exploration softwareExploration software

Page 11: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Now we do Now we do computational sciencecomputational science

• Wikipedia definition:Wikipedia definition:Computational science is the use of Computational science is the use of

computers to perform research in other computers to perform research in other fields. It is the application of fields. It is the application of computer computer simulationsimulation and other forms of computation and other forms of computation to problems in various scientific disciplines. to problems in various scientific disciplines.

It is not to be confused with computer It is not to be confused with computer science which is the study of topics related science which is the study of topics related to computers and information processing.to computers and information processing.

Page 12: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Related termsRelated terms

• Computational science and engineeringComputational science and engineering• Mathematical modeling and simulationMathematical modeling and simulation• Numerical modelingNumerical modeling• Scientific computing Scientific computing

(study, implement and apply algorithms)(study, implement and apply algorithms)• Numerical mathematics Numerical mathematics

(study properties of algorithms)(study properties of algorithms)

Page 13: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Computational science has become the third Computational science has become the third pillar of the scientific enterprise, a peer pillar of the scientific enterprise, a peer alongside theory and physical experiment.alongside theory and physical experiment.

Computational science is now indispensableComputational science is now indispensable to the solution of complex problems in every sector .

Advances in computing...make it possible to develop computational models...to address problems previously deemed intractable.

PITAC Report , ”Ensuring America’s Competitiveness”, to the US president, 2005

Page 14: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

The next 10 to 20 years will see computational science firmly embedded in the fabric of science – the most profound development in the scientific method in over three centuries. US Department of Energy, 2003

Page 15: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Processes

Computations

DATASET UNSTRUCTURED_GRIDPOINTS 201 float2.77828 2.18262 -0.25 0.476 2.4 -0.85 0.85 2.4 -0.476 -0.476 2.4 -0.85 -0.85 2.4 -0.476 -0.85 2.4 0.476 -0.476 2.4 0.85 0.476 2.4 0.85 0.85 2.4 0.476 2.55 0.8625 0.66 CELLS 458 22904 41 29 65 80 4 53 41 65 82 4 35 34 47 71

Results

Mathematical Model

The Simulation PipelineThe Simulation PipelinePrediction & Control

Refinement

Page 16: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Simulation vs. real Simulation vs. real experimentsexperiments

• Simulation is cheap compared to physical Simulation is cheap compared to physical experiments (lab or field)experiments (lab or field)

• Physical experiments may be dangerous, Physical experiments may be dangerous, impossible or too expensiveimpossible or too expensive

• Simulations give more detailed information Simulations give more detailed information and understandingand understanding

• The best is to do both!The best is to do both!

Page 17: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Past, present and future Past, present and future applications of applications of simulation simulation

• Weapons, logistics, space explorationWeapons, logistics, space exploration• Classical industry (structural, car, ship, airplane, oil & Classical industry (structural, car, ship, airplane, oil &

gas, chemical, consumer products, …)gas, chemical, consumer products, …)• Electronics, telecommunicationsElectronics, telecommunications• Advanced materials (incl. nanotechnology)Advanced materials (incl. nanotechnology)• Construction of new molecules (chemestry on computer)Construction of new molecules (chemestry on computer)• Environmental research, incl. climate predictionsEnvironmental research, incl. climate predictions• Medicine: surgery, diagnosticsMedicine: surgery, diagnostics• Geological evolution of the earth (e.g., oil reservoirs)Geological evolution of the earth (e.g., oil reservoirs)• Evolution of planets, galaxies, universeEvolution of planets, galaxies, universe• Biological processes and evolutionBiological processes and evolution• Sociological, psycological, economical processesSociological, psycological, economical processes

Page 18: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Warm winters and cold Warm winters and cold summerssummers

Each frame in this animation of the surface temperature of the Gulf Stream represents a seven day period.

Page 19: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Knut-Andreas Lie, SINTEF

Tsunamis in fjordsTsunamis in fjords

Page 20: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

The tsunami in the Indian Ocean, Dec 26, 2004

”Mesh level 1” 111 km x 111 km

”Mesh level 3” 1.7 km x 1.7 km

”Mesh level 4” 25 m x 25 m

Jan Olav LangsethDave GeorgeRandy LeVeque

Page 21: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo
Page 22: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Simulation is a key tool Simulation is a key tool in the aerospace in the aerospace industryindustry

Page 23: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Crashing cars in the Crashing cars in the computer is cheaper computer is cheaper than in realitythan in reality

Page 24: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

”High lift configuration”

CRAY T3E – 1450 processors, 25 million gridcells University of Wyoming (1998)

Unstructured gridsUnstructured grids

Page 25: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Simulation is a key tool Simulation is a key tool in studying the in studying the universeuniverse

A comet, 1 km in diameter, entering Jupiter’s atmosphere at 134,000 miles per hour. (Red comet core of solid ice.)

Page 26: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Facts about the simulation

• Turbulent structures

• Gravity/temperature driven

•1 million CPU hours

• 1000 processors

• 100.000 GB of data

Joe Werne, Colorado Research Associates DivisionNorthWestResearch Associates, Inc.

Page 27: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo
Page 28: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Simulation is a key tool Simulation is a key tool in the oil & gas in the oil & gas industryindustry

Page 29: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Knut-Andreas Lie, SINTEF

Oil-water flow in oil Oil-water flow in oil reservoirsreservoirs

Page 30: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

New understanding of New understanding of life processeslife processes

Simulation is important in the exploration oflife processes, ranging from studies of DNAto investigations of blood circulation and inner organs like the heart, brain and lungs.

Page 31: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

DNA and Drug DesignDNA and Drug Design

Better understanding of thestructure of DNA may leadto new and improved drugs, like a vaccine for the flu!

Page 32: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

What happens with What happens with smoke in your lungs?smoke in your lungs?

3D time-dependent Navier-Stokes simulations of the airflow in the lungs. Methods from aerospace and car industry are adapted to life sciences.

Page 33: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Electrical activity in the Electrical activity in the heart: estimate heart: estimate infarctions by simulationsinfarctions by simulations

Page 34: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Martin Sandve AlnæsTor IngebrigtsenJørgen IsaksenKent-Andre MardalOla Skavhaug

Univ. of Tromsø,Simula Research Lab.

Blood flow simulationBlood flow simulation

Page 35: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo
Page 36: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo
Page 37: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo
Page 38: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Challenges in simulation: Challenges in simulation: mathematics, algorithms, mathematics, algorithms, softwaresoftware

• Multi-physicsMulti-physics• Multi-scaleMulti-scale• Multi-disciplinaryMulti-disciplinary• Multi-institutional code/teamsMulti-institutional code/teams• Obtaining real-life input data, e.g., complex Obtaining real-life input data, e.g., complex

geometriesgeometries• Total system simulation Total system simulation

(trees of complex simulation components)(trees of complex simulation components)

Page 39: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Different types of Different types of mathematical models mathematical models are used for different are used for different physical scalesphysical scales

• Elementary particles: quantum mechanics Elementary particles: quantum mechanics Schrodinger equation, system of particlesSchrodinger equation, system of particles

• Molecules: molecular dynamics System of Molecules: molecular dynamics System of particles; ordinary differential eqs.particles; ordinary differential eqs.

• Macro-scale: continuum mechanics Partial Macro-scale: continuum mechanics Partial differential eqs.differential eqs.

Page 40: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Limitations of Limitations of simulationsimulation• For some industrial processes (esp. structural For some industrial processes (esp. structural

analysis), mathematical models and analysis), mathematical models and simulation have high precisionsimulation have high precision

• In complex media (geology, medicine) lack of In complex media (geology, medicine) lack of media details and complex physics may lead media details and complex physics may lead to low quantitative precisionto low quantitative precision

• Despite low precision, simulation may provide Despite low precision, simulation may provide important insight into the physicsimportant insight into the physics

• Simulation as a learning tool in combination Simulation as a learning tool in combination with human experience and knowledge is with human experience and knowledge is often more useful than accurate predictionoften more useful than accurate prediction

Page 41: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Hardware vs algorithmic development 1970 - 2000

Updated version of chart appearing in “Grand Challenges: High performance computing and communications”, OSTP committee on physical, mathematical and Engineering Sciences, 1992.

Page 42: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Computing in Computing in ParallelParallel

Computing in Computing in ParallelParallel

Computing in Computing in ParallelParallel

• Simulation requires enormous computational Simulation requires enormous computational power (speed, storage)power (speed, storage)

• Processors get faster…(2x every 18 months)Processors get faster…(2x every 18 months)• ……but a much larger gain in speed comes but a much larger gain in speed comes

from coupling computers in parallelfrom coupling computers in parallel• Split a problem in subproblems and let many Split a problem in subproblems and let many

computers deal with subproblems in parallelcomputers deal with subproblems in parallel• Requires computers to communicateRequires computers to communicate• Humans think sequentially; constructing Humans think sequentially; constructing

parallel algorithms is hardparallel algorithms is hard

Computing in Computing in ParallelParallel

Page 43: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Simulation software is Simulation software is more complex than most more complex than most other software!other software!

• Very large program systemsVery large program systems• Complicated mathematical modelsComplicated mathematical models• Great algorithmic complexityGreat algorithmic complexity• Difficult to test, complicated outputDifficult to test, complicated output• Extreme demands toExtreme demands to

fast computationsfast computations memory usagememory usage

• Fancy GUIs and colorful results…Fancy GUIs and colorful results…

Page 44: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Can anyone do Can anyone do simulation?simulation?• Simulation packages have become ”easy” to Simulation packages have become ”easy” to

use and provide impressive colorful resultsuse and provide impressive colorful results• Result: ”anyone” can simulate!Result: ”anyone” can simulate!• However, without a thorough understanding However, without a thorough understanding

of the mathematical model, it is easy to of the mathematical model, it is easy to provide wrong input data, or ignore optionsprovide wrong input data, or ignore options

• Judging the quality of the results is difficultJudging the quality of the results is difficult

Page 45: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

What can go wrong?What can go wrong?

• Lots of input data, usually with default values, Lots of input data, usually with default values, but are the default values appropriate?but are the default values appropriate?

• Picking the wrong mathematical modelPicking the wrong mathematical model• Forgetting boundary conditionsForgetting boundary conditions• Choosing an inadequate numerical solution Choosing an inadequate numerical solution

method and/or associated parametersmethod and/or associated parameters• Results consist of numerical artifacts and real Results consist of numerical artifacts and real

physical features – what is what?physical features – what is what?

Page 46: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Wrong simulations may Wrong simulations may lead to very expensive lead to very expensive disastersdisasters• A primary example is the Sleipner platformA primary example is the Sleipner platform• Insufficient use of computations caused a Insufficient use of computations caused a

structural failure and the platform sankstructural failure and the platform sank• Cost: 700M $Cost: 700M $

Page 47: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

What kind of What kind of competence do we competence do we need to do simulation?need to do simulation?

• Many can run simulation programs, but at least one in Many can run simulation programs, but at least one in the team must the team must understand understand the complexity of the complexity of the modelthe model and and pitfallspitfalls of the program’s simulation techniques of the program’s simulation techniques

• Education in simulation is immature and incompleteEducation in simulation is immature and incomplete• This competence is emerging in new computational This competence is emerging in new computational

science & engineering university programsscience & engineering university programs• To do high-quality simulations, one needs competence To do high-quality simulations, one needs competence

that take years to build that take years to build systematicallysystematically• This competence building requires long-term strategic This competence building requires long-term strategic

plans in R&D institutionsplans in R&D institutions

Page 48: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

Programming builds Programming builds competence in an competence in an effective wayeffective way

• Internal software developmentInternal software development is an effective is an effective and simple exercise to build competenceand simple exercise to build competence

• ””Programming is understanding” (K. Nygaard)Programming is understanding” (K. Nygaard)• Even if a sophisticated external software Even if a sophisticated external software

package is to be used for production package is to be used for production simulation, programming a simplified model is a simulation, programming a simplified model is a specific way to gain insight into the model and specific way to gain insight into the model and relevant numerical techniquesrelevant numerical techniques

• Programming is expensive, but building Programming is expensive, but building competence competence isis expensive, and delivering wrong expensive, and delivering wrong simulation results is even more expensive…simulation results is even more expensive…

Page 49: Matematisk modelering og simulering Hans Petter Langtangen Simula Research Laboratory Dept. of Informatics, Univ. of Oslo

SummarySummary

• Simulation (computer=lab) is a now key tool in Simulation (computer=lab) is a now key tool in science and technologyscience and technology

• Every project should investigate the possibilities Every project should investigate the possibilities offered by simulation!offered by simulation!

• Better numerics and faster hardware will make Better numerics and faster hardware will make simulation even more importantsimulation even more important

• Simulation involves advanced mathematics, Simulation involves advanced mathematics, physics, +++ and requires high competencephysics, +++ and requires high competence

• The success of simulation relies on sucess in The success of simulation relies on sucess in proper competence buildingproper competence building

• Programming = efficient competence buildingProgramming = efficient competence building