UTS Fakhri Saputra

From ccitonlinewiki
Jump to: navigation, search

3.

A.

from numpy import *

g = 9.82

a = 0

m1 = eval(input("massa benda 1 (kg): "))

m2 = eval(input("massa benda 2 (kg): "))

m3 = eval(input("massa benda 3 (kg): "))

u1 = eval(input("koefisien gesek benda 1: "))

u2 = eval(input("koefisien gesek benda 2: "))

u3 = eval(input("koefisien gesek benda 3: "))

alphadeg = eval(input("sudut kemiringan (degrees): "))

alpha = (alphadeg / 180) * pi

sina = sin(alpha)

cosa = cos(alpha)

b1 = m1 * g * (sina + u1 * cosa) + m1 * a

b2 = m2 * g * (sina + u2 * cosa) + m2 * a

b3 = m3 * g * (sina + u3 * cosa) + m3 * a

b = array([b1, b2, b3], float)

kt = array([[1, 0, 0], [-1, 1, 0], [0, -1, 1]], float)

t = linalg.solve(kt, b)

t1 = t[0]

t2 = t[1]

t3 = t[2]

print(f't1 = {t1}, t2 = {t2}, t3 = {t3}')

B.

from math import *

g = 9.81

m = eval(input("massa mobil (kg): "))

cd = eval(input("koefisien drag: "))

ut = eval(input("koefisien gesek roda: "))

amobil = eval(input("percepatan mobil (m/s^2): "))

vmax = eval(input("kecepatan yang dicapai (km/h): "))

v = vmax * (1000 / 3600)

vo = 0

to = 0

h = 0.01

fmob = m * a

fges = ut * m * g

fdr = cd * v ** 1.5

atot = (fmob - fges - fdr) / m

def f(v, t): return (v / atot) - t


def rungekutta(vo, to, v, h):

	n = int((v - vo)/h)
	t = to
	for i in range(1, n + 1):
		k1 = h * f(vo, t)
		k2 = h * f(vo + 0.5 * h, t + 0.5 * k1)
		k3 = h * f(vo + 0.5 * h, t + 0.5 * k2)
		k4 = h * f(vo + h, t + k3)
		t = t + (1 / 6) * (k1 + 2 * k2 + 2 * k3 + k4)
		vo = vo + h
	return t
	
	

print(f'waktu yang dibutuhkan untuk mencapai {vmax} km/h adalah {rungekutta(vo, to, v, h)}')


== Muhasabah diri

==