@@ -658,9 +658,11 @@ def _feedstock_marginal_cost(self, inputs, marginal_cost_data):
658658
659659 return np .full (self .n_timesteps , marginal_cost_scalar )
660660
661- def get_upstream_techs_for_commodity (self , tech_name : str , commodity : str ):
661+ def get_upstream_techs_for_commodity (
662+ self , tech_name : str , commodity : str , include_feedstock_sources = True
663+ ):
662664 """Get the name of technologies that are upstream
663- of `tech_name` and that output `commodity`
665+ of `tech_name` and that output `commodity`.
664666
665667 Args:
666668 tech_name (str): name of technology
@@ -669,6 +671,11 @@ def get_upstream_techs_for_commodity(self, tech_name: str, commodity: str):
669671 Returns:
670672 list[str]: list of technologies upstream of the tech_name that produce a given commodity
671673 """
674+ if include_feedstock_sources :
675+ input_techs = self .input_techs | set (self .feedstock_comps )
676+ else :
677+ input_techs = self .input_techs .copy ()
678+
672679 # figure out where the upstream commodity is coming from
673680 upstream_components = nx .ancestors (self .technology_graph , tech_name )
674681 # iterates through a list of 3 length tuples (source, dest, commodity)
@@ -678,36 +685,38 @@ def get_upstream_techs_for_commodity(self, tech_name: str, commodity: str):
678685 if s [0 ] in upstream_components and s [2 ] == commodity
679686 ]
680687 # get the technologies that are available to the controller
681- upstream_techs = set (upstream_components_shared_commodity ).intersection (
682- set (self .input_techs )
683- )
688+ upstream_techs = set (upstream_components_shared_commodity ).intersection (set (input_techs ))
684689 return list (upstream_techs )
685690
686- def find_converter_techs (self ):
691+ def find_converter_techs (self , include_feedstock_sources = True ):
687692 """Get the name of the technology that transforms a commodity.
693+ Does not include feedstocks.
688694
689695 Returns:
690696 set(tuple): set of converter technologies formatted as
691697 (input_commodity, converter tech name, output_commodity)
692698 """
699+ if include_feedstock_sources :
700+ input_techs = self .input_techs | set (self .feedstock_comps )
701+ else :
702+ input_techs = self .input_techs .copy ()
693703 if not self .multi_commodity_system :
694704 return
695705
696706 converter_techs = set ()
697707
698708 edges = list (self .technology_graph .edges (data = "commodity" ))
699709 upstream_converter = None
700- # for tech in self.input_techs:
701710 for edge in edges :
702711 tech , dest_tech , cmod = edge
703- if tech in self . input_techs :
712+ if tech in input_techs :
704713 tech_output_commodity = self ._get_commodity_for_tech (tech )
705714
706715 # NOTE: unsure how this would work for systems with tiered converters
707716 # aka - maybe have to eliminate a converter once we've discovered it
708717 if upstream_converter is None :
709718 upstream_techs = nx .ancestors (self .technology_graph , tech ).intersection (
710- set (self . input_techs )
719+ set (input_techs )
711720 )
712721 else :
713722 idx_upstream_converter = [
@@ -721,7 +730,7 @@ def find_converter_techs(self):
721730 if i > min (idx_upstream_converter )
722731 ]
723732 all_upstream_techs = nx .ancestors (self .technology_graph , tech ).intersection (
724- set (self . input_techs )
733+ set (input_techs )
725734 )
726735 upstream_techs = all_upstream_techs .intersection (
727736 set (downstream_of_previous_converter )
0 commit comments