tespy.models package

tespy.models.template module

class tespy.models.template.ModelTemplate[source]

Bases: object

get_objectives(objective_list: list) list[source]
get_parameter(parameter: str) float[source]
get_results(labels)[source]
optimize(algorithm, termination, variables: dict, constraints: dict = None, objective: list = None, minimize_flags: list = None, kpi: list = None) DataFrame[source]
plot_QT_diagram_matplotlib(heatexchanger_label, ax=None, save_dir=None, figsize=None)[source]
plot_Ts_diagram_matplotlib(connection_label, ax=None, save_dir=None, figsize=None, xlim=None, ylim=None)[source]
plot_logph_diagram_matplotlib(connection_label, ax=None, save_dir=None, figsize=None, xlim=None, ylim=None)[source]
run_exergy_analysis(Tamb, pamb, E_F, E_P, E_L=None)[source]

Run an exergy analysis via exerpy and cache the result.

Parameters:
  • Tamb (float) – Ambient temperature in °C.

  • pamb (float) – Ambient pressure in bar.

  • E_F (dict) – Fuel exergy definition, e.g. {'inputs': [...], 'outputs': [...]}.

  • E_P (dict) – Product exergy definition.

  • E_L (dict, optional) – Loss exergy definition.

Returns:

exerpy.ExergyAnalysis

save_design(path=None) None[source]

Save current network state as the design reference.

sensitivity_analysis(param_dict=None, result_param_list=None, mode='design', postproc_func=None) DataFrame[source]
Parameters:
  • param_dict (dict) – A dictionary of parameter names and lists of values to be used in the sensitivity analysis. All lists must have the same length, which determines the number of simulations to be run.

  • result_param_list (list, optional) – Names of model parameters (from _parameter_lookup()) to record after each simulation step.

  • mode (str, optional) – 'design' or 'offdesign'. Default is 'design'.

  • postproc_func (callable, optional) – A function postproc_func(model) -> dict | None called after each successful solve. Use it to run any postprocessing - e.g. an exergy analysis, custom KPI calculation, or result export. The returned dict (if any) is merged into the result row as additional columns alongside result_param_list. If the function returns None no extra columns are added.

    Example - running an exergy analysis after each offdesign solve:

    def run_exergy(model):
        model.run_exergy_analysis(Tamb, pamb, E_F, E_P)
    
    hp.sensitivity_analysis(
        param_dict={"T_geo": [8, 9, 10, 11]},
        result_param_list=["epsilon"],
        mode="offdesign",
        postproc_func=run_exergy,
    )
    
Returns:

pandas.core.frame.DataFrame – DataFrame with input parameter columns and result columns.

set_parameters(**kwargs) None[source]
solve_model(**kwargs) None[source]
solve_model_design(**kwargs) None[source]
solve_model_offdesign(**kwargs) None[source]