3D (Polar/Cylindrical Coordinate) Animation of 2D Diffusion Equation using Python, Scipy, and Matplotlib
The Wrong Code Will often Provide Beautiful Result, :)
It means to compute 2d diffusion equation just like previous post in polar/cylindrical coordinate, and all went to wrong direction, :) Still trying to understand matplotlib mplot3d behavior import scipy as sp from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm from matplotlib.ticker import LinearLocator, FormatStrFormatter import matplotlib.pyplot as plt import mpl_toolkits.mplot3d.axes3d as p3 import matplotlib.animation as animation #dr = .1 #dp = .1 #nr = int(1/dr) #np = int(2*sp.pi/dp) nr = 10 np = 10 dr = 1./nr dp = 2*sp.pi/np a = .5 tmax = 100 t = 0. dr2 = dr**2 dp2 = dp**2 dt = dr2 * dp2 / (2 * a * (dr2 + dp2) ) dt /=10. print dt ut = sp.zeros([nr,np]) u0 = sp.zeros([nr,np]) ur = sp.zeros([nr,np]) ur2 = sp.zeros([nr,np]) r = sp.arange(0.,1.,dr) p = sp.arange(0.,2*sp.pi,dp) #initial for i in range(nr): for j in range(np): if ( (i>(2*nr/5.)) & (i<(3.*nr/3.)) ): u0[i,j] = 1. #print u0 def hitung_ut(ut,u0): for i in sp.arange (len(r)): if r[i]!= 0.: ur[i,:] = u0[i,:]/r[i] ur2[i,:] = u0[i,:]/(r[i]**2) ut[1:-1, 1:-1] = u0[1:-1, 1:-1] + a*dt*( (ur[1:-1, 1:-1] - ur[:-2, 1:-1])/dr+ (u0[2:, 1:-1] - 2*u0[1:-1, 1:-1] + u0[:-2,1:-1])/dr2+ (ur2[1:-1, 2:] - 2*ur2[1:-1, 1:-1] + ur2[1:-1, :-2])/dp2) #hitung_ut(ut,u0) #print ut def data_gen(framenumber, Z ,surf): global ut global u0 hitung_ut(ut,u0) u0[:] = ut[:] Z = u0 ax.clear() plotset() surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False, alpha=0.7) return surf, fig = plt.figure() #ax = fig.gca(projection='3d') ax = fig.add_subplot(111, projection='3d') R = sp.arange(0,1,dr) P = sp.arange(0,2*sp.pi,dp) R,P = sp.meshgrid(R,P) X,Y = R*sp.cos(P),R*sp.sin(P) Z = u0 print len(R), len(P) def plotset(): ax.set_xlim3d(-1., 1.) ax.set_ylim3d(-1., 1.) ax.set_zlim3d(-1.,1.) ax.set_autoscalez_on(False) ax.zaxis.set_major_locator(LinearLocator(10)) ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f')) cset = ax.contour(X, Y, Z, zdir='x', offset=0. , cmap=cm.coolwarm) cset = ax.contour(X, Y, Z, zdir='y', offset=1. , cmap=cm.coolwarm) cset = ax.contour(X, Y, Z, zdir='z', offset=-1., cmap=cm.coolwarm) plotset() surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False, alpha=0.7) fig.colorbar(surf, shrink=0.5, aspect=5) ani = animation.FuncAnimation(fig, data_gen, fargs=(Z, surf),frames=500, interval=30, blit=False) #ani.save('2dDiffusionf500b512.mp4', bitrate=512) plt.show() .
Miss Lay.
Miss Lay.
3D Animation of 2D Diffusion Equation using Python, Scipy, and Matplotlib
2D Diffusion Equation using Python, Scipy, and VPython
Numpy Slice Expression
Car Free Day
Car Free Day
Create CSV file using Delphi
I used textfile variable to write to a file (or create it if it don't exist). CSV file? Just make sure that the name at assignfile  command had .csv extension, :) Of course we have to format the output to meet the CSV standart; separated by comma. procedure TForm1.Button1Click(Sender: TObject); var fileku:textfile; i,j,n:integer; begin n:=10; assignfile(fileku,'data.csv'); rewrite(fileku); writeln(fileku,'tadaa...'); for i:=1 to n do begin for j:=1 to n do begin writeln(fileku,i,',',j,',','data',i,j); end; end; closefile(fileku); end; .
Turn right! No! Your other right!
Turn right! No! Your other right!
Darurat.
Sepatu basah kena hujan. Gak bawa serep. Nyalakan AC, gantung di depan kipas, tunggu dua jam, :)
Delphi on OS X
Here's the WineSkin version. I found it's way smoother than WineBottler version, ...., but hard to figure how to use it To install Delphi in OS X using WineSkin, we have to download and install Wineskin, of course, :) Open Wineskin Winery.app Make sure you have a Wrapper version and an Engine Select the Engine you want to use (I use WS9Wine1.7.52) Press the Create Wrapper button Enter in the name Delphi (or whatever you have in mind) for the wrapper and press OK When its done being created, click the button to view it in Finder in the finished window Close Wineskin Winery.app. Right click Delphi.app in Finder and select “Show Package Contents” Double click and run Wineskin.app. Now click on the Install Software button Select to choose a setup executable Navigate to the Delphi setup exe file you downloaded in step one Select the setup exe file and press the choose button At this point Delphi setup should begin, go through the Delphi setup like a normal install After the setup is done, back in Wineskin.app, it should pop up asking you to select the .exe file Choose the delphi32.exe file in the drop down list and press the Select Button Now press the Quit button to exit Wineskin.app Back in Finder, double click Delphi.app and start coding It has the same problem with WineBottler,  the toolbar tab's seem order by itself alphabetically, so the default toolbar tab is not ' standard ' tab but 'additional' one code unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; jalan:boolean=false; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin jalan := not jalan; if jalan = true then button1.Caption:='Stop' else button1.Caption:='Run'; end; procedure TForm1.FormCreate(Sender: TObject); begin button1.Caption:='Run'; end; end. .
Delphi on OS X
I use WineBottler to install Delphi 7 on my El Capitan. It's installed, it can run. The one that tickle me is the toolbar list is scrambled, it's sorted alphabetically, so additional toolbar is in the first and act as default toolbar.
Pulpen Cadangan, iPod dan Prasangka Baik Terhadap Soal.
Senjata ujian jaman dulu, :)
Obat Tidur Alami
Obat Tidur Alami
Heel and Toe?
Yup...
Yup...
Sisi Lain
Sisi Lain
Status.
Status.
SwishMax in Mac.
:) Yeah, I use OS X El Capitan in My Macbook Air and use Wine Bottler to install it. Make sure that flash option is ticked in winetriks part
Integral menggunakan Metode Numerik di Python dan Plot Fungsi menggunakan Matplotlib.
List Files on Certain Google Drive Folder and It's Subfolders
...and display it in html format using div tag with border so the files in subfolders will displayed in box, and files in other subfolder will displayed in other box. If subfolder have subfolder, then files inside that sub-subfolder will displayed inside box inside box, :s :P :D The Algorithm itself is bit like this previous post. OK, I copy and paste a little bit of,..., ok most of code from it. All by Google App Script. I use string variable named text to receive all output. Basically, after the script is completely executed, the content of variable text  is complete html source code. :) Here it is Code.gs
Passing String Variable to a Function on Google App Script
:)
:)
Hujan
Hujan
Lari-lari di Parkiran "Garasi", :)
Hanya Kemungkinan.
Hanya Kemungkinan.
The Typical Rick, :)
The Typical Rick, :)
Tarian Ayam Kinanthi, :D
Archive
Label
Popular Posts
Popular Posts
Loading