This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
• Ordinary Differential Equations (ODEs)– Global ODEs– Distributed ODEs
• Algebraic Equations– Global algebraic equations– Distributed algebraic equations
When is Equation-Based Modeling Needed?
• Try to avoid equation-based modeling if possible!– Using built-in physics interfaces enables ready-made postprocessing variables
and other tools for faster model setup with much lower risk of human error
• Applications that previously required equation-based modeling but now has a dedicated physics interface:– Fluid-Structure Interaction (Structural Mechanics Module, MEMS Module)– Surface adsorption and reactions (Chemical Reaction Engineering Module,
Plasma Module)– Shell-Acoustics and Piezo-Acoustics (Acoustics Module)– Thermoacoustics (Acoustics Module)– and many more…
When is Equation-Based Modeling Needed?
• Try to avoid equation-based modeling if possible!• But: we don’t have every imaginable physics equation built-
into COMSOL (yet!). So there is sometimes a need for custom modeling.
Custom-Modeling in COMSOL
• COMSOL Multiphysics allows you to model with PDEs or ODEs directly:– Use one of the equation-template user interfaces
• You do *not* need to write “user-subroutines” in COMSOL to implement your own equation!– Benefit: COMSOL’s nonlinear solver gets all the nonlinear info with
gradients and all. Faster and more robust convergence.
Customization Approaches
• Four modeling approaches:1. Ready-made physics interfaces2. First principles with the equation templates3. Start with ready-made physics interface and add additional terms.4. Start with a ready-made physics interface and add your own
separate equation (PDE,ODE) to represent physics that is not already available as a ready-made application mode
• Also: – The Physics Builder lets you create your own user interfaces that hides the
mathematics for your colleagues and customers
PDEs
Linear Model Problems: Fundamental Phenomena
• Laplace’s equation
• Heat equation
• Wave equation
• Helmholtz equation
• Convective Transport equation
0 u
0)( ukut
0)( uutt
uu )(
0 xt buu
COMSOL PDE Modes: Graphical User Interfaces
• Coefficient form• General form• Weak form
• All these can be used for scalar equations or systems• Which to use?
– Whichever is more convenient for you and your simulation needs
Note: COMSOL convention has the integral in the right-hand side so additional negative
sign needed in the GUI
2
2 ( )a au ue d c u u u au fu t
accumulation/storage
diffusion
source
Transient Diffusion Equation ~ Heat Equation
sourceheat volume
fkcCda
“Heat Source” f=1
“Cooling” u=0 at ends
Demo:c=1
da=1
f=0
Transient 0->100 s
PDEs+ODEs
2
2 ( )a au ue d c u u u au fu t
Transient Diffusion Equation + ODE
integral volumeof integral e tim
solution of integral volume
dtUw
dVuU
t
V
What if we wish to measure the global accumulation of “heat” over time?
2
2 ( )a au ue d c u u u au fu t
Transient Diffusion Equation + ODE
0],[ 10
Uwt
Udtdw
dtUw
dVuU
ttt
V
=> This is a Global ODE in the global state variable w
What if we wish to measure the global accumulation of “heat” over time?
Demo:Global Equation ODE
Same time-dependent problem as earlier
Time-dependent 0-100
Volume integration of u
ODE: wt-U
PDEs + Distributed ODEs
2
2 ( )a au ue d c u u u au fu t
Transient Diffusion Equation + Distributed ODE
solution of integral timelocal ),,( ),,( dtzyxuzyxPt
What if we get “damage” from local accumulation of “heat”.
Example of real application: bioheating
We want to visualize the P-field to assess local damage.
Let’s assume damage happens where P>20.
Disclaimer: There is no need to use equation-based modeling for bioheating in COMSOL. You are better off using the preset user interface options of the Heat Transfer Module.
Transient Diffusion Equation + Distributed ODE
solution of integral timelocal ),,( ),,( dtzyxuzyxPt
What if we get “damage” from local accumulation of “heat”.
Example of real application: bioheating
spacein point each at udtdP
2
2 ( )a au ue d c u u u au fu t
Transient Diffusion Equation + Distributed ODE
solution of integral timelocal udtdP
But this can be seen as a PDE with no spatial derivatives =
= Distributed ODE
Use coefficient form with unknown field P, c = 0, f = u, da=1
Let all other coefficients be zero
Or use Domain ODEs and DAEs interface
2
2 ( )a au ue d c u u u au fu t
Volume where P>20 and we get damage
Demo:Distributed ODE
Same time-dependent problem as earlier
Time-dependent 0-100
Volume integration of u
ODE: wt-U
Distributed Algebraic Equations
Example: Ideal gas law
• Assume u=(u,v,w) and p given by Navier-Stokes• Want to solve Convection-Conduction in gas:
• given by ideal gas law:
• Easy - analytical
0u)( TCTk
RTpM
Example: Non-ideal gas law
• Assume u=(u,v,w) and p given by Navier-Stokes• Want to solve Convection-Conduction in gas:
• given by non-ideal gas law: • Needed for high molecular weight at very high pressures• Difficult – implicit equation• How to proceed?
0)1)((* 2 DCBpA
0u)( TCTk
Example: Non-ideal gas law
• How to solve:• Third order equation in • Pressure p is function of space• So: this is an algebraic equation at each point in space!
0)1)((* 2 DCBpA
Distributed Algebraic Equation
• So: this is an algebraic equation at each point in space• See as PDE with no space or time derivatives!
– A*(p+B*u^2)*(1-C*u)-D*u– Here we let: A=1,B=2,C=3, D=4, p=x*y
• How: Put the entire equation in the source (f) term and zero out the rest
• Or, use user interface for Domain ODEs and DAEs
The solution u corresponding to the equation A*(p+B*u^2)*(1-C*u)-D*u, where p=x*y is spatially varying.Here the equation is solved for each point within the unit square.
Distributed Algebraic Equation
• What about nonlinear equations with multiple solutions?• Which solution do you get?• For simplicity, consider the equation (u-2)^2-p=0, where p is a constant• This can be entered as earlier with an f=(u-2)^2-p• The solution is easy to get analytically: u=2±sqrt(p)• The solution you get will depend on the Initial Guess given by the PDE Physics
Interface
• If we let p=x*y and let our modeling region be the unit square, then at (x,y)=(0,0) we should get the unique solution u=2 but at (x,y)=(1,1) we get 1 or 3 depending on our starting guess (and also the convergence region of the solver). See next slide.