scholarly journals Component-oriented acausal modeling of the dynamical systems in Python language on the example of the model of the sucker rod string

2019 ◽  
Vol 5 ◽  
pp. e227
Author(s):  
Volodymyr B. Kopei ◽  
Oleh R. Onysko ◽  
Vitalii G. Panchuk

Typically, component-oriented acausal hybrid modeling of complex dynamic systems is implemented by specialized modeling languages. A well-known example is the Modelica language. The specialized nature, complexity of implementation and learning of such languages somewhat limits their development and wide use by developers who know only general-purpose languages. The paper suggests the principle of developing simple to understand and modify Modelica-like system based on the general-purpose programming language Python. The principle consists in: (1) Python classes are used to describe components and their systems, (2) declarative symbolic tools SymPy are used to describe components behavior by difference or differential equations, (3) the solution procedure uses a function initially created using the SymPy lambdify function and computes unknown values in the current step using known values from the previous step, (4) Python imperative constructs are used for simple events handling, (5) external solvers of differential-algebraic equations can optionally be applied via the Assimulo interface, (6) SymPy package allows to arbitrarily manipulate model equations, generate code and solve some equations symbolically. The basic set of mechanical components (1D translational “mass”, “spring-damper” and “force”) is developed. The models of a sucker rods string are developed and simulated using these components. The comparison of results of the sucker rod string simulations with practical dynamometer cards and Modelica results verify the adequacy of the models. The proposed approach simplifies the understanding of the system, its modification and improvement, adaptation for other purposes, makes it available to a much larger community, simplifies integration into third-party software.

2019 ◽  
Author(s):  
Volodymyr B Kopei ◽  
Oleh R Onysko ◽  
Vitalii G Panchuk

As a rule, the limitations of specialized modeling languages for acausal modeling of the complex dynamical systems are: limited applicability, poor interoperability with the third party software packages, the high cost of learning, the complexity of the implementation of hybrid modeling and modeling systems with the variable structure, the complexity of the modifications and improvements. In order to solve these problems, it is proposed to develop the easy-to-understand and to modify component-oriented acausal hybrid modeling system that is based on: (1) the general-purpose programming language Python, (2) the description of components by Python classes, (3) the description of components behavior by difference equations using declarative tools SymPy, (4) the event generation using Python imperative constructs, (5) composing and solving the system of algebraic equations in each discrete time point of the simulation. The classes that allow creating the models in Python without the need to study and apply specialized modeling languages are developed. These classes can also be used to automate the construction of the system of difference equations, describing the behavior of the model in a symbolic form. The basic set of mechanical components is developed — 1D translational components "mass", "spring-damper", "force". Using these components, the models of sucker rods string are developed and simulated. These simulation results are compared with the simulation results in Modelica language. The replacement of differential equations by difference equations allow simplifying the implementation of the hybrid modeling and the requirements for the modules for symbolic mathematics and for solving equations.


2019 ◽  
Author(s):  
Volodymyr B Kopei ◽  
Oleh R Onysko ◽  
Vitalii G Panchuk

As a rule, the limitations of specialized modeling languages for acausal modeling of the complex dynamical systems are: limited applicability, poor interoperability with the third party software packages, the high cost of learning, the complexity of the implementation of hybrid modeling and modeling systems with the variable structure, the complexity of the modifications and improvements. In order to solve these problems, it is proposed to develop the easy-to-understand and to modify component-oriented acausal hybrid modeling system that is based on: (1) the general-purpose programming language Python, (2) the description of components by Python classes, (3) the description of components behavior by difference equations using declarative tools SymPy, (4) the event generation using Python imperative constructs, (5) composing and solving the system of algebraic equations in each discrete time point of the simulation. The classes that allow creating the models in Python without the need to study and apply specialized modeling languages are developed. These classes can also be used to automate the construction of the system of difference equations, describing the behavior of the model in a symbolic form. The basic set of mechanical components is developed — 1D translational components "mass", "spring-damper", "force". Using these components, the models of sucker rods string are developed and simulated. These simulation results are compared with the simulation results in Modelica language. The replacement of differential equations by difference equations allow simplifying the implementation of the hybrid modeling and the requirements for the modules for symbolic mathematics and for solving equations.


Author(s):  
Hajrudin Pasic

