{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Exogeous prices market steps" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2026-03-24T13:40:05.706392Z", "iopub.status.busy": "2026-03-24T13:40:05.706015Z", "iopub.status.idle": "2026-03-24T13:40:06.214357Z", "shell.execute_reply": "2026-03-24T13:40:06.212026Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ModelType.EMPS\n", "SimulationType.Parallel\n" ] }, { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "F\n", "\n", "\n", "\n", "busbar_numedal\n", "\n", " \n", "busbar -1\n", "numedal  \n", "\n", "\n", "\n", "busbar_tev\n", "\n", " \n", "busbar -1\n", "tev  \n", "\n", "\n", "\n", "reservoir_LABRO\n", "\n", " \n", "reservoir 9995\n", "LABRO  \n", "\n", "\n", "\n", "plant_LABRO_plant\n", "\n", " \n", "plant 0\n", "LABRO_plant  \n", "\n", "\n", "\n", "reservoir_LABRO->plant_LABRO_plant\n", "\n", "\n", "\n", "\n", "\n", "reservoir_VITTINGFOSS\n", "\n", " \n", "reservoir 9996\n", "VITTINGFOSS  \n", "\n", "\n", "\n", "plant_VITTINGFOSS_plant\n", "\n", " \n", "plant 0\n", "VITTINGFOSS_plant  \n", "\n", "\n", "\n", "reservoir_VITTINGFOSS->plant_VITTINGFOSS_plant\n", "\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", "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\n", " ) as session:\n", " session.load(filename=\"model1.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())\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2026-03-24T13:40:06.219705Z", "iopub.status.busy": "2026-03-24T13:40:06.218588Z", "iopub.status.idle": "2026-03-24T13:40:07.799764Z", "shell.execute_reply": "2026-03-24T13:40:07.796275Z" } }, "outputs": [], "source": [ "with LtmSession(\n", " \"ikernel\", overwrite_session=True, ltm_core_path=ltm_core_path\n", ") as session:\n", " session.load(filename=\"model1.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", " except RuntimeError as e:\n", " print(e)\n", " raise(e)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2026-03-24T13:40:07.806188Z", "iopub.status.busy": "2026-03-24T13:40:07.805661Z", "iopub.status.idle": "2026-03-24T13:40:09.367548Z", "shell.execute_reply": "2026-03-24T13:40:09.365963Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "7: 17,T, * Datagruppe PRISREKKE\n", "8: 'HOVEDPRISREKKE.CSV', * Navn paa prisrekkefil\n", "18: 1, 52, * Start V.V., Slutt V.V.\n", "19: 51, 40, 0.001000, * Ant. pkt mag. V.V.,Maks ant. int V.V., Pres. krav V.V.\n", "20: T, 0, 0, 1, * Autom. gen. vekttall, Ant. tilsigsalt. ved vv. Beregn., Ant. sluttuker, Ant. tilsigtilstander ved vv. Beregn\n", "21: 4,T, * Datagruppe PREFDA: Kjp/import, salg/eksport, varmekraft, rasjonering\n", "22: 3, 12,'ms_exo_direct ',F, 0.000000, * Typenr, Kategori, Navn, Eget(T), Ekst.var.>>..003\n", "23: 'ms_exo_direct', * Filnavn til prisrekke for annen usikkerhet\n", "24: 0.000000, 1.000000, 0.000000, * Skaleringsfaktor hovedprisrekke, Skaleringsfaktor prisrekke for annen usikkerhet, Konstantledd\n", "25: TAPP, * * Kode for referanse til tidsserier kapasitet v.v.beregninger\n", "26: 4, 12,'ms_exo_ref ',F, 0.000000, * Typenr, Kategori, Navn, Eget(T), Ekst.var.>>..004\n", "27: 'sps1', * Filnavn til prisrekke for annen usikkerhet\n", "28: 0.200000, 0.500000, 1.200000, * Skaleringsfaktor hovedprisrekke, Skaleringsfaktor prisrekke for annen usikkerhet, Konstantledd\n", "29: TAPP, * * Kode for referanse til tidsserier kapasitet v.v.beregninger\n" ] } ], "source": [ "with LtmSession(\n", " \"ikernel\", overwrite_session=True, ltm_core_path=ltm_core_path\n", ") as session:\n", " session.load(filename=\"model2.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", " numedal_enmd_path = (\n", " f\"{session.model.global_settings.output_path}/numedal.ENMD\"\n", " )\n", "\n", " with open(numedal_enmd_path, \"r\", encoding=\"ISO-8859-1\") as file:\n", " for line_number, line in enumerate(file, start=1):\n", " if 7 <= line_number <= 8 or 18 <= line_number <= 29:\n", " print(f\"{line_number}: {line.strip()}\")\n", "\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 }