def getData2(variable1,variable2,data): fudge = 1.1 # Srinath added 10% to wcell?? keys = ['increment','time','exx','sxx','epamp','sxxT'] indexdict = Mdict.instantiate(keys,list(range(len(keys)))) scaledict = Mdict.instantiate(keys,[1,1.e9,1.e2*fudge,1.e6,1.e2*fudge,1.e6]) xy = data[:,[indexdict[variable1],indexdict[variable2]]] scale = [scaledict[variable1],scaledict[variable2]] return xy, scale
def solveEqnsNew(ep, r1bar=r1bartry, r2bar=r2bartry, r3bar=r3bartry, alphabar=alphabartry, offset=0, step=0.01, tol=1.e-8, r3barfac=0.98, n1=3, n2=3): # largest cutoff radius possible is r3bar # smallest cutoff radius possible is r2bar # tries to solve for largest cutoff radius possible # constructs smooth potential so that value of potential at r2bar is -ep # n1, n2 are order of splines while r3barfac > 0: r3barcurr = r2bar + (r3bar - r2bar) * r3barfac func = lambda coeff: solveEqnsSub(coeff, ep, r1bar, r2bar, r3barcurr, alphabar, offset, n1, n2) coeffsol = spo.fsolve(func, np.zeros(n1 + n2 + 2)) spline1, spline2 = coeffsol[0:n1 + 1], coeffsol[n1 + 1:n1 + n2 + 2] maxval2 = Mmath.maxPolyRoot(spline2) if maxval2 > tol: r3barfac = r3barfac - step else: keyslist = [ 'spline1', 'spline2', 'r1bar', 'r2bar', 'r3bar', 'alphabar', 'offset' ] valslist = [ spline1, spline2, r1bar, r2bar, r3barcurr, alphabar, offset ] return Mdict.instantiate(keyslist, valslist) print('Bad input')
def solveEqnsWarner( r3bar, r1bar=r1bartrywarner, alphabar=alphabartry, offset=0 ): # as r3bar (cutoff) increases, potential changes from brittle to ductile; brittle - r3bar = r2bartry; ductile - r3bar = 0.99*r3bartry (values outside bounds lead to bad potentials) func = lambda coeff: solveEqnsSubWarner(coeff, r1bar, r3bar, alphabar, offset) coeffsol = spo.fsolve(func, np.zeros(4)) keyslist = ['spline1', 'r1bar', 'r3bar', 'alphabar', 'offset'] valslist = [coeffsol, r1bar, r3bar, alphabar, offset] return Mdict.instantiate(keyslist, valslist)
def createPlotDicts(): colorlist = ['r','g','b','m','y'] markersizedisl = 100 # in points markersizesn = 25 # in points plotkeys = ['edgecolor','facecolor','s'] markerkeys = ['markertype', 'rotation'] objectkeys = ['spos','opos','pos','neg'] nucdictp = Mdict.instantiate(plotkeys,['k','k',markersizesn]) obsdictp = Mdict.instantiate(plotkeys,['k','None',markersizesn]) disldictp = Mdict.instantiate(plotkeys,[colorlist,'None',markersizedisl]) nucdictm = Mdict.instantiate(markerkeys,['o',0]) obsdictm = Mdict.instantiate(markerkeys,['o',0]) dislposdictm = Mdict.instantiate(markerkeys,['disl',0]) dislnegdictm = Mdict.instantiate(markerkeys,['disl',180]) plotdict = Mdict.instantiate(objectkeys,[nucdictp,obsdictp,disldictp,disldictp]) markerdict = Mdict.instantiate(objectkeys,[nucdictm,obsdictm,dislposdictm,dislnegdictm]) return (plotdict, markerdict)
def createPlotDicts(): colorlist = ['r', 'g', 'b', 'm', 'y'] markersizedisl = 100 # in points markersizesn = 25 # in points plotkeys = ['edgecolor', 'facecolor', 's'] markerkeys = ['markertype', 'rotation'] objectkeys = ['spos', 'opos', 'pos', 'neg'] nucdictp = Mdict.instantiate(plotkeys, ['k', 'k', markersizesn]) obsdictp = Mdict.instantiate(plotkeys, ['k', 'None', markersizesn]) disldictp = Mdict.instantiate(plotkeys, [colorlist, 'None', markersizedisl]) nucdictm = Mdict.instantiate(markerkeys, ['o', 0]) obsdictm = Mdict.instantiate(markerkeys, ['o', 0]) dislposdictm = Mdict.instantiate(markerkeys, ['disl', 0]) dislnegdictm = Mdict.instantiate(markerkeys, ['disl', 180]) plotdict = Mdict.instantiate(objectkeys, [nucdictp, obsdictp, disldictp, disldictp]) markerdict = Mdict.instantiate( objectkeys, [nucdictm, obsdictm, dislposdictm, dislnegdictm]) return (plotdict, markerdict)
def solveEqnsNew(ep,r1bar=r1bartry,r2bar=r2bartry,r3bar=r3bartry,alphabar=alphabartry,offset=0,step=0.01,tol=1.e-8,r3barfac=0.98,n1=3,n2=3): # largest cutoff radius possible is r3bar # smallest cutoff radius possible is r2bar # tries to solve for largest cutoff radius possible # constructs smooth potential so that value of potential at r2bar is -ep # n1, n2 are order of splines while r3barfac > 0: r3barcurr = r2bar + (r3bar - r2bar)*r3barfac func = lambda coeff: solveEqnsSub(coeff,ep,r1bar,r2bar,r3barcurr,alphabar,offset,n1,n2) coeffsol = spo.fsolve(func,np.zeros(n1+n2+2)) spline1, spline2 = coeffsol[0:n1+1], coeffsol[n1+1:n1+n2+2] maxval2 = Mmath.maxPolyRoot(spline2) if maxval2 > tol: r3barfac = r3barfac - step else: keyslist = ['spline1','spline2','r1bar','r2bar','r3bar','alphabar','offset'] valslist = [spline1,spline2,r1bar,r2bar,r3barcurr,alphabar,offset] return Mdict.instantiate(keyslist,valslist) print('Bad input')
def getData1(variable,data): keys = ['sxx', 'syy', 'sxy', 'u', 'v'] indexdict = Mdict.instantiate(keys,[2,3,4,2,3]) return data[:,0], data[:,1], data[:,indexdict[variable]]
def getFileInfo(variable): keys = ['sxx', 'syy', 'sxy', 'u', 'v'] filetypedict = Mdict.instantiate(keys,['stress']*3 + ['displ']*2) # this depends on what's used in GetDDFileName datakeydict = Mdict.instantiate(keys,['Stress']*3 + ['Displacement']*2) # this depends on the key used in .plt file return (filetypedict[variable], datakeydict[variable])
def solveEqnsWarner(r3bar,r1bar=r1bartrywarner,alphabar=alphabartry,offset=0): # as r3bar (cutoff) increases, potential changes from brittle to ductile; brittle - r3bar = r2bartry; ductile - r3bar = 0.99*r3bartry (values outside bounds lead to bad potentials) func = lambda coeff: solveEqnsSubWarner(coeff,r1bar,r3bar,alphabar,offset) coeffsol = spo.fsolve(func,np.zeros(4)) keyslist = ['spline1','r1bar','r3bar','alphabar','offset'] valslist = [coeffsol,r1bar,r3bar,alphabar,offset] return Mdict.instantiate(keyslist,valslist)