IndEcol / RECC-ODYM

The RECC model
MIT License
21 stars 10 forks source link

Error when running RECC_ScenarioControl.py #6

Closed nheeren closed 5 years ago

nheeren commented 5 years ago

When running RECC_ScenarioControl.py the following error reoccurs for all scenarios & countries. This may be related to issue #5, because the error occurs near that code.

INFO (ODYM_Functions.py <ReadParameterV2>): A total of 999 values was read from file for parameter 3_SHA_LightWeighting_Buildings.
INFO (ODYM_Functions.py <ReadParameterV2>): 972.0 of 4140 values for parameter 3_SHA_LightWeighting_Buildings were assigned.
INFO (RECC_G7IC_V1_1.py <main>): Current parameter file UUID: 3f620f27-6364-4b38-87f6-458f5f7b5d18
INFO (RECC_G7IC_V1_1.py <main>): Reading parameter 6_PR_Calibration
INFO (ODYM_Functions.py <ReadParameterV2>): A total of 45 values was read from file for parameter 6_PR_Calibration.
INFO (ODYM_Functions.py <ReadParameterV2>): 3.0 of 6 values for parameter 6_PR_Calibration were assigned.
INFO (RECC_G7IC_V1_1.py <main>): Current parameter file UUID: 5a59c156-fbfa-4aec-aec9-0df4f6bc0b1c
/Users/n/code/RECC-ODYM/RECC_G7IC_V1_1.py:559: RuntimeWarning: divide by zero encountered in true_divide
  pCStocks_2016 = np.einsum('gr,r->rg',Stocks_2016,1/ParameterDict['2_P_RECC_Population_SSP_32R'].Values[0,0,:,1])
INFO (RECC_G7IC_V1_1.py <main>): ## 3 - Initialize dynamic MFA model for RECC
INFO (RECC_G7IC_V1_1.py <main>): Define RECC system and processes.
INFO (RECC_G7IC_V1_1.py <main>): Computing RECC model for SSP scenario LED and RE scenario Baseline(unmitigated).
INFO (RECC_G7IC_V1_1.py <main>): ## 4 - Solve dynamic MFA model for RECC
INFO (RECC_G7IC_V1_1.py <main>): Calculate inflows and outflows for use phase.
100%|██████████| 15/15 [00:00<00:00, 63.32 commodity groups/s]
  0%|          | 0/2 [00:00<?, ? commodity groups/s]/Users/n/code/RECC-ODYM/RECC_G7IC_V1_1.py:822: RuntimeWarning: invalid value encountered in double_scalars
  StockMatch_2015[G,r] = TotalStockCurves_UsePhase[0, r, G]/InitialStocksum
100%|██████████| 2/2 [00:00<00:00, 84.92 commodity groups/s]
INFO (RECC_G7IC_V1_1.py <main>): Translate total flows into individual materials and elements, for 2015 and historic age-cohorts.
INFO (RECC_G7IC_V1_1.py <main>): Calculate material stocks and flows, material cycles, determine elemental composition.
  0%|          | 0/45 [00:00<?, ? years/s]/Users/n/code/RECC-ODYM/RECC_G7IC_V1_1.py:962: RuntimeWarning: invalid value encountered in true_divide
  MassShareVeh = RECC_System.FlowDict['F_7_8'].Values[t,0:CohortOffset,:,0:6,:,0] / np.einsum('m,crg->crgm',np.einsum('crgm->m',RECC_System.FlowDict['F_7_8'].Values[t,0:CohortOffset,:,0:6,:,0]),np.ones((CohortOffset,Nr,6)))
/Users/n/code/RECC-ODYM/RECC_G7IC_V1_1.py:968: RuntimeWarning: invalid value encountered in true_divide
  MassShareBld = RECC_System.FlowDict['F_7_8'].Values[t,0:CohortOffset,:,6::,:,0] / np.einsum('m,crg->crgm',np.einsum('crgm->m',RECC_System.FlowDict['F_7_8'].Values[t,0:CohortOffset,:,6::,:,0]),np.ones((CohortOffset,Nr,9)))
/Users/n/code/RECC-ODYM/RECC_G7IC_V1_1.py:974: RuntimeWarning: divide by zero encountered in true_divide
  InvMass = 1 / np.einsum('m,rg->rgm',np.einsum('rgm->m',RECC_System.FlowDict['F_6_7'].Values[t,:,:,:,0]),np.ones((Nr,Ng)))
/Users/n/code/RECC-ODYM/RECC_G7IC_V1_1.py:1002: RuntimeWarning: divide by zero encountered in true_divide
  Element_Material_Composition_t_SecondaryMaterial = np.einsum('me,me->me',RECC_System.FlowDict['F_9_12'].Values[t,-1,:,:],1/np.einsum('m,e->me',RECC_System.FlowDict['F_9_12'].Values[t,-1,:,0],np.ones(Ne)))
/Users/n/code/RECC-ODYM/RECC_G7IC_V1_1.py:1011: RuntimeWarning: divide by zero encountered in true_divide
  Manufacturing_Input_Split_gm = np.einsum('gm,m->gm',Manufacturing_Input_gm, 1/Manufacturing_Input_m)
/Users/n/code/RECC-ODYM/RECC_G7IC_V1_1.py:1032: RuntimeWarning: divide by zero encountered in true_divide
  Element_Material_Composition_t = np.einsum('me,me->me',RECC_System.FlowDict['F_4_5'].Values[t,:,:] + RECC_System.FlowDict['F_12_5'].Values[t,-1,:,:],1/np.einsum('m,e->me',RECC_System.FlowDict['F_4_5'].Values[t,:,0] + RECC_System.FlowDict['F_12_5'].Values[t,-1,:,0],np.ones(Ne)))
/Users/n/code/RECC-ODYM/RECC_G7IC_V1_1.py:1055: RuntimeWarning: divide by zero encountered in true_divide
nheeren commented 5 years ago

Depreciated numpy command seems to be the issue. Stefan will fix.

stefanpauliuk commented 5 years ago

Division was not properly implemented at several places:

# instead of 
C1 = A / B
C1[np.isnan(C)] = 0
# use
C2 = np.divide(A,B,out=np.zeros_like(B), where=B!=0)
nheeren commented 5 years ago

Fixes #7