Skip to content

CLI and export

The tango_core entry point and result files.

tango_core.cli

tango_core — command-line entry point for tango simulations.

Usage examples

Run a simulation and save its results (--save-dir or --no-save is required)::

tango_core run templates/hydro_sf_electric.yml --save-dir results/

Run with debug logging, saving nothing::

tango_core run templates/hydro_sf_electric.yml --no-save --log-level DEBUG

Validate an input file without running::

tango_core validate templates/hydro_sf_electric.yml

Print version::

tango_core --version

Copy the bundled templates into a local directory to start from::

tango_core init my_project

main()

Entry point registered as tango_core in pyproject.toml.

tango_core.results_export

Write a completed Workflow's results to disk as three files.

tango_core run --save-dir DIR is the only caller today. Three files, matching old tango's own summary/economic split, plus one new one tango didn't have before:

  • <stem>.results.yml: the full results, via Workflow.to_file() -- every component's complete config AND final solved state/history, reloadable with Workflow.from_file() for further analysis. This is the authoritative, complete record. The .results part keeps it from having the same name as the input file it came from.
  • <stem>.smry.csv: one row per step end time, one column per <component>_<field> for every SCALAR (not spatially-resolved) history field across all components -- a flat, spreadsheet-friendly view of how the run evolved. Deliberately excludes spatially-resolved fields (e.g. NumericalWellHistory.T_cells, one list per timestep) since those don't fit a flat per-timestep table; the full .yml output above is where that detail lives.
  • <stem>.econ.csv: one row, every field of the economic component's final state (CAPEX/LCOE/net power/...) -- omitted entirely if the config has no economic: block, since there's nothing to write.

Every CSV column header ends in its unit, e.g. production_well_T_outlet [K] ([-] for a dimensionless quantity), from FIELD_UNITS.

An external simulator's own output files go next to these, in <stem>.raft/ for a RAFT subsurface; keep_external_outputs sets that up before the run.

FIELD_UNITS = {'T_inlet': 'K', 'T_outlet': 'K', 'T_reservoir_initial': 'K', 'P_inlet': 'Pa', 'P_outlet': 'Pa', 'P_reservoir': 'Pa', 'P_tespy_inlet': 'Pa', 'h_inlet': 'J/kg', 'h_outlet': 'J/kg', 'mass_rate': 'kg/s', 'rho': 'kg/m^3', 'mu': 'Pa s', 'velocity': 'm/s', 'dP_pipe': 'Pa', 'delta_p_darcy': 'Pa', 'delta_p_friction': 'Pa', 'delta_p_hydrostatic': 'Pa', 'pump_delta_p': 'Pa', 'Re': '-', 'friction_factor': '-', 't_d': '-', 'impedance': 'Pa s/kg', 'psi': '-', 'gamma': '-', 'p1': '-', 'p2': '-', 'p3': '-', 'energy_extraction_rate': 'W', 'energy_extracted': 'J', 'heat_extracted_watts': 'W', 'mass_rate_inlet': 'kg/s', 'mass_rate_outlet': 'kg/s', 'trial_solves': '-', 'solve_seconds': 's', 'accepted_steps': '-', 'attempts': '-', 'cut_extrapolation': '-', 'cut_newton': '-', 'constraint_switches': '-', 'dt_min_proceeds': '-', 'ever_solved': 'bool', 'pump_power_watts': 'W', 'net_power_W': 'W', 'net_thermal_W': 'W', 'CAPEX_well': 'USD', 'CAPEX_permitting': 'USD', 'CAPEX_exploration': 'USD', 'CAPEX_surface_pipes': 'USD', 'CAPEX_surface_plant': 'USD', 'CAPEX_total': 'USD', 'LCOE': 'USD/kWh', 'specific_investment_cost': 'USD/kW', 'OPEX': 'USD/yr'} module-attribute

Unit of every field written to the CSVs, keyed by field name (no component prefix).

A field missing here raises KeyError when the CSVs are written, so a new history or economic field can't reach a CSV without a unit.

keep_external_outputs(wf, save_dir, stem)

Have each RAFT subsurface keep its own output files (VTKs, flow logs) in save_dir.

Call before wf.run(). With one RAFT component the directory is <stem>.raft/; with several, <stem>.<component>.raft/.

Returns:

Type Description
list[Path]

The directories RAFT will write into.

write_results(wf, save_dir, stem)

Write <stem>.results.yml/.smry.csv/.econ.csv into save_dir.

Parameters:

Name Type Description Default
wf Workflow

A Workflow whose run() has already completed.

required
save_dir Path

Directory to write into; created if it doesn't exist.

required
stem str

Base filename (no extension) -- typically the input YAML's own stem.

required

Returns:

Type Description
list[Path]

Paths actually written, in the order listed in this module's own

list[Path]

docstring.

tango_core.utils

Small helpers shared by the sweep and optimization scripts in applications/.

print_datetime()

Print the current datetime (YYYY-MM-DD HH:MM:SS) on its own line.