There is a Better Way to Automate and Manage Your (Fluid) Simulations

This is a story about applying Python and the “hacker mindset” to Computer Aided Engineering (CAE), an emerging domain within the Python ecosystem. Shell scripts have traditionally been the preferred tool for automating CAE pipelines, especially in subfield of Computational Fluid Dynamics (CFD). However, this approach is brittle, severely limited and cumbersome to manage at scale. Data management is also a challenge, with tens to hundreds of GB per simulation needing to be stored and versioned in complex folder structures. One possible approach is to use Python as an automation and glue language and Data Version Control (DVC) which is a Python based tool built on top of git to track pipelines and data.

This talk will show you how to use Python to automate many tasks in CAE workflows, even when the tools don’t offer a native Python interface:

  • Exporting CFD simulation results from Starccm+ to a PowerPoint template with python-pptx and updating the final presentation with new simulation data
  • Preparing input data for an electrical thermal simulation to improve performance 80-fold

Both examples will illustrate best practices and lessons learned in the automation of the CFD software that are applicable beyond the field.

DVC was originally designed and is broadly used for machine learning pipelines, but its flexibility allows it to be adapted to other domains. The potential benefits for engineering applications are immense. This talk will show you how easy it is to convert an existing CAE pipeline to DVC and show the benefits:

  • Running hundreds of simulations, comparing them and choosing the optimal with DVC
  • Managing software versions declaratively and comparing results across versions
  • Creating in-depth meta studies and comparing many simulations with Jupyter notebooks

Finally, this talk will give an outlook on the changing CAE ecosystem and propose new features for DVC to better leverage it for this use case.

Audience Either simulation engineers seeking to enhance and scale their workflows or software engineers aiming to build powerful and flexible simulation tooling.

Relevant talks or blog posts

  • Sending Rovers to Mars with Jupyter
  • Managing OpenFOAM Physical Simulations with DVC, CML, and Studio
  • How Python enables future computer chips

This session took place in track Industry & Academia Use-Cases and was classified suitable for intermediate domain / novice python by the speaker.

Transcript (auto)

Auto-generated from the recording utilizing Open-Source AI. Speaker labels (Speaker 1, Speaker 2) reflect diarization, not identity. Timestamps refer to the recording.

Speaker 1 [00:06]

