pystclient is a Python client library for Simulation Trust Center (STC).
It provides a convenient, typed Python API for interacting with STC backend,
so you can manage simulation projects and run simulations directly from Python
scripts, notebooks, or CI pipelines without having to call the underlying
HTTP API by hand.
pystclient supports:
- Authentication — interactive OAuth2 authorization-code flow via Veracity Identity with automatic token caching and refresh.
- Project management — create, configure, list, and delete STC projects; manage their FMU model selections, parameter sets, variable connections, and logging configuration.
- Simulator lifecycle management — provision (create) one or more simulators from a simulation configuration, wait for readiness, and start, stop, or terminate them.
- Simulator control & monitoring — query simulator status, start/stop result recording, and gracefully end running simulations.
- Retrieving simulation data — list per-instance measurement records, query time-series variable data over arbitrary time windows, and iterate through simulation results in configurable time steps.
pip install git+https://github.com/dnv-opensource/pystclient.gitfrom pystclient.clients import PyStclient
# Authenticate and create a client instance
client = PyStclient()
# If you want to use interactive login (browser-based OAuth2):
client.authenticate() # This will prompt for login if needed
# Now you can use the client to interact with STC
projects = client.list_projects()
print(projects)The following example runs a single non-interactive distributed simulation using a Spring-Mass-Damper project that has already been configured on the STC platform. A simulation is non-interactive when the simulator runs to completion without user intervention (create → run → finish).
import time
from pystclient.clients import PyStclient
from pystclient.models import (
LoggingConfiguration,
ModelParameters,
ModelVariable,
SimulationConfig,
SimulationParameters,
)
from pystclient.types import SimulationType
# 1 — Authenticate
client = PyStclient()
client.authenticate()
# 2 — Select an existing project
projects = client.project.info_all()
project = next(p for p in projects if p.name == "Spring-Mass-Damper")
# 3 — Configure simulation parameters
sim_params = SimulationParameters(
base_step_size=0.01,
end_time=20,
config_name="Config 1",
model_parameters=[
ModelParameters(
name="Mass1",
step_size=0.02,
parameters=[ModelVariable(name="absTolerance", initial_value=2e-4)],
),
ModelParameters(
name="Spring1",
parameters=[ModelVariable(name="absTolerance", initial_value=2e-4)],
),
ModelParameters(
name="Damper1",
parameters=[ModelVariable(name="absTolerance", initial_value=2e-4)],
),
],
)
client.project.update_parameters(project.id, sim_params)
# 4 — Enable post-plotting so results are persisted
client.project.update_log_config(
project.id, LoggingConfiguration(post_plotting=True)
)
# 5 — Create a non-interactive distributed simulator and wait until it is ready
statuses, future = client.simulator.create(
SimulationConfig(
project_id=project.id,
parameter_set_names=["Config 1"],
type=SimulationType.DISTRIBUTED,
)
)
simulator_id = statuses[0].id
assert future.result(600), "Simulator did not become ready in time!"
# 6 — Poll until the simulation finishes
while not client.simulator.finished(simulator_id):
s = client.simulator.status(simulator_id)
print(f" simulation_time={s.simulation_time} end_time={s.end_time}")
time.sleep(1)
print("Simulation finished.")Once a simulation has completed, you can retrieve it from the list of completed simulations and query time-series data for plotting with matplotlib:
import time
import matplotlib.pyplot as plt
from pystclient.models import MeasurementQuery, QueryVariable, SimulationInfo
from pystclient.types import FmuCausalityType
from pystclient.utils.time import convert_to_timestamp
# Wait for the simulation to appear in the completed list
completed_simulations: list[SimulationInfo] = []
while len(completed_simulations) != 1:
completed_simulations = client.project.completed_simulations(
project_id=project.id,
simulator_ids=[simulator_id],
limit=10,
)
time.sleep(5)
sim = completed_simulations[0]
print(f"Simulation {sim.id} name={sim.name} param_set={sim.parameter_set_name}")
# Retrieve measurements and query specific variable data
sim_measurements = client.measurement.measurements(project.id, sim.id)
assert sim_measurements, "No measurements found!"
measurement = sim_measurements[0]
q = MeasurementQuery(
variables=[
QueryVariable(
instance_name="Spring1",
name="dis_yx",
causality=FmuCausalityType.INPUT,
)
],
time_from=0,
time_to=10,
)
results = client.measurement.query(measurement.id, q)
# Plot the displacement data
fig, ax = plt.subplots(figsize=(10, 5))
for result in results:
x = convert_to_timestamp(result.x)
ax.plot(x, result.y, label=f"{sim.parameter_set_name}")
ax.set_xlabel("Time [s]")
ax.set_ylabel("Displacement [m]")
ax.set_title("Spring-Mass-Damper — Spring Displacement (dis_yx)")
ax.legend()
plt.tight_layout()
plt.show()See also: For complete, runnable notebooks check the
examples/directory.
The pystclient command-line interface supports the following options:
| Option | Description |
|---|---|
-c, --config <file> |
Name of the file containing the pystclient configuration. Optional. |
--login |
Login to Veracity Identity to retrieve and store an access token to a local cache. Mutually exclusive with --delete-token. Required unless --delete-token is used. |
--delete-token |
Delete an access token stored in a local cache. Mutually exclusive with --login. Required unless --login is used. |
-q, --quiet |
Console output will be quiet (sets log level to ERROR). Mutually exclusive with --verbose. |
-v, --verbose |
Console output will be verbose (sets log level to INFO). Mutually exclusive with --quiet. |
--log <file> |
Name of log file. If specified, activates logging to file. Optional. |
--log-level <level> |
Set a specific log level for file logging. Choices: DEBUG, INFO, WARNING, ERROR, CRITICAL. Default: WARNING. |
For more examples and usage, please refer to pystclient's documentation.
This project uses uv as package manager.
If you haven't already, install uv, preferably using it's "Standalone installer" method:
..on Windows:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"..on MacOS and Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh(see docs.astral.sh/uv for all / alternative installation methods.)
Once installed, you can update uv to its latest version, anytime, by running:
uv self updateClone the pystclient repository into your local development directory:
git clone https://github.com/dnv-opensource/pystclient path/to/your/dev/pystclientChange into the project directory after cloning:
cd pystclientRun uv sync -U to create a virtual environment and install all project dependencies into it:
uv sync -UNote: Using
--no-devwill omit installing development dependencies.
Explanation: The
-Uoption stands for--update. It forcesuvto fetch and install the latest versions of all dependencies, ensuring that your environment is up-to-date.
Note:
uvwill create a new virtual environment called.venvin the project root directory when runninguv sync -Uthe first time. Optionally, you can create your own virtual environment using e.g.uv venv, before runninguv sync -U.
When using uv, there is in almost all cases no longer a need to manually activate the virtual environment.
uv will find the .venv virtual environment in the working directory or any parent directory, and activate it on the fly whenever you run a command via uv inside your project folder structure:
uv run <command>However, you still can manually activate the virtual environment if needed.
When developing in an IDE, for instance, this can in some cases be necessary depending on your IDE settings.
To manually activate the virtual environment, run one of the "known" legacy commands:
..on Windows:
.venv\Scripts\activate.bat..on Linux:
source .venv/bin/activateThe .pre-commit-config.yaml file in the project root directory contains a configuration for pre-commit hooks.
To install the pre-commit hooks defined therein in your local git repository, run:
uv run pre-commit installAll pre-commit hooks configured in .pre-commit-config.yaml will now run each time you commit changes.
pre-commit can also manually be invoked, at anytime, using:
uv run pre-commit run --all-filesTo skip the pre-commit validation on commits (e.g. when intentionally committing broken code), run:
uv run git commit -m <MSG> --no-verifyTo update the hooks configured in .pre-commit-config.yaml to their newest versions, run:
uv run pre-commit autoupdateTo test that the installation works, run pytest in the project root folder:
uv run pytestA THIRD_PARTY_LICENSES file that aggregates the license texts of all
runtime dependencies can be generated by running:
pip-licenses --with-license-file --no-license-path --output-file THIRD_PARTY_LICENSESNote:
pip-licensesreports licenses of packages that are installed in the current environment. Make sure your project dependencies are installed (e.g. viauv sync) before running the command, otherwise the generated file will be empty or incomplete.
Using uv:
uv run pip-licenses --with-license-file --no-license-path --output-file THIRD_PARTY_LICENSESThis project is licensed under the Mozilla Public License, v. 2.0 (MPL‑2.0).
A copy of the license is included in the LICENSE file. You may also obtain a copy at https://mozilla.org/MPL/2.0/.
Copyright (c) 2026 DNV AS. All rights reserved.
pystclient is developed by DNV Group Research and Development in collaboration with DNV Maritime.
All code in pystclient is DNV intellectual property of DNV.
Hee Jong Park - @LinkedIn - hee.jong.park@dnv.com
Claas Rostock - @LinkedIn - claas.rostock@dnv.com
- Fork it (https://github.com/dnv-opensource/pystclient/fork)
- Create an issue in your GitHub repo
- Create your branch based on the issue number and type (
git checkout -b issue-name) - Evaluate and stage the changes you want to commit (
git add -i) - Commit your changes (
git commit -am 'place a descriptive commit message here') - Push to the branch (
git push origin issue-name) - Create a new Pull Request in GitHub
For your contribution, please make sure you follow the STYLEGUIDE before creating the Pull Request.