openego / osmTGmod

Open source German transmission grid model based on OpenStreetMap
GNU Affero General Public License v3.0
3 stars 1 forks source link

ERROR: division by zero inPL/pgSQL function otg_calc_transformer_specifications() #17

Open IsGut opened 1 day ago

IsGut commented 1 day ago

https://github.com/openego/osmTGmod/blob/features/egon/sql-scripts/functions.sql#L2502C21-L2502C33

Hi, unfortunately, this leading to error

NOTICE: v_branch.branch_id: 24907 NOTICE: v_branch.f_bus: 31814 NOTICE: v_branch.t_bus: 31815 NOTICE: v_S_long_MVA_sum_min: 0 NOTICE: v_U_OS: 380000 NOTICE: v_U_US: 110000 NOTICE: v_numb_transformers: 0 NOTICE: v_Srt: 3e+08 NOTICE: v_u_kr: 14 NOTICE: v_Z_TOS: 67.386665 NOTICE: v_X_TOS: 67.386665 NOTICE: v_Bl_TOS: -0.014839731 NOTICE: v_Bl_TOS_all: -0

ERROR: division by zero

e.g. [2024-10-19, 16:29:46 UTC] {init.py:484} ERROR - Exception raised with command 260. Check *** and code and restart with 'python ego_otg.py status2019 260'. Traceback (most recent call last): File "/home/ise/execution_folder/powerd-data/src/egon/data/datasets/osmtgmod/init.py", line 481, in osmtgmod cur.execute(command) psycopg2.errors.DivisionByZero: division by zero CONTEXT: PL/pgSQL function otg_calc_transformer_specifications() line 54 at assignment

Executing SQL statement 260: called here https://github.com/openego/powerd-data/blob/features/auto-update-function/src/egon/data/datasets/osmtgmod/__init__.py#L484

IsGut commented 1 day ago

As quickfix I would suggest something like take max if min is 0, e.g.

NOTICE: v_branch.branch_id: 24485 NOTICE: v_branch.f_bus: 28165 NOTICE: v_branch.t_bus: 28166 NOTICE: v_S_long_MVA_sum_min: 0 NOTICE: v_S_long_MVA_sum_max: 1040 NOTICE: v_U_OS: 220000 NOTICE: v_U_US: 110000 NOTICE: v_numb_transformers: 0 <- leading to v_Bl_TOS_all is 0 NOTICE: v_numb_transformers_max: 6 NOTICE: v_Srt: 2e+08 NOTICE: v_u_kr: 12 NOTICE: v_Z_TOS: 29.04 NOTICE: v_X_TOS: 29.04 NOTICE: v_Bl_TOS: -0.03443526 NOTICE: v_Bl_TOS_all: -0 <- due to v_numb_transformers is 0

IsGut commented 1 day ago

Hi @ulfmueller @ClaraBuettner as mentioned in our last jour fix, I faced an issue with osmtgmod. I assume for min, we don't have valid data for whole Germany, thus, Exception raised with command 260. Check *** and code and restart with 'python ego_otg.py status2019 260'. called here https://github.com/openego/powerd-data/blob/features/auto-update-function/src/egon/data/datasets/osmtgmod/__init__.py#L484

And resulting in an empty schemas.osmtgmod_results.branch_data & an empty schemas.osmtgmod_results.bus_data table

Testing with SH was working for me.

ClaraBuettner commented 14 hours ago

We fixed this problem in https://github.com/openego/osmTGmod/pull/18

There were some issues with two substations, both of them are not inside Schleswig-Holstein, so the test mode worked.