Hi, I'm Julian. I work at the Center of Excellence Battery at the Volkswagen Group. And I develop battery systems or battery packs. And I'm gonna talk to you about simulation data management and I'm gonna show you a better way to automate and manage your simulation data. So first of all, what is simulation data management? I think there are two parts of this. First of all, there's data management. And data management is defined as handling data so it can be used for decision making. And it's part of the curriculum of computer science, software engineering, data science, and so on. And so it's used mainly in the fields of machine learning, data science, and so on. And then the second part is the simulation engineering. And simulation is to create and validate designs without or with less physical prototypes. And it's part of the curriculum in electrical and mechanical engineering. And it's used mainly in the fields of automotive, aviation, and so on. And you can see there might be an issue here when we talk about simulation data management because persons from two fields need to come together to make really good solutions. And this is the story I want to tell you here. So for this story, I would like you to meet Jordan. So Jordan is a simulation engineer. Jordan is also a self-taught Python developer. And Jordan knows data version control from personal machine learning projects, and I later will tell you what DVC is. And Jordan is part of a growing team of simulation engineers. So let's meet the team. The team consists of very experienced simulation engineers. However, the team struggles to scale their workflows. As the number of simulations they're executing increases, there is an inflection point where the time and effort per simulation increases drastically. And ideally, we want to have a flat curve where there's no additional effort per simulation. So the team's goals are to iterate faster, of course, to have more transparency and traceability across the whole simulation workflow, and in the end, replace hardware tests. However, there are some challenges to overcome. We have many different simulation setups and software. So we have 0D, 1D, 3D simulation software. We have chemical simulation software. We have crash simulation software. We have thermal simulation software. All is needed to simulate a battery system. And the simulation software is mostly proprietary. It's a very complex piece of software that we're just using. And so we also don't want to change the work environment of the team because they really like their environment and we don't want to change that much. Also, we have very complex pipelines, which is not necessarily sequential one after the other, but there can be very strange dependencies between each other. And in the end, that's the bastion of every engineer, mechanical, electrical engineer, usually results are presented in PowerPoint, so it's an additional challenge. So Jordan sets out an emission, and this is now the agenda of my talk here. So first of all, use Python as a control and glue language to automate simulation software. Then second, use DVC to track and manage and compare simulation. And then third, use JupyterLab to create really rich comparison analyses. And in the end, use Python to sync PowerPoint with simulation data. And in the top right, you can always see where we are right now in the talk. Okay, this is not going to be a battery systems presentation. but so we have an example let's meet the mev platform it's a widely used platform for battery system inside the group works on group for volkswagen audi skoda and so on but also for example the ford explorer also uses this battery system for us so we have a 3d thermal simulation computational fluid dynamics cfd and such as m plus which is a software by siemens very popular software for this and we have some inputs just some generic inputs the temperature and the volume flow of the coolant going into the battery system and also the electrical current profile which is demanded by the car and then just some generic outputs and we have the temperature of each of the battery cells we can calculate a fast charge time and also the pressure drop of the cooling channels, which is like how much pressure the cooling pump has to create in order to pump the coolant through the cooling channels. And it's a measure of how efficient the cooling channels are. But I have to tell you, no real simulation data was used in this presentation for obvious reasons. So let's go right into it with the first thing. So we want to simulate a current profile. So, here's the current profile in green, and you can see all the spikes and so on. And now we want to simulate this, and we simulate this at the time interval of four seconds. So, every four seconds, we run all the physical time-step simulations, which is totally enough. But when we now start to see samples from this electrical current, we see here in the yellow line that there is an aliasing error. So, all those spikes are missed by the software. So probably the obvious solution is to just decrease the time step, but this increases, of course, the overall simulation time. So a better solution would be to use the Java API of StarCCM+, to calculate the root mean squared of the electricity current, which is like the effective current, and then sample from that value. but now you couple your simulation tightly with the java program and this creates a whole lot of different problems so i think the best solution is to use python to pre-compute the rms of the electricity current for a specific time interval and then sample from this and then we have a very decorative approach so we know what is going into the simulation we simulate it and then we have the outputs and it's always very clear what what is happening and so the the Takeaway here, simulation software is dumber than you think. No offense against the makers. And we should use Python to control it. So now that we kind of control our simulation software with Python, decoratively, we can look at another project which can automate something like this, which is called DVC. And DVC is an open source command line tool to manage data pipelines. And here you can see when you use Git, you version your scripts, input parameters, output metrics, basically text files, and that's where Git is really good at. And then DVC builds on top of this and versions all the large input files or the large output files, it can version plots as well, which are images, and additionally you can declare a pipeline in the DVC YAML file, that I'm going to show you how to do this, and then you can execute this pipeline very nicely. So who uses it? I think there are over 10,000 people using it on GitHub. really, really widely use the machine learning used by Fortune 500 companies, startups, and individuals. And who's behind it? The main vendor and developer is Intuitive AI, and they also have a commercial offering called DVC Studio. However, we are not going to use this in this presentation. Let's dive into our simulation case. So this is the visual demonstration of how it looks like. We have two stages, two shell commands we're executing here called simulate and the analysis into the simulate stage we input the current profile we pre-computed the case dot star file which is the simulation file and also some parameters we defined. And then at the output we just get the pressure drop out of the simulation and then we feed this into the analysis we compare this to the measurement data we already got from an experiment and we output the temperature distributions for all of the cells and we get a report as an html so this is just a generic example to show you dvc better so how do we actually now do this in code and for most of the simulation data software which is currently on the market this could take like a week a month because you have to grade integrate every software on its own so how do you set up this now for simulation first of all you create the scripts so we have those two scripts that's that's on you and most simulation engineers already have done this and at some point and then we have to initialize our git repository initialize our dvc and then we create the stages in the dvc yaml file and there are three things that are mandatory it's the command it's the dependencies and the output and now we find all of this we've seen in the previous site again here so we have the command, which is Python simulate.py, which executes the Python script here. Then we have to declare our dependencies. So this is the current profile, this is the case.star file, and also our script we're executing. And then we have the output file, which is our pressure drop here as a CSV file. And then we have a second stage called analysis. It also has a command. And then we have a dependency, which is really interesting, which is the pressure drop again. and so now the output of one stage is the input of another stage and this is how dvc knows that there's a dependency between those stages so we don't have to declare the order of execution to dvc but dvc finds it out on their own which is really really nice and then step five profit from this note we can also define input parameters output metrics and plots and i will later go into this in the dvc.yaml file but this is the bare bones and you can get someone started within like four hours using dvc without prior knowledge which is quite a step in the right direction so how is the normal workflow going with dvc is it is built on top of git so we first have to do a git clone or git pull or git checkout and to our commit we want then we do a dvc pull and that pulls all the large files from our DVC remote into our workspace. Then we can call DVC status, which is very similar to the Git status, so we see everything worked. And then we can just go into our simulation software, we go into our script, and we make changes. Then we execute a very special command called DVC Repro. DVC Repro looks at our whole workspace and see what has changed, and then only executes the necessary stages from which have changed. And when it executes the changes, it actually checks if the outputs have changed and then re-executes those stages again. So it's very smart about what to execute. So if you make a change and it will not change the output of something, all the stages after that will not get executed, which is really nice and you don't have to worry about executing specific steps in your pipeline. Just always call dbc-web-pro. And if we've done this, we can really go beyond all of this and this is like doing DVC experiments or execute parameter studies, which are really, really common in simulation engineering. So you can queue, run, and compare your experiments, and you can run them in parallel as well, and DVC takes care of all the data management. So it copies around all of the data, executes everything, grabs everything together, and then you can do a DVC XP show, and then you get a table of all your experiments, and it's really handy to do. And then you check out the best experiment you like the most. And then it's again to the Git workflow. So you do a Git commit. You do a DVC push. And then in the end, and DVC push pushes all of the large files to the DVC remote. And then you do a Git push to push all your Git objects to the Git remote. So how does this look like if you execute DVC exp show? I've brought you here the table. And we can see here all of the, every experiment gets a unique ID, and when it was executed, so those are from some tests I did two years ago, and then we can see here our pressure drop has changed based on some morphing parameters we applied here. And this is, I think, really nice, and we can also add plots here, so if we have a CSV file, we can define the X and the Y axes, and then we can compare those plots as well, And this is just an image I grabbed from the DVC documentation, but I think you get the idea. So, and as a bonus, you can also track your software versions decoratively with those parameters. This is a huge issue in simulation engineering, I think, to, yeah, track your versions and to update your versions you're executing the whole pipeline with. And so you have a namespace in the paramims.yaml file called versions, and then we have a list of, for example, our ANZOR version we are using or star-ccm-plus version we are using. And then in the simulate.py file, we have a function called run star-ccm-plus, and this also takes a version parameter. So it executes the simulation with the given version of that software. And if we've now extracted, and if we have like five steps and three of them, such as the M, is being used, it always uses that version from the params.yaml file. And so, if we now have this decoratively in the params.yaml file, we can run an ETL pipeline every Sunday and get all of the versions we are using of all of the simulation softwares. And we can identify old versions, update them, which is, I think, really nice. And also, if you want to update a new version, we can just change it in one place, do the DVC comparison I've shown you, and then you can actually see if it made a difference or if there's some issue to fix. And even if you're not in simulation engineering, it's a good idea to create a schema for your Paramsort YAML file, because then you can compare across projects, and that's really handy, I think. So, but what if those things are not enough? Then you can do meta studies with JupyterLab, thank you, And DVC. So I've brought you a little snippet of Python code. So in our experiments variable are all the unique strings for all the experiments and we iterate over that. And then we use the DVC API, the Python DVC API to open here the pressure drop.csv with the specified revision. And we can open that as a path object and then put it into pandas or all our favorite tools. and DVC abstracts away all the data management. So it doesn't matter if it's on our local workspace, if it's on the DVC remote in the cloud, or in some cache in between. DVC will give us the path object, download the file, we can analyze it, and it's very handy, and yeah, don't have to care about the data management. So how could this look like? I think there are two really, really good use cases. First of all, you can use really cool and sophisticated algorithms to select your experiments. Here I've just shown you the data envelopment analysis, which I'm a really big fan of. I'm not gonna go into detail how this especially works, but it builds on top of the Pareto optimal analysis. And the second use case is you can do customized visualizing of your experiments with really fancy charts. So for example, if management wants a radar chart, you can make a radar chart. I would not recommend doing a radar chart for obvious, for many reasons, but if somebody wants that, you can easily create this directly from the simulation data in your JupyterLab report. And the core idea behind this, make it a data science problem. So create all of your data set of simulation experiments, go dig deep into that, and then maybe execute new simulations based on that inside data, and then really dig into what is the best, what are the best parameters for your simulation. I think this is a really powerful and good idea. So, last but not least, the last question of any engineer, PowerPoint. So I know NP-Convert and it's really great for standardized reports, but it doesn't deliver the creative freedom of visual storytelling like PowerPoint does. And also PowerPoint is widely used by the team, we don't want to change this. So how does the normal pipeline look like? We have our simulation data, it outputs images, CSV files, metrics, videos, and so on. And then with our corporate PowerPoint template, and then we create the presentation. And that's a one-way street. So after we created the presentation and we have our final PowerPoint presentation, we don't really know where those images came from. And this can be an issue if you want to find out the simulation, where those results came from. And also, if new simulation data comes in and you want to update the presentation and you have 60 slides, that's a lot of work to update all those slides. So this is the normal workflow, I would say, but it's not really ideal. It can be very cumbersome. So how can we improve this in just 200 lines of Python code? So first of all, we have our same setup. we have our simulation which creates the images and so on, and a corporate PowerPoint template, but then we call a Sync Shapes function, and the Sync Shape function basically takes all of your files and then puts them at the end of the presentation, and you can actually name your objects, your shapes in PowerPoint, and gives this unique name inside the PowerPoint file, and this unique name will be kept even if you copy around the shape inside of PowerPoint to, I don't know, three locations, three different slides, or if you crop the picture or whatever, it will always keep the same name. So then later you can reference the shape by that name. And so now we have a custom PowerPoint template. And you can manually update that presentation, no new tooling needed for the engineer, and now we have a customizable and updatable custom PowerPoint template, and we can also manually update it again, it's not a one-way street. But then, if new simulation data comes in with a new best version, I would say, and we already have our final simulation, we can call Sync Shapes again, it will find all the images and all the bar charts and so on and the whole presentation by the name and replace it as in place, and then we have a new presentation which is also manually updatable. And I think this is really nice, and you automate the boring parts of PowerPoint. But you can still, and the team can still keep using PowerPoint, which I think is really the best of both worlds. So in conclusion, I guess everyone in this room is familiar with the term DevOps. I think some of you already know the term MLOps, and I want to coin a new term called SimOps. This is the interdisciplinary paradigm to integrate simulation engineering and data management. So coming from both camps and integrating into a nice solution which worked really well. And I think DVC is currently maybe the only tool but definitely the best tool to do this. And I've loosely defined some criteria. It has to be agnostic regarding simulation software, vendor and environment. It needs to allow automation via APIs and also has to be fast and reliable. Otherwise, yeah, the team will not use it. Now I want to give you a brief outlook for DVC and SimOps in general. We are currently looking for partners, so we have, I think we've shown that DVC is a good tool for simulation data management, but currently we're like just a few companies using it for simulation data management, and it would be nicer to have more stakeholders in this ecosystem and to develop DVC further, sponsor features, get around discussion, what can improve and this is just a list of here and also sim ops in general i think we have some special requirements in simulation engineering and yeah i think we we could really improve this the space here from from the simulation side if you want to know more about dvc and simulation there's a great blog post on their website and from another company doing this with open foam which is another computation fluid dynamics, software, I can really recommend seeing this. So all in all, I think Jordan accomplished the vision, they wanted to iterate faster, they can do this, have more transparency and traceability from the simulation until the PowerPoint, and I think in the future they will replace more and more hardware tests. So to repeat myself, use Python as a control and glue language to automate simulation software. Use DVC to track and manage and compare simulations. Use JupyterLab to create rich comparisons and analyses. And then use Python to sync PowerPoint with new simulation data. And again, if you're in this domain, please reach out. And let's make an open SimOps ecosystem reality. Also, if you know someone who does simulation engineering, tell them about this presentation. I think that we really like it and enjoy it. The more, the merrier, I think. So thank you for listening to my talk. Yeah, you can reach me via these things. And of course, Volkswagen Group is hiring. If you want to be in the middle of the e-mobility transitions in one of the largest companies in the world, yeah, please go talk to me or go to our career website. And yeah, thanks for listening.

