QSD-Group / QSDsan

Quantitative Sustainable Design (QSD) of sanitation and resource recovery systems.
https://qsdsan.com
Other
30 stars 12 forks source link

BM factor #45

Closed vlmorgan93 closed 2 years ago

vlmorgan93 commented 2 years ago

It does not recognize a purchase cost correctly setting the BM factor to one.

yalinli2 commented 2 years ago

OK I figured this out. Firstly to give some context, the question was actually about even with this line: https://github.com/QSD-Group/QSDsan/blob/0b1b77ed69336a0001b83a7fda1ab8c17d432719/qsdsan/sanunits/_solar_reclaimer.py#L86

There'll still be an error like:

/Users/yalinli_cabbi/OneDrive/Coding/bst/biosteam/_unit.py:629: RuntimeWarning: the purchase cost item, 'Battery System', has no defined bare-module factor in the 'SolarReclaimer.F_BM' dictionary; bare-module factor now has a default value of 1 warn(warning) /Users/yalinli_cabbi/OneDrive/Coding/bst/biosteam/_unit.py:629: RuntimeWarning: the purchase cost item, 'Solar Cost', has no defined bare-module factor in the 'SolarReclaimer.F_BM' dictionary; bare-module factor now has a default value of 1 warn(warning)

This was because that in biosteam, _init_results (would be called by __init__), will do this:

    def _init_results(self):
        try:
            #: [dict] All bare-module factors for each purchase cost.
            #: Defaults to values in the class attribute `_F_BM_default`.
            self.F_BM = self._F_BM_default.copy()
        except AttributeError:
            self.F_BM = {}

which overwrite the F_BM

So, the correct way (if you wish to set all F_BM to a certain number) is to use the F_M_default attribute, which is what you are doing now: https://github.com/QSD-Group/QSDsan/blob/0b1b77ed69336a0001b83a7fda1ab8c17d432719/qsdsan/sanunits/_solar_reclaimer.py#L50

So, you can remove the following two lines (because now you have that line 50): https://github.com/QSD-Group/QSDsan/blob/0b1b77ed69336a0001b83a7fda1ab8c17d432719/qsdsan/sanunits/_solar_reclaimer.py#L86 https://github.com/QSD-Group/QSDsan/blob/0b1b77ed69336a0001b83a7fda1ab8c17d432719/qsdsan/sanunits/_solar_reclaimer.py#L91