equation-based modeling © copyright 2014 comsol. comsol, comsol multiphysics, capture the concept,...

69
Equation-Based Modeling © Copyright 2014 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 www.comsol.com/trademarks

Upload: emma-walters

Post on 24-Dec-2015

387 views

Category:

Documents


18 download

TRANSCRIPT

Page 1: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Equation-Based Modeling

© Copyright 2014 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 www.comsol.com/trademarks

Page 2: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Product Suite – COMSOL 4.4

Page 5: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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 6: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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 7: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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 8: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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 9: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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 10: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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 11: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Coefficient Form

• Coefficient Matching Example: Poisson’s equation

rhu

hgquuuc T )(n

inside domain

on boundary

1 u

0u

inside subdomain

on subdomain boundary

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

fauuuuct

ud

t

ue aa

)(

2

2

Page 12: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Example:

Block: 10x1x1

PDE: default Poisson’s equation with unknown u.

Dirichlet boundary condition everywhere: u=0

Page 13: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Model Wizard: Coefficient Form PDE with one dependent field variable u

Page 14: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Stationary study

Page 15: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Geometry: block 10-by-1-by-1. Units in meters (SI).

Page 16: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Coefficient Form PDE with c=1, a=0, f=1

Page 17: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Mass Coefficients are inactive due to Stationary Study

Page 18: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Dirichlet Boundary Condition

Page 19: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

All boundaries: u=0

Page 20: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Automatic tet mesh

….or swept hex mesh

Page 21: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Control over shape function and element order

Page 22: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Stationary solution

Plot of dependent field variable u on slices

Page 23: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Differentiate u with respect to x: d(u,x)

Page 24: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Recover option for derivatives switched on. Gives smoother derivative field.

Page 25: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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 26: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Second derivative: d(d(u,x),z)

Page 27: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Coefficient Form, Interpretations

mass damping/mass

diffusion

convection

source

convection

absorption

source

fauuuuct

ud

t

ue aa

)(

2

2

Page 28: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

mass damped mass

elastic stress initial/thermal stress

body force (gravitation)

a

ae

d

c

c

u

2

2( )a ae d c a f

t t

u u

u u u u

Coefficient Form, Structural Analysis Wave Equation

density

damping coefficient

stress, u= displacement vector

stiffness, “spring constant”

Page 29: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

accumulation/storage

diffusion

convection

source

convection

absorption

source

Coefficient Form, Transport Diffusion Equation

fauuuuct

ud

t

ue aa

)(

2

2

Page 30: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

fauuuuct

ud

t

ue aa

)(

2

2

0

0

2

2

t

u

t

u

Coefficient Form, Steady-State Equation

Page 31: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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

fauuuuct

ud

t

ue aa

)(

2

2

Page 32: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Example:

lambda=2.5

k=2*pi/lambda

a= - k^2

f=0

u=1 one end

u=0 other end

Page 33: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

User-defined Parameters:

Wavelength: lambda=2.5 m

Wavenumber: k=2p/lambda~2.5 m-1

Page 34: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Coefficient Form PDE

c=1

a=-k^2

f=0

Page 35: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Dirichlet Boundary Condition u=1

Oscillating wave with peak value 1

Spatial frequency is given by wavenumber k

Page 36: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Dirichlet Boundary Condition u=0

Mirror reflection

Page 37: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Solution u: wave with 4 wavelengths over 10 m block length

Page 38: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Text input field allows typing complex valued expressions.

Here: u + superimposed higher frequency wave with wavenumber 5*k

Page 39: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

abs() for absolute value (complex modulus)

Page 40: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Complex Arithmetics

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

Page 41: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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

Ru

RG

T

0

n

uyux .uR

1F

Ft

ud

t

ue aa

2

2

Page 42: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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 43: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

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 44: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Modifying Variables and Equations

• Enable Equation View on the Model Builder Show menu– Once enabled, Equation View stays

enabled for new models

• Variables, weak expressions and constraints can be modified– Modified rows are marked with

warning signs

• Use reset buttons to cancel modifications

Page 45: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

2

2( )a a

u ue d c u u u au fu t

accumulation/storage

diffusion

source

Transient Diffusion Equation ~ Heat Equation

sourceheat volume

f

kc

Cda

Page 46: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

“Heat Source” f=5+3*sin(2*pi*0.1[Hz]*t)

“Cooling” u=0 at ends

Example:

c=1

da=1

f=0

Transient 0->100 s

Page 47: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Time Dependent study

Page 48: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

3 overlapping blocks of length 4,6, and 10 m

COMSOL partitions these into 3 non-overlapping domains.

Field and flux automatically continuous across interior boundaries

Page 49: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Cofficient Form PDE with no volume source: f=0

Page 50: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Cofficient Form PDE with no volume source: f=0

Page 51: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Mass Coefficients are here active due to Time Dependent Study

Page 52: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Superimposed source term: f=5+3*sin(2*pi*0.1[Hz]*t)

Page 53: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

u=0 at the ends

Page 54: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Time Dependent study settings: solve between 0s and 100s, output solution at every 0.1s.

Underlying time stepping algorithm is automatic and controlled by user-defined tolerances.

Page 55: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Solution u at 38.2s

Page 56: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Sample solution inside domain using Domain Point Probe

Page 57: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Probe position controlled by slider control

Page 58: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Value of u vs. time at probe location

Page 59: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Equation Systems

• COMSOL can handle systems of equations in all of– Coefficient Form– General Form– Weak Form

or combinations of the above• Easy setup from Model Wizard

Page 60: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Model Wizard: Coefficient Form PDE with two dependent field variables u1 & u2

Page 61: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

The Coefficient Form PDE for two dependent field variables.

The PDE coefficients and sources are now matrices (or high-order tensor-like entities) and vectors.

Page 62: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

1

1

00

00

0,00,0

0,00,0)

10

01(

10

01

2

1

2

1

2

1

2

1

u

u

u

u

u

u

t

ut

u

da c b a f

Coefficient Form PDE for 2 variables in 2D Space

The default coefficients corresponds to two decoupled Poisson’s equations. Fill out with nonlinear or off-diagonal coefficients, as well as nonlinear source terms for couplings.

Page 63: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

𝜕𝑢1

𝜕𝑡=𝛻2𝑢1+ (α −𝑢1 ) (𝑢1−1 )𝑢1−𝑢2

𝜕𝑢2

𝜕𝑡=ε ( 𝛽𝑢1−𝛾𝑢1−𝛿 )

Examples: Electrical Signals in a Heart, General Form PDE

• Fitzhugh-Nagumo Equations

• Landau-Ginzburg Equations𝜕𝑣1

𝜕𝑡−𝛻2(𝑣¿¿1−𝑐1𝑣2)=𝑣1− (𝑣1−𝑐3𝑣2) (𝑣1

2+𝑣12 )¿

𝜕𝑣2

𝜕𝑡−𝛻2(𝑐1𝑣¿¿1+𝑣2)=𝑣2− (𝑐3𝑣1−𝑣2 ) (𝑣1

2+𝑣12 )¿

Page 64: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Simplified representation of a heart as ½ sphere + ½ ellipsoid

Page 65: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Fitzhugh-Nagumo Equations

Page 66: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Fitzhugh-Nagumo Equations

Solution: u1

Page 67: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Landau-Ginzburg Equations

Page 68: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

Landau-Ginzburg Equations

Solution: v1

Page 69: Equation-Based Modeling © Copyright 2014 COMSOL. COMSOL, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, and LiveLink are either registered trademarks

End of Presentation