Mirza Nur Hidayat

Articles
eBooks
HaKI
Grants
Events
Notes
Home
Visualisasi Sains - Roller Coaster - Multiplot


Plot visualisasi di atas dengan menggunakan aplikasi gnuplot (http://gnuplot.info) dengan kode program sebagai berikut.

    set term qt size 500,300
    set multiplot layout 2,1 title "Grafik Lintasan dan Kecepatan Roller Coaster"
    set grid
    set ylabel "ketinggian (m)"
    set xrange [0:100]
    plot "rollcoas.dat" u 1:2 w l lt 6 lw 2 t "lintasan"
    set yrange [0:20]
    set ylabel "kecepatan (m/s)"
    set xlabel "lintasan horisontal (m)"
    plot "rollcoas.dat" u 1:3 w l lt 7 lw 2 t "kecepatan"
    unset multiplot
Data "rollcoas.dat" diperoleh dari hasil eksekusi kode program berikut.
    program rollercoaster
	implicit none

	real*4, dimension(960) :: x, h, Em, Ep, Ek, v
	real, parameter :: m = 1.0
	real, parameter :: g = 9.8
	integer :: i

	open(1,  file  = "../rollcoas.dat")

	x(1) = 0.0

	do i = 1, 960
		x(i + 1) = x(i) + 0.1

		if (x(i) < 284.0 / 9.0) then
			h(i) = (1.0 / 16.0) * (x(i) - 20.0) ** 2
		else if (x(i) < 400.0 / 9.0) then
			h(i) = 13.0 - ((13.0 / 116.0) * (x(i) - 38.0) ** 2)
		else if (x(i) < 456.0 / 7.0) then
			h(i) = (1.0 / 16.0) * (x(i) - 56.0) ** 2
		else if (x(i) < 534.0 / 7.0) then
			h(i) = 8.0 - ((2.0 / 17.0) * (x(i) - 70.0) ** 2)
		else if (x(i) < 90.0) then
			h(i) = (1.0 / 16.0) * (x(i) - 84.0) ** 2
		else
			h(i) = 5.0 - ((5.0 / 64.0) * (x(i) - 96.0) ** 2)
		end if
	end do

	v(1) = 0.0

	do i = 1, 960
		v(i + 1) = sqrt(v(i) ** 2 - 2.0 * g * (h(i + 1) - h(i)) - (4.0 / 7.0) * g * abs(h(i + 1) - h(i)))
	end do

	do i = 1, 960
		Ep(i) = m * g * h(i)
		Ek(i) = 0.5 * m * v(i) ** 2
		Em(i) = Ep(i) + Ek(i)

		write(1, *) x(i), h(i), v(i), Ep(i), Ek(i), Em(i)
	end do
		
end program rollercoaster
    
Selamat mencoba!