def loadCellFromFile(step,numOfLayer = 8,eta = 1.,kappa = 0.2,fastkappa = 2.0, targetid = 135): #################################### loadedcell = qd.objReadCell("qdObject_step=%03d.obj"%step) loadedcell.setInitialParameters() # Flipping the Face ID after Loading to cell so that the face id before and after matches faces = qd.CellFaceIterator(loadedcell) facecount = loadedcell.countFaces() face= faces.next() while face != None: faceid = face.getID() face.setID(facecount-faceid+1) #print face.getID() face = faces.next() ###################################################### #print "######################################################" #print "#"," "*10, "step %d"%step #print "######################################################" #settig target Form Matrix : #TMF step corresponds to coordinate step #### sf.setTargetFormMatrix(loadedcell,step) #### CELL PARAMETERS #### loadedcell.setKappa(kappa) loadedcell.setEta(eta) #setTargetFormMatrix(loadedcell,step) loadedcell.setParameters() #calculating forces, stress-matrix and strain-matrix loadedcell.calculateStressStrain() loadedcell = fastGrowth(loadedcell,targetid,fastkappa = fastkappa) ###################################################### #latdev.plotSurface(loadedcell,numOfLayer,name="dome_remake_%03d.png"%step,ids=False,alpha = 1.,elev = 7) #plotTargetFaceArrayGrowSurface(loadedcell,numOfLayer) return loadedcell
numOfLayer = args.layer gamma = args.gamma anglethreshold = args.angle targetface = args.target azim = args.azimuthal elev = args.elevation ################################################################################# import sys import os for step in range(startStep, endStep + 1): percentStep = int((step - startStep) / float(endStep - startStep) * 100) sys.stdout.write('\r' + "step : " + str(step) + " " + "#" * percentStep + ' ' * (100 - percentStep) + "%d%%" % percentStep) sys.stdout.flush() cell = qd.objReadCell("qdObject_step=%03d.obj" % step) # Flipping the Face ID after Loading to cell so that the face id before and after matches faces = qd.CellFaceIterator(cell) facecount = cell.countFaces() face = faces.next() while face != None: faceid = face.getID() face.setID(facecount - faceid + 1) #print face.getID() face = faces.next() ###################################################### #settig target Form Matrix : #TMF step corresponds to coordinate step #### cell = sf.setTargetFormMatrix(cell, step) cell.setParameters()
def plotMeanGrowthRate(step, numOfLayer=8, eta=0, targetface=10, alpha=0.8, Length=1.0, save=False, azim=-70, elev=50): import matplotlib.colors as colors import matplotlib.cm as cmx #import the libraries from mpl_toolkits.mplot3d import Axes3D import matplotlib as mpl from mpl_toolkits.mplot3d.art3d import Poly3DCollection import numpy as np import matplotlib.pyplot as plt #limits of the plot radius = (numOfLayer > 1) * (np.sqrt(3.) * (numOfLayer - 1) - Length) + Length #the radius of circle to be projected on #plotting part fig = plt.figure(frameon=False, figsize=(10, 8)) #fig = plt.figure(frameon=False) fig.subplots_adjust(left=0, right=1, bottom=0, top=1) ax = Axes3D(fig) ax.set_xlim((-0.7 * radius, 0.7 * radius)) ax.set_ylim((-0.7 * radius, 0.7 * radius)) ax.set_zlim((-0., 1.4 * radius)) ax.axis('off') ax.xaxis.pane.set_edgecolor('black') ax.yaxis.pane.set_edgecolor('black') #ax.xaxis.pane.fill = False #ax.yaxis.pane.fill = False #ax.zaxis.pane.fill = False ####################################################################### # Checking if the files exists if not going to step down try: #cell = qd.objReadCell("qdObject_step=%03d.obj"%step) cell = sf.loadCellFromFile(step) #print "success" except: #print " exception reached" step -= 1 #sys.stdout.write("step : ", step , os.getcwd()) #sys.stdout.flush() #print "step : ", step , os.getcwd() plotMeanGrowthRate(step, azim=azim, elev=elev, eta=eta, save=save) return #print "Step : ", step ######################################################################## # Loading the step-1 step # ######################################################################## completeFaceArray = getFaceAreaArray(step) rateDict = {} for key in completeFaceArray: value = np.array(completeFaceArray[key]) rateDict[key] = np.mean(np.array(getRates(value))) #################################################################################### # PLotting the faces now #################################################################################### cell = qd.objReadCell("qdObject_step=%03d.obj" % step) # Flipping the Face ID after Loading to cell so that the face id before and after matches faces = qd.CellFaceIterator(cell) facecount = cell.countFaces() face = faces.next() while face != None: faceid = face.getID() face.setID(facecount - faceid + 1) #print face.getID() face = faces.next() ###################################################### #settig target Form Matrix : #TMF step corresponds to coordinate step #### cell = sf.setTargetFormMatrix(cell, step) cell.setParameters() #calculating forces, stress-matrix and strain-matrix #cell.calculateVertexForce() cell.calculateStrain() ######## ######## ######## ######## ######## # Plotting the Cell # ######## ######## ######## ######## ######## ######### Color Map jet = cm = plt.get_cmap('viridis') maxvalue = 0.006 minvalue = 0. #print "Max value", maxvalue, " minvalue", minvalue cNorm = colors.Normalize(vmin=minvalue, vmax=maxvalue) scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=jet) faces = qd.CellFaceIterator(cell) ################### face = faces.next() xcenarray = [] ycenarray = [] zcenarray = [] counter = 0 while (face != None): if face.getID() == 1: face = faces.next() continue faceid = face.getID() #grabbing face id xlist = [] ylist = [] zlist = [] xproj = [] yproj = [] zproj = [] #print "== Face ID : ", faceid, "==" xmean = face.getXCentralised() ymean = face.getYCentralised() zmean = face.getZCentralised() edges = qd.FaceEdgeIterator(face) edge = edges.next() while edge != None: ####grabbing the origin of edge#### #centralised coordiante vertex = edge.Org() #print vertex.getID() xCoord1 = vertex.getXcoordinate() yCoord1 = vertex.getYcoordinate() zCoord1 = vertex.getZcoordinate() xlist.append(xCoord1) ylist.append(yCoord1) zlist.append(zCoord1) edge = edges.next() xlist.append(xlist[0]) ylist.append(ylist[0]) zlist.append(zlist[0]) verts = [zip(xlist, ylist, zlist)] #adding to 3d plot xcenarray.append(face.getXCentralised()) ycenarray.append(face.getYCentralised()) zcenarray.append(face.getZCentralised()) #print "face ID : ", face.getID(), " ratio : ", ratio #ratio = (face.getStrainTrace()+minTrace)/(minTrace+maxTrace) """if sf.checkExternalFace(face): ratio = 0. color = scalarMap.to_rgba(ratio) else: """ ratio = rateDict[face.getID()] #print ratio color = scalarMap.to_rgba(ratio) #print ratio #print face.getZCentralised(), alpha_fac #ax.add_collection3d(arrow(xcen-0.5,ycen-0.5,zcen-0.5,xcen+0.5,ycen+0.5,zcen+0.5)) pc = Poly3DCollection(verts, alpha=alpha, facecolor=color, linewidths=1, zorder=0) pc.set_edgecolor('k') ax.add_collection3d(pc) ax.scatter(xcenarray[-1], ycenarray[-1], zcenarray[-1], c='r') face = faces.next() #if face.getID() == 1: break #plt.clf() ax.view_init(azim=azim, elev=elev) scalarMap._A = [] ax.set_title("Mean Growth Rate Step %d" % step) cbar_ax = fig.add_axes([0.873, 0.2, 0.04, 0.55]) clrbar = plt.colorbar( scalarMap, cax=cbar_ax) #,orientation='horizontal',cax = cbar_ax) clrbar.ax.tick_params(labelsize=20) clrbar.set_label("Growth Rate step", fontsize=30) #ax.set_title("Time %d : Magnitude of Strain : Max %.4f ; Min %.4f"%(step,maxTrace,minTrace), fontsize = 20) #print xcenarray-0.5 #plt.close("all") if save: saveDirectory = "../meanGrowthRate" import os if not os.path.exists(saveDirectory): os.makedirs(saveDirectory) plt.savefig(saveDirectory + r"/meanGrowthRate_eta=%.3f_time=%03d.png" % (eta, step), transparent=True) plt.close() return