plt.camera.SetParallelScale(1.8) plt.camera.SetViewUp([-0.1, 1, -0.3]) # Let's start with creating 3 colonies of 1 cell each # of types: red, green and blue, in different positions in space # and with 3 different rates of division (tdiv in hours) c1 = Colony([Cell([1, 0, 0], tdiv=8)], c="b") c2 = Colony([Cell([0, 1, 0], tdiv=9)], c="g") c3 = Colony([Cell([0, 0, 1], tdiv=10)], c="r") colonies = [c1, c2, c3] # time goes from 0 to 90 hours pb = ProgressBar(0, 50, step=0.1, c=1) for t in pb.range(): msg = "[Nb,Ng,Nr,t] = " plt.actors = [] # clean up the list of actors for colony in colonies: newcells = [] for cell in colony.cells: if cell.dieAt(t): continue if cell.divideAt(t): newc = cell.split() # make daughter cell plt += Line(cell.pos, newc.pos, c="k", lw=3, alpha=0.5) newcells.append(newc) newcells.append(cell) colony.cells = newcells
plt = Plotter(interactive=False) bck = plt.load(dataurl+"images/schrod.png").alpha(.3).scale(.0256).pos([0,-5,-.1]) barrier = Line(np.stack((x, V*15, np.zeros_like(x)), axis=1), c="black", lw=2) box = bck.box().c('black') lines = [] for i in range(0, Nsteps): for j in range(500): Psi += d_dt(Psi) * dt # integrate for a while before showing things A = np.real(Psi * np.conj(Psi)) * 1.5 # psi squared, probability(x) coords = np.stack((x, A), axis=1) Aline = Line(coords, c="db", lw=3) plt.show(barrier, bck, Aline, box).remove(Aline) lines.append([Aline, A]) # store objects # now show the same lines along z representing time plt.actors= [] # clean up internal list of objects to show plt.camera.Elevation(20) plt.camera.Azimuth(20) bck.alpha(1) for i in range(Nsteps): p = [0, 0, i*size/Nsteps] # shift along z l, a = lines[i] l.cmap("gist_earth_r", a) plt += [box, bck, l.pos(p), barrier.clone().alpha(0.3).pos(p)] plt.show() interactive().close()
positions_rk.append(y_rk) pb.print("Integrate: RK-4 and Euler") #################################################### # Visualize the result #################################################### vp = Plotter(interactive=0, axes=2) # choose axes type nr.2 vp.ytitle = "u(x,t)" vp.ztitle = "" # will not draw z axis for i in x: vp += Point([i, 0, 0], c="green", r=6) pts_actors_eu = vp.actors # save a copy of the actors list pts_actors_eu[0].legend = "Euler method" vp.actors = [] # clean up the list for i in x: vp += Point([i, 0, 0], c="red", r=6) pts_actors_rk = vp.actors # save a copy of the actors list pts_actors_rk[0].legend = "Runge-Kutta4" # merge the two lists and set it as the current actors vp.actors = pts_actors_eu + pts_actors_rk # let's also add a fancy background image from wikipedia vp.load(datadir + "images/wave_wiki.png", alpha=0.8).scale(0.4).pos(0, -100, -20) vp += __doc__ pb = ProgressBar(0, Nsteps, c="red", ETA=1)