comsol equation based modeling 4.3b

47
Equation-Based Modeling © Copyright 2013 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks or trademarks of COMSOL AB. All other trademarks are the property of their respective owners, and COMSOL AB and its subsidiaries and products are not affiliated with, endorsed by, sponsored by, or supported by those trademark owners. For a list f au u u u c t u d t u e a a ) ( 2 2

Upload: vkchau

Post on 08-Apr-2016

171 views

Category:

Documents


7 download

DESCRIPTION

Presentation

TRANSCRIPT

Page 1: COMSOL Equation Based Modeling 4.3b

Equation-Based Modeling

© Copyright 2013 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks or trademarks of COMSOL AB. All other trademarks are the property of their respective owners, and COMSOL AB and its subsidiaries and products are not affiliated with, endorsed by, sponsored by, or supported by those trademark owners. For a list of such trademark owners, see http://www.comsol.com/tm

fauuuuctud

tue aa

)(2

2

Page 2: COMSOL Equation Based Modeling 4.3b

Multiphysics and Single-Physics Simulation Platform

• Mechanical, Fluid, Electrical, and Chemical Simulations

• Multiphysics - Coupled Phenomena– Two or more physics phenomena that affect each other with no

limitation on• which combinations• how many combinations

• Single Physics– One integrated environment – different physics and applications– One day you work on Heat Transfer, next day Structural

Analysis, then Fluid Flow, and so on– Same workflow for any type of modeling

• Enables cross-disciplinary product development and a unified simulation platform

Page 3: COMSOL Equation Based Modeling 4.3b

Highly Customizable and Adaptable

• Create your own multiphysics couplings• Customize material properties and boundary

conditions– Type in mathematical expressions, combine with look-up

tables and function calls• User-interfaces for differential and algebraic equations• Parameterize on material properties, boundary

conditions, geometric dimensions, and more• High-Performance Computing (HPC)

– Multicore & Multiprocessor: Included with any license type

– Clusters & Cloud: With floating network licenses

Page 4: COMSOL Equation Based Modeling 4.3b

The COMSOL Multiphysics® 4.3b Product Suite

Page 5: COMSOL Equation Based Modeling 4.3b

Equation-Based Modeling

• Partial Differential Equations (PDEs)– PDE Interfaces– Boundary Conditions

• Ordinary Differential Equations (ODEs)– Global ODEs– Distributed ODEs

• Algebraic Equations– Global algebraic equations– Distributed algebraic equations

Page 6: COMSOL Equation Based Modeling 4.3b

When is Equation-Based Modeling Needed?

• Try to avoid equation-based modeling if possible!– Using built-in physics interfaces enables ready-made postprocessing variables

and other tools for faster model setup with much lower risk of human error

• Applications that previously required equation-based modeling but now has a dedicated physics interface:– Fluid-Structure Interaction (Structural Mechanics Module, MEMS Module)– Surface adsorption and reactions (Chemical Reaction Engineering Module,

Plasma Module)– Shell-Acoustics and Piezo-Acoustics (Acoustics Module)– Thermoacoustics (Acoustics Module)– and many more…

Page 7: COMSOL Equation Based Modeling 4.3b

When is Equation-Based Modeling Needed?

• Try to avoid equation-based modeling if possible!• But: we don’t have every imaginable physics equation built-

into COMSOL (yet!). So there is sometimes a need for custom modeling.

Page 8: COMSOL Equation Based Modeling 4.3b

Custom-Modeling in COMSOL

• COMSOL Multiphysics allows you to model with PDEs or ODEs directly:– Use one of the equation-template user interfaces

• You do *not* need to write “user-subroutines” in COMSOL to implement your own equation!– Benefit: COMSOL’s nonlinear solver gets all the nonlinear info with

gradients and all. Faster and more robust convergence.

Page 9: COMSOL Equation Based Modeling 4.3b

Customization Approaches

• Four modeling approaches:1. Ready-made physics interfaces2. First principles with the equation templates3. Start with ready-made physics interface and add additional terms.4. Start with a ready-made physics interface and add your own

separate equation (PDE,ODE) to represent physics that is not already available as a ready-made application mode

• Also: – The Physics Builder lets you create your own user interfaces that hides the

mathematics for your colleagues and customers

Page 10: COMSOL Equation Based Modeling 4.3b

PDEs

Page 11: COMSOL Equation Based Modeling 4.3b

Linear Model Problems: Fundamental Phenomena

• Laplace’s equation

• Heat equation

• Wave equation

• Helmholtz equation

• Convective Transport equation

0 u

0)( ukut

0)( uutt

uu )(

0 xt buu

Page 12: COMSOL Equation Based Modeling 4.3b

COMSOL PDE Modes: Graphical User Interfaces

• Coefficient form• General form• Weak form

• All these can be used for scalar equations or systems• Which to use?

– Whichever is more convenient for you and your simulation needs

Page 13: COMSOL Equation Based Modeling 4.3b

Coefficient Form

• Coefficient Matching Example: Poisson’s equation

rhuhgquuuc T )(n

inside domain

on boundary

1 u0u

inside subdomain

on subdomain boundary

Implies c=f=h=1 and all other coefficients are 0.

fauuuuctud

tue aa

)(2

2

Page 14: COMSOL Equation Based Modeling 4.3b

Demo:Block: 10x1x1

PDE: default Poisson’s equation with unknown u.

Dirichlet boundary condition everywhere: u=0

Page 15: COMSOL Equation Based Modeling 4.3b

d(u,x) with no Recover smoothing

d(u,x) with Recover smoothing

The Recover feature applies “polynomial-preserving recovery” on the partial derivatives (gradients).

Higher-order approximation of the solution on a patch of mesh elements around each mesh vertex.

Also available as ppr operator.

Page 16: COMSOL Equation Based Modeling 4.3b

Coefficient Form, Interpretations

mass damping/mass

diffusion

convection

source

convection

absorption

source

fauuuuctud

tue aa

)(2

2

Page 17: COMSOL Equation Based Modeling 4.3b

mass damped mass

elastic stress initial/thermal stress

body force (gravitation)

a

aed

cc

u

2

2 ( )a ae d c a ft t

u u u u u u

Coefficient Form, Structural Analysis Wave Equation

density

damping coefficient

stress, u= displacement vectorstiffness, “spring constant”

Page 18: COMSOL Equation Based Modeling 4.3b

accumulation/storage

diffusion

convection

source

convection

absorption

source

Coefficient Form, Transport Diffusion Equation

fauuuuctud

tue aa

)(2

2

Page 19: COMSOL Equation Based Modeling 4.3b

fauuuuctud

tue aa

)(2

2

0

0

2

2

tutu

Coefficient Form, Steady-State Equation

Page 20: COMSOL Equation Based Modeling 4.3b

diffusion Helmholtz term

source2

2

( )

2

c u k u f

a k

k

Helmholtz equation:

Coefficient Form, Frequency-Response Wave Equation

Wave number

Wave length

fauuuuctud

tue aa

)(2

2

Page 21: COMSOL Equation Based Modeling 4.3b

Demo:lambda=2.5

k=2*pi/lambda

a= - k^2

f=0

u=1 one end

u=0 other end

Page 22: COMSOL Equation Based Modeling 4.3b

Complex Arithmetics

• Can compute:real(w)imag(w)abs(w)arg(w)conj(w)

Page 23: COMSOL Equation Based Modeling 4.3b

General Form – A more compact formulation

• inside domain

• on domain boundary

• For Poisson’s equation, the corresponding general form implies

• All other coefficients are 0

RuRG

T

0

n

uyux .uR

1F

Ftud

tue aa

2

2

Page 24: COMSOL Equation Based Modeling 4.3b

Weak Form• Think of the weak form as a generalization of the principal of virtual

work (for those familiar with that) with virtual displacement du– The test function n ~ du

• Convection-diffusion equation:

• Multiply by test function n and integrate:

• Integrate by parts and use boundary conditions:

• In COMSOL you can type the integrands of this integral expression: Weak Form PDE

Page 25: COMSOL Equation Based Modeling 4.3b

Typing the Weak Form

c*grad(u) ·grad(test(u))=c*grad(u) ·test(grad(u))=

c*(ux*test(ux)+uy*test(uy)+uz*test(uz))

Note: COMSOL convention has the integral in the right-hand side so additional negative

sign needed in the GUI

Page 26: COMSOL Equation Based Modeling 4.3b

2

2 ( )a au ue d c u u u au fu t

accumulation/storage

diffusion

source

Transient Diffusion Equation ~ Heat Equation

sourceheat volume

fkcCda

Page 27: COMSOL Equation Based Modeling 4.3b

“Heat Source” f=1

“Cooling” u=0 at ends

Demo:c=1

da=1

f=0

Transient 0->100 s

Page 28: COMSOL Equation Based Modeling 4.3b

PDEs+ODEs

Page 29: COMSOL Equation Based Modeling 4.3b

2

2 ( )a au ue d c u u u au fu t

Transient Diffusion Equation + ODE

integral volumeof integral e tim

solution of integral volume

dtUw

dVuU

t

V

What if we wish to measure the global accumulation of “heat” over time?

Page 30: COMSOL Equation Based Modeling 4.3b

2

2 ( )a au ue d c u u u au fu t

Transient Diffusion Equation + ODE

0],[ 10

Uwt

Udtdw

dtUw

dVuU

ttt

V

=> This is a Global ODE in the global state variable w

What if we wish to measure the global accumulation of “heat” over time?

Page 31: COMSOL Equation Based Modeling 4.3b
Page 32: COMSOL Equation Based Modeling 4.3b

Demo:Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE: wt-U

Page 33: COMSOL Equation Based Modeling 4.3b
Page 34: COMSOL Equation Based Modeling 4.3b

PDEs + Distributed ODEs

Page 35: COMSOL Equation Based Modeling 4.3b

2

2 ( )a au ue d c u u u au fu t

Transient Diffusion Equation + Distributed ODE

solution of integral timelocal ),,( ),,( dtzyxuzyxPt

What if we get “damage” from local accumulation of “heat”.

Example of real application: bioheating

We want to visualize the P-field to assess local damage.

Let’s assume damage happens where P>20.

Disclaimer: There is no need to use equation-based modeling for bioheating in COMSOL. You are better off using the preset user interface options of the Heat Transfer Module.

Page 36: COMSOL Equation Based Modeling 4.3b

Transient Diffusion Equation + Distributed ODE

solution of integral timelocal ),,( ),,( dtzyxuzyxPt

What if we get “damage” from local accumulation of “heat”.

Example of real application: bioheating

spacein point each at udtdP

2

2 ( )a au ue d c u u u au fu t

Page 37: COMSOL Equation Based Modeling 4.3b

Transient Diffusion Equation + Distributed ODE

solution of integral timelocal udtdP

But this can be seen as a PDE with no spatial derivatives =

= Distributed ODE

Use coefficient form with unknown field P, c = 0, f = u, da=1

Let all other coefficients be zero

Or use Domain ODEs and DAEs interface

2

2 ( )a au ue d c u u u au fu t

Page 38: COMSOL Equation Based Modeling 4.3b

Volume where P>20 and we get damage

Demo:Distributed ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE: wt-U

Page 39: COMSOL Equation Based Modeling 4.3b

Distributed Algebraic Equations

Page 40: COMSOL Equation Based Modeling 4.3b

Example: Ideal gas law

• Assume u=(u,v,w) and p given by Navier-Stokes• Want to solve Convection-Conduction in gas:

• given by ideal gas law:

• Easy - analytical

0u)( TCTk

RTpM

Page 41: COMSOL Equation Based Modeling 4.3b

Example: Non-ideal gas law

• Assume u=(u,v,w) and p given by Navier-Stokes• Want to solve Convection-Conduction in gas:

• given by non-ideal gas law: • Needed for high molecular weight at very high pressures• Difficult – implicit equation• How to proceed?

0)1)((* 2 DCBpA

0u)( TCTk

Page 42: COMSOL Equation Based Modeling 4.3b

Example: Non-ideal gas law

• How to solve:• Third order equation in • Pressure p is function of space• So: this is an algebraic equation at each point in space!

0)1)((* 2 DCBpA

Page 43: COMSOL Equation Based Modeling 4.3b

Distributed Algebraic Equation

• So: this is an algebraic equation at each point in space• See as PDE with no space or time derivatives!

– A*(p+B*u^2)*(1-C*u)-D*u– Here we let: A=1,B=2,C=3, D=4, p=x*y

• How: Put the entire equation in the source (f) term and zero out the rest

• Or, use user interface for Domain ODEs and DAEs

Page 44: COMSOL Equation Based Modeling 4.3b

The solution u corresponding to the equation A*(p+B*u^2)*(1-C*u)-D*u, where p=x*y is spatially varying.Here the equation is solved for each point within the unit square.

Page 45: COMSOL Equation Based Modeling 4.3b

Distributed Algebraic Equation

• What about nonlinear equations with multiple solutions?• Which solution do you get?• For simplicity, consider the equation (u-2)^2-p=0, where p is a constant• This can be entered as earlier with an f=(u-2)^2-p• The solution is easy to get analytically: u=2±sqrt(p)• The solution you get will depend on the Initial Guess given by the PDE Physics

Interface

• If we let p=x*y and let our modeling region be the unit square, then at (x,y)=(0,0) we should get the unique solution u=2 but at (x,y)=(1,1) we get 1 or 3 depending on our starting guess (and also the convergence region of the solver). See next slide.

Page 46: COMSOL Equation Based Modeling 4.3b

Distributed Algebraic Equation

u=3

u=2

u=1u=2

Page 47: COMSOL Equation Based Modeling 4.3b

End of Presentation