480 likes | 503 Views
Support for Dymola in the Modeling and Simulation of Physical Systems with Distributed Parameters. Student: Dshabarow Farid Professor: Prof. Fran ç ois Cellier Verantwortlich: Prof. Walter Gander. Outline. Objectives of the Master Thesis Building Blocks Dymola and Modelica
E N D
Support for Dymola in the Modeling and Simulation of Physical Systems with Distributed Parameters Student: Dshabarow Farid Professor: Prof. François Cellier Verantwortlich: Prof. Walter Gander
Outline • Objectives of the Master Thesis • Building Blocks • Dymola and Modelica • Partial Differential Equations • Method of Lines • Finite Volume Method • General Block • Conclusion • Literature
Objectives of the Master Thesis • Create blocks in Dymola that can be used to „construct“ partial differential equations (PDEs) and implement numerical methods to solve them • Numerical Methods: • Method of Lines • Finite Volume Method • Adaptive Method of Lines
Building Blocks: PDE • PDE Blocks Which blocks do we need for PDEs? For example: • Derivator Block • Integrator Block • Blocks for Addition, Subtraction, Product, ...
Building Blocks: PDE • PDE Construction After we have the blocks, we can use them to construct PDEs
Example: Advection Equation dq/dt = - c * dq/dx
Dymola & Modelica • Dymola (Dynamic Modeling Laboratory) is an integrated environment for the modeling and simulation of physical systems in Modelica language • Modelica is a general, high-level language for object-oriented modeling with differential-algebraic equations • Dymola provides standard blocks like sum, product, division, ...
PDE Library • Provides necessary blocks for the PDEs „construction“ and numerical methods for their solution • Implements new blocks and uses standard blocks provided by Modelica • Two numerical methods are provided for solving PDEs: • Method of Lines • Finite Volume Methods
Partial Differential Equations • Definition: A partial differential equation is an equation involving partial derivatives of an unknown function with respect to more than one independent variable • Examples: • Diffusion equation: • Wave equation:
Method of Lines (1D) • The Method of Lines (MOL) solves numerically a PDE by discretizing the space variable but leaving the time variable continuous • We are thus converting a PDE into a set of Ordinary Differential Equations (ODEs)! • Advantage: efficient ODE solvers are known
Method of Lines: Heat Equation • Example: Heat equation
Method of Lines: Heat equation • MOL solution to the heat equation Picture from „Scientific Computing“, M. Heath
Method of Lines: Implementation • Integrator block R
Method of Lines: Implementation • Derivator block: computes derivatives • Provided blocks: • Use Newton-Gregory polynomial to compute the derivatives First-order derivative Second-order derivative
Method of Lines: Implementation • Derivator block: includes three derivative blocks, each with different order of approximation accuracy • Different approximation orders can be selected by the user through the appropriate parameter • Provided approximation orders: • Second-order central difference approximation • Fourth-order central difference approximation • Sixth-order central difference approximation
Method of Lines: Boundary Conditions • There are many possibilities to specify boundary conditions: • Dirichlet The solution of the function at the boundary point is specified • Von Neumann The derivative of the function at the boundary point is specified • Robin A combination of the solution and derivative values of the function at the boundary point is specified • PDE Library currently allows Dirichlet boundary condition and a special case of von Newmann boundary condition: ∂u/∂x = 0
Method of Lines: Examples • Wave equation Cannot be passed to the integrator block in this form X v = ut
Method of Lines: Examples • Wave equation
Method of Lines: Examples • MOL solution to the wave equation 10 grid points were used error ~ 10-2
Method of Lines: Examples • Simple supported beam equation X v = ut w = uxx
Method of Lines: Examples • Simple supported beam equation
Method of Lines: Examples • Simple supported Beam equation 10 grid points 60 grid points
Finite Volume Methods (1D) • Subdivide the spatial domain into intervals (cells) • Approximate the integral of the function q over each of these cells at each time step • Denote the i-th cell by Ci = (xi-1/2, xi+1/2), then the approximation to the average of q in the cell Ci at time t, Qi, is
Finite Volume Methods (1D) • Example: cell average approximation with a constant function • Other approximations: linear (slope # 0), logarithmic, … ... ...
Finite Volume Methods (1D) • How can we find this approximation? • Conservation laws: the average within the cell can only change due to fluxes at the boundaries (assumption: no sink and no source in the cell) • The integral form of the conservation law:
Finite Volume Methods (1D) Integrate in time from t to t+Δt Divide by Δx ≈ Qit+Δt ≈ Qit
Finite Volume Methods (1D) • Average update rule where approximates the average flux along xi-1/2
Finite Volume Methods (1D) • The average update rule can also be written in this form • We have thus an ODE for each cell!
Finite Volume Methods (1D) • Example of fluxes: • Advection equation: qt + uqx = 0 t Fi-1/2 = uQi-1 if u > 0 Fi-1/2 = uQi otherwise t+Δt
Finite Volume Methods: Ghost Cells • Instead of writing special formulas for boundary cells, extend the domain with additional cells, the ghost cells
Finite Volume Methods: Implementation • Integrator block
Finite Volume Methods: Implementation • Flux block: Upwind Fi-1/2 = uQi-1 if u > 0 Fi-1/2 = uQi if u < 0 u
Example: Advection Equation • Upwind flux used
Example: Advection Equation • FVM solution to the advection equation • 10 cells used • Maximum error magnitude of order 10-1
Example: Euler Equations • Fluids (liquids and gases) are governed by conservation laws: • Conservation of mass • Conservation of momentum • Conservation of energy • The resulting system of 3 equations gives the Euler equations of gas dynamics
Example: Euler Equations • How do these equations look like? It depends on the chosen model • Two fundamental ways to derive the equations: • Eulerian approach • Lagrangian approach
Example: Euler Equations • Consider for ex. the velocity field • Eulerian description: • Describes the behavior of the velocity field at a particular point over time • Lagrangian description: • Describes the behavior of the velocity of the particles as they move through the flow
Example: Euler Equations • Euler system with Eulerian description: • γ = 1.4 for air • The fourth equation comes from the equation of state Conservation of mass Conservation of momentum Conservation of energy
Example: Euler Equations Logarithmic Reconstruction
Example: Euler Equations • FVM solution to Euler Equations: Density 10 cells used
Example: Euler Equations • FVM solution to Euler Equations: Momentum 10 cells used
Example: Euler Equations • FVM solution to Euler Equations: Energy 10 cells used
General Block • Contains two integrators: • MOL Integrator • FVM Integrator • Can be used to solve PDEs with either MOL or FVM technique
Conclusion • Method of Lines • Simple to implement • Gives accurate results • Not suited for the simulation of Euler equations (spurious oscillations) • Finite Volume Method • Poor Literature • Complicated theory • Equations must be rewritten in conservation form • First-order methods are not as accurate as Method of Lines • Better suited for the simulation of Euler equations
Literature • Stanley J. Farlow: Partial Differential Equations for Scientists and Engineers • François E. Cellier, Ernesto Kofman: Continous System Simulation • Randall J. Leveque: Finite Volume Methods for Hyperbolic Problems • John D. Anderson: Computational Fluid Dynamics