Showing posts with label Physicist. Show all posts
Showing posts with label Physicist. Show all posts
Thursday, March 19, 2009
Sunday, December 28, 2008
Problem with Checkbox
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
CheckBox1: TCheckBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
m,n:integer;
implementation
{$R *.dfm}
procedure lingkaran;
begin
form1.Image1.Canvas.Brush.Color:=clwhite;
form1.Image1.Canvas.Ellipse(m-77,n-77,m+77,n+77);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
m:=75;
n:=57;
//buat kotak putih//
form1.Image1.Canvas.Brush.Color:=clwhite;
form1.Image1.Canvas.Rectangle(0,0,form1.Image1.Width,form1.Image1.Height);
//buat pohon//
//buat lingkaran//
if form1.CheckBox1.Checked=true then begin
lingkaran;
end;
form1.Image1.Canvas.Brush.Color:=clblue;
form1.Image1.Canvas.Ellipse(m-7,n-7,m+7,n+7);
end;
end.
Saturday, November 29, 2008
The Answer of My Introduction Mathemathical for Physicist (Jawaban ujian Fismatku)
I use fortran to generate x n y position:
below is the code
PROGRAM Grafik
IMPLICIT NONE
REAL :: gaya,ygaya,k,ky,a,ay,m,v,vy,t,x,y,z
REAL :: sbx,sby,sbz,g,fx,fy,fz
REAL :: r,dt,dx,dy,dz,dv,dvy,theta,phi
INTEGER :: i,j,n
r =100
g =10
n =50
k =10000
ky =1000
t=0
dt=0.001
OPEN (80, FILE = 'data.dat', STATUS = 'NEW', FORM = 'FORMATTED')
WRITE(80,*) ' i t x y'
CLOSE(80)
OPEN(80, ACCESS = 'APPEND', FILE = 'data.dat', FORM = 'FORMATTED')
DO i=-n,n
x=i
x=x/10
IF (x .NE. 1) THEN
!y=(2+x-x*x)/(x-1)/(x-1)
z=2-x-x*x
vy=(x-1)*(x-1)
y=z/vy
END IF
WRITE(80,81) x,y
8¹FORMAT(e14.7,' ',e14.7)
END DO
CLOSE(80)
END PROGRAM Grafik
compile using:
$gfortran grafik.f90
that syntax has output a.out
run using:
$./a.out
It'll create file named data.dat and generate number of f(x)=(2-x-x^2)/(x-1)^2
plot using kst :
$kst -x ¹-y 2 data.dat
It means kst will plot a graph using 1st column as x-axis and 2nd column as y-axis of data.dat
to simplify that procedure, I create text file named run.sh contain:
rm *.dat
gfortran grafik.f90
./a.out
kst -x ¹-y 2 data.dat
make run.sh executable
then run:
$./run.sh
.........dan mereka hidup bahagia berdua selamanya.
Wednesday, November 19, 2008
First on Fortran
My first program written in fortran is below
!================================================
PROGRAM Grafik
IMPLICIT NONE
!declare variable
REAL :: gaya,ygaya,k,ky,a,ay,m,v,vy,t,x,y,z
REAL :: sbx,sby,sbz,g,fx,fy,fz
REAL :: r,dt,dx,dy,dz,dv,dvy,theta,phi
INTEGER :: i,j,n
!initial value
r =100
g =10
n =10000
k =10000
ky =1000
t=0
dt=0.001
!dx=0.01
m=10
v=0
x=10
y=10
vy=0
!create new file named data.dat (you may change the extension. I used that as I think .dat is cool extension )
OPEN (80, FILE = 'data.dat', STATUS = 'NEW', FORM = 'FORMATTED')
WRITE(80,*) ' i t x y'
CLOSE(80)
OPEN(80, ACCESS = 'APPEND', FILE = 'data.dat', FORM = 'FORMATTED')
!the algorithm
DO i=1,n
gaya=-k*x
a=gaya/m
dv=a*dt
v=v+dv
dx=v*dt
x=x+dx
ygaya=-ky*y
ay=ygaya/m
dvy=ay*dt
vy=vy+dvy
dy=vy*dt
y=y+dy
t=t+dt
!write the result of calclation to data.dat
WRITE(80,81) i, t, x, y
81 FORMAT(i7,' 'e14.7,' ',e14.7,' ',e14.7)
END DO
CLOSE(80)
END PROGRAM Grafik
!===========================================
save to grafik.f90 then compile using this syntax
$gfortran grafik.f90
that'll produce file named a.out
run using
$./a.out
and data.dat will appear
to plot the graphic using value in data.dat I use kst
$kst -x 2 -y 3 data dat
mean kst will use 2nd column as x-axis n 3rd as y-axis
Yeah, I know that the steps look boring, so I used sh script below to generate it automatically.
using kwrite, create text file like below:
rm *.dat
gfortran grafik.f90
./a.out
kst -x 2 -y 3 data.dat
save as run.sh, make it executable then run:
$./run.sh
!I also used script below to generate x, y, z in text file and plot it using kst
!
!DO i=1 ,100
! dt=i
! dt=dt/100
! sbx=r*sin(dt)
! sby=r*cos(dt)
! sbz=dt
! WRITE(80,81) sbx, sby, sbz
! 81 FORMAT(F10.2,' ',e14.7,' ',e14.7)
!END DO
!DO i=1, n
!DO j=1, n
! theta=i
! phi=j
! sbx=r*sin(theta)*cos(phi)
! sby=r*sin(theta)*sin(phi)
! sbz=r*cos(theta)
! !sbz=2
! WRITE(80,81) i, j, sbx, sby, sbz
! 81 FORMAT(i7,' ',i7,' 'e14.7,' ',e14.7,' ',e14.7)
! PRINT*, 'theta: ',i,' -------------'
! PRINT*, 'phi: ',j,' -------------'
! PRINT*, 'sb-x :', sbx
! PRINT*, 'sb-y :', sby
! PRINT*, 'sb-z :', sbz
!END DO
!END DO
There is something strange in two script above. The result is x, y, z (THREE variable) but why the plot is just in TWO axis? Err..., that the weakness of kst.
At prior time :), I used gnuplot to generate "3D" picture--of course, it just projection of z-axis (or x-axis if you using left-handed coordinate)--but I have'nt yet found to automating it using .sh script.
If you like to using gnuplot:
$gnuplot
>plot "data.dat" using 2:3 (oops, that still 2D. Plotting data.dat using 2nd and 3rd column)
>splot "data.dat" using 2:3:4 (that is.)
I've skimmed "man gnuplot" but did'nt found how to do it automatically
anybody can help me automating it using gnuplot?
oh yeah, almost forget, I use Linux.
!================================================
PROGRAM Grafik
IMPLICIT NONE
!declare variable
REAL :: gaya,ygaya,k,ky,a,ay,m,v,vy,t,x,y,z
REAL :: sbx,sby,sbz,g,fx,fy,fz
REAL :: r,dt,dx,dy,dz,dv,dvy,theta,phi
INTEGER :: i,j,n
!initial value
r =100
g =10
n =10000
k =10000
ky =1000
t=0
dt=0.001
!dx=0.01
m=10
v=0
x=10
y=10
vy=0
!create new file named data.dat (you may change the extension. I used that as I think .dat is cool extension )
OPEN (80, FILE = 'data.dat', STATUS = 'NEW', FORM = 'FORMATTED')
WRITE(80,*) ' i t x y'
CLOSE(80)
OPEN(80, ACCESS = 'APPEND', FILE = 'data.dat', FORM = 'FORMATTED')
!the algorithm
DO i=1,n
gaya=-k*x
a=gaya/m
dv=a*dt
v=v+dv
dx=v*dt
x=x+dx
ygaya=-ky*y
ay=ygaya/m
dvy=ay*dt
vy=vy+dvy
dy=vy*dt
y=y+dy
t=t+dt
!write the result of calclation to data.dat
WRITE(80,81) i, t, x, y
81 FORMAT(i7,' 'e14.7,' ',e14.7,' ',e14.7)
END DO
CLOSE(80)
END PROGRAM Grafik
!===========================================
save to grafik.f90 then compile using this syntax
$gfortran grafik.f90
that'll produce file named a.out
run using
$./a.out
and data.dat will appear
to plot the graphic using value in data.dat I use kst
$kst -x 2 -y 3 data dat
mean kst will use 2nd column as x-axis n 3rd as y-axis
Yeah, I know that the steps look boring, so I used sh script below to generate it automatically.
using kwrite, create text file like below:
rm *.dat
gfortran grafik.f90
./a.out
kst -x 2 -y 3 data.dat
save as run.sh, make it executable then run:
$./run.sh
!I also used script below to generate x, y, z in text file and plot it using kst
!
!DO i=1 ,100
! dt=i
! dt=dt/100
! sbx=r*sin(dt)
! sby=r*cos(dt)
! sbz=dt
! WRITE(80,81) sbx, sby, sbz
! 81 FORMAT(F10.2,' ',e14.7,' ',e14.7)
!END DO
!DO i=1, n
!DO j=1, n
! theta=i
! phi=j
! sbx=r*sin(theta)*cos(phi)
! sby=r*sin(theta)*sin(phi)
! sbz=r*cos(theta)
! !sbz=2
! WRITE(80,81) i, j, sbx, sby, sbz
! 81 FORMAT(i7,' ',i7,' 'e14.7,' ',e14.7,' ',e14.7)
! PRINT*, 'theta: ',i,' -------------'
! PRINT*, 'phi: ',j,' -------------'
! PRINT*, 'sb-x :', sbx
! PRINT*, 'sb-y :', sby
! PRINT*, 'sb-z :', sbz
!END DO
!END DO
There is something strange in two script above. The result is x, y, z (THREE variable) but why the plot is just in TWO axis? Err..., that the weakness of kst.
At prior time :), I used gnuplot to generate "3D" picture--of course, it just projection of z-axis (or x-axis if you using left-handed coordinate)--but I have'nt yet found to automating it using .sh script.
If you like to using gnuplot:
$gnuplot
>plot "data.dat" using 2:3 (oops, that still 2D. Plotting data.dat using 2nd and 3rd column)
>splot "data.dat" using 2:3:4 (that is.)
I've skimmed "man gnuplot" but did'nt found how to do it automatically
anybody can help me automating it using gnuplot?
oh yeah, almost forget, I use Linux.
in the middle of the night
Well, it's time to start anything seriously. And prove that I'm physicist
Monday, September 15, 2008
Mekanika klasik, duh...
Sunday, September 14, 2008
simulasi perkotaan
Membuat simulasi pertumbuhan daerah kota meggunakan CA:
langkah:
Bagaimana kita tahu bahwa sebuah sel itu kota, sungai atau jalan?
buat variabel 'status' berupa integer.
jika status=1 maka dia adalah 'sel kosong'
jika status=2 maka dia adalah 'kota'
jika status=3 maka dia adalah 'jalan'
langkah:
- Buat sel 200x200
- dari sel-sel tersebut, tentukan mana sel yang merupakan sungai, jalan, kota, danau, polusi atau daerah kosong, menggunakan record.
- proses menggunakan syarat-syarat yang telah ditentukan
- lihat hasilnya.
- jika dia 'sungai', biarkan saja
- begitu juga jika dia 'jalan'
- jika memiliki 3 atau lebih tetangga yang berupa 'kota' DAN tidak punya tetangga yang berupa 'polusi', ubah dia mejadi kota
- jika punya tetangga berupa 'polusi', biarkan saja
- jika tetangganya 'jalan DAN satu atau lebih 'kota' DAN tidak punya tetangga 'polusi', ubah dia menjadi 'kota'.
- jika satu atu lebih tetangganya 'danau' DAN satu atau lebih 'kota' DAN tidak ada tetangga berupa polusi, ubah dia menjadi kota
- jika dia 'kota' biarkan saja.
Bagaimana kita tahu bahwa sebuah sel itu kota, sungai atau jalan?
buat variabel 'status' berupa integer.
jika status=1 maka dia adalah 'sel kosong'
jika status=2 maka dia adalah 'kota'
jika status=3 maka dia adalah 'jalan'
Subscribe to:
Posts (Atom)
My sky is high, blue, bright and silent.
Nugroho's (almost like junk) blog
By: Nugroho Adi Pramono
323f
(5)
amp
(1)
android
(12)
apple
(7)
arduino
(18)
art
(1)
assembler
(21)
astina
(4)
ATTiny
(23)
blackberry
(4)
camera
(3)
canon
(2)
cerita
(2)
computer
(106)
crazyness
(11)
debian
(1)
delphi
(39)
diary
(286)
flash
(8)
fortran
(6)
freebsd
(6)
google apps script
(8)
guitar
(2)
HTML5
(10)
IFTTT
(7)
Instagram
(7)
internet
(12)
iOS
(5)
iPad
(6)
iPhone
(5)
java
(1)
javascript
(1)
keynote
(2)
LaTeX
(6)
lazarus
(1)
linux
(29)
lion
(15)
mac
(28)
macbook air
(8)
macbook pro
(3)
macOS
(1)
Math
(3)
mathematica
(1)
maverick
(6)
mazda
(4)
microcontroler
(35)
mountain lion
(2)
music
(37)
netbook
(1)
nugnux
(6)
os x
(36)
php
(1)
Physicist
(29)
Picture
(3)
programming
(189)
Python
(109)
S2
(13)
software
(7)
Soliloquy
(125)
Ubuntu
(5)
unix
(4)
Video
(8)
wayang
(3)
yosemite
(3)