Scientific Simulation Framework

Introduction

Development of a scientific programming environment to solve numerically the St-Venant one-dimensional equations on the well-known DamBreak problem. This project has been initiated many years ago and effort are focused on the development of scientific software aimed at understanding physics via modern modeling techniques and using new software development paradigms. We have put special effort into making the framework flexible and extendible, which means that it is possible to program new algorithms with little coding using classes at a high abstraction level. Using this approach to organize and design numerical software, we can derive flexible simulators that can be easily constructed in a flexible way.

with emphasis on reusability and extensibility of software components.

We present an OO analysis and design of a scientific framework to solve numerically ODE (Ordinary Differential Equation) corresponding to the explicit finite difference scheme with main application to validate numerical physics algorithm on the so-called DamBreak problem.

Motivation

(objective is to dramatically reduce the time and effort needed )

Industrial application

Accelerate the prototyping phase (validation of numerical scheme) where focus is made on the ease of programming/implementing new physical algorithm with a minimum effort. In industrial research projects, the physicist is often called to test or experiment different scenarios, this type of environment meets this need.

Scientific Simulation System (SFX)

The Finite Difference Framework

This framework implemented within first-version software still undergoing development, contains basic building blocks for the numerical solution of a generic differential equation of type,Ut=LΔ(U;t)Ut=LΔ(U;t)where L is a differential operator in “space” i. e. one which does not contain partial derivatives in but can otherwise contain any derivative in any other variable of the problem.

UML design to provide solid and clear relations between classes

Framework Architecture

Example of Development Application

Physics Modeling Of The Dam-Break Problem (Non-Linear Wave Propagation)

Dam-Break Problem

The dam break problem in a horizontal channel is a classical problem in fluid mechanics and is motivated by numerous applications in environment and industrial processes. In this problem, a rectangular column of water, in hydrostatic equilibrium, is confined between two walls. Gravity is acting downwards with a magnitude of -9.81 m/s2. At the beginning of the calculation, the right wall is removed and the water is allowed to flow out to the horizontal wall.

This classical test case is considered a benchmark for comparison of the performance of numerical schemes (numerical stability) specially designed for discontinuous transient flow and is widely considered a standard test case for validation of schemes …of the one-dimensional shallow-water equations on the Dam-Break Problem.

Mathematic Model

This phenomenon is best described by the equations of St-Venant which constitute a nonlinear system of partial differential equations of the hyperbolic type with a nonlinear source term. …

We need to solve a set of equations by some method of approximation (numerical method). A conservative finite difference method is used to solve numerically these equations and consist of evaluating a discrete equation on each cell, these equations are in a conservative form, which mean that the variation of state variables inside a cell depend only on the fluxes (in/out).

Numerical Model

Use of Finite Volumes solver to integrate the simplified 1D Shallow-Water Equations (SWE) written in conservative form of unsteady open channel flow. This method can reproduce the discontinuities of a flow regime variations without incur in instabilities of the solution.

Object-Oriented framework that can be used to solve the Dam-Break problem in one-dimension numerically

the discretization of the differential operatorLΔ=∂xF∗−Δt×Si−Δt×PiLΔ=∂xF∗−Δt×Si−Δt×Piwhere F is the numerical flux at cell face.

DamBreak++ API

documentation api

Cookbook recipes

The following steps outline how to develop a physics simulator using the Framework.

  1. Create a Physical Simulator by sub-classing the appropriate system object
  2. Provide an implementation for IPhysicalConfiguration
  3. Provide an implementation for IPhysicalAlgorithm
  4. Provide an implementation for IPhysicalMeasurement
  5. A Data Source to store physical measurement information
  6. If specified, a Final Report for statistic, visualizing the solution, etc…

User dev

Below an example of how to program a physics simulator using our programming environment or framework. The sample application is setup to simulate wave propagation (nonlinear flow with shocks) in the so-called dam break problem in a horizontal channel without friction under Newton’s Law of Gravity.

An example of how to program a physics simulator using the programming environment or framework. The physics simulator that we are going to program will simulate the wave propagation in the so-called dam break problem. This physical phenomenon has many mathematical difficulties, namely its non-linearity can give rise to discontinuous solutions currently referred to as bores or jumps.

Case under consideration (one-dimensional) is defined by the system of homogeneous shallow water equations for the ideal case of a flat and frictionless channel of unit width and rectangular cross section (known analytical solution).

Code examples

Code snippet #1 (Building a physics simulator)

An example taken from our programming environment (DamBreak simulator)