Speaker 2 [22:27]

very much for them. I have a few questions here.

Speaker 1 [22:29]

Okay.

Speaker 2 [22:30]

How are optimizers integrated inside DVC? Is it possible to sample new parameter sets inside the loop?

Speaker 1 [22:37]

Yeah, very good question. There is an open GitHub issue on this for integrating optimizers with DVC. I don't know the actual status of that. I think last time I looked, it was like six months ago, and they didn't have an implementation. But I think you could easily integrate it yourself. There is no official standard, but you can integrate it yourself.

Speaker 2 [23:01]

Does DVC do anything for optimising for handling large files like compression for transfer?

Speaker 1 [23:07]

Um, I actually don't know. I don't think so. It will. Yeah, I don't think so. No.

Speaker 2 [23:18]

It's a script to sync files with PowerPoint open source.

Speaker 1 [23:22]

No, yeah, if you have demand for this, please reach out to me and we will see if we can get this open source. Currently it's the very beginning of this and also we're depending on Python PPTX and the maintainer ship is not really that clear and we first want to get like our open source um, uh, uh, uh, pipeline, like, um, there's just, no, it's called, uh, Nifa, Nifa Kata supply chain, the open source supply chain, uh, right. Um, before we build on top of it. Um, but yeah, I've, I think I've given you all of the knowledge you need to know, to re-implement it yourself. It's just like 200 lines of code. And we can talk to this after the wars, but yeah, it would be great to have this open source because I think it's really handy.

