def RunUtilities(self, sense='single'): # Get the pressure difference (Using an external utility) pUtil = UtilityRunner( argv=[self.pCmd, "-case", self.case_path, "-latestTime"], silent=True, logname="Pressure") pUtil.add("PressureDifference", "Pressure drop = (%f%) between inlet and outlet", idNr=1) pUtil.start() deltaP = UtilityRunner.get(pUtil, "PressureDifference")[0] tUtil = UtilityRunner( argv=[self.tCmd, "-case", self.case_path, "-latestTime"], silent=True, logname="Temperature") tUtil.add("TemperatureDifference", "Temperature drop = (%f%) between inlet and outlet", idNr=1) tUtil.start() deltaT = UtilityRunner.get(tUtil, "TemperatureDifference")[0] if sense == "multi": return float(deltaT), float(deltaP) else: return float(deltaT)
def RunUtilities(self, sense='single'): # Get the pressure difference (Using an external utility) pUtil = UtilityRunner( argv=[self.pCmd, "-case", self.case_path, "-latestTime"], silent=True, logname="Pressure") pUtil.add("PressureDifference", "Pressure drop = (%f%) between inlet and outlet", idNr=1) pUtil.start() deltaP = UtilityRunner.get(pUtil, "PressureDifference")[0] if sense == "multi": # Get the mass flow (Using an external utility) mUtil = UtilityRunner( argv=[self.mCmd, "-case", self.case_path, "-latestTime"], silent=True, logname="MassFlow") mUtil.add("mass", "Flux at outlet = (%f%)", idNr=1) mUtil.start() massFlow = UtilityRunner.get(mUtil, "mass")[0] return float(deltaP), float(massFlow) else: return float(deltaP)
def RunUtilities(): current = os.getcwd() solver1 = "icoUncoupledKinematicCustomInteractionFoam" # run parcelFoam for one timestep: mCalculated = UtilityRunner(argv=[solver1, "-case", current], silent=True, logname="ParticleEscape") print( "RunUtilities(x): icoUncoupledKinematicCustomInteractionFoam run for 1 timestep" ) mCalculated.add("massEscape", "- escape = outflow_top = (%f%)", idNr=1) mCalculated.add("massIntroduced", "- mass introduced = (%f%)", idNr=1) mCalculated.start() massEscape1 = UtilityRunner.get(mCalculated, "massEscape")[0] print("RunUtilities(): read massEscape to a number", str(massEscape1)) massIntro1 = UtilityRunner.get(mCalculated, "massIntroduced")[0] print("RunUtilities(): read massIntroduced to a number", str(massIntro1)) if ((platform == 'isambard_test') or (platform == 'isca_test')): subprocess.call(['rm', '-rf', current + '/0.011']) print("RunUtilities(): removed 0.011 directory") # remove redundant files subprocess.call([ 'pyFoamClearCase.py', current, '--after=0.01', '--processors-remove' ]) subprocess.call(['rm', '-rf', current + '/0']) print("RunUtilities(): removed processor directories and 0 directory") else: subprocess.call(['rm', '-rf', current + '/262.001']) print("RunUtilities(): removed 262.001 directory") # remove redundant files subprocess.call([ 'pyFoamClearCase.py', current, '--after=262', '--processors-remove' ]) subprocess.call(['rm', '-rf', current + '/0']) print("RunUtilities(): removed processor directories and 0 directory") with open(current + "/efficiency.txt", "a") as myfile_efficiency: myfile_efficiency.write( str((float(massIntro1) - float(massEscape1)) / float(massIntro1)) + '\n') print("RunUtilities(): written efficiency to a file")
def RunUtilities(self, sense='multi'): # Get the pressure difference (Using an external utility) pUtil = UtilityRunner( argv=[self.pCmd, "-case", self.case_path, "-latestTime"], silent=True, logname="Pressure") pUtil.add("PressureDifference", "Total pressure drop = (%f%) between Inlet and Outlet1", idNr=1) pUtil.add("PressureDifference2", "Total pressure drop = (%f%) between Inlet and Outlet2", idNr=1) pUtil.start() deltaP = UtilityRunner.get(pUtil, "PressureDifference")[0] deltaP2 = UtilityRunner.get(pUtil, "PressureDifference2")[0] if sense == "multi": return float(deltaP), float(deltaP2) else: return max(np.abs(float(deltaP)), np.abs(float(deltaP2))),
def RunUtilities(self, sense='single'): lines = [] lines2 = [] if os.path.isdir(self.case_path + "10000"): N = 1000 else: N = 1 subprocess.call( ['pyFoamCopyLastToFirst.py', self.case_path, self.case_path]) subprocess.call([ 'pyFoamClearCase.py', self.case_path, '--processors-remove', '--keep-postprocessing' ]) # Get the pressure difference (Using an external utility) pUtil = UtilityRunner( argv=[self.pCmd, "-case", self.case_path, "-latestTime"], silent=True, logname="Pressure") pUtil.add("PressureDifference", "Pressure drop = (%f%) between inlet and outlet", idNr=1) pUtil.start() deltaP = UtilityRunner.get(pUtil, "PressureDifference")[0] if sense == "multi": # Get the mass flow (Using an external utility) mUtil = UtilityRunner( argv=[self.mCmd, "-case", self.case_path, "-latestTime"], silent=True, logname="MassFlow") mUtil.add("mass", "Flux at outlet = (%f%)", idNr=1) mUtil.start() massFlow = UtilityRunner.get(mUtil, "mass")[0] return -float(deltaP), -float(massFlow) else: return -float(deltaP)
# Run the solver run = ConvergenceRunner(BoundingLogAnalyzer(), argv=[solver, "-case", case], silent=True) run.start() print "Last Time = ", dire.getLast() # Get the pressure difference (Using an external utility) pUtil = UtilityRunner(argv=[pCmd, "-case", case], silent=True, logname="Pressure") pUtil.add("deltaP", "Pressure at .* Difference .*\] (.+)") pUtil.start() deltaP = pUtil.get("deltaP")[0] # Get the mass flow mUtil = UtilityRunner(argv=[mCmd, "-case", case, "-latestTime"], silent=True, logname="MassFlow") mUtil.add("mass", "Flux at (.+?) .*\] (.+)", idNr=1) mUtil.start() massFlow = mUtil.get("mass", ID="outlet")[0] # Archive the results dire.lastToArchive("vel=%g" % (val)) # Clear results dire.clearResults()
val=(maximum*i)/nr print "Inlet velocity:",val sol.replaceBoundary("inlet","(%f 0 0)" %(val)) # Run the solver run=ConvergenceRunner(BoundingLogAnalyzer(),argv=[solver,"-case",case],silent=True) run.start() print "Last Time = ",dire.getLast() # Get the pressure difference (Using an external utility) pUtil=UtilityRunner(argv=[pCmd,"-case",case],silent=True,logname="Pressure") pUtil.add("deltaP","Pressure at .* Difference .*\] (.+)") pUtil.start() deltaP=pUtil.get("deltaP")[0] # Get the mass flow mUtil=UtilityRunner(argv=[mCmd,"-case",case,"-latestTime"],silent=True,logname="MassFlow") mUtil.add("mass","Flux at (.+?) .*\] (.+)",idNr=1) mUtil.start() massFlow=mUtil.get("mass",ID="outlet")[0] # Archive the results dire.lastToArchive("vel=%g" % (val)) # Clear results dire.clearResults() # Output current stuff