<!-- wp:code -->
<pre class="wp-block-code"><code> // create the discretization
  GlobalDiscretization* w_globalDisscr = new GlobalDiscretization();
  PhysicalSystem* physicalSystem = nullptr;
  IPhysicalAlgorithm* w_phyAlgo = nullptr;
  IPhysicalConfiguration* w_phyConfig = nullptr;
  DataStore* w_dataStore = nullptr;
  IPhysicalMeasurement* w_phyMeasurement = nullptr;
  IFinalReport* w_simReport = nullptr;
        
   // Now create the simulation environment that the user
   // has defined using the appropriate factory methods
   try 
   {
     // Create a new Physical System Factory
     std::cout << "Creating the physical system...\n";

     PhysicalSystemFactory* w_PhySysF = PhysicalSystemFactory::getInstance();
     physicalSystem = dynamic_cast<DamBreakSystem*>( w_PhySysF->create( w_globalDisscr));
     g_pLogger->write2File( "PhysicalSystem created successfully");
     std::cout << "created\n";

    // Configure the objects in the physical system
    std::cout << "Configuring system using < " 
        + g_pSimulation->getPhysicalConfigurationClass() + ">...\n";
     Class* setupClazz = Class::forName( g_pSimulation->getPhysicalConfigurationClass());
      w_phyConfig = (IPhysicalConfiguration*)setupClazz->newInstance();
      w_phyConfig->configure( physicalSystem);
      g_pLogger->write2File( "PhysicalSystem configured successfully");
   
      // Define the algorithm class to be used per iteration on the PhysicalSystem
      std::cout << "Configuring Algorithm using < " 
           + g_pSimulation->getPhysicalAlgorithmClass() + ">...\n";
      Class* algorithmClazz = Class::forName( g_pSimulation->getPhysicalAlgorithmClass());
       w_phyAlgo = (IPhysicalAlgorithm*)algorithmClazz->newInstance();
       g_pLogger->write2File( "PhysicalAlgorithm created successfully");

     // Define the measurement class to be used on the physical system
     std::cout << "Configuring Physical Measurement using <" + 
     g_pSimulation->getPhysicalMeasurementClass() + ">...\n";
     Class* measurementClazz = Class::forName( simulation.getPhysicalMeasurementClass());
     physicalMeasurement = (IPhysicalMeasurement*)measurementClazz.newInstance();
     g_pLogger->write2File("");
     std::cout << "configured\n";

     // Configure the data store for usage based 
     // on the type selected by the user
     std::cout << "Configuring the Persistent Data Source using <" + 
           g_pSimulation->getDataStore() + ">...\n";
     DataStoreFactory* dsf = DataStoreFactory::getInstance();
     w_dataStore = dsf->create( g_pSimulation->getDataStore());
     w_dataStore->open( g_pSimulation->getDataStoreFile());
     g_pLogger->write2File( "Simulation configuration complete");
  
    // Configure the simulation report if there is one defined
    if( g_pSimulation->doFinalReport()) 
    {
         std::cout << "Configuring the FinalReport using <" 
            + g_pSimulation->getFinalReportClass() + ">...\n";

        Class* reportClazz = Class::forName( g_pSimulation->getFinalReportClass());
        w_simReport = (IFinalReport*)reportClazz->newInstance();
     }
   }
   catch(...) // all exceptions
   {
       // to do: ....
   }
};</code></pre>
<!-- /wp:code -->

References

An Extensible C++ Framework for One-Dimensional Open Channel Flow Simulation , – J. Belanger (in preparation)

Abstract In this report we provide an introduction to ODE, then present an extensible Object-Oriented framework – written in C++ – with emphasis on the reusability of modules for ODE solvers. The ability to extend this API to accommodate new algorithms as they are developed is particularly attractive. This facilitates our work to find the best numerical method, and speed the development of a dedicated simulator for specific cases.

A C++ Differential Equations Solver using Object-Oriented Numeric” – J. Belanger Elligno Inc. Technical Report no. TR-2006-01 (September 2006)

Abstract * to be completed …

“Validating Shock Capturing Schemes On The Dam Break Problem”,

J. Belanger, Elligno Inc. Technical report no. TR1-2007-01 (March 2007)

Abstract to be completed …

Presentation

On the Development of a Scientific Programming Environment For The DamBreak Simulation”, MathWorks (MathLab Core Group), Boston, MA (USA) (September 2015)

Presented the programming environment that I have developed for the dam break simulation. This environment provides an easy way to program and test numerical scheme on the well-known DamBreak problem. I have presented the architecture of the framework and an example of how to program a numerical algorithm.