def stopIfDamaged(): global mode if O.iter<2 or not plot.data.has_key('sigma'): return # do nothing at the very beginning sigma,eps=plot.data['sigma'],plot.data['eps'] extremum=max(sigma) if (strainer.strainRate>0) else min(sigma) minMaxRatio=0.5 if mode=='tension' else 0.5 if extremum==0: return # uncomment to get graph for the very first time stopIfDamaged() is called #eudoxos.estimatePoissonYoung(principalAxis=axis,stress=strainer.avgStress,plot=True,cutoff=0.3) print O.tags['id'],mode,strainer.strain,sigma[-1] import sys; sys.stdout.flush() if abs(sigma[-1]/extremum)<minMaxRatio or abs(strainer.strain)>(5e-3 if isoPrestress==0 else 5e-2): if mode=='tension' and doModes & 2: # only if compression is enabled mode='compression' O.save('/tmp/uniax-tension.woo.gz') print "Saved /tmp/uniax-tension.woo.gz (for use with interaction-histogram.py and uniax-post.py)" print "Damaged, switching to compression... "; O.pause() # important! initTest must be launched in a separate thread; # otherwise O.load would wait for the iteration to finish, # but it would wait for initTest to return and deadlock would result import thread; thread.start_new_thread(initTest,()) return else: print "Damaged, stopping." ft,fc=max(sigma),min(sigma) print 'Strengths fc=%g, ft=%g, |fc/ft|=%g'%(fc,ft,abs(fc/ft)) title=O.tags['description'] if 'description' in O.tags.keys() else O.tags['params'] print 'gnuplot',plot.saveGnuplot(O.tags['id'],title=title) print 'Bye.' #O.pause() sys.exit(0)
def stopIfDamaged(): global mode if O.iter<2 or 'sigma' not in plot.data: return # do nothing at the very beginning sigma,eps=plot.data['sigma'],plot.data['eps'] extremum=max(sigma) if (strainer.maxStrainRate>0) else min(sigma) # FIXME: only temporary, should be .5 minMaxRatio=0.5 if mode=='tension' else 0.5 if extremum==0: return print(O.tags['id'],mode,strainer.strain[axis],sigma[-1]) #print 'strain',strainer['strain'],'stress',strainer['stress'] import sys; sys.stdout.flush() if abs(sigma[-1]/extremum)<minMaxRatio or abs(strainer.strain[axis])>6e-3: if mode=='tension' and doModes & 2: # only if compression is enabled mode='compression' #O.save('/tmp/uniax-tension.xml.bz2') print("Damaged, switching to compression... "); O.pause() # important! initTest must be launched in a separate thread; # otherwise O.load would wait for the iteration to finish, # but it would wait for initTest to return and deadlock would result import _thread; _thread.start_new_thread(initTest,()) return else: print("Damaged, stopping.") ft,fc=max(sigma),min(sigma) print('Strengths fc=%g, ft=%g, |fc/ft|=%g'%(fc,ft,abs(fc/ft))) title=O.tags['description'] if 'description' in O.tags.keys() else O.tags['params'] print('gnuplot',plot.saveGnuplot(O.tags['id'],title=title)) print('Bye.') # O.pause() sys.exit(0)
def stopIfDamaged(): global mode if O.iter<2 or 'sigma' not in plot.data: return # do nothing at the very beginning sigma,eps=plot.data['sigma'],plot.data['eps'] extremum=max(sigma) if (strainer.strainRate>0) else min(sigma) minMaxRatio=0.5 if mode=='tension' else 0.5 if extremum==0: return # uncomment to get graph for the very first time stopIfDamaged() is called #eudoxos.estimatePoissonYoung(principalAxis=axis,stress=strainer.avgStress,plot=True,cutoff=0.3) print(O.tags['id'],mode,strainer.strain,sigma[-1]) import sys; sys.stdout.flush() if abs(sigma[-1]/extremum)<minMaxRatio or abs(strainer.strain)>(5e-3 if isoPrestress==0 else 5e-2): if mode=='tension' and doModes & 2: # only if compression is enabled mode='compression' O.save('/tmp/uniax-tension.woo.gz') print("Saved /tmp/uniax-tension.woo.gz (for use with interaction-histogram.py and uniax-post.py)") print("Damaged, switching to compression... "); O.pause() # important! initTest must be launched in a separate thread; # otherwise O.load would wait for the iteration to finish, # but it would wait for initTest to return and deadlock would result import _thread; _thread.start_new_thread(initTest,()) return else: print("Damaged, stopping.") ft,fc=max(sigma),min(sigma) print('Strengths fc=%g, ft=%g, |fc/ft|=%g'%(fc,ft,abs(fc/ft))) title=O.tags['description'] if 'description' in O.tags.keys() else O.tags['params'] print('gnuplot',plot.saveGnuplot(O.tags['id'],title=title)) print('Bye.') #O.pause() sys.exit(0)