From 8450a76e644856d53ed79bcad4d2b2e8933ab824 Mon Sep 17 00:00:00 2001 From: Silvana Ovaitt Date: Wed, 11 Sep 2024 17:48:27 -0700 Subject: [PATCH] pytest 2 and 3 --- tests/test_main.py | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 26f7b91..a818621 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -46,41 +46,38 @@ def test_project_lifetime(): def test_infinite_Weibull(): r1 = PV_ICE.Simulation() - r1.createScenario('standard', file=MODULEBASELINE) - r1.scenario['standard'].addMaterial('glass', file=MATERIALBASELINE) - r1.scenario['standard'].data['mod_lifetime'] = 50.0 - failyear = r1.scenario['standard'].data['mod_lifetime'][0] - r1.calculateMassFlow() - data = r1.scenario['standard'].data - EOLrow = data.loc[0, data.columns.str.startswith("EOL_on_Year")] - assert round(r1.scenario['standard'].data['Area'][0],0) ==round(EOLrow.sum(),0) - EOLrow = data.loc[10, data.columns.str.startswith("EOL_on_Year")] - assert round(r1.scenario['standard'].data['Area'][10],0) ==round(EOLrow.sum(),0) + r1.createScenario('standard', massmodulefile=MODULEBASELINE) + r1.scenario['standard'].addMaterial('glass', massmatfile=MATERIALBASELINE) + r1.scenario['standard'].dataIn_m['mod_lifetime'] = 50.0 + r1.calculateMassFlow(debugflag=True) + data = r1.scenario['standard'].dataDebug_m # If no recycling as input material, then virgin material is constant for this scenario - r1.scenario['standard'].material['glass'].materialdata['mat_EOL_RecycledHQ_Reused4MFG'] = 0.0 + r1.scenario['standard'].material['glass'].matdataIn_m['mat_EOL_RecycledHQ_Reused4MFG'] = 0.0 r1.calculateMassFlow() - assert r1.scenario['standard'].material['glass'].materialdata['mat_Virgin_Stock'][0] == r1.scenario['standard'].data['Area'][10]*mat_massperm2 + mat_massperm2 = r1.scenario['standard'].material['glass'].matdataIn_m['mat_massperm2'].iloc[0] + + assert r1.scenario['standard'].material['glass'].matdataOut_m['mat_Virgin_Stock'][0] == r1.scenario['standard'].dataOut_m['Area'][10]*mat_massperm2 # If nothing is collected, everything goes to landfill. - r1.scenario['standard'].data['mod_EOL_collection_eff'] = 0.0 + r1.scenario['standard'].dataIn_m['mod_EOL_collection_eff'] = 0.0 r1.calculateMassFlow() # Comparing to a year in the future where steady state has been achieved. - assert (round(r1.scenario['standard'].data['Area'][0]*mat_massperm2,0) == - round(r1.scenario['standard'].material['glass'].materialdata['mat_Total_Landfilled'][30],0)) - assert (round(r1.scenario['standard'].material['glass'].materialdata['mat_Total_Landfilled'][0],0) == - round(r1.scenario['standard'].material['glass'].materialdata['mat_Total_EOL_Landfilled'][0],0)) + assert (round(r1.scenario['standard'].dataOut_m['Area'][0]*mat_massperm2/1000,0) == + round(r1.scenario['standard'].material['glass'].matdataOut_m['mat_Total_Landfilled'][30]/1000,0)) + assert (round(r1.scenario['standard'].material['glass'].matdataOut_m['mat_Total_Landfilled'][0],0) == + round(r1.scenario['standard'].material['glass'].matdataOut_m['mat_Total_EOL_Landfilled'][0],0)) def test_landfilledArea_vs_AreafromWaste(): r1 = PV_ICE.Simulation() - r1.createScenario('standard', file=MODULEBASELINE) - r1.scenario['standard'].addMaterial('glass', file=MATERIALBASELINE) - r1.scenario['standard'].data['mod_EOL_collection_eff'] = 0.0 + r1.createScenario('standard', massmodulefile=MODULEBASELINE) + r1.scenario['standard'].addMaterial('glass', massmatfile=MATERIALBASELINE) + r1.scenario['standard'].dataIn_m['mod_EOL_collection_eff'] = 0.0 r1.calculateMassFlow() - data = r1.scenario['standard'].data - matdata = r1.scenario['standard'].material['glass'].materialdata - UscumAreaDisp_100years = data['Cumulative_Area_disposed'].cumsum() + data = r1.scenario['standard'].dataOut_m + matdata = r1.scenario['standard'].material['glass'].matdataOut_m + UscumAreaDisp_100years = data['Yearly_Sum_Area_atEOL'].cumsum() # original called for Cumulative_Area_disposed UscumAreaDisp_100years = UscumAreaDisp_100years*1e-6 # convert to km2 B = UscumAreaDisp_100years.iloc[-1]