82
Equation-Based Modeling COMSOL Conference 2017 Singapore Pratyush Sharma © Copyright 2017 COMSOL. COMSOL, the COMSOL logo, COMSOL Multiphysics, Capture the Concept, COMSOL Desktop, COMSOL Server, 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 .

Equation-Based Modeling - iMath Asia

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Equation-Based Modeling - iMath Asia

Equation-Based Modeling

COMSOL Conference 2017 Singapore

Pratyush Sharma

copy Copyright 2017 COMSOL COMSOL the COMSOL logo COMSOL Multiphysics Capture the Concept COMSOL Desktop COMSOL Server 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 wwwcomsolcomtrademarks

QTTuCt

TC

)(

vFSt

u

2

2

A Look Under the Hood

A Look Under the Hood

Modeling Approaches bull Insert predefined physics

bull Coupling physics (manual or automatic)

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Add or change terms of the equations set in the physics (and multiphysics) nodes

fauu

uuc

t

ud

t

ue aa

)(

2

2

)( tuFdt

du

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Add or change terms of the equations set in the physics (and multiphysics) nodes

bull Insert your own equations with equation forms (and make it automatic with Physics Builder)

The Mathematics Interface

Equation-Based Modelingbull What

ndash ODE amp DAE interfaces PDE interfaces boundary conditions

bull Whyndash Lumped parameter systems continuous systems

bull Howndash Demo population dynamics thermal curing

bull Could I get myself in troublendash Verification amp validation

bull Hands on Coupling PDE with global and distributed ODE

What PDE ODE and DAE stand forbull Partial differential equations (PDE)

ndash Three main interfaces (form)

ndash Need boundary conditions

bull Ordinary differential equations (ODEs)

ndash Global (space indipendent)

ndash Distributed (space dependent)

ndash Distributed but not continuous

ndash (Always) time dependent

bull Algebraic equations

ndash As for ODE global or distributed

ndash Do not contain time (and often not even the space)

fuct

uda

)( tuFdt

du

012 u

Mechanics CFD EMhellip

Electricalcircuits

cinematism

Part I Lumped Parameter Systems

bull Global ODEs

bull Global Algebraic Equation

Lumped Parameter Systems

Contaminant concentration119888(119909 119910 119911 119905)

Contaminant amount 119862(119905)

Population dynamics Population dynamics

Lumped Parameter Systems

bull Balance lawsRate of change of some quantity = amount entering - leaving + production - consumption

1198981198892119906

1198891199052= minus119896119906 minus 119888

119889119906

119889119905

1198981198892119906

1198891199052+ 119896119906 + 119888

119889119906

119889119905= 0

119889119906

119889119905= 1198861119906 1 minus ൗ119906 119896 minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

Example 1 Dynamics Example 2 Prey-predator system

119889119906

119889119905minus 1198861119906 1 minus ൗ119906 119896 + 1198871119906119907 = 0

119889119907

119889119905+ 1198862119907 minus 1198872119906119907 = 0

Global ODEsbull Example Lotka-Volterra equations

119889119906

119889119905= 1198861119906(1 minus Τ119906 119896) minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

119906 0 = 119906119894119899119894 119907 0 = 119907119894119899119894

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 2: Equation-Based Modeling - iMath Asia

QTTuCt

TC

)(

vFSt

u

2

2

A Look Under the Hood

A Look Under the Hood

Modeling Approaches bull Insert predefined physics

bull Coupling physics (manual or automatic)

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Add or change terms of the equations set in the physics (and multiphysics) nodes

fauu

uuc

t

ud

t

ue aa

)(

2

2

)( tuFdt

du

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Add or change terms of the equations set in the physics (and multiphysics) nodes

bull Insert your own equations with equation forms (and make it automatic with Physics Builder)

The Mathematics Interface

Equation-Based Modelingbull What

ndash ODE amp DAE interfaces PDE interfaces boundary conditions

bull Whyndash Lumped parameter systems continuous systems

bull Howndash Demo population dynamics thermal curing

bull Could I get myself in troublendash Verification amp validation

bull Hands on Coupling PDE with global and distributed ODE

What PDE ODE and DAE stand forbull Partial differential equations (PDE)

ndash Three main interfaces (form)

ndash Need boundary conditions

bull Ordinary differential equations (ODEs)

ndash Global (space indipendent)

ndash Distributed (space dependent)

ndash Distributed but not continuous

ndash (Always) time dependent

bull Algebraic equations

ndash As for ODE global or distributed

ndash Do not contain time (and often not even the space)

fuct

uda

)( tuFdt

du

012 u

Mechanics CFD EMhellip

Electricalcircuits

cinematism

Part I Lumped Parameter Systems

bull Global ODEs

bull Global Algebraic Equation

Lumped Parameter Systems

Contaminant concentration119888(119909 119910 119911 119905)

Contaminant amount 119862(119905)

Population dynamics Population dynamics

Lumped Parameter Systems

bull Balance lawsRate of change of some quantity = amount entering - leaving + production - consumption

1198981198892119906

1198891199052= minus119896119906 minus 119888

119889119906

119889119905

1198981198892119906

1198891199052+ 119896119906 + 119888

119889119906

119889119905= 0

119889119906

119889119905= 1198861119906 1 minus ൗ119906 119896 minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

Example 1 Dynamics Example 2 Prey-predator system

119889119906

119889119905minus 1198861119906 1 minus ൗ119906 119896 + 1198871119906119907 = 0

119889119907

119889119905+ 1198862119907 minus 1198872119906119907 = 0

Global ODEsbull Example Lotka-Volterra equations

119889119906

119889119905= 1198861119906(1 minus Τ119906 119896) minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

119906 0 = 119906119894119899119894 119907 0 = 119907119894119899119894

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 3: Equation-Based Modeling - iMath Asia

A Look Under the Hood

A Look Under the Hood

Modeling Approaches bull Insert predefined physics

bull Coupling physics (manual or automatic)

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Add or change terms of the equations set in the physics (and multiphysics) nodes

fauu

uuc

t

ud

t

ue aa

)(

2

2

)( tuFdt

du

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Add or change terms of the equations set in the physics (and multiphysics) nodes

bull Insert your own equations with equation forms (and make it automatic with Physics Builder)

The Mathematics Interface

Equation-Based Modelingbull What

ndash ODE amp DAE interfaces PDE interfaces boundary conditions

bull Whyndash Lumped parameter systems continuous systems

bull Howndash Demo population dynamics thermal curing

bull Could I get myself in troublendash Verification amp validation

bull Hands on Coupling PDE with global and distributed ODE

What PDE ODE and DAE stand forbull Partial differential equations (PDE)

ndash Three main interfaces (form)

ndash Need boundary conditions

bull Ordinary differential equations (ODEs)

ndash Global (space indipendent)

ndash Distributed (space dependent)

ndash Distributed but not continuous

ndash (Always) time dependent

bull Algebraic equations

ndash As for ODE global or distributed

ndash Do not contain time (and often not even the space)

fuct

uda

)( tuFdt

du

012 u

Mechanics CFD EMhellip

Electricalcircuits

cinematism

Part I Lumped Parameter Systems

bull Global ODEs

bull Global Algebraic Equation

Lumped Parameter Systems

Contaminant concentration119888(119909 119910 119911 119905)

Contaminant amount 119862(119905)

Population dynamics Population dynamics

Lumped Parameter Systems

bull Balance lawsRate of change of some quantity = amount entering - leaving + production - consumption

1198981198892119906

1198891199052= minus119896119906 minus 119888

119889119906

119889119905

1198981198892119906

1198891199052+ 119896119906 + 119888

119889119906

119889119905= 0

119889119906

119889119905= 1198861119906 1 minus ൗ119906 119896 minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

Example 1 Dynamics Example 2 Prey-predator system

119889119906

119889119905minus 1198861119906 1 minus ൗ119906 119896 + 1198871119906119907 = 0

119889119907

119889119905+ 1198862119907 minus 1198872119906119907 = 0

Global ODEsbull Example Lotka-Volterra equations

119889119906

119889119905= 1198861119906(1 minus Τ119906 119896) minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

119906 0 = 119906119894119899119894 119907 0 = 119907119894119899119894

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 4: Equation-Based Modeling - iMath Asia

A Look Under the Hood

Modeling Approaches bull Insert predefined physics

bull Coupling physics (manual or automatic)

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Add or change terms of the equations set in the physics (and multiphysics) nodes

fauu

uuc

t

ud

t

ue aa

)(

2

2

)( tuFdt

du

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Add or change terms of the equations set in the physics (and multiphysics) nodes

bull Insert your own equations with equation forms (and make it automatic with Physics Builder)

The Mathematics Interface

Equation-Based Modelingbull What

ndash ODE amp DAE interfaces PDE interfaces boundary conditions

bull Whyndash Lumped parameter systems continuous systems

bull Howndash Demo population dynamics thermal curing

bull Could I get myself in troublendash Verification amp validation

bull Hands on Coupling PDE with global and distributed ODE

What PDE ODE and DAE stand forbull Partial differential equations (PDE)

ndash Three main interfaces (form)

ndash Need boundary conditions

bull Ordinary differential equations (ODEs)

ndash Global (space indipendent)

ndash Distributed (space dependent)

ndash Distributed but not continuous

ndash (Always) time dependent

bull Algebraic equations

ndash As for ODE global or distributed

ndash Do not contain time (and often not even the space)

fuct

uda

)( tuFdt

du

012 u

Mechanics CFD EMhellip

Electricalcircuits

cinematism

Part I Lumped Parameter Systems

bull Global ODEs

bull Global Algebraic Equation

Lumped Parameter Systems

Contaminant concentration119888(119909 119910 119911 119905)

Contaminant amount 119862(119905)

Population dynamics Population dynamics

Lumped Parameter Systems

bull Balance lawsRate of change of some quantity = amount entering - leaving + production - consumption

1198981198892119906

1198891199052= minus119896119906 minus 119888

119889119906

119889119905

1198981198892119906

1198891199052+ 119896119906 + 119888

119889119906

119889119905= 0

119889119906

119889119905= 1198861119906 1 minus ൗ119906 119896 minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

Example 1 Dynamics Example 2 Prey-predator system

119889119906

119889119905minus 1198861119906 1 minus ൗ119906 119896 + 1198871119906119907 = 0

119889119907

119889119905+ 1198862119907 minus 1198872119906119907 = 0

Global ODEsbull Example Lotka-Volterra equations

119889119906

119889119905= 1198861119906(1 minus Τ119906 119896) minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

119906 0 = 119906119894119899119894 119907 0 = 119907119894119899119894

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 5: Equation-Based Modeling - iMath Asia

Modeling Approaches bull Insert predefined physics

bull Coupling physics (manual or automatic)

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Add or change terms of the equations set in the physics (and multiphysics) nodes

fauu

uuc

t

ud

t

ue aa

)(

2

2

)( tuFdt

du

bull Insert predefined physicsbull Coupling physics (manual or automatic)

bull Enter user defined functions All expressions can depend on all the variables introduced (analytical interpolation from file )

bull Add or change terms of the equations set in the physics (and multiphysics) nodes

bull Insert your own equations with equation forms (and make it automatic with Physics Builder)

The Mathematics Interface

Equation-Based Modelingbull What

ndash ODE amp DAE interfaces PDE interfaces boundary conditions

bull Whyndash Lumped parameter systems continuous systems

bull Howndash Demo population dynamics thermal curing

bull Could I get myself in troublendash Verification amp validation

bull Hands on Coupling PDE with global and distributed ODE

What PDE ODE and DAE stand forbull Partial differential equations (PDE)

ndash Three main interfaces (form)

ndash Need boundary conditions

bull Ordinary differential equations (ODEs)

ndash Global (space indipendent)

ndash Distributed (space dependent)

ndash Distributed but not continuous

ndash (Always) time dependent

bull Algebraic equations

ndash As for ODE global or distributed

ndash Do not contain time (and often not even the space)

fuct

uda

)( tuFdt

du

012 u

Mechanics CFD EMhellip

Electricalcircuits

cinematism

Part I Lumped Parameter Systems

bull Global ODEs

bull Global Algebraic Equation

Lumped Parameter Systems

Contaminant concentration119888(119909 119910 119911 119905)

Contaminant amount 119862(119905)

Population dynamics Population dynamics

Lumped Parameter Systems

bull Balance lawsRate of change of some quantity = amount entering - leaving + production - consumption

1198981198892119906

1198891199052= minus119896119906 minus 119888

119889119906

119889119905

1198981198892119906

1198891199052+ 119896119906 + 119888

119889119906

119889119905= 0

119889119906

119889119905= 1198861119906 1 minus ൗ119906 119896 minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

Example 1 Dynamics Example 2 Prey-predator system

119889119906

119889119905minus 1198861119906 1 minus ൗ119906 119896 + 1198871119906119907 = 0

119889119907

119889119905+ 1198862119907 minus 1198872119906119907 = 0

Global ODEsbull Example Lotka-Volterra equations

119889119906

119889119905= 1198861119906(1 minus Τ119906 119896) minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

119906 0 = 119906119894119899119894 119907 0 = 119907119894119899119894

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 6: Equation-Based Modeling - iMath Asia

The Mathematics Interface

Equation-Based Modelingbull What

ndash ODE amp DAE interfaces PDE interfaces boundary conditions

bull Whyndash Lumped parameter systems continuous systems

bull Howndash Demo population dynamics thermal curing

bull Could I get myself in troublendash Verification amp validation

bull Hands on Coupling PDE with global and distributed ODE

What PDE ODE and DAE stand forbull Partial differential equations (PDE)

ndash Three main interfaces (form)

ndash Need boundary conditions

bull Ordinary differential equations (ODEs)

ndash Global (space indipendent)

ndash Distributed (space dependent)

ndash Distributed but not continuous

ndash (Always) time dependent

bull Algebraic equations

ndash As for ODE global or distributed

ndash Do not contain time (and often not even the space)

fuct

uda

)( tuFdt

du

012 u

Mechanics CFD EMhellip

Electricalcircuits

cinematism

Part I Lumped Parameter Systems

bull Global ODEs

bull Global Algebraic Equation

Lumped Parameter Systems

Contaminant concentration119888(119909 119910 119911 119905)

Contaminant amount 119862(119905)

Population dynamics Population dynamics

Lumped Parameter Systems

bull Balance lawsRate of change of some quantity = amount entering - leaving + production - consumption

1198981198892119906

1198891199052= minus119896119906 minus 119888

119889119906

119889119905

1198981198892119906

1198891199052+ 119896119906 + 119888

119889119906

119889119905= 0

119889119906

119889119905= 1198861119906 1 minus ൗ119906 119896 minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

Example 1 Dynamics Example 2 Prey-predator system

119889119906

119889119905minus 1198861119906 1 minus ൗ119906 119896 + 1198871119906119907 = 0

119889119907

119889119905+ 1198862119907 minus 1198872119906119907 = 0

Global ODEsbull Example Lotka-Volterra equations

119889119906

119889119905= 1198861119906(1 minus Τ119906 119896) minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

119906 0 = 119906119894119899119894 119907 0 = 119907119894119899119894

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 7: Equation-Based Modeling - iMath Asia

Equation-Based Modelingbull What

ndash ODE amp DAE interfaces PDE interfaces boundary conditions

bull Whyndash Lumped parameter systems continuous systems

bull Howndash Demo population dynamics thermal curing

bull Could I get myself in troublendash Verification amp validation

bull Hands on Coupling PDE with global and distributed ODE

What PDE ODE and DAE stand forbull Partial differential equations (PDE)

ndash Three main interfaces (form)

ndash Need boundary conditions

bull Ordinary differential equations (ODEs)

ndash Global (space indipendent)

ndash Distributed (space dependent)

ndash Distributed but not continuous

ndash (Always) time dependent

bull Algebraic equations

ndash As for ODE global or distributed

ndash Do not contain time (and often not even the space)

fuct

uda

)( tuFdt

du

012 u

Mechanics CFD EMhellip

Electricalcircuits

cinematism

Part I Lumped Parameter Systems

bull Global ODEs

bull Global Algebraic Equation

Lumped Parameter Systems

Contaminant concentration119888(119909 119910 119911 119905)

Contaminant amount 119862(119905)

Population dynamics Population dynamics

Lumped Parameter Systems

bull Balance lawsRate of change of some quantity = amount entering - leaving + production - consumption

1198981198892119906

1198891199052= minus119896119906 minus 119888

119889119906

119889119905

1198981198892119906

1198891199052+ 119896119906 + 119888

119889119906

119889119905= 0

119889119906

119889119905= 1198861119906 1 minus ൗ119906 119896 minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

Example 1 Dynamics Example 2 Prey-predator system

119889119906

119889119905minus 1198861119906 1 minus ൗ119906 119896 + 1198871119906119907 = 0

119889119907

119889119905+ 1198862119907 minus 1198872119906119907 = 0

Global ODEsbull Example Lotka-Volterra equations

119889119906

119889119905= 1198861119906(1 minus Τ119906 119896) minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

119906 0 = 119906119894119899119894 119907 0 = 119907119894119899119894

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 8: Equation-Based Modeling - iMath Asia

What PDE ODE and DAE stand forbull Partial differential equations (PDE)

ndash Three main interfaces (form)

ndash Need boundary conditions

bull Ordinary differential equations (ODEs)

ndash Global (space indipendent)

ndash Distributed (space dependent)

ndash Distributed but not continuous

ndash (Always) time dependent

bull Algebraic equations

ndash As for ODE global or distributed

ndash Do not contain time (and often not even the space)

fuct

uda

)( tuFdt

du

012 u

Mechanics CFD EMhellip

Electricalcircuits

cinematism

Part I Lumped Parameter Systems

bull Global ODEs

bull Global Algebraic Equation

Lumped Parameter Systems

Contaminant concentration119888(119909 119910 119911 119905)

Contaminant amount 119862(119905)

Population dynamics Population dynamics

Lumped Parameter Systems

bull Balance lawsRate of change of some quantity = amount entering - leaving + production - consumption

1198981198892119906

1198891199052= minus119896119906 minus 119888

119889119906

119889119905

1198981198892119906

1198891199052+ 119896119906 + 119888

119889119906

119889119905= 0

119889119906

119889119905= 1198861119906 1 minus ൗ119906 119896 minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

Example 1 Dynamics Example 2 Prey-predator system

119889119906

119889119905minus 1198861119906 1 minus ൗ119906 119896 + 1198871119906119907 = 0

119889119907

119889119905+ 1198862119907 minus 1198872119906119907 = 0

Global ODEsbull Example Lotka-Volterra equations

119889119906

119889119905= 1198861119906(1 minus Τ119906 119896) minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

119906 0 = 119906119894119899119894 119907 0 = 119907119894119899119894

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 9: Equation-Based Modeling - iMath Asia

Part I Lumped Parameter Systems

bull Global ODEs

bull Global Algebraic Equation

Lumped Parameter Systems

Contaminant concentration119888(119909 119910 119911 119905)

Contaminant amount 119862(119905)

Population dynamics Population dynamics

Lumped Parameter Systems

bull Balance lawsRate of change of some quantity = amount entering - leaving + production - consumption

1198981198892119906

1198891199052= minus119896119906 minus 119888

119889119906

119889119905

1198981198892119906

1198891199052+ 119896119906 + 119888

119889119906

119889119905= 0

119889119906

119889119905= 1198861119906 1 minus ൗ119906 119896 minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

Example 1 Dynamics Example 2 Prey-predator system

119889119906

119889119905minus 1198861119906 1 minus ൗ119906 119896 + 1198871119906119907 = 0

119889119907

119889119905+ 1198862119907 minus 1198872119906119907 = 0

Global ODEsbull Example Lotka-Volterra equations

119889119906

119889119905= 1198861119906(1 minus Τ119906 119896) minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

119906 0 = 119906119894119899119894 119907 0 = 119907119894119899119894

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 10: Equation-Based Modeling - iMath Asia

Lumped Parameter Systems

Contaminant concentration119888(119909 119910 119911 119905)

Contaminant amount 119862(119905)

Population dynamics Population dynamics

Lumped Parameter Systems

bull Balance lawsRate of change of some quantity = amount entering - leaving + production - consumption

1198981198892119906

1198891199052= minus119896119906 minus 119888

119889119906

119889119905

1198981198892119906

1198891199052+ 119896119906 + 119888

119889119906

119889119905= 0

119889119906

119889119905= 1198861119906 1 minus ൗ119906 119896 minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

Example 1 Dynamics Example 2 Prey-predator system

119889119906

119889119905minus 1198861119906 1 minus ൗ119906 119896 + 1198871119906119907 = 0

119889119907

119889119905+ 1198862119907 minus 1198872119906119907 = 0

Global ODEsbull Example Lotka-Volterra equations

119889119906

119889119905= 1198861119906(1 minus Τ119906 119896) minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

119906 0 = 119906119894119899119894 119907 0 = 119907119894119899119894

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 11: Equation-Based Modeling - iMath Asia

Lumped Parameter Systems

bull Balance lawsRate of change of some quantity = amount entering - leaving + production - consumption

1198981198892119906

1198891199052= minus119896119906 minus 119888

119889119906

119889119905

1198981198892119906

1198891199052+ 119896119906 + 119888

119889119906

119889119905= 0

119889119906

119889119905= 1198861119906 1 minus ൗ119906 119896 minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

Example 1 Dynamics Example 2 Prey-predator system

119889119906

119889119905minus 1198861119906 1 minus ൗ119906 119896 + 1198871119906119907 = 0

119889119907

119889119905+ 1198862119907 minus 1198872119906119907 = 0

Global ODEsbull Example Lotka-Volterra equations

119889119906

119889119905= 1198861119906(1 minus Τ119906 119896) minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

119906 0 = 119906119894119899119894 119907 0 = 119907119894119899119894

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 12: Equation-Based Modeling - iMath Asia

Global ODEsbull Example Lotka-Volterra equations

119889119906

119889119905= 1198861119906(1 minus Τ119906 119896) minus 1198871119906119907

119889119907

119889119905= minus1198862119907 + 1198872119906119907

119906 0 = 119906119894119899119894 119907 0 = 119907119894119899119894

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 13: Equation-Based Modeling - iMath Asia

Global Algebraic Equationsbull Same template as Global ODEs

bull What are the initial values for

ndash Stationary solvers

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 14: Equation-Based Modeling - iMath Asia

Physics + Global Algebraic Equationsbull You can add extra degrees of freedom to a physics interface

httpswwwcomsolcomblogsmodeling-hydrostatic-pressure-fluid-deformable-container

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 15: Equation-Based Modeling - iMath Asia

bull Domain ODEs and DAEsbull Boundary ODEs and DAEsbull Edge ODEs and DAEsbull Point ODEs and DAEs

Part II Continuous SystemsWithout Spatial Interaction

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 16: Equation-Based Modeling - iMath Asia

Domain ODEs

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 17: Equation-Based Modeling - iMath Asia

Domain ODEsbull Problem parameters are spatially variable

ndash Initial conditions 119906 119909 0 = 119906119894119899119894(119909)hellip

ndash Carrying capacity is spatially variable 119896 = 119896(119909)

ndash Prey-predator interactions have different outcomes based on location bull 1198871 = 1198871 119909 1198872 = 1198872(119909)

ndash Climate effect 1198861 = 1198861 (119909 119879)

bull Every point evolves independent of neighborsndash No spatial derivatives in the equation

ndash No boundary conditions needed

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 18: Equation-Based Modeling - iMath Asia

Domain ODEs in Physicsbull Material evolution

120597120572

120597119905= 119860119890(minus ൗ119864119886

119877119879)(1 minus 120572)119899

120597120572

120597119905= 119860119890

(minus ൗ119864119886

119877119879(119909))(1 minus 120572)119899

bull Reaction kineticsndash Built-in if you use the Chemical Reaction Engineering Module

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 19: Equation-Based Modeling - iMath Asia

ODE or 1D PDE1198892119906

1198891199052minus 119886119906 + 119892 119905 = 0

1198892119906

1198891199092minus 119886119906 + 119892 119909 = 0

Spatial derivative use PDE interfaces

IVP = ODE

BVP = PDE

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 20: Equation-Based Modeling - iMath Asia

Domain Algebraic Equations

bull Solve 1199063 = 119901(119909 119905 ) for 119906

bull Interface is the same as Domain ODE

httpswwwcomsolcomblogssolving-algebraic-field-equations

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 21: Equation-Based Modeling - iMath Asia

Example IdealNon-ideal gas lawbull Assume u=(uvw) and p given by Navier-Stokes

bull Want to solve Convection-Conduction in gas

0u)( TCTk

bull Ideal gas 120588 given by

bull Easy - analytical

bull non-ideal gas law (needed for high molecular weight at very high pressures) 120588 solution of

bull Difficult ndash implicit equation

bull How to proceed

0)1)(( 2 DCBpA

RT

pM

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 22: Equation-Based Modeling - iMath Asia

Example Non-ideal gas lawbull How to solve

bull Third order equation in

bull Pressure p is function of space

bull So this is an algebraic equation at each point in space Solution

0)1)(( 2 DCBpA

httpwwwcomsolcomblogssolving-algebraic-field-equations

DCBpAfde aa )1)((0 2

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 23: Equation-Based Modeling - iMath Asia

Distributed Algebraic Equationbull What about non-linear equations with multiple solutionsbull Which solution do you getbull For simplicity consider the equation (u-2)^2-p=0 where p is a constantbull The solution you get will depend on the Initial Guess given by the PDE

Physics Interface

bull If we let p=xy and let our modeling region be the unit square then at (xy)=(00) we should get the unique solution u=2 but at (xy)=(11) we get 1 or 3 depending on our starting guess See next slide

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 24: Equation-Based Modeling - iMath Asia

Distributed Algebraic Equationu=3

u=2

u=1

u=2

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 25: Equation-Based Modeling - iMath Asia

u=3

u=2

u=1

u=2

Distributed Algebraic Equation

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 26: Equation-Based Modeling - iMath Asia

Part III Continuous Systemswith Spatial Interaction

Partial Differential Equations

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 27: Equation-Based Modeling - iMath Asia

Prey-Predator System with Migrationbull PDEs

bull What if the second species does not migrate

ndash Domain ODE or PDE with 1198882 = 0

bull Can we have a convective term

bull What happens for negative 1198881 or 1198882

uvbvavct

v

uvbkuuauct

u

222

111

)(

)1()(

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 28: Equation-Based Modeling - iMath Asia

Balance Laws Integral Formulationbull Balance laws for a continuous system

Rate of change of some quantity = amount entering or leaving through the boundary + production or consumption inside

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 29: Equation-Based Modeling - iMath Asia

Balance Laws Differential Equations

119889

119889119905න119881

ϕ119889119881 = minusන119878

ԦΓ119899119889119878 + න119881

119891119889119881

V

S

119899Γ

න119881

120597ϕ

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

Divergence theorem

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 30: Equation-Based Modeling - iMath Asia

Balance Laws Differential Equations

න119881

[120597ϕ

120597119905+ 119889119894119907 ԦΓ minus 119891]119889119881 = 0

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

Localization argument

V

S

119899Γ

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 31: Equation-Based Modeling - iMath Asia

General Form PDE

Usually 120601 = 119890120597119906

120597119905+ 119889119906

120597ϕ

120597119905+ 119889119894119907 ԦΓ = 119891

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

HT 120601 = 120588119888119901119879 120588119888119901120597119879

120597119905+ 119889119894119907 ԦΓ = 119891

Template

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 32: Equation-Based Modeling - iMath Asia

Constitutive Assumptions

bull Take the usual form for the flux

ԦΓ = minus119888120571119906 minus 120572119906 + 120574

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

You specify 119888 120572 120574

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 33: Equation-Based Modeling - iMath Asia

bull Specify units for independent variable and source

Coefficient Form PDE Template

fauuuuct

ud

t

ue aa

)(

2

2

Mass Damping or mass

Conservative flux source

Diffusion

Conservative flux convection

Convection

Absorption

Source

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 34: Equation-Based Modeling - iMath Asia

Coefficient Form PDEAcoustics Chemistry Black-Scholes Fischerrsquos Ecologic

Model

119958 Pressure Concentration Cost of option Population

119838119834 11205881198882

119941119834 1 1 1

119940 1120588 Diffusion coefminus1

212059021199092

Dispersal rate

120632 119902119889120588

120631 Velocity 119903119909 minus 1205902119909

119938 minus119903 119903( ൗ119906 119870 minus 1)

119943 119876119898 Reaction rate

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 35: Equation-Based Modeling - iMath Asia

Helmholtz Equation Coefficient Form PDE

fauuuuct

ud

t

ue aa

)(

2

2

gukuc 2)(

Coefficient matching

119886 = minus1205812

119891 = 119892119886 = 0119891 = 119892 + 1205812119906

Option 1 Option 2

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 36: Equation-Based Modeling - iMath Asia

Helmholtz Equation General Form PDE

gukuc 2)(

Match terms

1198901205972119906

1205971199052+ 119889

120597119906

120597119905+ 119889119894119907 ԦΓ = 119891

119891 = 119892 + 1198962119906

ԦΓ = minus119888120571119906

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 37: Equation-Based Modeling - iMath Asia

fauuuuct

ud

t

ue aa

)(

2

2

02

12

222

ru

x

urx

x

ux

t

u

httpswwwcomsolcommodelthe-black-scholes-equation-82

0][)2

1( 222

ru

x

uxrx

x

ux

xt

u

raxrx

xcda

2

11

2

22

Coefficient matching

x

uxrxf

ra

xcda

)(

0

2

11

2

22

Alternative

Black-Scholes Equation Coefficient Form PDE

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 38: Equation-Based Modeling - iMath Asia

Weak Form PDE

bull NO TEMPLATE

bull Extreme flexibility

119862120597119906

120597119905+ 120571 ∙ minus120581120571119906 minus 119876 = 0

න 119862120597119906

120597119905119908 + 120581120571119908 ∙ 120571119906 119889Ω = න119876119908119889Ω +න119908119902119899119889119878 forall119908

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 39: Equation-Based Modeling - iMath Asia

PDE in Weak formulationbull Weak = Integral based on variational formulation (conservation law)

bull Most of COMSOL (and other toolsrsquo) physics use such a formulation since most versatile

bull It is the base of finite element (but also used within other schemes)

bull Understanding how it works is the way to master what COMSOL does under the hood

F Γ

dVFdV

Γ

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 40: Equation-Based Modeling - iMath Asia

Weak Form Stationarybull General form 120571 ∙ Γ = 119865bull Multiply by test function v

and integrate Ω 119907120571 ∙ Γ119889119860 = Ω 119907119865119889119860

bull Perform integration by parts

on left-hand side 120597Ω 119907Γ ∙ 119899 119889119904 minus Ω 120571119907 ∙ Γ 119889119860 = Ω 119907119865 119889119860

bull Rearrange 0 = Ω 120571119907 ∙ Γ + 119907119865 119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Remember

ndash For Poissonrsquos eq Γ = [119906119909 119906119910] F = 1 R = u - 0(u constrained to 0 on boundaries)

ndash Subdomain integral above is entered in the ldquoweakrdquo field -test(ux)ux - test(uy)uy + test(u)F

ndash On the boundary set constraint expression u

120571 ∙ Γ = 119865

Ω

120597Ω

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 41: Equation-Based Modeling - iMath Asia

Weak Form Time Dependentbull Same development as stationary but start from

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

bull And arrive at0 = Ω 120571119907 ∙ Γ + 119907119865 minus 119889119886119907

120597119906

120597119905119889119860 + Ω minus119907Γ ∙ 119899 119889119904

bull Subdomain integral in the weak field-test(ux)ux - test(uy)uy + test(u)F ndash datest(u) ut

119889119886120597119906

120597119905+ 120571 ∙ Γ = 119865

Ω

120597Ω

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 42: Equation-Based Modeling - iMath Asia

Using the Weak Form PDE Interface

httpswwwcomsolcomblogsimplementing-the-weak-form-in-comsol-multiphysics httpswwwcomsolcoinblogsbrief-

introduction-weak-form

httpswwwcomsolcomblogsstrength-weak-form

httpswwwcomsolcoinblogsdiscretizing-the-weak-form-equations

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 43: Equation-Based Modeling - iMath Asia

DerivativesSolution field u

Spatial 1st derivatives ux uy uz

Spatial 2nd derivatives uxx uxy hellip uyz uzz

Time derivatives ut utt

Mixed derivatives uxt uytt

Derivatives tangent to surfaces uTx uTy uTz

Derivatives of quantities other than the primary dependent variable

d(qt)d(qx)

More ldquoDifferentiation Operatorsrdquo in the COMSOL Multiphysics Reference Manual

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 44: Equation-Based Modeling - iMath Asia

Integrated Demo Thermal Curing Physics

Heated mold

Thermoset in the cavity

T α

x

Image by Joe Haupt mdash Own work Licensed under CC BY-SA 20 via Wikimedia Commons

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 45: Equation-Based Modeling - iMath Asia

Thermal Curing Mathematical Model

bull Initial conditions room temperature zero curing

bull Boundary conditions heat flux of 10 ΤkW m2

bull Step 1 Pick appropriate Mathematics interfaces

ndash PDE + Domain ODE

bull Step 2 Fit the equations into the templates

tHT

t

TC rp

)(

nRTEaAet

)1()(

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 46: Equation-Based Modeling - iMath Asia

tHT

t

TC rp

)(

nRTEaAet

)1()(

ft

dt

e aa

2

2

Domain ODE

nRTE

aaAefd )1(1

)(

Thermal Curing Choosing the Interface

fauuuuct

ud

t

ue aa

)(

2

2

tHfcCd rpa

PDE

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 47: Equation-Based Modeling - iMath Asia

Thermal Curing Heat Transfer Interface

httpswwwcomsolcomblogsmodeling-the-thermal-curing-process

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 48: Equation-Based Modeling - iMath Asia

Part IV Boundaries and Interfaces

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 49: Equation-Based Modeling - iMath Asia

The World Versus Your World

Image by Strebe mdash Own work Licensed under CC BY-SA 30 via Wikimedia Commons

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 50: Equation-Based Modeling - iMath Asia

Jump and Boundary Conditions

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

න119881

120597ϕ

120597119905119889119881 = minusන

119881

119889119894119907( ԦΓ) 119889119881 + න119881

119891119889119881

Canrsquot do this

1 Stay with the integral equation2 Focus

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 51: Equation-Based Modeling - iMath Asia

Jump and Boundary Conditions

S

1198991 rarr 119899 1198992 rarr minus119899

119899 1198991

1198992 S

න119881

120597120601

120597119905119889119881 = minusන

119878

ԦΓ119899119889119878 + න119881

119891119889119881

119881 rarr 0 119878 ne 0

න119878

ԦΓ119899119889119878 = 0

න119878

( ԦΓ1minusԦΓ2)119899119889119878 = 0

ԦΓ ∙ 119899=0

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 52: Equation-Based Modeling - iMath Asia

Jump and Boundary Conditions

bull Think about what is outside

bull We have NOT considered surface production here

119899

S

119894 119900minusԦΓ119894 ∙ 119899=minusԦΓ119900 ∙ 119899

Inward flux

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 53: Equation-Based Modeling - iMath Asia

Boundary Conditions 1 Flux

bull Example Heat Transfer in Solids

bull Natural (Neumann) boundary conditions

119899120595

minusԦΓ119894 ∙ 119899 = 120595

Inward flux

minus(minus120581120571119879) ∙ 119899 = 1199020

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 54: Equation-Based Modeling - iMath Asia

Boundary Conditions Mixedbull A constitutive assumption about the outside

bull Example Heat Transfer in Solids

bull Mixed (Robin) boundary conditions

minusԦΓ119894 ∙ 119899 = 120595

120595 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

minus(minus120581120571119879) ∙ 119899 = ℎ(119879119890119909119905 minus 119879)

119899120595119906119890119909119905

119906

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 55: Equation-Based Modeling - iMath Asia

Boundary Conditions Extremes

bull Temperature voltage displacement

119899120595119906119890119909119905

119906

minusԦΓ119894 ∙ 119899 = 120595

minus(minus120581120571119906) ∙ 119899 =120581119900119871119890119909119905

(119906119890119909119905 minus 119906)

(120581

120581119900119871119890119909119905120571119906) ∙ 119899 = (119906119890119909119905 minus 119906)

120581119900 ≫ 120581 rArr 119906 = 119906119890119909119905

bull Dirichlet boundary conditions

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 56: Equation-Based Modeling - iMath Asia

More on Boundary Conditions

bull Built-in spring foundation bull DIY boundary condition119891 = 119891(119906 ሶ119906)

httpswwwcomsolcomblogshow-to-make-boundary-conditions-conditional-in-your-simulationhttpswwwcomsolcomblogsmodeling-natural-and-forced-convection-in-comsol-multiphysics

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 57: Equation-Based Modeling - iMath Asia

Part V Surface Phenomena

bull Boundary PDEs

bull Edge PDEs

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 58: Equation-Based Modeling - iMath Asia

Lower Dimension PDE Interfaces

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 59: Equation-Based Modeling - iMath Asia

Built-In Interfaces for Lower Dimensional Physics

bull Fluid Flow

ndash Pipe Flow (pfl)

ndash Water Hammer (whtd)

ndash Thin-Film Flow Shell (tffs)

bull Heat Transfer

ndash Heat Transfer in Pipes (htp)

ndash Heat Transfer in Thin Shell (htsh)

ndash Heat Transfer in Thin Films (htsh)

ndash Heat Transfer in Fractures (htsh)

bull Structural Mechanics

ndash Shell (shell)

ndash Membrane (mbrn)

ndash Beam (beam)

ndash Truss (truss)

bull ACDC

ndash Electric Currents Shell (ecs)

bull RF

ndash Transmission Line (tl)

bull Chemical and Reaction Engineering

ndash Surface Reactions (sr)

bull Electrochemistry

ndash Electrode Shell (els)

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 60: Equation-Based Modeling - iMath Asia

Part VI Miscellaneous

bull PDEs in axisymmetric componentsbull Integrodifferential equationsbull Nonlocal interactionsbull Verification and validationbull Stabilization

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 61: Equation-Based Modeling - iMath Asia

PDEs in Axisymmetric Componentsbull In the PDE interfaces differential operators do not have tensorial meanings

bull The source term is your friend

120571 ∙ Γ = 119876

1

119903

120597(119903Γ119903)

120597119903+120597Γ120601

120597120601+120597Γ119911120597119911

= 119876

Axisymmetry

120597Γ119903120597119903

+120597Γ119911120597119911

+Γ119903119903= 119876 120597Γ119903

120597119903+120597Γ119911120597119911

= 119891

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 62: Equation-Based Modeling - iMath Asia

bull Guidelines for Equation-Based Modeling in Axisymmetric Components

ndash httpswwwcomsolcomblogsguidelines-for-equation-based-modeling-in-axisymmetric-components

COMSOL Blog Post

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 63: Equation-Based Modeling - iMath Asia

Integrodifferential Equations

119868 = න

0

119871

119888119860119889119909 Integration Coupling Operator

119868(119904) = න

0

119904

119888119860119889119909

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 64: Equation-Based Modeling - iMath Asia

Variable Limits of Integration

119868(119904) = 0119904119888119860119889119909=0

119871119896(119904 119909)119888119860119889119909

Integration Coupling operator

119868(119904) = 0119904119888119860119889119909=0

119871119896(119889119890119904119905(119909) 119909)119888119860119889119909

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 65: Equation-Based Modeling - iMath Asia

Solving Integrodifferential Equations

120588119862119901120597119879

120597119909+

120597

120597119909minus120581

120597119879

120597119909= 1198861198794 minus 119887න

0

119871

119870 119909 119904 119879(119904)4119889119904

Source 1 aT^4

Source 2 -bintop1(K(dest(x)x)T^4)

httpswwwcomsolcomblogsintegrals-with-moving-limits-and-solving-integro-differential-equations

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 66: Equation-Based Modeling - iMath Asia

Nonlocal Interactions Component Coupling Operators

Purpose bull Pass data from one part of a component to

anotherbull Pass data between different components

119902119889 119909119889 = 119891 119902119904 119909119904119879 119909119889 rarr 119909119904

Usage bull Define operator in the source

componententitybull Use in the destination componententity

httpswwwcomsolcomblogspart-2-mapping-variables-with-general-extrusion-operators

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 67: Equation-Based Modeling - iMath Asia

Verification amp Validationbull Exact solutionsbull Benchmarksbull Analogous modules in COMSOL Multiphysicsreg

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 68: Equation-Based Modeling - iMath Asia

VerificationMethod of manufactured solutions1 Assume a solution2 Plug in PDE to get source term

3 Find initial amp boundary conditions4 Compute with IC BC and source term 5 Compare assumed and computed solution

fauuuc )(

httpswwwcomsolcomblogsverify-simulations-with-the-method-of-manufactured-solutions

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 69: Equation-Based Modeling - iMath Asia

Stabilizationbull Convection dominated

transport problems are numerically unstable

bull Sophisticated techniques implemented in physics interfaces

bull A simple stabilization technique for convective transport problems

fubut

fucubut )(

httpswwwcomsolcomblogsunderstanding-stabilization-methods

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 70: Equation-Based Modeling - iMath Asia

Hands-on 1

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 71: Equation-Based Modeling - iMath Asia

3D time dependentUse General form PDE

Computing integrals over time and space(Adding ODE global or distributed)

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 72: Equation-Based Modeling - iMath Asia

General Form ndash A more compact formulation

bull Inside domain

bull On domain boundary

Ru

RG

T

0

n

Ft

ud

t

ue aa

2

2

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 73: Equation-Based Modeling - iMath Asia

Coefficient form

c=1

General form

ux uy uz

ldquoCoolingrdquo (0 at ends)

coefficient from u=0

general form uR

ldquoHeat Sourcerdquo

Transient 0-gt100 s

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 74: Equation-Based Modeling - iMath Asia

2

2( )a a

u ue d c u u u au f

u 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 ldquoheatrdquo over time

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 75: Equation-Based Modeling - iMath Asia

2

2( )a a

u ue d c u u u au f

u t

Adding a ODETransient Diffusion Equation + ODE

0

][ 10

Uwt

Udt

dwdtUw

dVuU

ttt

V

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

What if we wish to measure the global accumulation of ldquoheatrdquo over time

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 76: Equation-Based Modeling - iMath Asia

Global Equation ODE

Same time-dependent problem as earlier

Time-dependent 0-100

Volume integration of u

ODE wt-U

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 77: Equation-Based Modeling - iMath Asia

PDEs + Distributed ODEs

(what if the ODE is depending on space)(comment on continuity of the solution)

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 78: Equation-Based Modeling - iMath Asia

Transient Diffusion Equation + Distributed ODE

dtzyxuzyxPt

)( )(

What if we get ldquodamagerdquo from local accumulation of ldquoheatrdquo

Example of real application bioheating

local time

integral of solution

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

Letrsquos assume damage happens where Pgt20

spacein point each at udt

dP

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 79: Equation-Based Modeling - iMath Asia

solution of integral timelocal udt

dP

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 new Domain ODEs and DAEs interface

Transient Diffusion Equation +Distributed ODE

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 80: Equation-Based Modeling - iMath Asia

Use of logical operators

Volume where Pgt20 and we get damage

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 81: Equation-Based Modeling - iMath Asia

Questions

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint

Page 82: Equation-Based Modeling - iMath Asia

Letrsquos comparebull derived valuesbull with the value obtained using the operator ldquotimeintrdquoWhatrsquos timeint