Skip to content

Commit

Permalink
Adaptign for tqdm progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
andr1976 committed Oct 3, 2021
1 parent 703ae7d commit ce69385
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ src/hyddown/__pycache__/validator.cpython-38.pyc
src/hyddown/__pycache__/hdclass.cpython-38.pyc
.gitignore
src/hyddown/__pycache__/validator.cpython-38.pyc
src/hyddown/__pycache__/hdclass.cpython-38.pyc
Binary file modified src/hyddown/__pycache__/hdclass.cpython-38.pyc
Binary file not shown.
9 changes: 6 additions & 3 deletions src/hyddown/hdclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def UDproblem(self, U, rho, Pguess, Tguess):
return P1, T1, Ures


def run(self):
def run(self,generator=False):
"""
Routine for running the actual problem defined i.e. integrating the mass and energy balances
"""
Expand Down Expand Up @@ -410,7 +410,6 @@ def run(self):

# Run actual integration by updating values by numerical integration/time stepping
# Mass of fluid is calculated from previous time step mass and mass flow rate

for i in range(1, len(self.time_array)):
self.time_array[i] = self.time_array[i - 1] + self.tstep
self.mass_fluid[i] = (
Expand Down Expand Up @@ -561,7 +560,7 @@ def run(self):
self.S_mass[i] = self.fluid.smass()
self.U_mass[i] = self.fluid.umass()

print("Progress", int(i/(self.time_tot / self.tstep)*100),"%",end="\r")
#print("Progress", int(i/(self.time_tot / self.tstep)*100),"%",end="\r")

# Calculating vent temperature (adiabatic) only for discharge problem
if self.input["valve"]["flow"] == "discharge":
Expand Down Expand Up @@ -624,8 +623,12 @@ def run(self):
massflow_stop_switch = 1
if massflow_stop_switch:
self.mass_rate[i]=0
if generator == True:
yield i

self.isrun = True


def get_dataframe(self):
"""
Storing relevant results in pandas dataframe for e.g. export
Expand Down
14 changes: 6 additions & 8 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
from hyddown import HydDown
import time
from tqdm import tqdm


if __name__ == "__main__":
Expand All @@ -19,11 +20,8 @@


hdown=HydDown(input)
start = time.time()
hdown.run()
end = time.time()
print('Elapsed time: ',end-start,' sec.')
hdown.plot()

hdown.fluid.build_phase_envelope("None")
PE=hdown.fluid.get_phase_envelope_data()

for i in tqdm(hdown.run(generator=True),desc='hyddown',total=len(hdown.time_array)):
pass

hdown.plot()

0 comments on commit ce69385

Please sign in to comment.