In [1]:
Copied!
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import pickle
import openpyxl
import pylab
from copy import deepcopy
import logging as log
import odym.classes as msc # import the ODYM class file
import odym.functions as msf # import the ODYM function file
import odym.dynamic_stock_model as dsm # import the dynamic stock model library
# Initialize loggin routine
log_verbosity = eval("log.DEBUG")
log_filename = 'LogFileTest.md'
[Mylog, console_log, file_log] = msf.function_logger(log_filename, os.getcwd(),
log_verbosity, log_verbosity)
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import pickle
import openpyxl
import pylab
from copy import deepcopy
import logging as log
import odym.classes as msc # import the ODYM class file
import odym.functions as msf # import the ODYM function file
import odym.dynamic_stock_model as dsm # import the dynamic stock model library
# Initialize loggin routine
log_verbosity = eval("log.DEBUG")
log_filename = 'LogFileTest.md'
[Mylog, console_log, file_log] = msf.function_logger(log_filename, os.getcwd(),
log_verbosity, log_verbosity)
2) Load Config file and read model control parameters¶
Note The functionalities below are shown so that one can see how the model works. For practical applications of ODYM, they have been built into the ODYM functions
msf.ParseModelControl, msf.ParseConfigFile, and msf.ParseClassificationFile_Main'
In [2]:
Copied!
#Read main script parameters
#Load project-specific config file
ProjectSpecs_Name_ConFile = 'ODYM_Config_Tutorial.xlsx'
Model_Configfile = openpyxl.load_workbook(os.path.join(DataPath, ProjectSpecs_Name_ConFile), data_only=True)
ScriptConfig = {'Model Setting': Model_Configfile['Config'].cell(4,4).value}
Model_Configsheet = Model_Configfile['Setting_' + ScriptConfig['Model Setting']]
Name_Scenario = Model_Configsheet.cell(4,4).value
print(Name_Scenario)
### 1.2) Read model control parameters
#Read control and selection parameters into dictionary
SCix = 0
# search for script config list entry
while Model_Configsheet.cell(SCix+1, 2).value != 'General Info':
SCix += 1
SCix += 2 # start on first data row
while Model_Configsheet.cell(SCix+1, 4).value is not None:
ScriptConfig[Model_Configsheet.cell(SCix+1, 3).value] = Model_Configsheet.cell(SCix+1,4).value
SCix += 1
SCix = 0
# search for script config list entry
while Model_Configsheet.cell(SCix+1, 2).value != 'Software version selection':
SCix += 1
SCix += 2 # start on first data row
while Model_Configsheet.cell(SCix+1, 4).value is not None:
ScriptConfig[Model_Configsheet.cell(SCix+1, 3).value] = Model_Configsheet.cell(SCix+1,4).value
SCix += 1
print(ScriptConfig)
#Read main script parameters
#Load project-specific config file
ProjectSpecs_Name_ConFile = 'ODYM_Config_Tutorial.xlsx'
Model_Configfile = openpyxl.load_workbook(os.path.join(DataPath, ProjectSpecs_Name_ConFile), data_only=True)
ScriptConfig = {'Model Setting': Model_Configfile['Config'].cell(4,4).value}
Model_Configsheet = Model_Configfile['Setting_' + ScriptConfig['Model Setting']]
Name_Scenario = Model_Configsheet.cell(4,4).value
print(Name_Scenario)
### 1.2) Read model control parameters
#Read control and selection parameters into dictionary
SCix = 0
# search for script config list entry
while Model_Configsheet.cell(SCix+1, 2).value != 'General Info':
SCix += 1
SCix += 2 # start on first data row
while Model_Configsheet.cell(SCix+1, 4).value is not None:
ScriptConfig[Model_Configsheet.cell(SCix+1, 3).value] = Model_Configsheet.cell(SCix+1,4).value
SCix += 1
SCix = 0
# search for script config list entry
while Model_Configsheet.cell(SCix+1, 2).value != 'Software version selection':
SCix += 1
SCix += 2 # start on first data row
while Model_Configsheet.cell(SCix+1, 4).value is not None:
ScriptConfig[Model_Configsheet.cell(SCix+1, 3).value] = Model_Configsheet.cell(SCix+1,4).value
SCix += 1
print(ScriptConfig)
ODYM_Tutorial
{'Model Setting': 'Tutorial', 'Name of model setting': 'ODYM_Tutorial', 'Description': 'A tutorial on the classification, configuration, and data formats of ODYM', 'Name of model script used': 'ODYM_Tutorial_1', 'Version of master classification': 'ODYM_Classifications_Master_Tutorial', 'Version of ODYM Classes': 'V01', 'Version of ODYM Functions': 'V01'}
3) Read classification and data¶
In [3]:
Copied!
# Read model run config data
Classfile = openpyxl.load_workbook(os.path.join(DataPath,
str(ScriptConfig['Version of master classification']) \
+ '.xlsx'), data_only=True)
Classsheet = Classfile['MAIN_Table']
ci = 1 # column index to start with
MasterClassification = {} # Dict of master classifications
while True:
TheseItems = []
ri = 10 # row index to start with
if Classsheet.cell(1,ci+1).value is not None:
ThisName = Classsheet.cell(1,ci+1).value
ThisDim = Classsheet.cell(2,ci+1).value
ThisID = Classsheet.cell(4,ci+1).value
ThisUUID = Classsheet.cell(5,ci+1).value
TheseItems.append(Classsheet.cell(ri+1,ci+1).value) # read the first classification item
else:
print('End of file or formatting error while reading the classification file in column '+ str(ci) +'.')
break
while True:
ri +=1
if Classsheet.cell(ri+1,ci+1).value is not None:
ThisItem = Classsheet.cell(ri+1,ci+1).value
else:
break
if ThisItem is not None:
TheseItems.append(ThisItem)
MasterClassification[ThisName] = msc.Classification(Name = ThisName, Dimension = ThisDim,
ID = ThisID, UUID = ThisUUID, Items = TheseItems)
ci +=1
print('Read index table from model config sheet.')
ITix = 0
while True: # search for index table entry
if Model_Configsheet.cell(ITix+1,2).value == 'Index Table':
break
else:
ITix += 1
IT_Aspects = []
IT_Description = []
IT_Dimension = []
IT_Classification = []
IT_Selector = []
IT_IndexLetter = []
ITix += 2 # start on first data row
while True:
if Model_Configsheet.cell(ITix+1,3).value is not None:
IT_Aspects.append(Model_Configsheet.cell(ITix+1,3).value)
IT_Description.append(Model_Configsheet.cell(ITix+1,4).value)
IT_Dimension.append(Model_Configsheet.cell(ITix+1,5).value)
IT_Classification.append(Model_Configsheet.cell(ITix+1,6).value)
IT_Selector.append(Model_Configsheet.cell(ITix+1,7).value)
IT_IndexLetter.append(Model_Configsheet.cell(ITix+1,8).value)
ITix += 1
else:
break
print('Read parameter list from model config sheet.')
PLix = 0
while True: # search for parameter list entry
if Model_Configsheet.cell(PLix+1,2).value == 'Model Parameters':
break
else:
PLix += 1
PL_Names = []
PL_Description = []
PL_Version = []
PL_IndexStructure = []
PL_IndexMatch = []
PL_IndexLayer = []
PLix += 2 # start on first data row
while True:
if Model_Configsheet.cell(PLix+1,3).value is not None:
PL_Names.append(Model_Configsheet.cell(PLix+1,3).value)
PL_Description.append(Model_Configsheet.cell(PLix+1,4).value)
PL_Version.append(Model_Configsheet.cell(PLix+1,5).value)
PL_IndexStructure.append(Model_Configsheet.cell(PLix+1,6).value)
PL_IndexMatch.append(Model_Configsheet.cell(PLix+1,7).value)
# strip numbers out of list string
PL_IndexLayer.append(msf.ListStringToListNumbers(Model_Configsheet.cell(PLix+1,8).value))
PLix += 1
else:
break
print('Read process list from model config sheet.')
PrLix = 0
while True: # search for process list entry
if Model_Configsheet.cell(PrLix+1,2).value == 'Process Group List':
break
else:
PrLix += 1
PrL_Number = []
PrL_Name = []
PrL_Code = []
PrL_Type = []
PrLix += 2 # start on first data row
while True:
if Model_Configsheet.cell(PrLix+1,3).value is not None:
try:
PrL_Number.append(int(Model_Configsheet.cell(PrLix+1,3).value))
except:
PrL_Number.append(Model_Configsheet.cell(PrLix+1,3).value)
PrL_Name.append(Model_Configsheet.cell(PrLix+1,4).value)
PrL_Code.append(Model_Configsheet.cell(PrLix+1,5).value)
PrL_Type.append(Model_Configsheet.cell(PrLix+1,6).value)
PrLix += 1
else:
break
print('Read model run control from model config sheet.')
PrLix = 0
while True: # search for model flow control entry
if Model_Configsheet.cell(PrLix+1,2).value == 'Model flow control':
break
else:
PrLix += 1
PrLix += 2 # start on first data row
while True:
if Model_Configsheet.cell(PrLix+1,3).value is not None:
try:
ScriptConfig[Model_Configsheet.cell(PrLix+1,3).value] = Model_Configsheet.cell(PrLix+1,4).value
except:
None
PrLix += 1
else:
break
# Read model run config data
Classfile = openpyxl.load_workbook(os.path.join(DataPath,
str(ScriptConfig['Version of master classification']) \
+ '.xlsx'), data_only=True)
Classsheet = Classfile['MAIN_Table']
ci = 1 # column index to start with
MasterClassification = {} # Dict of master classifications
while True:
TheseItems = []
ri = 10 # row index to start with
if Classsheet.cell(1,ci+1).value is not None:
ThisName = Classsheet.cell(1,ci+1).value
ThisDim = Classsheet.cell(2,ci+1).value
ThisID = Classsheet.cell(4,ci+1).value
ThisUUID = Classsheet.cell(5,ci+1).value
TheseItems.append(Classsheet.cell(ri+1,ci+1).value) # read the first classification item
else:
print('End of file or formatting error while reading the classification file in column '+ str(ci) +'.')
break
while True:
ri +=1
if Classsheet.cell(ri+1,ci+1).value is not None:
ThisItem = Classsheet.cell(ri+1,ci+1).value
else:
break
if ThisItem is not None:
TheseItems.append(ThisItem)
MasterClassification[ThisName] = msc.Classification(Name = ThisName, Dimension = ThisDim,
ID = ThisID, UUID = ThisUUID, Items = TheseItems)
ci +=1
print('Read index table from model config sheet.')
ITix = 0
while True: # search for index table entry
if Model_Configsheet.cell(ITix+1,2).value == 'Index Table':
break
else:
ITix += 1
IT_Aspects = []
IT_Description = []
IT_Dimension = []
IT_Classification = []
IT_Selector = []
IT_IndexLetter = []
ITix += 2 # start on first data row
while True:
if Model_Configsheet.cell(ITix+1,3).value is not None:
IT_Aspects.append(Model_Configsheet.cell(ITix+1,3).value)
IT_Description.append(Model_Configsheet.cell(ITix+1,4).value)
IT_Dimension.append(Model_Configsheet.cell(ITix+1,5).value)
IT_Classification.append(Model_Configsheet.cell(ITix+1,6).value)
IT_Selector.append(Model_Configsheet.cell(ITix+1,7).value)
IT_IndexLetter.append(Model_Configsheet.cell(ITix+1,8).value)
ITix += 1
else:
break
print('Read parameter list from model config sheet.')
PLix = 0
while True: # search for parameter list entry
if Model_Configsheet.cell(PLix+1,2).value == 'Model Parameters':
break
else:
PLix += 1
PL_Names = []
PL_Description = []
PL_Version = []
PL_IndexStructure = []
PL_IndexMatch = []
PL_IndexLayer = []
PLix += 2 # start on first data row
while True:
if Model_Configsheet.cell(PLix+1,3).value is not None:
PL_Names.append(Model_Configsheet.cell(PLix+1,3).value)
PL_Description.append(Model_Configsheet.cell(PLix+1,4).value)
PL_Version.append(Model_Configsheet.cell(PLix+1,5).value)
PL_IndexStructure.append(Model_Configsheet.cell(PLix+1,6).value)
PL_IndexMatch.append(Model_Configsheet.cell(PLix+1,7).value)
# strip numbers out of list string
PL_IndexLayer.append(msf.ListStringToListNumbers(Model_Configsheet.cell(PLix+1,8).value))
PLix += 1
else:
break
print('Read process list from model config sheet.')
PrLix = 0
while True: # search for process list entry
if Model_Configsheet.cell(PrLix+1,2).value == 'Process Group List':
break
else:
PrLix += 1
PrL_Number = []
PrL_Name = []
PrL_Code = []
PrL_Type = []
PrLix += 2 # start on first data row
while True:
if Model_Configsheet.cell(PrLix+1,3).value is not None:
try:
PrL_Number.append(int(Model_Configsheet.cell(PrLix+1,3).value))
except:
PrL_Number.append(Model_Configsheet.cell(PrLix+1,3).value)
PrL_Name.append(Model_Configsheet.cell(PrLix+1,4).value)
PrL_Code.append(Model_Configsheet.cell(PrLix+1,5).value)
PrL_Type.append(Model_Configsheet.cell(PrLix+1,6).value)
PrLix += 1
else:
break
print('Read model run control from model config sheet.')
PrLix = 0
while True: # search for model flow control entry
if Model_Configsheet.cell(PrLix+1,2).value == 'Model flow control':
break
else:
PrLix += 1
PrLix += 2 # start on first data row
while True:
if Model_Configsheet.cell(PrLix+1,3).value is not None:
try:
ScriptConfig[Model_Configsheet.cell(PrLix+1,3).value] = Model_Configsheet.cell(PrLix+1,4).value
except:
None
PrLix += 1
else:
break
End of file or formatting error while reading the classification file in column 11. Read index table from model config sheet. Read parameter list from model config sheet. Read process list from model config sheet. Read model run control from model config sheet.
In [4]:
Copied!
print('Define model classifications and select items for model classifications according to information provided by config file.')
ModelClassification = {} # Dict of model classifications
for m in range(0,len(IT_Aspects)):
ModelClassification[IT_Aspects[m]] = deepcopy(MasterClassification[IT_Classification[m]])
EvalString = msf.EvalItemSelectString(IT_Selector[m],len(ModelClassification[IT_Aspects[m]].Items))
if EvalString.find(':') > -1: # range of items is taken
RangeStart = int(EvalString[0:EvalString.find(':')])
RangeStop = int(EvalString[EvalString.find(':')+1::])
ModelClassification[IT_Aspects[m]].Items = ModelClassification[IT_Aspects[m]].Items[RangeStart:RangeStop]
elif EvalString.find('[') > -1: # selected items are taken
ModelClassification[IT_Aspects[m]].Items = \
[ModelClassification[IT_Aspects[m]].Items[i] for i in eval(EvalString)]
elif EvalString == 'all':
None
else:
Mylog.info('ITEM SELECT ERROR for aspect ' + IT_Aspects[m] + ' were found in datafile.</br>')
break
print('Define model classifications and select items for model classifications according to information provided by config file.')
ModelClassification = {} # Dict of model classifications
for m in range(0,len(IT_Aspects)):
ModelClassification[IT_Aspects[m]] = deepcopy(MasterClassification[IT_Classification[m]])
EvalString = msf.EvalItemSelectString(IT_Selector[m],len(ModelClassification[IT_Aspects[m]].Items))
if EvalString.find(':') > -1: # range of items is taken
RangeStart = int(EvalString[0:EvalString.find(':')])
RangeStop = int(EvalString[EvalString.find(':')+1::])
ModelClassification[IT_Aspects[m]].Items = ModelClassification[IT_Aspects[m]].Items[RangeStart:RangeStop]
elif EvalString.find('[') > -1: # selected items are taken
ModelClassification[IT_Aspects[m]].Items = \
[ModelClassification[IT_Aspects[m]].Items[i] for i in eval(EvalString)]
elif EvalString == 'all':
None
else:
Mylog.info('ITEM SELECT ERROR for aspect ' + IT_Aspects[m] + ' were found in datafile.')
break
Define model classifications and select items for model classifications according to information provided by config file.
The following code block creates the index table for the MFA system and parses all parameter files specified into the parameter dictionary ParameterDict.
In [5]:
Copied!
# Define model index table and parameter dictionary
Model_Time_Start = int(min(ModelClassification['Time'].Items))
Model_Time_End = int(max(ModelClassification['Time'].Items))
Model_Duration = Model_Time_End - Model_Time_Start
print('Define index table dataframe.')
IndexTable = pd.DataFrame({'Aspect' : IT_Aspects, # 'Time' and 'Element' must be present!
'Description' : IT_Description,
'Dimension' : IT_Dimension,
'Classification': [ModelClassification[Aspect] for Aspect in IT_Aspects],
# Unique one letter (upper or lower case) indices to be used later for calculations.
'IndexLetter' : IT_IndexLetter})
# Default indexing of IndexTable, other indices are produced on the fly
IndexTable.set_index('Aspect', inplace = True)
# Add indexSize to IndexTable:
IndexTable['IndexSize'] = \
pd.Series([len(IndexTable.Classification[i].Items) for i in range(0,len(IndexTable.IndexLetter))], index=IndexTable.index)
# list of the classifications used for each indexletter
IndexTable_ClassificationNames = [IndexTable.Classification[i].Name for i in range(0,len(IndexTable.IndexLetter))]
#Define shortcuts for the most important index sizes:
Nt = len(IndexTable.Classification[IndexTable.index.get_loc('Time')].Items)
NG = len(IndexTable.Classification[IndexTable.set_index('IndexLetter').index.get_loc('g')].Items)
print('Read model data and parameters.')
ParameterDict = {}
for mo in range(0,len(PL_Names)):
ParPath = os.path.join(DataPath,PL_Version[mo])
print('Reading parameter ' + PL_Names[mo])
# Do not change order of parameters handed over to function!
MetaData, Values = msf.ReadParameterXLSX(ParPath, PL_Names[mo], PL_IndexStructure[mo],
PL_IndexMatch[mo], PL_IndexLayer[mo],
MasterClassification, IndexTable,
IndexTable_ClassificationNames, ScriptConfig,Mylog, False)
ParameterDict[PL_Names[mo]] = msc.Parameter(Name = MetaData['Dataset_Name'],
ID = MetaData['Dataset_ID'],
UUID = MetaData['Dataset_UUID'],
P_Res = None,
MetaData = MetaData,
Indices = PL_IndexStructure[mo],
Values=Values,
Uncert=None,
Unit = MetaData['Dataset_Unit'])
# Define model index table and parameter dictionary
Model_Time_Start = int(min(ModelClassification['Time'].Items))
Model_Time_End = int(max(ModelClassification['Time'].Items))
Model_Duration = Model_Time_End - Model_Time_Start
print('Define index table dataframe.')
IndexTable = pd.DataFrame({'Aspect' : IT_Aspects, # 'Time' and 'Element' must be present!
'Description' : IT_Description,
'Dimension' : IT_Dimension,
'Classification': [ModelClassification[Aspect] for Aspect in IT_Aspects],
# Unique one letter (upper or lower case) indices to be used later for calculations.
'IndexLetter' : IT_IndexLetter})
# Default indexing of IndexTable, other indices are produced on the fly
IndexTable.set_index('Aspect', inplace = True)
# Add indexSize to IndexTable:
IndexTable['IndexSize'] = \
pd.Series([len(IndexTable.Classification[i].Items) for i in range(0,len(IndexTable.IndexLetter))], index=IndexTable.index)
# list of the classifications used for each indexletter
IndexTable_ClassificationNames = [IndexTable.Classification[i].Name for i in range(0,len(IndexTable.IndexLetter))]
#Define shortcuts for the most important index sizes:
Nt = len(IndexTable.Classification[IndexTable.index.get_loc('Time')].Items)
NG = len(IndexTable.Classification[IndexTable.set_index('IndexLetter').index.get_loc('g')].Items)
print('Read model data and parameters.')
ParameterDict = {}
for mo in range(0,len(PL_Names)):
ParPath = os.path.join(DataPath,PL_Version[mo])
print('Reading parameter ' + PL_Names[mo])
# Do not change order of parameters handed over to function!
MetaData, Values = msf.ReadParameterXLSX(ParPath, PL_Names[mo], PL_IndexStructure[mo],
PL_IndexMatch[mo], PL_IndexLayer[mo],
MasterClassification, IndexTable,
IndexTable_ClassificationNames, ScriptConfig,Mylog, False)
ParameterDict[PL_Names[mo]] = msc.Parameter(Name = MetaData['Dataset_Name'],
ID = MetaData['Dataset_ID'],
UUID = MetaData['Dataset_UUID'],
P_Res = None,
MetaData = MetaData,
Indices = PL_IndexStructure[mo],
Values=Values,
Uncert=None,
Unit = MetaData['Dataset_Unit'])
Define index table dataframe. Read model data and parameters. Reading parameter Par_ManufacturingYield
C:\Users\spauliuk.AD\Anaconda3\lib\site-packages\openpyxl\worksheet\header_footer.py:48: UserWarning: Cannot parse header or footer so it will be ignored
warn("""Cannot parse header or footer so it will be ignored""")
INFO (ODYM_Functions.py <ReadParameterXLSX>): A total of 800 values was read from file for parameter Par_ManufacturingYield.
INFO (ODYM_Functions.py <ReadParameterXLSX>): 800.0 of 23698 values for parameter Par_ManufacturingYield were assigned.
INFO (ODYM_Functions.py <ReadParameterXLSX>): A total of 32 values was read from file for parameter Par_ElementContent_Materials.
TABLE Reading parameter Par_ElementContent_Materials LIST
INFO (ODYM_Functions.py <ReadParameterXLSX>): 16.0 of 123 values for parameter Par_ElementContent_Materials were assigned.
4) Define MFA system¶
With the index table and parameter dictionary defined, we can now define the MFA system.
In [6]:
Copied!
print('Define MFA system and processes.')
Tutorial_MFA_System = msc.MFAsystem(Name = 'TestSystem_Tutorial',
Geogr_Scope = 'World',
Unit = 'Mt',
ProcessList = [],
FlowDict = {},
StockDict = {},
ParameterDict = ParameterDict,
Time_Start = Model_Time_Start,
Time_End = Model_Time_End,
IndexTable = IndexTable,
Elements = IndexTable.loc['Element'].Classification.Items,
Graphical = None) # Initialize MFA system
# Check Validity of index tables:
# returns true if dimensions are OK and time index is present and element list is not empty
Tutorial_MFA_System.IndexTableCheck()
# Add processes to system
for m in range(0, len(PrL_Number)):
Tutorial_MFA_System.ProcessList.append(msc.Process(Name = PrL_Name[m], ID = PrL_Number[m]))
# Define system variables: Flows.
Tutorial_MFA_System.FlowDict['F_m3_4'] = msc.Flow(Name = 'Final consumption', P_Start = 'm3',
P_End = 4, Indices = 't,g,e',
Values=None, Uncert=None, Color = None,
ID = None, UUID = None)
Tutorial_MFA_System.FlowDict['F_4_m5'] = msc.Flow(Name = 'EoL products', P_Start = 4,
P_End = 5, Indices = 't,g,e',
Values=None, Uncert=None, Color = None,
ID = None, UUID = None)
# Define system variables: Stocks.
Tutorial_MFA_System.StockDict['S_4'] = msc.Stock(Name = 'In-use stock', P_Res = 4, Type = 1,
Indices = 't,g,e', Values=None, Uncert=None,
ID = None, UUID = None)
Tutorial_MFA_System.Initialize_StockValues() # Assign empty arrays to stocks according to dimensions.
Tutorial_MFA_System.Initialize_FlowValues() # Assign empty arrays to flows according to dimensions.
print('Define MFA system and processes.')
Tutorial_MFA_System = msc.MFAsystem(Name = 'TestSystem_Tutorial',
Geogr_Scope = 'World',
Unit = 'Mt',
ProcessList = [],
FlowDict = {},
StockDict = {},
ParameterDict = ParameterDict,
Time_Start = Model_Time_Start,
Time_End = Model_Time_End,
IndexTable = IndexTable,
Elements = IndexTable.loc['Element'].Classification.Items,
Graphical = None) # Initialize MFA system
# Check Validity of index tables:
# returns true if dimensions are OK and time index is present and element list is not empty
Tutorial_MFA_System.IndexTableCheck()
# Add processes to system
for m in range(0, len(PrL_Number)):
Tutorial_MFA_System.ProcessList.append(msc.Process(Name = PrL_Name[m], ID = PrL_Number[m]))
# Define system variables: Flows.
Tutorial_MFA_System.FlowDict['F_m3_4'] = msc.Flow(Name = 'Final consumption', P_Start = 'm3',
P_End = 4, Indices = 't,g,e',
Values=None, Uncert=None, Color = None,
ID = None, UUID = None)
Tutorial_MFA_System.FlowDict['F_4_m5'] = msc.Flow(Name = 'EoL products', P_Start = 4,
P_End = 5, Indices = 't,g,e',
Values=None, Uncert=None, Color = None,
ID = None, UUID = None)
# Define system variables: Stocks.
Tutorial_MFA_System.StockDict['S_4'] = msc.Stock(Name = 'In-use stock', P_Res = 4, Type = 1,
Indices = 't,g,e', Values=None, Uncert=None,
ID = None, UUID = None)
Tutorial_MFA_System.Initialize_StockValues() # Assign empty arrays to stocks according to dimensions.
Tutorial_MFA_System.Initialize_FlowValues() # Assign empty arrays to flows according to dimensions.
Define MFA system and processes.
In [7]:
Copied!
Tutorial_MFA_System.IndexTable
Tutorial_MFA_System.IndexTable
Out[7]:
| Description | Dimension | Classification | IndexLetter | IndexSize | |
|---|---|---|---|---|---|
| Aspect | |||||
| Time | Model time | Time | <ODYM_Classes.Classification object at 0x00000... | t | 36 |
| Element | chemical elements | Element | <ODYM_Classes.Classification object at 0x00000... | e | 3 |
| Unity | trivial classification, 1 entry only | Unity | <ODYM_Classes.Classification object at 0x00000... | 1 | 1 |
| ManufacturingProcess | Manufacturing processes | Process | <ODYM_Classes.Classification object at 0x00000... | F | 17 |
| UsePhase | Use phase sectors | Process | <ODYM_Classes.Classification object at 0x00000... | U | 13 |
| WasteManagementIndustries | Waste management industries | Process | <ODYM_Classes.Classification object at 0x00000... | W | 19 |
| Engineering materials | Engineering materials considered | Material | <ODYM_Classes.Classification object at 0x00000... | m | 41 |
| Good | Goods and products considered | Material | <ODYM_Classes.Classification object at 0x00000... | g | 13 |
| Waste_Scrap | waste and scrap types considered | Material | <ODYM_Classes.Classification object at 0x00000... | w | 34 |
In [8]:
Copied!
Tutorial_MFA_System.ParameterDict
Tutorial_MFA_System.ParameterDict
Out[8]:
{'Par_ManufacturingYield': <ODYM_Classes.Parameter at 0x237678a1280>,
'Par_ElementContent_Materials': <ODYM_Classes.Parameter at 0x23767bf1fd0>}
In [9]:
Copied!
print(Tutorial_MFA_System.ProcessList)
print([i.Name for i in Tutorial_MFA_System.ProcessList])
print([i.ID for i in Tutorial_MFA_System.ProcessList])
print(Tutorial_MFA_System.ProcessList)
print([i.Name for i in Tutorial_MFA_System.ProcessList])
print([i.ID for i in Tutorial_MFA_System.ProcessList])
[<ODYM_Classes.Process object at 0x0000023767BEB880>, <ODYM_Classes.Process object at 0x0000023767BEBD00>, <ODYM_Classes.Process object at 0x0000023767BEB940>, <ODYM_Classes.Process object at 0x0000023767BEB7C0>, <ODYM_Classes.Process object at 0x0000023767BEB5E0>, <ODYM_Classes.Process object at 0x0000023767BEBA60>, <ODYM_Classes.Process object at 0x0000023767BEBCA0>] ['Material production', 'Manufacturing_Construction', 'Use phase', 'Waste mgt. industries', 'Material markets', 'Product markets', 'Waste_Scrap markets'] [2, 3, 4, 5, 'm2', 'm3', 'm5']
5) Building the MFA model.¶
With the parameter loaded into the MFA system structure the system model can now be built as shown in the previous tutorials.