How to Debug CADET on Windows with Visual Studio

I thought I’d turn this into it’s own post to make it easier to find it.
Here’s a guide on how to Debug CADET on Windows with Visual Studio

  1. Set up your Visual Studio to build cadet
  2. Create a launch.vs.json file in the cadet root directory with the following contents, where you only need to modify :
    a. the "args" field to contain the path to the simulation .h5 file and
    b. the "name". You can have multiple alternative debug configurations defined here.
{
  "version": "0.2.1",
  "defaults": {},
  "configurations": [
    {
      "type": "default",
      "project": "CMakeLists.txt",
      "projectTarget": "cadet-cli.exe (Install) (bin\\cadet-cli.exe)",
      "name": "debug simulation A",
      "args": [
        "C:\\Users\\Path\\To\\Simulation_A.h5"
      ]
    },
    {
      "type": "default",
      "project": "CMakeLists.txt",
      "projectTarget": "cadet-cli.exe (Install) (bin\\cadet-cli.exe)",
      "name": "debug simulation B",
      "args": [
        "C:\\Users\\Path\\To\\Simulation_B.h5"
      ]
    }
  ]
}
  1. At the top of the VS Window, set the Configuration to DEBUG and wait for the CMake cache to regenerate.
  2. At the top of the VS Window, next to the solid green triangle pointing right, where it says “Select Startup Item” is a small dropdown menu.
    image
    There you can select the configurations you created in the launch.vs.json. Now the bar at the top of VS should look like this:
    image
    If you can’t select your configuration, the most common reason is, that the CMake cache needs to be rebuilt.
  3. Place a breakpoint where you want to break the simulation. This is done by clicking the grey area next to the line numbers in the code editor, like this:
    image
  4. Click on debug simulation A (or however you called the configuration) to start the debugger.
  5. If the debugger does not break at your breakpoints, use file explorer to find the files you want to break at in the folder build\src\libcadet, drag those into VS and set breakpoints there.
3 Likes

If you need to quickly turn a CADET-Process process into an HDF5 file for debugging, you can use the simulator.save_to_h5() function, as in this example by @ortler

from CADETProcess.simulator import Cadet

from examples.batch_elution.process import process

simulator = Cadet()

simulator.save_to_h5(process, r"Path\to\where\to\save\the\simulation\sim.h5")
1 Like