{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exogenous Prices Water Value"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-24T13:40:10.545169Z",
"iopub.status.busy": "2026-03-24T13:40:10.544545Z",
"iopub.status.idle": "2026-03-24T13:40:11.089129Z",
"shell.execute_reply": "2026-03-24T13:40:11.086606Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ModelType.EMPS\n",
"SimulationType.Parallel\n"
]
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import os\n",
"from pyltmapi import LtmSession\n",
"from pathlib import Path\n",
"\n",
"import numpy as np\n",
"\n",
"from generate_plots import display_dot_image\n",
"\n",
"ltm_core_path = os.environ.get(\"LTM_CORE_PATH\", str(Path(\"~\").expanduser().joinpath(\"ltm/release/bin/\")))\n",
"license_file = os.environ.get(\"LTM_CORE_LICENSE_FILE\", str(Path(\"~\").expanduser().joinpath(\"ltm/ltm-license.dat\")))\n",
"\n",
"\n",
"with LtmSession(\n",
" \"ikernel\", overwrite_session=True, ltm_core_path=ltm_core_path\n",
") as session:\n",
" session.load(filename=\"model.json\")\n",
" print(session.model.global_settings.model_type)\n",
" print(session.model.global_settings.simulation_type)\n",
" display_dot_image(session.build_connection_tree())"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-24T13:40:11.093189Z",
"iopub.status.busy": "2026-03-24T13:40:11.092684Z",
"iopub.status.idle": "2026-03-24T13:40:13.807098Z",
"shell.execute_reply": "2026-03-24T13:40:13.805357Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(1, 1, 1, 1)\n",
"(1, 1, 1, 1)\n"
]
}
],
"source": [
"with LtmSession(\n",
" \"ikernel\", overwrite_session=True, ltm_core_path=ltm_core_path\n",
") as session:\n",
" session.load(filename=\"model.json\")\n",
"\n",
" session.model.global_settings.ltm_license_file_path = license_file\n",
"\n",
" try:\n",
" discrepancies = session.validate_model()\n",
" if not discrepancies:\n",
"\n",
" write_model = session.write_model()\n",
" last_rc, results = session.execute_model()\n",
"\n",
" for busbar in reversed(session.model.busbars()):\n",
" wv_return_value = busbar.water_value_results()\n",
" wv_time, wv_data = wv_return_value\n",
" water_values = np.array(wv_data, copy=False)\n",
" print(water_values.shape)\n",
" except RuntimeError as e:\n",
" print(e)\n",
" raise(e)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ltmio-venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}