Jekyll2021-11-10T22:26:25+00:00https://pysim.org/feed.xmlPySimModelling and Simulation of Dynamical SystemsPySim Release 2.4.02021-11-10T00:00:00+00:002021-11-10T00:00:00+00:00https://pysim.org/blog/PySim-Release-2-4-0<h1 id="pysim-release-240">PySim Release 2.4.0</h1>
<p>This is the first release for quite some time. There are no new features and the only change in code is to make it compatible with newer compilers and new Python versions. The release has been tested against:</p>
<ul>
<li>Python 3.7</li>
<li>Python 3.8</li>
<li>Python 3.9</li>
</ul>
<p>at the following platforms</p>
<ul>
<li>Windows 10</li>
<li>macOS</li>
<li>Linux</li>
</ul>
<p>There has also been some infrastructure changes for the CI/CD system. Github Actions are now used to build, test and deploy the macOS and Linux versions, replacing Travis. The windows tests are still running at Appveyor. Finally the web page has been changed for both this blog and the documentation, it is now https://pysim.org and the documentation can be found at https://doc.pysim.org.</p>
<h2 id="install">Install</h2>
<p>The source distribution as well as wheel files for macOS and Linux can be found on <a href="https://pypi.python.org/pypi?:action=display&name=pysim&version=2.4.0">PyPi</a>. You can also download the source directly from github and follow the <a href="https://doc.pysim.org/tutorial.html#installing-pysim">install instructions</a>.</p>Running against Python 3.9PySim Release 2.1.02016-10-30T00:00:00+00:002016-10-30T00:00:00+00:00https://pysim.org/blog/PySim-Release-2-1-0<h1 id="pysim-release-210">PySim Release 2.1.0</h1>
<p>This release is mostly about the added composite systems introduced. These type of systems can consist of other c++ or python systems that are nested under it. These “subsystems” are not visible to the outside of the composite system but are communicating through ports of the composite system. There is more information on how to create these type of systems in the documentation, please have a look.</p>
<p>Apart from the composite system another new functionality is the possibility to connect a element of a vector to a scalar input of another system.</p>
<h2 id="install">Install</h2>
<p>The source distribution as well as wheel files for windows can be found on <a href="https://pypi.python.org/pypi?:action=display&name=pysim&version=2.0.0">PyPi</a>. You can also download the source directly from github and follow the <a href="http://pysim.readthedocs.io/en/latest/installing_pysim.html">install instructions</a> at readthedocs.</p>
<h2 id="development">Development</h2>
<p>There has been some major refactoring in between release 2.0.0 and 2.1.0. There is now a parent class called “commonsystem” that contains the functionality that is shared between the cythonsystem, cppsystem and the compositesystem. There is also a new Variable class that contains the functionality of the inputs and outputs. This will decrease the code that was previously repeated between these functions.</p>
<p>A release branch for this release has been created at github and is named <em>2-1-stable</em>, and a tag for release 2.1.0 has been taken from that branch. Any future bugfixes will be made in the <em>master</em> branch and merged into the release branch, from which a tag for the next 2.1.x release will be taken. Once the time has come for a 2.2.0 release a new release branch will be taken from <em>master</em> in the same manner.</p>
<h2 id="whats-next">Whats next?</h2>
<p>For the next part i will focus on better documentation, perhaps a slideshow introducing pysim. I would also love to have some more systems implemented. Right now there are a couple of example systems with varying quality and usability. In order to use PySim you pretty much have to implement some systems yourself. So, more and better organised systems!</p>This new release adds a third type of system, the composite systemPySim Release 2.0.02016-08-14T00:00:00+00:002016-08-14T00:00:00+00:00https://pysim.org/blog/PySim-Release-2-0-0<h1 id="pysim-release-200">PySim Release 2.0.0</h1>
<p>There is a first public open source release of pysim, 2.0.0. I have been very reluctant up to the last minute to actually do the release since I would hate to break backward compatability after this release. But there had to be a release eventually, and here it is. Since this is the first public release there will be no changelog, but the most work done lately has been in three areas:</p>
<ul>
<li>Adding Python and Cython systems</li>
<li>More flexible inputs, <em>parameters</em></li>
<li>Compatability with Linux and Mac OS</li>
<li>Integration with Travis-CI and Appveyor</li>
<li>Improved documentation, integrated with readthedocs</li>
<li>Improved Binary Compatibility</li>
</ul>
<p>A template for creating your own pysim-systems has also been created in a separate repository, https://github.com/aldebjer/pysim-system-template. If you want to create systems in c++ it is probably easiest to clone that repo and use it as a starting point for your systems. If you think they are useful for others please let me know and we can include the systems into the standard pysim.</p>
<p>PySim will use semantic versioning, which means that 2.0.x will only be bugfixes for this release, while new features will be introduced in release 2.1.0.</p>
<h2 id="install">Install</h2>
<p>The source distribution as well as wheel files for windows can be found on <a href="https://pypi.python.org/pypi?:action=display&name=pysim&version=2.0.0">PyPi</a>. You can also download the source directly from github and follow the <a href="http://pysim.readthedocs.io/en/latest/installing_pysim.html">install instructions</a> at readthedocs.</p>
<h2 id="development">Development</h2>
<p>A release branch for this release has been created at github and is named <em>2-0-stable</em>, and a tag for release 2.0.0 has been taken from that branch. Any future bugfixes will be made in the <em>master</em> branch and merged into the release branch, from which a tag for the next 2.0.x release will be taken. Once the time has come for a 2.1.0 release a new release branch will be taken from <em>master</em> in the same manner.</p>
<h2 id="whats-next">Whats next?</h2>
<p>I would really like to create some way of nesting systems, so that you can create a new system out of existing ones, and make more and more complex simulations. I have some ideas on how to do it, but they need some more thought before implemented. Besides this I would love to have some more systems implemented. Right now there are a couple of example systems with varying quality and usability. In order to use PySim you pretty much have to implement some systems yourself. So, more and better organised systems!</p>The first public open source release of PySimBinary compatibility2016-08-07T00:00:00+00:002016-08-07T00:00:00+00:00https://pysim.org/blog/Binary-Compatibility<h1 id="binary-compatibility">Binary compatibility</h1>
<p>Binary compatibility for pysim basically means that if you compile a c++ system for a version of pysim it will still work for future relases of PySim. This if obviously important since it saves everybody the trouble of recompiling as soon as something changes in a minor version of PySim.</p>
<h3 id="implementation">Implementation</h3>
<p>Some refactoring has been made to hide some of the implementation from the child classes of Systems, i.e. all third party system implementations. This is acheived by using <a href="https://wiki.qt.io/D-Pointer">d-pointers</a>, a concept borrowed from trolltech and Qt. The pointers contains most of the data of each system, and is only visible to the implementation of CommonSystem, and is not visible to the child systems. This means that the interface to the child systems is less likely to change when the implementation of PySim changes, and that there is no need to re compile them. For a detailed instruction of Binary compatability see for example the <a href="https://community.kde.org/Policies/Binary_Compatibility_Issues_With_C%2B%2B">KDE policies</a> on the matter.</p>
<h3 id="results">Results</h3>
<p>One immediate result is that the systems will be faster to compile, since they are less complex - more implementation is hidden in the CommonSystem implementation. Over time the most important result is that the systems will not need to be recompiled as often. There might still be changes to the interface exposed, but these changes will be a lot less common. The refactoring resulted in a lot less code duplication as well, which is always nice.</p>Binary compatibility means that if you compile a c++ system for a version of pysim it will still work for future relases...Introducing Python Systems2016-07-09T00:00:00+00:002016-07-09T00:00:00+00:00https://pysim.org/blog/python-systems<h1 id="python-systems">Python Systems</h1>
<p>Python systems are now implemented! This means that it is possible to write your new system in Python first, to verify its functionality. Once you have a proof of concept it is still probably a good idea to translate it to a complete c++ system if you are going to use it again. I have done some simple tests that show that a python system is about 200 times slower than a c++ system, just by calling python from c++. If you are doing calculations in python instead of c++ in your system, that difference in speed will add to it. There is also a way to increase the performance without going to c++ and that is by creating a cython system. I have not yet spent any time looking into the performance but it will probably be much better than the python system.</p>
<h3 id="implementation">Implementation</h3>
<p>The Python systems are actually inheriting from a cython system. So in the same way that it is possible to create a python system it is also possible to create a cython system. Anyway, the cython system is inheriting from something called a “CommonSystem”. This is a base class that is used by both the cython systems and the trusted old c++ systems. This change means that some refactoring was done to the c++ systems as well, and I believe that they turned up much nicer in the process, as well.</p>
<h3 id="documentation">Documentation</h3>
<p>The documentation of the new python and cython systems needs to be created, as is the documentation of the new “parameters” (see below). This is the next thing to do for me, and perhaps the last thing before a 2.0 release.</p>
<h3 id="what-else-is-new">What else is new?</h3>
<p>A lot of small changes and bug fixes have been made, such as the introduction of namespaces in c++ systems. The change that is most important to users of pysim is probably the introduction of parameters. These are designed to be more flexible than “inputs” in what types are allowed. They are not, however, designed for connecting to other systems in the way that the inputs/outputs are used. So far there is two type of parameters: strings and maps of doubles.</p>Python systems are now implementedShort term goals2016-06-05T00:00:00+00:002016-06-05T00:00:00+00:00https://pysim.org/blog/short-term-goals<h1 id="where-is-pysim-right-now">Where is Pysim right now?</h1>
<p>As mentioned in the previous article Pysim has been used in-house at SSPA for some years now, and now has a revision number larger
than 1 but smaller than two. Before launching Pysim to the world there are some breaking changes both in architecture and
api that I would like to do. Thus <strong>the first public Pysim will be versioned as Pysim 2.0</strong>. In these days were 0.1 is the new 1.0 this
might seem strange and overconfident (Is the project really <em>that</em> mature), but it is the only way to not mess up dependancies in-house at SSPA.</p>
<p>So what breaking changes do I want to do?</p>
<h3 id="python-systems">Python Systems</h3>
<p>The first and perhaps most important is to allow for Python systems. Right now when you
create a system it has to be in C++. But sometimes it is nice to be able to prototype with the quickness of Python, and sacrifice
the speed of C++. When everything is working, or at least seems feasible to work in Python the system can be implemented in C++.</p>
<h3 id="more-flexible-inputs">More flexible inputs</h3>
<p>All the individual systems communicate with something called “inputs” and “outputs”. The output of one system can be the input to
another system, making it possible to build simulations of multiple systems. Normally the inputs/outputs are either doubles or arrays
of doubles. This is fine when running the simulation, but when setting up a system more flexibility is needed. It would sometimes
be nice to be able to pass a python dict to a system for example. But it would not be very common to pass dicts between systems during
the simulation. So <strong>a new type of variable for systems are needed, “parameters”</strong>. The parameters of a system can only be set before
the simulation, and cannot be connected to other systems. So in this regard it is more limited. But the type of parameters could
be much more flexible, for example dicts, strings, variable length arrays, etc.</p>
<h3 id="automatic-tests">Automatic tests</h3>
<p>Pysim has used in house infrastructure at SSPA to perform the tests. Since it now is open source it is natural to do these tests
at services like Travis CI (for Linux and Mac OS) and AppVeyor (for Windows). Most of this has been done, but some things remain,
such as builds for Mac OS. I have built Pysim under Mac OS for testing purposes, but there is not yet automatic building and tests
under Travis CI.</p>
<h1 id="where-will-pysim-be">Where will Pysim be?</h1>
<p>My ambition is to release a beta of Pysim 2.0.0 at the first of July, even if these changes are not yet implemented. But with any luck
they will be!</p>Some discussion on the short term goals of Pysim.First Post2016-06-01T00:00:00+00:002016-06-01T00:00:00+00:00https://pysim.org/blog/first-post<h1 id="setting-up-an-open-source-project">Setting up an open source project</h1>
<p>My first encounter with differential equations in high school was decidedly underwhelming.
I understood that there was numerous rules on how to solve them, and that one could devote
their entire life to understand these rules, and even make up new ones for particular hard
equations. It all seemed a little… boring, unlike most of the other parts of mathematics.
But at the same time our teacher stressed that differential equations are an extremely powerful
tool for describing the world around us. Years later university and my experiences as an engineer
have proven him right.</p>
<h1 id="the-background-of-pysim">The background of Pysim</h1>
<p>The work with Pysim actually started some time ago, in 2010 to be exact. After four years
of working with control algorithms for underwater vehicles at Saab I had a new job working
with nautical simulations at SSPA. At SSPA there are very sophisticated models of ships.
The models are based on solid physics combined with the long experience SSPA has in model
testing. The models are expressed as differential equations (you guessed it). The problem
were that the legacy software used to solve these equations was quite dated and no longer
maintained. So Pysim was born to replace it. The development have been ongoing ever since,
driven by the need of the simulations at SSPA. But at the same time Pysim is a quite general
tool, and could be used by others as well. So before my parental leave in 2016 I proposed to
management that we should take Pysim open source. This would hopefully benefit the open source
society as a whole, and maybe also SSPA if there are external contributions to the project.
Management agreed to my proposal, which I am forever grateful. So here I am, launching Pysim,
a tool for simulation of dynamical systems as open source. I hope you will find it useful!</p>Some of the history behind Pysim, why it is released now, and how SSPA made it possible to do so.