BioSTEAMDevelopmentGroup / thermosteam

BioSTEAM's Premier Thermodynamic Engine
Other
57 stars 12 forks source link

Save report bug #92

Closed Ikegwuugo closed 1 year ago

Ikegwuugo commented 1 year ago

Describe the bug Unable to save report to excel file

To Reproduce

# Import the relevant libraries 
import biosteam as bst
from biosteam import units
import thermosteam as tmo
from biosteam import Stream, settings
import numpy as np

# Create a function to simulate this process
def process(Temp):

    chemicals = bst.Chemicals([bst.Chemical("C2H4", phase="s"), "Dodecane", "Water", "N2", "O2", "CH4", "CO2"], cache=True)  ## Change
    bst.settings.set_thermo(chemicals)

    cooling_temp_after_precipitation = Temp
    temp_dryer = 373.15

    feed = bst.Stream('feed', Dodecane=800, C2H4=200, units="kg/hr")                                                        ## Change
    H101 = units.DrumDryer(ID='H101',thermo=None, split={'C2H4':0, 'Dodecane':1}, R= 1.4, H=20,length_to_diameter=25,          ## Change
                        T=temp_dryer, moisture_content=0, utility_agent="Natural gas")
    E102 = units.HXutility(ID='E102', T=cooling_temp_after_precipitation, rigorous=True)
    S101 = units.PhaseSplitter(ID='S101', outs=('Vapour_solvent_A', 'Liquid_solvent_A'))

    (feed) - H101
    (H101 - 1) - E102
    (E102) - S101

    pp_cond_sys = bst.System("pp_condenser", path=([H101, E102, S101]))

    pp_cond_sys.simulate()
    pp_cond_sys.save_report('cond_result.xlsx')
    rec_solvent = pp_cond_sys.outs[3].get_flow('kmol/hr', 'Dodecane')                                         ## Change
    feed_solv = pp_cond_sys.ins[0].get_flow('kmol/hr', 'Dodecane')                                               ## Change
    return rec_solvent, feed_solv
print (process(300.15))

Expected behavior When the save_report line is commented, the code works well. The save_report is meant to see the report from the simulation in an excel file.

Actual behavior

pp_cond_sys.save_report('cond_result.xlsx')
IndexError: invalid index kind

Version

Additional context This script might work properly for you because it works well on my colleague's computer but with a different version of biosteam (2.32.18) and thermosteam (0.28.13).

yoelcortes commented 1 year ago

@Ikegwuugo, thanks for submitting this issue! The IndexError: invalid index kind was actually resolved previously (in a recent thermosteam commit). There was also another bug with BioSTEAM using the deprecated method save in panda's xlsx writer. I just corrected this.

You should be able to save the system report if use the latest biosteam and thermosteam versions on github. Note that if you are pip installing using a github link, make sure you first delete (or pip uninstall) your old biosteam/thermosteam first since pip will not attempt to reinstall.

Thanks, Let me know if you have any question!

Ikegwuugo commented 1 year ago

@yoelcortes Thanks for your response. I deleted pip uninstalled BioSTEAM and reinstalled it. The versions of BioSTEAM and thermosteam now are 2.37.4 and 0.35.1 respectively. The IndexError: invalid index kind issue is still coming up after restarting my VScode.

yoelcortes commented 1 year ago

@Ikegwuugo, I think you might be confused with the PyPI and github versions. These are different. You can run the following to install the github versions without having to clone them:

pip uninstall thermosteam pip install git+https://github.com/BioSTEAMDevelopmentGroup/thermosteam.git

pip uninstall biosteam pip install git+https://github.com/BioSTEAMDevelopmentGroup/biosteam.git

Thanks,

Ikegwuugo commented 1 year ago

@yoelcortes Thanks! it works now!