PinchWorkspace
OpenPinch.classes.pinch_workspace.PinchWorkspace is the public
multi-case interface in OpenPinch. It keeps named study cases, but each case
still resolves to a real PinchProblem
instance for targeting, plotting, summaries, export, and advanced workflows.
It also exposes a second surface for serializable variant views that are useful
for applications or frontend-oriented comparisons.
When To Use It
Use PinchWorkspace when you want:
named baseline-versus-variant study cases
script or notebook comparisons without rebuilding case-input helpers
case copying, input editing, and bundle save/load in one object
the normal
PinchProblemworkflow on each case once it is selectedserializable comparison views in addition to live
PinchProblemobjects
Lifecycle
The typical lifecycle is:
construct the workspace from input data, an existing
PinchProblem, or a packaged sample-case nameuse
case(...)oruse_case(...)to work with the activePinchProblemclone cases with
copy_case(...)and mutate them withupdate_options(...)orset_dt_cont_multiplier(...)compare cases with
compare_cases(...)or solve serializable views withsolve_variant(...)persist the study with
save_bundle(...)
Core Workflow Members
The main user-facing workflow members are case(), use_case(),
copy_case(), list_cases(), get_case_payload(),
update_options(), set_dt_cont_multiplier(), compare_cases(),
solve_variant(), compare_variants(), save_bundle(), and
load_bundle().
Workflow Names and Support Levels
solve_variant() accepts the same high-level workflow names exposed on
problem.target.* after normalizing case, hyphens, and spaces.
- Stable workflows
target,direct_heat_integration,indirect_heat_integration- Advanced workflows
direct_heat_pump,indirect_heat_pump,direct_refrigeration,indirect_refrigeration,cogeneration,area_cost
The advanced workflows are supported, but the workspace marks them as advanced explicitly so consuming applications can surface that distinction.
Typical Pattern
from OpenPinch import PinchWorkspace
workspace = PinchWorkspace(
source="crude_preheat_train.json",
project_name="crude_preheat_train",
)
baseline = workspace.case("baseline")
workspace.copy_case("baseline", "wide_dt", activate=False)
workspace.set_dt_cont_multiplier(0.5, case_name="wide_dt")
comparison = workspace.compare_cases("baseline", "wide_dt")
For application-style usage:
view = workspace.solve_variant(
"baseline",
workflow="indirect_heat_integration",
)
comparison_view = workspace.compare_variants(["baseline", "wide_dt"])
PinchWorkspace API
- class OpenPinch.classes.pinch_workspace.PinchWorkspace(source=None, *, project_name='Site', baseline_name='baseline')[source]
Bases:
objectManage multiple named
PinchProblemcases with a script-native API.- Parameters:
source (TargetInput | JsonDict | PathLike | tuple[PathLike, PathLike] | PinchProblem | None)
project_name (Optional[str])
baseline_name (str)
- classmethod load_bundle(path)[source]
Load a previously persisted workspace bundle.
- Parameters:
- Return type:
- load(source, *, case_name=None, activate=True, project_name=None)[source]
Load or replace a named case and return a live validated case.
- get_variant_payload(name)[source]
Return a defensive copy of one stored payload.
- payload_view(name)[source]
Return a frontend-friendly editable payload view.
- Parameters:
name (str)
- Return type:
VariantPayloadView
- validate_variant(name)[source]
Return a structured validation report for one payload.
- Parameters:
name (str)
- set_variant_payload(name, payload, *, base=None)[source]
Create or replace one stored payload.
- solve_variant(name, *, workflow='target', workflow_options=None)[source]
Solve one case and return a serializable frontend-facing view.
- compare_variants(variant_names=None, *, base=None)[source]
Return deterministic comparison payloads across solved variants.
- case(name=None)[source]
Return the live
PinchProblemfor one named case.- Parameters:
name (str | None)
- Return type:
- copy_case(source_name, new_name, *, activate=False)[source]
Clone one existing case into a new named case.
- Parameters:
- Return type:
- get_case_payload(name=None, *, canonical=True)[source]
Return one case payload, optionally normalised to canonical form.
- to_problem_json(*, case_name=None, canonical=True)[source]
Return the payload for one case using
PinchProblemnaming.
- property target
Delegate the
targetaccessor to the active case.
- property plot
Delegate the
plotaccessor to the active case.
- property problem_data
Return the active case payload.
- property problem_filepath
Return the active case filepath when available.
- property results
Return the active case results when available.
- property master_zone
Return the active case master zone when available.
- summary_frame(*, case_name=None, detailed=False)[source]
Return the solved summary for one case.
- export_excel(results_dir=None, *, case_name=None)[source]
Export one case to an Excel workbook.
- set_dt_cont_multiplier(value, *, zone_name=None, case_name=None)[source]
Update one case multiplier and keep the stored payload in sync.
- update_options(options, *, case_name=None, replace=False)[source]
Update one case’s options and keep the stored payload in sync.
- show_dashboard(*, case_name=None, zone=None, graph_payload=None, page_title='OpenPinch Dashboard', value_rounding=2)[source]
Launch the dashboard for one case.
- compare_to(other_problem, *, case_name=None, other_case_name=None, target_name=None, base_label='Base case', other_label='Scenario')[source]
Compare one workspace case to another problem or workspace case.
- compare_cases(base_case, other_case, *, target_name=None, base_label=None, other_label=None)[source]
Compare two cases in the same workspace.
- save_bundle(path)[source]
Persist the current workspace, syncing any live case edits first.
Relationship To PinchProblem
PinchWorkspace is not a second solver. It orchestrates multiple named
case inputs and live PinchProblem cases on top of the same validation,
preparation, targeting, graph, export, and stateful workflow surfaces
documented for PinchProblem.
Use PinchProblem when you only need one case at a time. Use
PinchWorkspace when the study itself has to remember multiple named cases.