Speaker 2 [24:14]

Okay, now a very important question.

Speaker 1 [24:14]

Okay, now.

Speaker 2 [24:16]

If you automate PPT generation, does it mean your manager can permanently stay in meetings?

Speaker 1 [24:24]

Of course, meetings are very important.

Speaker 2 [24:26]

Yeah, so it's open source. I had this already if they are something to sell the to self-host DVC Just like it lab or kit and you self-host this DVC thing. Yes

Speaker 1 [24:37]

Yes, so DVC is just a command line tool, so there's no hosting on your side, and the DVC remote is just an S3 bucket or Azure Blob storage or an SSH server or just a folder on your file system, so you don't need to really host something.

Speaker 2 [24:55]

Okay, why not be more latex latex

Speaker 1 [24:59]

Because I'm a big lover of LaTeX. Don't do this as much anymore, but during my studies, I did that a lot more. Yeah, it's about the visual storytelling aspect, and if you really have to do presentations, it's not always the best tool, or it takes longer to make those really nice presentations. And also, yeah, the team doesn't use it. And one of the most important rules if you want to do something like this, don't change the workflow of the team that much if you're going to do change projects. But LaTeX is really nice.

Speaker 2 [25:37]

Is DVC used in academia?

Speaker 1 [25:40]

I guess so, yeah. So it's really widely used, so I think it's also used in academia.

