OGSTools Framework - Quick Start#

This is a condensed version of the OGSTools workflow.

Workflow: Setup → Compose → Run → Analyze → Store

For detailed explanations of each step, see OGSTools Framework - Complete Workflow Guide.

import tempfile
from pathlib import Path

import ogstools as ot
from ogstools.examples import load_meshes_simple_lf, load_project_simple_lf

1. Setup: Load Project and Meshes#

project = load_project_simple_lf()
meshes = load_meshes_simple_lf()

model = ot.Model(project=project, meshes=meshes)
# Visualize setup with boundary conditions
fig = model.plot_constraints()
plot framework short

2. Run: Execute Simulation#

sim = model.run()
print(f"Simulation status: {sim.status_str}")
Simulation status: Status: completed successfully (results available)

3. Analyze: Visualize Results#

# Plot final pressure distribution
fig = ot.plot.contourf(sim.meshseries[-1], "pressure")
plot framework short

Plot simulation time

df_ts = ot.logparser.analysis_time_step(sim.log.df_log).reset_index()
times = ["assembly_time", "dirichlet_time", "linear_solver_time"]
df_ts.plot.area(x="time_step", y=times, ylabel="time / s", grid=True)
plot framework short
<Axes: xlabel='time_step', ylabel='time / s'>

4. Store: Save Simulation#

tmp = Path(tempfile.mkdtemp())
sim.save(tmp / "mysim", archive=True)
[]

Next Steps#

Total running time of the script: (0 minutes 0.860 seconds)