Abstract Presented is an algorithm suitable for numerical solutions of multibody mechanics problems. When s-stage fully implicit Runge-Kutta (RK) method is used to solve these problems described by a system of n ordinary differential equations (ODE), solution of the resulting algebraic system requires 2s3 n3 / 3 operations. In this paper we present an efficient algorithm, whose formulation differs from the traditional RK method. The procedure for uncoupling the algebraic system into a block-diagonal matrix with s blocks of size n is derived for any s. In terms of number of multiplications, the algorithm is about s2 / 2 times faster than the original, nondiagonalized system, as well as s2 times in terms of number of additions/multiplications. With s = 3 the method has the same precision and stability property as the well-known RADAU5 algorithm. However, our method is applicable with any s and not only to the explicit ODEs My′ = f(x, y), where M = constant matrix, but also to the general implicit ODEs of the form f (x, y, y′) = 0. In the solution procedure y is assumed to have a form of the algebraic polynomial whose coefficients are found by using the collocation technique. A proper choice of locations of collocation points guarantees good precision/stability properties. If constructed such as to be L-stable, the method may be used for solving differential-algebraic equations (DAEs). The application is illustrated by a constrained planar manipulator problem.


Processes ◽  
2018 ◽  
Vol 6 (8) ◽  
pp. 106 ◽  
Author(s):  
Logan Beal ◽  
Daniel Hill ◽  
R. Martin ◽  
John Hedengren

This paper introduces GEKKO as an optimization suite for Python. GEKKO specializes in dynamic optimization problems for mixed-integer, nonlinear, and differential algebraic equations (DAE) problems. By blending the approaches of typical algebraic modeling languages (AML) and optimal control packages, GEKKO greatly facilitates the development and application of tools such as nonlinear model predicative control (NMPC), real-time optimization (RTO), moving horizon estimation (MHE), and dynamic simulation. GEKKO is an object-oriented Python library that offers model construction, analysis tools, and visualization of simulation and optimization. In a single package, GEKKO provides model reduction, an object-oriented library for data reconciliation/model predictive control, and integrated problem construction/solution/visualization. This paper introduces the GEKKO Optimization Suite, presents GEKKO’s approach and unique place among AMLs and optimal control packages, and cites several examples of problems that are enabled by the GEKKO library.


Author(s):  
Hamid M. Lankarani ◽  
Behnam Bahr ◽  
Saeid Motavalli

Abstract This paper presents the description of an ideal tool for analysis and design of complex multibody mechanical systems. It is in the form of a general-purpose computer program, which can be used for simulation of many different systems. The generality of this computer-integrated environment allows a wide range of applications with significant engineering importance. No matter how complicated the mechanical system under consideration is, a numerical multibody model of the system is constructed. The governing mixed differential/algebraic equations of motion are automatically formulated and numerically generated. State-of-the-art numerical techniques and computational methods are employed and developed which produce in the response of the system at discrete time junctures. Postprocessing of the results in the form of graphical images or real-time animations provides an enormous aid in visualizing motion of the system. The analysis package may be merged with an efficient design optimization algorithm. The developed integrated analysis/design system is a valuable tool for researchers, design engineers, and analysts of mechanical systems. This computer-integrated tool provides an important bridge between the classical decision making process by an engineer and the emerging technology of computers.


Author(s):  
Matteo Fancello ◽  
Pierangelo Masarati ◽  
Marco Morandini

Multi-rigid-body dynamics problems with unilateral constraints, like frictionless and frictional contacts, are characterized by nonsmooth dynamics. The issue of nonsmoothness can be addressed with methods that apply a mathematical regularization, called continuous contact methods; alternatively, hard constraints with complementarity approaches can be proficiently used. This work presents an attempt at integrating consistently modeled unilateral constraints in a general purpose multibody formulation and implementation originally designed to address intrinsically smooth problems. The focus is on the analysis of generally smooth problems, characterized by significant multidisciplinarity, with the need to selectively include nonsmooth events localized in time and in specific components of the model. A co-simulation approach between the smooth Differential-Algebraic Equations solver and the classic Moreau-Jean timestepping approach is devised as an alternative to entirely redesigning a monolithic nonsmooth solver, in order to provide elements subject to frictionless and frictional contact in the general-purpose, free multibody solver MBDyn. The implementation uses components from the INRIA’s Siconos library for the solution of Complementarity Problems. The proposed approach is applied to several problems of increasing complexity to empirically evaluate its properties and versatility. The applicability of the family of second-order accurate, A/L stable multistep integration algorithms used by MBDyn to nonsmooth dynamics is also discussed and assessed.


2018 ◽  
Vol 4 ◽  
pp. e160 ◽  
Author(s):  
Dragan D. Nikolić

