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
[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>
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>
busbar: numedal