Openmodelica User's Guide

Total Page:16

File Type:pdf, Size:1020Kb

Openmodelica User's Guide OpenModelica User’s Guide Release v1.19.0-dev-270-g618c742bb2 Open Source Modelica Consortium 2021 CONTENTS 1 Introduction 3 1.1 System Overview...........................................4 1.2 Interactive Session with Examples..................................5 1.3 Summary of Commands for the Interactive Session Handler.................... 24 1.4 Running the compiler from command line.............................. 25 2 OMEdit – OpenModelica Connection Editor 27 2.1 Starting OMEdit........................................... 27 2.2 MainWindow & Browsers...................................... 28 2.3 Perspectives............................................. 32 2.4 File Menu............................................... 37 2.5 Edit Menu.............................................. 38 2.6 View Menu.............................................. 38 2.7 Simulation Menu........................................... 38 2.8 Debug Menu............................................. 39 2.9 SSP Menu.............................................. 39 2.10 Sensitivity Optimization Menu.................................... 39 2.11 Tools Menu.............................................. 39 2.12 Help Menu.............................................. 39 2.13 Modeling a Model.......................................... 40 2.14 Simulating a Model......................................... 42 2.15 2D Plotting.............................................. 45 2.16 Re-simulating a Model........................................ 47 2.17 3D Visualization........................................... 47 2.18 Animation of Realtime FMUs.................................... 50 2.19 Interactive Simulation........................................ 51 2.20 How to Create User Defined Shapes – Icons............................. 51 2.21 Global head section in documentation................................ 52 2.22 Options................................................ 53 2.23 __OpenModelica_commandLineOptions Annotation........................ 60 2.24 __OpenModelica_simulationFlags Annotation........................... 60 2.25 Global and Local Flags........................................ 61 2.26 Debugger............................................... 61 2.27 Editing Modelica Standard Library................................. 61 2.28 State Machines............................................ 62 2.29 Using OMEdit as Text Editor.................................... 65 2.30 Temporary Directory, Log Files and Working Directory...................... 66 2.31 High DPI Settings.......................................... 67 3 2D Plotting 73 3.1 Example............................................... 73 3.2 Plot Command Interface....................................... 75 4 Solving Modelica Models 77 i 4.1 Integration Methods......................................... 77 4.2 DAE Mode Simulation........................................ 79 4.3 Initialization............................................. 79 4.4 Algebraic Solvers.......................................... 83 5 Debugging 85 5.1 The Equation-based Debugger.................................... 85 5.2 The Algorithmic Debugger...................................... 88 6 Porting Modelica libraries to OpenModelica 93 6.1 Mapping of the library on the file system.............................. 93 6.2 Modifiers for arrays......................................... 93 6.3 Access to conditional components.................................. 94 6.4 Access to classes defined in partial packages............................ 95 6.5 Equality operator in algorithms................................... 96 6.6 Public non-input non-output variables in functions......................... 96 6.7 Subscripting of expressions..................................... 97 6.8 Incomplete specification of initial conditions............................ 97 6.9 Modelica_LinearSystems2 Library................................. 98 7 Generating Graph Representations for Models 99 8 FMI and TLM-Based Simulation and Co-simulation of External Models 101 8.1 Functional Mock-up Interface - FMI................................. 101 8.2 Transmission Line Modeling (TLM) Based Co-Simulation..................... 104 8.3 Composite Model Editing of External Models............................ 104 9 OMSimulator 119 9.1 Introduction............................................. 119 9.2 OMSimulator............................................. 119 9.3 OMSimulatorLib........................................... 121 9.4 OMSimulatorLua........................................... 136 9.5 OMSimulatorPython......................................... 150 9.6 OpenModelicaScripting....................................... 165 9.7 Graphical Modelling......................................... 180 9.8 SSP Support............................................. 184 10 System Identification 191 10.1 Examples............................................... 191 10.2 Python and C API.......................................... 193 11 OpenModelica Encryption 201 11.1 Encrypting the Library........................................ 201 11.2 Loading an Encrypted Library.................................... 201 11.3 Notes................................................. 201 12 OMNotebook with DrModelica and DrControl 203 12.1 Interactive Notebooks with Literate Programming......................... 203 12.2 DrModelica Tutoring System – an Application of OMNotebook.................. 204 12.3 DrControl Tutorial for Teaching Control Theory.......................... 210 12.4 OpenModelica Notebook Commands................................ 220 12.5 References.............................................. 225 13 Optimization with OpenModelica 227 13.1 Builtin Dynamic Optimization with OpenModelica and IpOpt................... 227 13.2 Compiling the Modelica code.................................... 227 13.3 An Example............................................. 228 13.4 Different Options for the Optimizer IPOPT............................. 230 13.5 Dynamic Optimization with OpenModelica and CasADi...................... 230 13.6 Parameter Sweep Optimization using OMOptim.......................... 235 ii 14 Parameter Sensitivities with OpenModelica 243 14.1 Single Parameter sensitivities with IDA/Sundials.......................... 243 14.2 Single and Multi-parameter sensitivities with OMSens....................... 245 15 PDEModelica1 259 15.1 PDEModelica1 language elements.................................. 259 15.2 Limitations.............................................. 260 15.3 Viewing results............................................ 260 16 MDT – The OpenModelica Development Tooling Eclipse Plugin 261 16.1 Introduction............................................. 261 16.2 Installation.............................................. 261 16.3 Getting Started............................................ 262 17 MDT Debugger for Algorithmic Modelica 277 17.1 The Eclipse-based Debugger for Algorithmic Modelica....................... 277 18 Modelica Performance Analyzer 285 18.1 Profiling information for ProfilingTest................................ 286 18.2 Genenerated JSON for the Example................................. 288 18.3 Using the Profiler from OMEdit................................... 289 19 Simulation in Web Browser 291 20 Interoperability – C and Python 293 20.1 Calling External C functions..................................... 293 20.2 Calling external Python Code from a Modelica model....................... 294 20.3 Calling OpenModelica from Python Code.............................. 296 21 OpenModelica Python Interface and PySimulator 299 21.1 OMPython – OpenModelica Python Interface............................ 299 21.2 Enhanced OMPython Features.................................... 302 21.3 PySimulator............................................. 306 22 OMMatlab – OpenModelica Matlab Interface 307 22.1 Features of OMMatlab........................................ 307 22.2 Test Commands........................................... 307 22.3 WorkDirectory............................................ 309 22.4 BuildModel.............................................. 309 22.5 Standard get methods........................................ 309 22.6 Usage of getMethods......................................... 309 22.7 Standard set methods......................................... 311 22.8 Usage of setMethods......................................... 312 22.9 Advanced Simulation........................................ 312 22.10 Linearization............................................. 313 22.11 Usage of Linearization methods................................... 313 23 OMJulia – OpenModelica Julia Scripting 315 23.1 Features of OMJulia......................................... 315 23.2 Test Commands........................................... 315 23.3 WorkDirectory............................................ 317 23.4 BuildModel.............................................. 317 23.5 Standard get methods........................................ 317 23.6 Usage of getMethods......................................... 317 23.7 Standard set methods......................................... 319 23.8 Usage of setMethods......................................... 319 23.9 Advanced Simulation........................................ 319 23.10 Linearization............................................. 320 23.11 Usage of Linearization methods................................... 320 23.12 Sensitivity Analysis......................................... 320 iii 23.13 Usage................................................
Recommended publications
  • Opensource Software in Mac OS X V. Zhhuta
    Foss Lviv 2013 191 - Linux VM з Wordpress на Azure під’єднано до SQL-бази в приватному центрі обробки даних. Як бачимо, бізнес Microsoft вже дуже сильно зав'язаний на Open Source! Далі в доповіді будуть розглянуті подробиці інтероперабельності платформ з Linux Server, Apache Hadoop, Java, PHP, Node.JS, MongoDb, і наостанок дізнаємося про цікаві Open Source-розробки Microsoft Research. OpenSource Software in Mac OS X V. Zhhuta UK2 LImIted t/a VPS.NET, [email protected] Max OS X stem from Unix: bSD. It contains a lot of things that are common for Unix systems. Kernel, filesystem and base unix utilities as well as it's own package managers. It's not a secret that Mac OS X has a bSD kernel Darwin. The raw Mac OS X won't provide you with all power of Unix but this could be easily fixed: install package manager. There are 3 package manager: MacPorts, Fink and Homebrew. To dive in OpenSource world of mac os x we would try to install lates version of bash, bash-completion and few other utilities. Where we should start? First of all you need to install on you system dev-tools: Xcode – native development tools that contain GCC and libraries. Next step: bring a GIU – X11 into your system. Starting from Mac OS 10.8 X11 is not included in base-installation and it's need to install Xquartz(http://xquartz.macosforge.org). Now it's time to look closely to package managers MacPorts Site: www.macports.org Latest MacPorts release: 2.1.3 Number of ports: 16740 MacPorts born inside Apple in 2002.
    [Show full text]
  • Xcode Package from App Store
    KH Computational Physics- 2016 Introduction Setting up your computing environment Installation • MAC or Linux are the preferred operating system in this course on scientific computing. • Windows can be used, but the most important programs must be installed – python : There is a nice package ”Enthought Python Distribution” http://www.enthought.com/products/edudownload.php – C++ and Fortran compiler – BLAS&LAPACK for linear algebra – plotting program such as gnuplot Kristjan Haule, 2016 –1– KH Computational Physics- 2016 Introduction Software for this course: Essentials: • Python, and its packages in particular numpy, scipy, matplotlib • C++ compiler such as gcc • Text editor for coding (for example Emacs, Aquamacs, Enthought’s IDLE) • make to execute makefiles Highly Recommended: • Fortran compiler, such as gfortran or intel fortran • BLAS& LAPACK library for linear algebra (most likely provided by vendor) • open mp enabled fortran and C++ compiler Useful: • gnuplot for fast plotting. • gsl (Gnu scientific library) for implementation of various scientific algorithms. Kristjan Haule, 2016 –2– KH Computational Physics- 2016 Introduction Installation on MAC • Install Xcode package from App Store. • Install ‘‘Command Line Tools’’ from Apple’s software site. For Mavericks and lafter, open Xcode program, and choose from the menu Xcode -> Open Developer Tool -> More Developer Tools... You will be linked to the Apple page that allows you to access downloads for Xcode. You wil have to register as a developer (free). Search for the Xcode Command Line Tools in the search box in the upper left. Download and install the correct version of the Command Line Tools, for example for OS ”El Capitan” and Xcode 7.2, Kristjan Haule, 2016 –3– KH Computational Physics- 2016 Introduction you need Command Line Tools OS X 10.11 for Xcode 7.2 Apple’s Xcode contains many libraries and compilers for Mac systems.
    [Show full text]
  • Fulltext PDF 3,1 MB
    alpaka Parallel Programming – Online Tutorial Lecture 00 – Getting Started with alpaka Lesson 04: Installation www.casus.science Lesson 04: Installation How to download alpaka ● Install git for your operating system: ● Linux: sudo dnf install git (RPM) or sudo apt install git (DEB) ● macOS: Enter git --version in your terminal, you will be asked if you want to install git ● Windows: Download the installer from https://git-scm.com/download/win ● Open the terminal (Linux / macOS) or PowerShell (Windows) ● Navigate to a directory of your choice: cd /path/to/some/directory ● Download alpaka: git clone -b release-0.5.0 https://github.com/alpaka-group/alpaka.git alpaka Parallel Programming – Online Tutorial – Lesson 04: Installation | 2 Lesson 04: Installation Install alpaka’s dependencies ● alpaka only requires Boost and a modern C++ compiler (g++, clang++, Visual C++, …) ● Linux: ● sudo dnf install boost-devel (RPM) ● sudo apt install libboost-all-dev (DEB) ● macOS: ● brew install boost (Using Homebrew, https://brew.sh) ● sudo port install boost (Using MacPorts, https://macports.org) ● Windows: vcpkg install boost (Using vcpkg, https://github.com/microsoft/vcpkg) ● Depending on your target platform you may need additional packages ● NVIDIA GPUs: CUDA Toolkit (https://developer.nvidia.com/cuda-toolkit) ● AMD GPUs: ROCm / HIP (https://rocmdocs.amd.com/en/latest/index.html) alpaka Parallel Programming – Online Tutorial – Lesson 04: Installation | 3 Lesson 04: Installation Preparing alpaka for installation, Part 1 ● CMake is the preferred system
    [Show full text]
  • The TEX Live Guide TEX Live 2012
    The TEX Live Guide TEX Live 2012 Karl Berry, editor http://tug.org/texlive/ June 2012 Contents 1 Introduction 2 1.1 TEX Live and the TEX Collection...............................2 1.2 Operating system support...................................3 1.3 Basic installation of TEX Live.................................3 1.4 Security considerations.....................................3 1.5 Getting help...........................................3 2 Overview of TEX Live4 2.1 The TEX Collection: TEX Live, proTEXt, MacTEX.....................4 2.2 Top level TEX Live directories.................................4 2.3 Overview of the predefined texmf trees............................5 2.4 Extensions to TEX.......................................6 2.5 Other notable programs in TEX Live.............................6 2.6 Fonts in TEX Live.......................................7 3 Installation 7 3.1 Starting the installer......................................7 3.1.1 Unix...........................................7 3.1.2 MacOSX........................................8 3.1.3 Windows........................................8 3.1.4 Cygwin.........................................9 3.1.5 The text installer....................................9 3.1.6 The expert graphical installer.............................9 3.1.7 The simple wizard installer.............................. 10 3.2 Running the installer...................................... 10 3.2.1 Binary systems menu (Unix only).......................... 10 3.2.2 Selecting what is to be installed...........................
    [Show full text]
  • Teamcity 7.1 Documentation.Pdf
    1. TeamCity Documentation . 4 1.1 What's New in TeamCity 7.1 . 5 1.2 What's New in TeamCity 7.0 . 14 1.3 Getting Started . 26 1.4 Concepts . 30 1.4.1 Agent Home Directory . 31 1.4.2 Agent Requirements . 32 1.4.3 Agent Work Directory . 32 1.4.4 Authentication Scheme . 33 1.4.5 Build Agent . 33 1.4.6 Build Artifact . 34 1.4.7 Build Chain . 35 1.4.8 Build Checkout Directory . 36 1.4.9 Build Configuration . 37 1.4.10 Build Configuration Template . 38 1.4.11 Build Grid . 39 1.4.12 Build History . 40 1.4.13 Build Log . 40 1.4.14 Build Number . 40 1.4.15 Build Queue . 40 1.4.16 Build Runner . 41 1.4.17 Build State . 41 1.4.18 Build Tag . 42 1.4.19 Build Working Directory . 43 1.4.20 Change . 43 1.4.21 Change State . 43 1.4.22 Clean Checkout . 44 1.4.23 Clean-Up . 45 1.4.24 Code Coverage . 46 1.4.25 Code Duplicates . 47 1.4.26 Code Inspection . 47 1.4.27 Continuous Integration . 47 1.4.28 Dependent Build . 47 1.4.29 Difference Viewer . 49 1.4.30 Guest User . 50 1.4.31 History Build . 51 1.4.32 Notifier . 51 1.4.33 Personal Build . 52 1.4.34 Pinned Build . 52 1.4.35 Pre-Tested (Delayed) Commit . 52 1.4.36 Project . 53 1.4.37 Remote Run . ..
    [Show full text]
  • The Apple Ecosystem
    APPENDIX A The Apple Ecosystem There are a lot of applications used to manage Apple devices in one way or another. Additionally, here’s a list of tools, sorted alphabetically per category in order to remain vendor agnostic. Antivirus Solutions for scanning Macs for viruses and other malware. • AVG: Basic antivirus and spyware detection and remediation. • Avast: Centralized antivirus with a cloud console for tracking incidents and device status. • Avira: Antivirus and a browser extension. Avira Connect allows you to view device status online. • BitDefender: Antivirus and malware managed from a central console. • CarbonBlack: Antivirus and Application Control. • Cylance: Ransomware, advanced threats, fileless malware, and malicious documents in addition to standard antivirus. • Kaspersky: Antivirus with a centralized cloud dashboard to track device status. © Charles Edge and Rich Trouton 2020 707 C. Edge and R. Trouton, Apple Device Management, https://doi.org/10.1007/978-1-4842-5388-5 APPENDIX A THe AppLe ECOSYSteM • Malware Bytes: Antivirus and malware managed from a central console. • McAfee Endpoint Security: Antivirus and advanced threat management with a centralized server to track devices. • Sophos: Antivirus and malware managed from a central console. • Symantec Mobile Device Management: Antivirus and malware managed from a central console. • Trend Micro Endpoint Security: Application whitelisting, antivirus, and ransomware protection in a centralized console. • Wandera: Malicious hot-spot monitoring, jailbreak detection, web gateway for mobile threat detection that integrates with common MDM solutions. Automation Tools Scripty tools used to automate management on the Mac • AutoCasperNBI: Automates the creation of NetBoot Images (read: NBI’s) for use with Casper Imaging. • AutoDMG: Takes a macOS installer (10.10 or newer) and builds a system image suitable for deployment with Imagr, DeployStudio, LANrev, Jamf Pro, and other asr or Apple Systems Restore-based imaging tools.
    [Show full text]
  • Early Insights on FMI-Based Co-Simulation of Aircraft Vehicle Systems
    The 15th Scandinavian International Conference on Fluid Power, SICFP’17, June 7-9, 2017, Linköping, Sweden Early Insights on FMI-based Co-Simulation of Aircraft Vehicle Systems Robert Hallqvist*, Robert Braun**, and Petter Krus** E-mail: [email protected], [email protected], [email protected] *Systems Simulation and Concept Design, Saab Aeronautics, Linköping, Sweden **Department of Fluid and Mechatronic Systems, Linköping University, Linköping, Sweden Abstract Modelling and Simulation is extensively used for aircraft vehicle system development at Saab Aeronautics in Linköping, Sweden. There is an increased desire to simulate interacting sub-systems together in order to reveal, and get an understanding of, the present cross-coupling effects early on in the development cycle of aircraft vehicle systems. The co-simulation methods implemented at Saab require a significant amount of manual effort, resulting in scarcely updated simulation models, and challenges associated with simulation model scalability, etc. The Functional Mock-up Interface (FMI) standard is identified as a possible enabler for efficient and standardized export and co-simulation of simulation models developed in a wide variety of tools. However, the ability to export industrially relevant models in a standardized way is merely the first step in simulating the targeted coupled sub-systems. Selecting a platform for efficient simulation of the system under investigation is the next step. Here, a strategy for adapting coupled Modelica models of aircraft vehicle systems to TLM-based simulation is presented. An industry-grade application example is developed, implementing this strategy, to be used for preliminary investigation and evaluation of a co- simulation framework supporting the Transmission Line element Method (TLM).
    [Show full text]
  • Exploitable Results by Third Parties 11004 MODRIO
    Exploitable Results by Third Parties 11004 MODRIO Project details Project leader: Daniel Bouskela Email: [email protected] Website: https://www.modelica.org/external-projects/modrio 4 Exploitable Results by Third Parties 11004 MODRIO Name: O3PRM editor Input(s): Main feature(s) Output(s): . PRM (Probabilistic . Syntactic editor for O3PRM . Probability Relational Model) language distributions of written in the . Bayesian inference engine the requested O3PRM modeling variables language . Observations and requests on some variables of the PRM Unique Selling . Supports object oriented PRM Proposition(s): . Will soon be connected to Modelica models . Performance of inference algorithms . Free, open source . Web site including documentation, ready to use executable, source code: http://o3prm.lip6.fr Integration . Uses the Agrum open source library for inference constraint(s): Intended user(s): . In a first step: researchers interested in creating diagnosis applications. Then the users of such applications in the industry. Provider: . Lip6 (Laboratoire d’informatique de Paris 6) and EDF Contact point: . Marc Bouissou (EDF R&D) Condition(s) for . This software is currently under a GPL license reuse: Latest update: 19/04/2016 5 Exploitable Results by Third Parties 11004 MODRIO Name: SKELBO Figaro library Input(s): Main feature(s) Output(s): . Thermohydraulic . This library can be exploited . Fault tree(s) system architecture by the Figaro processor in order to generate a fault tree describing the causes of a thermohydraulic system failure . Describes failure modes (on demand and in function) of the most common thermohydraulic components, with the way they can propagate in a system . Includes 29 classes of objects that can be used to describe a system .
    [Show full text]
  • Openmodelica Development Environment with Eclipse Integration for Browsing, Modeling, and Debugging
    OpenModelica Development Environment with Eclipse Integration for Browsing, Modeling, and Debugging Adrian Pop, Peter Fritzson, Andreas Remar, Elmir Jagudin, David Akhvlediani PELAB – Programming Environment Lab, Dept. Computer Science Linköping University, S-581 83 Linköping, Sweden {adrpo, petfr}@ida.liu.se Abstract mental if it gives quick feedback, e.g. without recom- puting everything from scratch, and maintains a dia- The OpenModelica (MDT) Eclipse Plugin integrates logue with the user, including preserving the state of the OpenModelica compiler and debugger with the previous interactions with the user. Interactive envi- Eclipse Integrated Development Environment Frame- ronments are typically both more productive and more work.. MDT, together with the OpenModelica compiler fun to use. and debugger, provides an environment for Modelica There are many things that one wants a program- development projects. This includes browsing, code ming environment to do for the programmer, particu- completion through menus or popups, automatic inden- larly if it is interactive. What functionality should be tation even of syntactically incorrect models, and included? Comprehensive software development envi- model debugging. Simulation and plotting is also pos- ronments are expected to provide support for the major sible from a special command window. To our knowl- development phases, such as: edge, this is the first Eclipse plugin for an equation- • based language. Requirements analysis. • Design. • Implementation. 1 Introduction • Maintenance. The goal of our work with the Eclipse framework inte- A programming environment can be somewhat more gration in the OpenModelica modeling and develop- restrictive and need not necessarily support early ment environment is to achieve a more comprehensive phases such as requirements analysis, but it is an ad- and more powerful environment.
    [Show full text]
  • A Modelica Power System Library for Phasor Time-Domain Simulation
    2013 4th IEEE PES Innovative Smart Grid Technologies Europe (ISGT Europe), October 6-9, Copenhagen 1 A Modelica Power System Library for Phasor Time-Domain Simulation T. Bogodorova, Student Member, IEEE, M. Sabate, G. Leon,´ L. Vanfretti, Member, IEEE, M. Halat, J. B. Heyberger, and P. Panciatici, Member, IEEE Abstract— Power system phasor time-domain simulation is the FMI Toolbox; while for Mathematica, SystemModeler often carried out through domain specific tools such as Eurostag, links Modelica models directly with the computation kernel. PSS/E, and others. While these tools are efficient, their individual The aims of this article is to demonstrate the value of sub-component models and solvers cannot be accessed by the users for modification. One of the main goals of the FP7 iTesla Modelica as a convenient language for modeling of complex project [1] is to perform model validation, for which, a modelling physical systems containing electric power subcomponents, and simulation environment that provides model transparency to show results of software-to-software validations in order and extensibility is necessary. 1 To this end, a power system to demonstrate the capability of Modelica for supporting library has been built using the Modelica language. This article phasor time-domain power system models, and to illustrate describes the Power Systems library, and the software-to-software validation carried out for the implemented component as well as how power system Modelica models can be shared across the validation of small-scale power system models constructed different simulation platforms. In addition, several aspects of using different library components. Simulations from the Mo- using Modelica for simulation of complex power systems are delica models are compared with their Eurostag equivalents.
    [Show full text]
  • Paramagic(TM) Users Guide
    75 Fifth Street NW, Suite 213 Atlanta, GA 30308, USA Voice: +1- 404-592-6897 Web: www.InterCAX.com E-mail: [email protected] ParaMagicTM v16.6 sp1 Users Guide Table of Contents 1! About ..................................................................................................................................................... 3! 2! Quick Start ............................................................................................................................................ 3! 2.1! First Pass – execute existing models .............................................................................................. 3! 2.2! Second Pass – create new models .................................................................................................. 4! 3! Installation ............................................................................................................................................ 5! 3.1! Installation Requirements ............................................................................................................... 5! 3.1.1! System Requirements .............................................................................................................. 5! 3.1.2! MagicDraw Requirements ....................................................................................................... 5! 3.1.3! Core Solver Requirements ...................................................................................................... 5 ! 3.2! Installation Process .....................................................................................................................
    [Show full text]
  • Component-Oriented Acausal Modeling of the Dynamical Systems in Python Language on the Example of the Model of the Sucker Rod String
    Component-oriented acausal modeling of the dynamical systems in Python language on the example of the model of the sucker rod string Volodymyr B. Kopei, Oleh R. Onysko and Vitalii G. Panchuk Department of Computerized Mechanical Engineering, Ivano-Frankivsk National Technical University of Oil and Gas, Ivano-Frankivsk, Ukraine ABSTRACT 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 Submitted 22 March 2019 Accepted 24 September 2019 Modelica results verify the adequacy of the models.
    [Show full text]