OpenGeoRock
2.12

Reports, scripting and the command line

Describes OGR Slip2D 0.1.235

Results leave the program as a PDF report, images, prints and DXF drawings. The program can also be run without the mouse, from the Python terminal inside the window, the command line, the Python API or an AI agent connected through the MCP server. The last three have their own reference chapters; here they are introduced from the point of view of the desktop program.

2.12.1The PDF report#

File → Generate Report… writes an A4 PDF of the last Compute, with every method it ran; without a Compute it refuses, with a message. The file name proposed is the project's name followed by _report.pdf. The report has eight sections:

  1. Project Summary: title, file, author, company, dates and comments;
  2. General Settings: units, time and permeability units, failure direction;
  3. Analysis Options: the methods, number of slices, tolerance and maximum iterations, and the surface options;
  4. Material Properties;
  5. Global Minimums: for each method, the factor of safety and the critical surface (centre and radius for a circle, the two end points, the total slice area);
  6. Valid / Invalid Surfaces: the counts per method, with the generation attempts;
  7. Slice Data of the critical surface of each method;
  8. List of Coordinates of the boundaries.

The title, author and company come from Analysis → Project Settings → Project Summary.

Before you send a report (version 0.1.235)
  • A new project carries the program author's name and institution as its default Author and Company in Project Summary. Replace them, or the report will name someone else.
  • The report contains tables only, no drawing of the model; add one with File → Export Image….
  • It does not include the analysis notes, and it does not record a design standard: with one applied, the value it labels Factor of Safety (FS) is an over-design factor (Section 2.11).
  • Its footer states the licence as GPL-3.0; the program is licensed under AGPL-3.0-or-later.

2.12.2Images#

  • File → Export Image… writes a PNG of everything drawn in the model view (the whole extent, not only the part on screen) on a white background. It asks for the Width in pixels (1920 by default; 200 to 12 000); the height follows from the proportions of the model.
  • Edit → Copy Image copies the view as it is on screen to the clipboard, as a bitmap.
  • The Interpret window has its own File → Export Image… (PNG or JPEG of its view) and Edit → Copy Image (Section 2.8).
Note

Edit → Picture Format offers Bitmap and Vector (SVG), but in version 0.1.235 the choice has no effect: Copy Image always places a bitmap on the clipboard.

2.12.3Printing#

File → Page Setup… chooses the paper and margins, and File → Print Preview… shows the whole model drawn on that page; print from the preview window. In version 0.1.235 File → Print… (Ctrl+P) only displays a message.

2.12.4DXF drawings#

File → Export DXF… writes the model to a DXF drawing for CAD. The dialog sets the unit of the coordinates (m, cm, mm, km, ft or in; the model is in metres and the unit is recorded in the file), the Load arrow size as a percentage of the model diagonal (2 %), and what to include: Boundaries (geometry), Supports, Loads (as arrows), Finite element mesh (off by default, as it writes one line per element edge), Critical slip surface (after a Compute) and Annotations (title, factor of safety). The geometry goes to the layers the DXF importer recognises, so the drawing can be edited and imported back; loads, mesh, slip surface and annotations go to separate layers whose names start with OGR_X_, which the importer ignores, so a load arrow cannot come back as a boundary. Importing a DXF is described in Section 2.2.

2.12.5The Python terminal#

Window → Terminal (Ctrl+`) opens a Python console inside the window, connected to the live model. These names are defined in it:

Table 2.12.1 Names available in the terminal.
NameWhat it is
projectThe project open in the window, which is the same object you are editing. It follows New Project, Open Project and Load Demo Slope.
canvasThe model view.
mainwindowThe main window.
ogr_core, ogr_slip2dThe model and analysis packages.
npNumPy.
help_ogr()Prints these names, a few examples and the keys.

Enter runs the input, Shift+Enter starts a new line of the same input, Ctrl+↑ and Ctrl+↓ move through the history, and Ctrl+L clears the console. To run the analysis as the project is configured, as Compute does, use the analysis runner:

>>> [m.name for m in project.materials]
>>> from ogr_slip2d.analysis_runner import run_analysis
>>> out = run_analysis(project)            # the methods enabled in the project
>>> {mid: r.critical.fos for mid, r in out.results.items() if r.critical}
>>> out.warnings                           # the analysis notes
Note

Changes made to project from the terminal do not go through Edit → Undo, and the view is not redrawn by itself: call canvas.refresh_scene(). A calculation started here runs in the window's own thread, so the window waits until it ends. A search built by hand from its class, as in the example of help_ogr(), uses that class's defaults, not the project's settings; run_analysis uses the project's.

2.12.6The command line#

ogr-slip2d-cli runs a saved project without opening the window. It computes the analysis the project describes, through the same runner as the desktop program; each option overrides one setting of the project in memory, and the file is not modified.

Table 2.12.2 Commands of ogr-slip2d-cli. The full reference is Section 5.2.
CommandWhat it does
info project.ogrA summary of the project and its materials.
compute project.ogrRuns the analysis, prints every note and a table of the critical value of each method, and saves each method's result as HDF5 (project.h5, or one file per method). Options: --method, --slices, --nx, --ny (grid intervals), --dr (Radius Increment), --search, --samples (Number of Surfaces of the Slope, Block and Path searches) and --output.
methodsThe nine methods with the equilibrium each satisfies.
strength-modelsThe strength models and their parameters.
new-demo out.ogrSaves the demo slope as a project.

A project the analysis cannot honour is refused with its reasons and exit code 3, as Compute refuses it in the window. Version 0.1.235 has no command-line command for the statistical analyses. --search takes the search ids grid, slope, auto_refine, block, path, simulated_annealing and particle_swarm; an id it does not recognise is not refused, and the run falls back to a Grid Search.

2.12.7Python API#

The packages of the program can be imported from Python. The shortest way to analyse a saved project is the same runner the window and the command line use:

from ogr_core.project import Project
from ogr_slip2d.analysis_runner import run_analysis

project = Project.load("slope.ogr")
out = run_analysis(project)        # refuses, with reasons, what Compute refuses
for method_id, result in out.results.items():
    crit = result.critical
    print(method_id, crit.fos if crit else "no valid surface")
for note in out.warnings:
    print("Note:", note)

For building and editing models from code, the operations layer ogr_api offers the same operations as the tools of the MCP server, with validation, undo and long runs as background jobs; the repository's examples/ folder has a worked script. The Python API is described in Section 5.3.

2.12.8AI agents#

The MCP server, ogr-slip2d-mcp, lets an AI agent build, run and read models through the same operations (it needs the [mcp] extra; see Section 1.1). When it starts, the desktop program opens an agent bridge (Tools → Agent bridge (MCP)) that accepts local connections only and requires a token, so that a server started with ogr-slip2d-mcp --attach works on the open window: every edit the agent makes appears on screen and can be undone. Start the program with ogr-slip2d --no-agent-bridge, or untick the menu item, to keep agents out. How to connect an agent is explained on the AI & MCP page, and every tool is listed in Section 5.1.