Numerical solutions of equation-based simulations require computationally intensive tasks such as evaluation of model equations, linear algebra operations and solution of systems of linear equations. The focus in this work is on parallel evaluation of model equations on shared memory systems such as general purpose processors (multi-core CPUs and manycore devices), streaming processors (Graphics Processing Units and Field Programmable Gate Arrays) and heterogeneous systems. The current approaches for evaluation of model equations are reviewed and their capabilities and shortcomings analysed. Since stream computing differs from traditional computing in that the system processes a sequential stream of elements, equations must be transformed into a data structure suitable for both types. The postfix notation expression stacks are recognised as a platform and programming language independent method to describe, store in computer memory and evaluate general systems of differential and algebraic equations of any size. Each mathematical operation and its operands are described by a specially designed data structure, and every equation is transformed into an array of these structures (a Compute Stack). Compute Stacks are evaluated by a stack machine using a Last In First Out queue. The stack machine is implemented in the DAE Tools modelling software in the C99 language using two Application Programming Interface (APIs)/frameworks for parallelism. The Open Multi-Processing (OpenMP) API is used for parallelisation on general purpose processors, and the Open Computing Language (OpenCL) framework is used for parallelisation on streaming processors and heterogeneous systems. The performance of the sequential Compute Stack approach is compared to the direct C++ implementation and to the previous approach that uses evaluation trees. The new approach is 45% slower than the C++ implementation and more than five times faster than the previous one. The OpenMP and OpenCL implementations are tested on three medium-scale models using a multi-core CPU, a discrete GPU, an integrated GPU and heterogeneous computing setups. Execution times are compared and analysed and the advantages of the OpenCL implementation running on a discrete GPU and heterogeneous systems are discussed. It is found that the evaluation of model equations using the parallel OpenCL implementation running on a discrete GPU is up to twelve times faster than the sequential version while the overall simulation speed-up gained is more than three times.


Author(s):  
Pierangelo Masarati ◽  
Marco Morandini ◽  
Alessandro Fumagalli

This paper discusses the problem of control constraint realization applied to the design of maneuvers of complex underactuated systems modeled as multibody problems. Applications of interest in the area of aerospace engineering are presented and discussed. The tangent realization of the control constraint is discussed from a theoretical point of view and is used to determine feedforward control of realistic underactuated systems. The effectiveness of the computed feedforward input is subsequently verified by applying it to more detailed models of the problems, in the presence of disturbances and uncertainties in combination with feedback control. The problems are solved using a free general-purpose multibody software that writes the constrained dynamics of multifield problems formulated as differential-algebraic equations. The equations are integrated using unconditionally stable algorithms with tunable dissipation. The essential extension to the multibody code consisted of the addition of the capability to write arbitrary constraint equations and apply the corresponding reaction multipliers to arbitrary equations of motion. The modeling capabilities of the formulation could be exploited without any undue restriction on the modeling requirements.


Author(s):  
Joseph Saad ◽  
Matthias Liermann

Inverse dynamic simulation of hydraulic drives is helpful in early design stages of hydraulic machines to answer the question whether the drive can meet dynamic load requirements and at the same time to predict the energy consumption for required load cycles. While a forward simulation of the hydraulic drive needs an implementation of the controller which generates the control input as a function of the control error, the inverse dynamic simulation can be implemented without control. This is because the required motion is simply defined as a constraint and therefore the control error is always zero. This paper surveys examples of successful use of inverse dynamic simulation in engineering. We use the example of a hydraulic servo-drive to explain the procedure how to generate a state space description of the inverse problem from the given system of differential algebraic equations. Equation based modeling languages such as Modelica lend themselves naturally for inverse simulation because the definitions of which variables of the model are inputs and which are outputs is not made explicit in the model itself.


Author(s):  
Pierangelo Masarati ◽  
Marco Morandini ◽  
Alessandro Fumagalli

This paper discusses the problem of control constraint realization applied to the design of maneuvers of complex under-actuated systems modeled as multibody problems. Applications of interest in the area of aerospace engineering are presented and discussed. The tangent realization of the control constraint is discussed from a theoretical point of view and used to determine feedforward control of realistic under-actuated systems. The effectiveness of the computed feedforward input is subsequently verified by applying it to more detailed models of the problems, in presence of disturbances and uncertainties in combination with feedback control. The proposed applications consist in the position control of a complex closed chain mechanism representative of a robotic system, the control of a simplified model of a canard and a conventional air vehicle in the vertical plane, and the angular velocity control of a wind-turbine. In the aeromechanics examples, the tangent realization of the control relies on the availability of the Jacobian matrix of an aeroelastic model. All problems are solved using a free general-purpose multibody software that writes the constrained dynamics of multi-field problems in form of Differential-Algebraic Equations (DAE). The equations are integrated using A/L-stable algorithms. The essential extension to the multibody code consisted in the addition of the capability to write arbitrary constraint equations and apply the corresponding reaction multipliers to arbitrary equations of motion. This allowed to exploit the modeling capabilities of the formulation without any undue restriction on the modeling requirements.


Sign in / Sign up

Export Citation Format

Share Document