This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
OSPSuite.SimModel is the ODE-based calculation engine for PK/PD models built with PK-Sim or MoBi (Open Systems Pharmacology). It consists of a C++ native simulation kernel wrapped by a .NET managed layer via P/Invoke, packaged as a unified multi-platform NuGet package.
# 1. Restore native NuGet packages (required before first C++ build)
nuget restore packages.config -PackagesDirectory packages
# 2. Build the C++ native library (use VS Developer Command Prompt or ensure msbuild is on PATH)
msbuild src/OSPSuite.SimModelNative/OSPSuite.SimModelNative.vcxproj /p:Configuration=Release /p:Platform=x64 "/p:SolutionDir=$(pwd)/"
# 3. Build the .NET managed layer and tests
dotnet build OSPSuite.SimModel.sln --configuration ReleaseThe C++ vcxproj projects require MSBuild (not dotnet build). The .NET projects can be built with dotnet build. CI creates a .NetOnly.sln (with C++ projects removed) for the managed build step.
./buildNix.sh Linux # or MacOSThis runs CMake + make for the native library, then dotnet build and dotnet test for the managed layer.
# .NET tests (NUnit, BDD-style)
dotnet test tests/OSPSuite.SimModel.Tests/OSPSuite.SimModel.Tests.csproj --configuration Release
# C++ unit tests (Google Test) — requires SimModelNative to be built first
msbuild tests/OSPSuite.SimModelNative.Tests/OSPSuite.SimModelNative.Tests.vcxproj /p:Configuration=Release /p:Platform=x64 "/p:SolutionDir=$(pwd)/"
Build/Release/x64/OSPSuite.SimModelNative.Tests.exeHeaders in include/SimModel/, sources in src/. Namespace: SimModelNative.
Core classes:
Simulation— orchestrates loading XML, managing entities, running the ODE solver, collecting resultsDESolver— wraps CVODES (Adams/BDF methods, sensitivity analysis, band linear solver)- Formula hierarchy —
Formulabase with ~20 subtypes (ExplicitFormula,TableFormula,IfFormula, etc.) loaded from XMLFormulaList Species(ODE state variables),Parameter,Observer(computed outputs),Switch(events)PInvokeSimulation.h/PInvokeQuantity.h— flatextern "C"API exported for .NET interop
Platform abstraction:
OSPSuite.SysTool— dynamic library loading, file system helpersOSPSuite.XMLWrapper— MSXML6 on Windows, libxml2 on Linux/macOSSIM_EXPORTmacro:__declspec(dllexport)on Windows, empty elsewhere
Target: net10.0. All P/Invoke uses CallingConvention.Cdecl.
Simulation.cs— main public API. Lifecycle:LoadFromXMLFile/LoadFromXMLString→ set variable parameters/species →FinalizeSimulation→RunSimulation→ read resultsNativeLibraryPreload.cs—[ModuleInitializer]that preloads transitive native dependencies (FuncParserNative,SimModelSolver_CVODES) viaNativeLibrary.LoadSimModelImportDefinitions.cs— DLL name constant for[DllImport]
- OSPSuite.SimModelSolver_CVODES — SUNDIALS CVODES ODE solver (native + managed wrapper)
- OSPSuite.FuncParser — mathematical formula parser (native + managed wrapper)
- OSPSuite.Utility — shared .NET utilities
Git submodules (clone with --recursive):
src/OSPSuite.SimModelSolverBase— abstract solver interface (ISolverCaller)schema/— XSD schema for SimModel XML format
Native binaries go to Build/<Configuration>/x64/ on Windows, or runtimes/<rid>/native/ for NuGet packaging. The unified nupkg includes native binaries for win-x64, linux-x64, and osx-arm64.
- .NET tests use
OSPSuite.BDDHelperwithContextSpecification<T>pattern. Test classes inherit fromconcern_for_Simulationand follow theBecause/should_*naming convention. XML test fixtures live intests/TestData/. - C++ unit tests (
tests/OSPSuite.SimModelNative.Tests/) use Google Test with two distinct build modes:- MSBuild (Windows): The
.vcxprojlists every SimModelNative.cppas aClCompileitem, compiling the sources directly rather than linking against the DLL. This gives tests access to non-exported internal classes. Uses NuGet packageMicrosoft.googletest.v140.windesktop.msvcstl.static.rt-dyn. - CMake (Linux/macOS):
CMakeLists.txtdoes not recompile SimModelNative sources; instead it links against the pre-builtlibOSPSuite.SimModelNative.${EXT}shared library whose location is supplied bybuildNix.shvia theSIMMODEL_NATIVE_DIRvariable. GoogleTest is fetched at configure time viaFetchContent.
- MSBuild (Windows): The
Version is defined in src/OSPSuite.SimModelNative/version.h with placeholder values (0.0.0.0). CI replaces these with the actual version (currently 5.0.0.<build_number>).
- macOS Intel (x86_64) support was dropped; only arm64 is supported
- The
ProduceReferenceAssemblyis disabled in the .NET csproj to avoid a race condition in mixed C++/C# parallel builds (see comment in csproj) - Native NuGet packages (from
packages.config) are separate from .NET NuGet packages and must be restored withnuget restore, notdotnet restore