Speaker 2 [25:46]

And now how does the sink shape work? Can you show an example?

Speaker 1 [25:50]

No, I can't. But yeah, basically, yeah. Like I said, I can repeat this again, go a little bit more detail. Basically, you can name your shapes in the PowerPoint and then it makes the index of all the shapes in the PowerPoint file. If a certain key doesn't exist, it puts it at the end. And if the key already exists somewhere in the PowerPoint, will replace every all the shapes and then you just have to do some mangling if it's a graph or if it's an image and so on

Speaker 2 [26:27]

coming in uh a dvc versus snake make do you know snake make i

Speaker 1 [26:31]

I don't know SnakeMake, but yeah, it could be interesting. Maybe there are more projects in the MLOps space, but I think DVC is really battle-tested and also very flexible, so that's also for, I have to look into it.

Speaker 2 [26:48]

Are you involved in the DVC development?

Speaker 1 [26:51]

No, not right now. We are in talk with the maintainers, but currently we don't have a business relationship.

Speaker 2 [27:02]

Okay, I think that's it in terms of questions. Thank you very much for this very interesting talk. Thank you.

Julian Wagenschütz

About — in the speaker's own words

I am a simulation engineer developing sustainable battery system platforms at Volkswagen. I have been working on battery systems since 2016, starting in Formula Student. There, I created an open source library for analyzing vehicle control unit data with a Pandas-like interface called CANdas. I hold a master's degree in mechanical engineering with a strong focus on simulation and data management. I am always on the lookout to improve simulation workflows using Python.

Social card for talk: There is a Better Way to Automate and Manage Your (Fluid) Simulations