At Collimator, we are building the future of advanced modeling and simulation, and we believe that future has Python—with its growing versatility and popularity—at its center. This might be an unexpected conclusion, so we thought we would take a few minutes to explain why we chose Python, what has been missing from the Python ecosystem, and what we’ve added to not only fill the gaps, but take modeling and simulation to the next level.
MathWorks was founded in 1984, with their first product, PC-MATLAB, a reworked version of a free, open source numerical computing language originally designed for academia. As the company grew, so did their platform, adding more and more language features, as well as visual modeling tools, analysis modules, graphical interface builders, and so on. Currently, the company’s MATLAB and Simulink products are indisputably the dominant players in the market for scientific computing and engineering applications.
With that said, let’s look at what key features a modeling and simulation environment has historically needed to provide to be useful:
So, Mathworks provides a single unified platform offering all the traditionally necessary features in a modeling and simulation tool. Unsurprisingly, it is a preferred one-stop shop for many engineers. Alternative ecosystems either lack necessary functionality under a single umbrella, or fail to provide a tight integration between components.
Since about 2012, Python has been a rising star in industry and academia, driven primarily by major improvements to it’s support for numerical computing (NumPy and SciPy), data processing (Pandas), and of course, AI / ML (TensorFlow and PyTorch). As data science continued to grow as a field, Python became even more popular due its general purpose nature, leading it to be useful throughout the data acquisition, pre-processing, computation (e.g., for ML), and then post-processing workflow. Add in strong community support and relatively easy-to-use language features, and it makes sense why Python has become so popular.
Likely due to its increasing popularity, its ease of use, and widespread adoption, engineers and students started asking when there would be a tool based on Python that could match the workflow of Simulink:
For many years, there was not a clear answer to that question. Despite its popularity and capabilities, Python was still lacking key functionality, keeping it from seeing mass adoption for modeling and simulation. Collimator was founded to create the solution many were asking for, but in order to move forward with Python, we would have to identify and overcome its weaknesses.
Let’s revisit our list of traditional modeling and simulation capabilities from above, and see how Python stacks up:
So it’s clear that vanilla Python support for most of our list of traditional modeling and simulation requirements is spotty at best. There are a few other issues worth mentioning as well.
First is fragmentation. There are library repositories such as PyPI, and the Anaconda folks have done some amazing integration work, but when you get down to the brass tacks of creating a solid, performant, easily upgradable Python environment for modeling and simulation, it’s still not simple. Getting disparate libraries to work together, sorting out dependencies and version conflicts, not to mention data storage and management—suffice it to say that it can be a lot.
Second is the issue of performance. Python is an interpreted language that supports dynamic typing and high-level abstractions. While these features make it user-friendly and versatile, they also introduce overhead that can slow down execution speed compared to lower-level, statically-typed languages like C or C++. Julia was designed to address the “two-language problem” by providing high-level syntax with the performance of low-level languages. However, recent advancements in Python, such as the introduction of frameworks like JAX and performance optimizations in recent versions, are enhancing performance through just-in-time compilation, efficient parallelization techniques, and various under-the-hood improvements.
So Python on its own does not offer a clear alternative to the MathWorks suite of products. The lack of a modern graphical user interface, the somewhat fragmented ecosystem from the perspective of a one-stop platform for modeling and simulation, and the performance pitfalls mean that if you want to use Python for serious modeling and simulation, you’ll have your work cut out for you.
Collimator is a Python and cloud-native modeling and simulation platform. For the details of our simulation engine, and how we leverage the popularity and flexibility of Python along with high performance with just-in-time compilation, see this article. For our purposes here, it is sufficient to understand that we aim to leverage the strengths of Python and the strengths of the Mathworks paradigms in order to create a whole that is greater than the sum of its parts. In short, a platform for the problems of today and the future. Let’s take a look:
Collimator provides a web and cloud native block-diagram based environment where blocks can be a combination of causal systems, state machines, code, and acausal blocks. The user can combine and interconnect these blocks freely in the intuitive interface.
Collimator provides a framework for modeling state machines on the graphical canvas and integrating them seamlessly with other blocks.
Collimator provides a framework for acausal modeling with a continuously improving and growing acausal systems library.
Code generation for deployment to hardware is a challenge. The poor performance and unreliable timing of interpreted code, along with the considerable requirements of Python relative to typical microcontrollers means that it is almost never used for industrial control applications. Collimator settles on two solutions: for small, low-power MCUs, it produces MISRA-compliant C code for controllers built as low-level discrete logic blocks; for more robust, OS-based systems such as those using GPUs, it compiles the code with tools from major machine learning libraries and then integrates the compiled code into a C program. For instance, JAX allows this path via the XLA compiler and the TensorFlow C API.
Being Python native allows Collimator to tightly integrate all the libraries in the Python ecosystem—and those outside but providing Python bindings—under a single umbrella. This cohesive integration enables further development on top of the combined power of the existing state-of-the-art. Some key integrations are highlighted below.
Collimator provides pre-built blocks to easily import models trained in PyTorch, Tensorflow, and Equinox. It also allows users to train their own models in Equinox within Collimator.
Collimator integrates with system identification libraries—that allow learning of a mathematical model for dynamics of a system from experimentally obtained data—such as pysindy.
Driven by the popularity of Python, increasingly many simulation tools offer a Python API. For example, Ansys provides the capability to export reduced order models as digital twins through their PyTwin library. Such models can be imported into Collimator and used seamlessly with other blocks. Similarly, tools that use the Modelica modeling language can export Functional Mockup Units (FMUs) which can then be imported into Collimator and used in simulations.
Collimator integrates with advanced Robotics libraries such as MuJoCo, to model and control Robots.
Where dedicated integrations are not made available, Collimator allows users to import any Python library in a PythonScript block and use the capabilities of the library in the block through Python code.
Lastly, Collimator also integrates with virtual hardware in the loop testing platforms such as Quanser, and the Robot Operating System (ROS).
Collimator provides a one-stop platform for a seamless integration of the advanced capabilities of existing libraries. Developing on top of these combinations with our state-of-the-art simulation and scientific-computing engine unlocks countless possibilities.
Collimator’s goal is not to be a mere alternative to MathWorks, but to go far beyond in providing new and advanced capabilities as the modeling and simulation platform of the future. This goal has influenced the design of Collimator’s simulation engine, detailed here. There are three points to highlight in this respect:
One of the key principles in the design of Collimator is automatic differentiation of any simulation output, objective, or constraint, with respect to any model parameters (which could be neural network weights) and initial conditions. As such, most native Collimator blocks are fully differentiable. Where possible, integration with other libraries is also ensured to be compatible with automatic differentiation. This unlocks opportunities for optimization, neural network training, and creating models that combine classical physics-based modeling, data-driven approaches, and AI methods. This greatly enhances productivity by automating a time-consuming process traditionally based on manual trial-and-error.
Being cloud-native, Collimator provides instant scale-up of computing power. Whether you need to run parameter sweeps, Monte Carlo simulations, uncertainty quantification workflows, or single compute-heavy simulations, the required computing power is always available instantly.
Additionally, our architecture enables seamless collaboration. From central storage of shared files to real-time co-editing of models, the cloud allows teams to work together more efficiently.
Collimator is the first to explore how Generative AI can help engineers in their day-to-day tasks, boosting their productivity. See early examples of this approach published in this video. Since Collimator’s model representation is in Python, a language very well understood by large language models (LLMs), it is relatively easy for off-the-shelf LLMs to navigate and understand Collimator’s modeling paradigm, resulting in efficient processing of user requests. Our goal is to make model creation, iteration, visualization, and results interpretation faster and more natural, using multi-modal inputs and outputs.
In conclusion, Collimator offers a robust platform for the modeling and simulation needs of today, and looking into the future. By addressing the limitations of the Python ecosystem and offering seamless integration of advanced Python libraries within a modern graphical block-diagram environment, Collimator delivers on both functionality and ease of use. Its cloud-native platform, support for state machines and acausal modeling, and capabilities in automatic differentiation and high-performance computing highlight its potential to meet diverse needs. Beyond being an alternative, Collimator redefines simulation by integrating classical physics-based approaches with the latest in AI technology.
Want to learn more? Check out the documentation and tutorials for our open-source simulation engine and libraries at py.collimator.ai, and get started with the browser-based modeling environment at app.collimator.ai.