Академический Документы
Профессиональный Документы
Культура Документы
© 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.
2u
2 S Fv
t
T
C C u T (T ) Q
t
A Look Under the Hood
A Look Under the Hood
Modeling Approaches
•• Insert
Insertpredefined
Insert predefinedphysics
predefined physics
physics
••• Coupling
Coupling physics
Couplingphysics (manual
(manualor
physics(manual orautomatic)
or automatic)
automatic) 2u u
ea 2 d a
•• Enter
Enteruser
userdefined
expressions
definedfunctions.
expressionscan
functions.All
can depend
dependon onall
All
all the
the t t
variables
variablesintroduced
introduced(analytical,
interpolation
interpolationfrom
fromfile
(analytical,
file...)
...)
(cu u )
•• Add
Addoror change
changeterms
termsof
ofthe
theequations
equations u au f
set
setin
in the
thephysics
physics(and
(andmultiphysics)
multiphysics)
nodes
nodes
𝑑𝑢
= 𝑎1 𝑢(1 − 𝑢Τ𝑘) − 𝑏1 𝑢𝑣
𝑑𝑡
𝑑𝑣
= −𝑎2 𝑣 + 𝑏2 𝑢𝑣
𝑑𝑡
𝑢 0 = 𝑢𝑖𝑛𝑖 , 𝑣 0 = 𝑣𝑖𝑛𝑖
Global Algebraic Equations
• Same template as Global ODEs
• What are the initial values for?
– Stationary solvers
https://www.comsol.com/blogs/modeling-hydrostatic-pressure-fluid-deformable-container/
Physics + Global Algebraic Equations
• You can add extra degrees of freedom to a physics interface
https://www.comsol.com/blogs/modeling-hydrostatic-pressure-fluid-deformable-container/
Part II: Continuous Systems
Without Spatial Interaction
• Domain ODEs and DAEs
• Boundary ODEs and DAEs
• Edge ODEs and DAEs
• Point ODEs and DAEs
Domain ODEs
Domain ODEs
• Problem parameters are spatially variable
– Initial conditions 𝑢 𝑥, 0 = 𝑢𝑖𝑛𝑖 (𝑥),…
– Carrying capacity is spatially variable 𝑘 = 𝑘(𝑥)
– Prey-predator interactions have different outcomes based on location
• 𝑏1 = 𝑏1 𝑥 , 𝑏2 = 𝑏2 (𝑥)
– Climate effect? 𝑎1 = 𝑎1 (𝑥, 𝑇)
• Every point evolves independent of neighbors
– No spatial derivatives in the equation!
– No boundary conditions needed
Domain ODEs in Physics
• Material evolution
𝜕𝛼 𝐸
(− 𝑎ൗ𝑅𝑇)
= 𝐴𝑒 (1 − 𝛼)𝑛
𝜕𝑡
𝜕𝛼 𝐸
(− 𝑎ൗ𝑅𝑇(𝑥))
= 𝐴𝑒 (1 − 𝛼)𝑛
𝜕𝑡
• Reaction kinetics
– Built-in if you use the Chemical Reaction Engineering Module
ODE or 1D PDE?
𝑑2 𝑢
2
− 𝑎𝑢 + 𝑔 𝑡 = 0 IVP = ODE
𝑑𝑡
𝑑2𝑢 BVP = PDE
− 𝑎𝑢 + 𝑔 𝑥 = 0
𝑑𝑥2
https://www.comsol.com/blogs/solving-algebraic-field-equations/
Example: Ideal/Non-ideal gas law
• Assume u=(u,v,w) and p given by Navier-Stokes
• Want to solve Convection-Conduction in gas:
(kT ) C u T 0
• Ideal gas: 𝜌 given by • non-ideal gas law (needed for
pM high molecular weight at very
RT high pressures): 𝜌 solution of
• Easy - analytical A( p B 2 )(1 C ) D 0
• Difficult – implicit equation
• How to proceed?
Example: Non-ideal gas law
• How to solve: A( p B 2 )(1 C ) D 0
• Third order equation in
• Pressure p is function of space
• So: this is an algebraic equation at each point in space. Solution
ea d a 0, f A( p B 2 )(1 C ) D
http://www.comsol.com/blogs/solving-algebraic-field-equations/
Distributed Algebraic Equation
• What about non-linear equations with multiple solutions?
• Which solution do you get?
• For simplicity, consider the equation (u-2)^2-p=0, where p is a constant
• The solution you get will depend on the Initial Guess given by the PDE
Physics Interface
• If we let p=x*y and let our modeling region be the unit square, then at
(x,y)=(0,0) we should get the unique solution u=2 but at (x,y)=(1,1) we get 1
or 3 depending on our starting guess. See next slide.
Distributed Algebraic Equation
u=3
u=2
u=2
u=1
Distributed Algebraic Equation
u=3
u=2
u=2
u=1
Part III: Continuous Systems
with Spatial Interaction
Partial Differential Equations
Prey-Predator System with Migration
• PDEs!
• What if the second species does not migrate?
– Domain ODE or PDE with 𝑐2 = 0?
• Can we have a convective term?
• What happens for negative 𝑐1 or 𝑐2 ?
u
(c1u ) a1u (1 u k ) b1uv
t
v
(c2v) a2 v b2uv
t
Balance Laws: Integral Formulation
• Balance laws for a continuous system 𝑛
Γ
S
Rate of change of some quantity = amount entering or leaving through the boundary + production or
consumption inside
𝑑
Ԧ
න ϕ𝑑𝑉 = − න Γ·𝑛𝑑𝑆 + න 𝑓𝑑𝑉
𝑑𝑡 𝑉 𝑆 𝑉
Balance Laws: Differential Equations
𝑛 𝑑
Γ 𝑑𝑡 𝑉 𝑆
Ԧ
න ϕ𝑑𝑉 = − න Γ·𝑛𝑑𝑆 + න 𝑓𝑑𝑉
𝑉
S
𝜕ϕ
න Ԧ
𝑑𝑉 = − න Γ·𝑛𝑑𝑆 + න 𝑓𝑑𝑉
𝑉 𝜕𝑡 𝑆 𝑉
V
Divergence theorem
𝜕ϕ
න Ԧ 𝑑𝑉 + න 𝑓𝑑𝑉
𝑑𝑉 = − න 𝑑𝑖𝑣(Γ)
𝑉 𝜕𝑡 𝑉 𝑉
𝜕ϕ
න [ + 𝑑𝑖𝑣 ΓԦ − 𝑓]𝑑𝑉 = 0
𝑉 𝜕𝑡
Balance Laws: Differential Equations
𝑛
Γ න [
𝜕ϕ
+ 𝑑𝑖𝑣 ΓԦ − 𝑓]𝑑𝑉 = 0
S 𝑉 𝜕𝑡
Localization argument 𝜕ϕ
+ 𝑑𝑖𝑣 ΓԦ = 𝑓
𝜕𝑡
General Form PDE
𝜕ϕ
+ 𝑑𝑖𝑣 ΓԦ = 𝑓
𝜕𝑡
𝜕𝑢
Usually 𝜙 = 𝑒 + 𝑑𝑢
𝜕𝑡
2
𝜕 𝑢 𝜕𝑢
Template
𝑒 2 +𝑑 + 𝑑𝑖𝑣 ΓԦ = 𝑓
𝜕𝑡 𝜕𝑡
𝜕𝑇
HT 𝜙 = 𝜌𝑐𝑝 𝑇 𝜌𝑐𝑝 + 𝑑𝑖𝑣 ΓԦ = 𝑓
𝜕𝑡
Constitutive Assumptions
𝜕2𝑢 𝜕𝑢
𝑒 2 +𝑑 + 𝑑𝑖𝑣 ΓԦ = 𝑓
𝜕𝑡 𝜕𝑡
2u u
ea 2 d a (cu u ) u au f
t t
Coefficient Form PDE
Acoustics Chemistry Black-Scholes Fischer’s Ecologic
Model
𝒖 Pressure Concentration Cost of option Population
𝐞𝐚 1/𝜌𝑐 2
𝒅𝐚 1 1 1
𝜷 Velocity 𝑟𝑥 − 𝜎 2 𝑥
𝒂 −𝑟 𝑟(𝑢ൗ𝐾 − 1)
𝒇 𝑄𝑚 Reaction rate
Helmholtz Equation, Coefficient Form PDE
(cu ) k 2u g
2u u
ea 2 d a (cu u ) u au f
t t
Coefficient matching
𝑎 = −𝜅 2 𝑎=0
𝑓=𝑔 𝑓 = 𝑔 + 𝜅2𝑢
Option 1 Option 2
Helmholtz Equation, General Form PDE
(cu ) k 2u g
𝜕2𝑢 𝜕𝑢
𝑒 2 +𝑑 + 𝑑𝑖𝑣 ΓԦ = 𝑓
𝜕𝑡 𝜕𝑡
Match terms
ΓԦ = −𝑐𝛻𝑢
𝑓 = 𝑔 + 𝑘2𝑢
Black-Scholes Equation Coefficient Form PDE
u 1 2 2 2u u
x rx ru 0
t 2 x 2 x
2u u
ea 2 d a (cu u ) u au f
t t
u 1 2 2 u u
( x ) [rx 2 x] ru 0
t x 2 x x
Coefficient matching Alternative
1
1 d a 1, c 2 x 2
d a 1, c 2 x 2 2
2 0, a r
rx 2 x, a r
u
f ( rx 2 x)
x
https://www.comsol.com/model/the-black-scholes-equation-82
Weak Form PDE
• NO TEMPLATE!
• Extreme flexibility!
𝜕𝑢
𝐶 + 𝛻 ∙ −𝜅𝛻𝑢 − 𝑄 = 0
𝜕𝑡
𝜕𝑢
න 𝐶 𝑤 + 𝜅𝛻𝑤 ∙ 𝛻𝑢 𝑑Ω = න 𝑄𝑤𝑑Ω + න 𝑤𝑞𝑛 𝑑𝑆 ∀𝑤
𝜕𝑡
https://www.comsol.com/blogs/implementing-the-weak-form-in-comsol-multiphysics/
PDE in Weak formulation
• Weak = Integral ; based on variational formulation (conservation law)
• Most of COMSOL (and other tools’) physics use such a formulation since most
versatile
• It is the base of finite element (but also used within other schemes)
• Understanding how it works is the way to master what COMSOL does under the hood
Γ F
Γ dV F dV
Weak Form, Stationary
𝜕Ω
• General form: 𝛻∙Γ=𝐹
• Multiply by test function v 𝛻∙Γ=𝐹
• And arrive at Ω
𝜕𝑢
0 = Ω 𝛻𝑣 ∙ Γ + 𝑣𝐹 − 𝑑𝑎 𝑣 𝑑𝐴 + 𝜕Ω −𝑣Γ ∙ 𝑛 𝑑𝑠
𝜕𝑡
https://www.comsol.com/blogs/implementing-
the-weak-form-in-comsol-multiphysics/ https://www.comsol.co.in/blogs/brief-
introduction-weak-form/
https://www.comsol.com/blogs/strength-weak-form/
https://www.comsol.co.in/blogs/discretizing-the-
weak-form-equations/
Derivatives
Solution field: u
Spatial 1st derivatives: ux, uy, uz
Spatial 2nd derivatives: uxx, uxy, …, uyz, uzz
Time derivatives: ut, utt
Mixed derivatives: uxt, uytt
Derivatives tangent to surfaces: uTx, uTy, uTz
Derivatives of quantities other than the
d(q,t),d(q,x)
primary dependent variable:
Thermoset in
the cavity
Image by Joe Haupt — Own work. Licensed
under CC BY-SA 2.0, via Wikimedia Commons.
Heated
mold
Thermal Curing: Mathematical Model
T
C p (T ) H r
t t
Ae ( Ea / RT ) (1 ) n
t
• Initial conditions: room temperature, zero curing
• Boundary conditions: heat flux of 10 kWΤm2
• Step 1: Pick appropriate Mathematics interfaces
– PDE + Domain ODE
• Step 2: Fit the equations into the templates
Thermal Curing: Choosing the Interface
T
C p (T ) H r PDE
t t
2u u
ea 2 d a (cu u ) u au f
t t
d a C p , c , f H r
t
Ae ( Ea / RT ) (1 ) n Domain ODE
t 2
ea d f
t 2 t
a
d a 1, f Ae ( Ea / RT ) (1 ) n
Thermal Curing: Heat Transfer Interface
https://www.comsol.com/blogs/modeling-the-thermal-curing-process/
Part IV: Boundaries and Interfaces
The World Versus Your World!
Image by Strebe — Own work. Licensed under CC BY-SA 3.0, via Wikimedia Commons.
Jump and Boundary Conditions
𝜕𝜙
න Ԧ
𝑑𝑉 = − න Γ·𝑛𝑑𝑆 + න 𝑓𝑑𝑉
𝑉 𝜕𝑡 𝑆 𝑉
Can’t do this!
𝜕ϕ
න Ԧ 𝑑𝑉 + න 𝑓𝑑𝑉
𝑑𝑉 = − න 𝑑𝑖𝑣(Γ)
𝑉 𝜕𝑡 𝑉 𝑉
𝑉 → 0, 𝑆 ≠ 0
S Ԧ
න Γ·𝑛𝑑𝑆 =0
𝑆
𝑛 𝑛1
න (ΓԦ1 −ΓԦ2 )·𝑛𝑑𝑆 = 0
𝑆
𝑛2 S ΓԦ ∙ 𝑛=0
𝑛1 → 𝑛, 𝑛2 → −𝑛
Jump and Boundary Conditions
𝑛 −ΓԦ𝑖 ∙ 𝑛=−ΓԦ𝑜 ∙ 𝑛
𝑖 𝑜 Inward flux
S
𝜓 𝑛
𝑢𝑒𝑥𝑡 −ΓԦ𝑖 ∙ 𝑛 = 𝜓
𝑢 𝜅𝑜
𝜓= (𝑢 − 𝑢)
𝐿𝑒𝑥𝑡 𝑒𝑥𝑡
𝜅𝑜 ≫ 𝜅 ⇒ 𝑢 = 𝑢𝑒𝑥𝑡
• Temperature, voltage, displacement
• Dirichlet boundary conditions
More on Boundary Conditions
https://www.comsol.com/blogs/how-to-make-boundary-conditions-conditional-in-your-simulation/
https://www.comsol.com/blogs/modeling-natural-and-forced-convection-in-comsol-multiphysics/
Part V: Surface Phenomena
• Boundary PDEs
• Edge PDEs
Lower Dimension PDE Interfaces
Built-In Interfaces for Lower Dimensional Physics
• Fluid Flow • AC/DC
– Pipe Flow (pfl) – Electric Currents, Shell (ecs)
– Water Hammer (whtd) • RF
– Thin-Film Flow, Shell (tffs) – Transmission Line (tl)
• Heat Transfer • Chemical and Reaction Engineering
– Heat Transfer in Pipes (htp) – Surface Reactions (sr)
– Heat Transfer in Thin Shell (htsh) • Electrochemistry
– Heat Transfer in Thin Films (htsh) – Electrode, Shell (els)
– Heat Transfer in Fractures (htsh)
• Structural Mechanics
– Shell (shell)
– Membrane (mbrn)
– Beam (beam)
– Truss (truss)
Part VI: Miscellaneous
• PDEs in axisymmetric components
• Integrodifferential equations
• Nonlocal interactions
• Verification and validation
• Stabilization
PDEs in Axisymmetric Components
• In the PDE interfaces, differential operators do not have tensorial meanings
𝛻∙Γ=𝑄 Axisymmetry
1 𝜕(𝑟Γ𝑟 ) 𝜕Γ𝜙 𝜕Γ𝑧
+ + =𝑄
𝑟 𝜕𝑟 𝜕𝜙 𝜕𝑧
𝜕Γ𝑟 𝜕Γ𝑧 Γ𝑟
+ + =𝑄 𝜕Γ𝑟 𝜕Γ𝑧
𝜕𝑟 𝜕𝑧 𝑟 + =𝑓
• The source term is your friend! 𝜕𝑟 𝜕𝑧
COMSOL Blog Post
• Guidelines for Equation-Based Modeling in
Axisymmetric Components
– https://www.comsol.com/blogs/guidelines-for-
equation-based-modeling-in-axisymmetric-
components/
Integrodifferential Equations
𝐼(𝑠) = න 𝑐𝐴 𝑑𝑥 ?
0
Variable Limits of Integration
𝑠 𝐿
𝐼(𝑠) = 0 𝑐𝐴 𝑑𝑥=0 𝑘(𝑠, 𝑥)𝑐𝐴 𝑑𝑥
Integration Coupling operator!
𝑠 𝐿
𝐼(𝑠) = 0 𝑐𝐴 𝑑𝑥=0 𝑘(𝑑𝑒𝑠𝑡(𝑥), 𝑥)𝑐𝐴 𝑑𝑥
Solving Integrodifferential Equations
𝐿
𝜕𝑇 𝜕 𝜕𝑇
𝜌𝐶𝑝 + −𝜅 = 𝑎𝑇 4 − 𝑏 න 𝐾 𝑥, 𝑠 𝑇(𝑠)4 𝑑𝑠
𝜕𝑥 𝜕𝑥 𝜕𝑥 0
Source 1: a*T^4
Source 2: -b*intop1(K(dest(x),x)*T^4)
https://www.comsol.com/blogs/integrals-with-moving-limits-and-solving-integro-differential-equations/
Nonlocal Interactions: Component Coupling Operators
Purpose:
• Pass data from one part of a component to
another
• Pass data between different components
𝑞𝑑 𝑥𝑑 = 𝑓 𝑞𝑠 𝑥𝑠
𝑇: 𝑥𝑑 → 𝑥𝑠
Usage:
• Define operator in the source
component/entity
• Use in the destination component/entity
https://www.comsol.com/blogs/part-2-mapping-variables-with-general-extrusion-operators/
Verification & Validation
• Exact solutions
• Benchmarks
• Analogous modules in COMSOL Multiphysics®
Verification
Method of manufactured solutions:
1. Assume a solution
2. Plug in PDE to get source term
(cu u ) au f
3. Find initial & boundary conditions
4. Compute with IC, BC, and source term
5. Compare assumed and computed solution
https://www.comsol.com/blogs/verify-simulations-with-the-method-of-manufactured-solutions/
Stabilization
u t b u f
• Convection dominated
transport problems are ut b u ( cu ) f
numerically unstable
• A simple stabilization
• Sophisticated techniques technique for convective
implemented in physics transport problems
interfaces
https://www.comsol.com/blogs/understanding-stabilization-methods/
Hands-on #1
3D, time dependent
Use General form PDE
• Inside domain
2u u
ea 2 d a F
t t
• On domain boundary
R
T
n G
u
0R
“Cooling” (0 at ends)
coefficient from u=0
general form R u.
“Heat Source”
Coefficient form:
c=1
General form:
ux uy uz Transient 0->100 s
Transient Diffusion Equation + ODE
2u u
ea 2 d a (cu u ) u au f
u t
What if we wish to measure the global accumulation of “heat” over time?
U u dV
V
dw
w U dt
t [ t 0 ,t1 ]
dt
U