EOPS Example RunΒΆ

This example shows a basic EOPS series simulation.

It also contains two hydraulic couplings, one station joined and one non-station joined.

If licensed feature LTM_OPS_UTJAMNVASS is active, non-station joined coupling will also write additional results showing the hydraulic flow between the connected reservoirs.

[1]:
import os

from pyltmapi import LtmSession, LtmDot
from pathlib import Path

from generate_plots import generate_plots

ltm_core_path =  os.environ.get("LTM_CORE_PATH", str(Path("~").expanduser().joinpath("ltm/release/bin/")))
license_file = os.environ.get("LTM_CORE_LICENSE_FILE", str(Path("~").expanduser().joinpath("ltm/ltm-license.dat")))


with LtmSession("ikernel", overwrite_session=True) as session:
    session.load(filename="eops.json")
    print(session.model.global_settings.model_type)
    print(session.model.global_settings.simulation_type)
    LtmDot.display_dot_image(session.build_connection_tree())
ModelType.EOPS
SimulationType.Serial
../../../_images/ltm-api_guides_eops_eops-example-run_1_1.svg
[2]:
from IPython.display import HTML, display, display_markdown
import logging
from pyltmapi import LtmPlot

logging.basicConfig(level=logging.WARN)


with LtmSession(
    "ikernel", ltm_core_path=ltm_core_path, overwrite_session=True
) as session:
    session.load(filename="eops.json")

    # session.set_execute_callback(usercallback, {})

    session.model.global_settings.ltm_license_file_path = license_file
    validation = session.validate_model()

    write_model = session.write_model()
    last_rc, results = session.execute_model()

    if last_rc != 0:
        err = results[0]["log_file_contents"]
        display_markdown(err)

    else:
        try:
            for bb in session.model.busbars():
                print(bb)
                for hc in bb.hydraulic_couplings():
                    print(hc)
                    print(f"hc.station_joined:              {hc.station_joined}")
                    print(f"hc.have_hydraulic_flow_results: {hc.have_hydraulic_flow_results}")

                    if hc.station_joined:
                        pass
                        LtmPlot.make_generic_plot(
                            hc.discharge(), f"Discharge '{hc.name}'"
                        )
                        LtmPlot.make_generic_plot(
                            hc.production(), f"Production '{hc.name}'"
                        )
                    else:
                        if hc.have_hydraulic_flow_results:
                            for rsv in hc.connected_reservoirs():
                                LtmPlot.make_generic_plot(
                                    rsv.flow(),
                                    f"Hydraulic flow '{hc.name}' - '{rsv.name}'",
                                )

                        else:
                            print(
                                f"{hc}: Does not have hydraulic exchange/flow results"
                            )

        except Exception as e:
            print(e)
            pass

        generate_plots(session)
busbar/numedal
hydraulic_coupling/coupling_200
hc.station_joined:              False
hc.have_hydraulic_flow_results: <bound method PyCapsule.have_hydraulic_flow_results of hydraulic_coupling/coupling_200>
../../../_images/ltm-api_guides_eops_eops-example-run_2_1.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_2.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_3.png
hydraulic_coupling/plant_coupling_100
hc.station_joined:              True
hc.have_hydraulic_flow_results: <bound method PyCapsule.have_hydraulic_flow_results of hydraulic_coupling/plant_coupling_100>
../../../_images/ltm-api_guides_eops_eops-example-run_2_5.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_6.png
busbar: numedal
../../../_images/ltm-api_guides_eops_eops-example-run_2_8.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_9.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_10.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_11.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_12.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_13.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_14.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_15.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_16.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_17.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_18.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_19.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_20.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_21.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_22.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_23.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_24.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_25.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_26.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_27.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_28.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_29.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_30.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_31.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_32.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_33.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_34.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_35.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_36.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_37.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_38.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_39.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_40.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_41.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_42.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_43.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_44.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_45.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_46.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_47.png
../../../_images/ltm-api_guides_eops_eops-example-run_2_48.png