I am firing a SPH simulation using a Dual SPH executables. It has four consecutive subprocess commands that progresses to produce the vtk files of the simulation. The problem is that assuming particle distance in SPH is very sensitive and there is no proper way to calculate it. If the particle distance is too high then it will fail to run the first command and it will give an error. I want to write a code which could read the error given by the first subprocess so that i can optimize over particle distance. Is there any way I can read the error given by the first subprocess?
Gen = subprocess.Popen(args = sph_location+"\\"+"GenCase4_win64"+" "+def_out+" "+out+"\\"+r"z -save:all", shell='TRUE')
Gen.communicate()
Dual = subprocess.Popen(args= sph_location+"\\"+"DualSPHysics4.2_win64"+" "+out+"\\"+r"z -svres -cpu", shell='TRUE')
Dual.communicate()
Vtk = subrocess.Popen(args= sphlocation+"\\"+"PartVTK4_win64"+" -savevtk "+out+"\\"+r"zPartFluid -onlytype:-all,+fluid -vars:+vol", shell='TRUE')
Surface = subprocess.Popen(args= sph_location+"\\"+"IsoSurface4_win64"+" "+r"-onlytype:+fluid -vars:+vol -saveiso surface" ,shell='TRUE')
Surface.communicate()
Gen = subprocess.Popen(args = sph_location+"\\"+"GenCase4_win64"+" "+def_out+" "+out+"\\"+r"z -save:all", shell='TRUE', stderr=subprocess.PIPE)
output,error = Gen.communicate()
print(error)
This will wait for command to finish and give you output or error depending on the state of command.