brky.ai
Scientific Programming — Course Project Bilimsel Programlama — Ders Projesi

Projectile Motion with
Linear Drag
Doğrusal Sürüklemeli
Mermi Hareketi

A numerical simulation comparing projectile trajectories with and without air resistance, using forward Euler integration and analytical solutions. Developed as a final project for the Scientific Programming course at Marmara University. Hava direnciyle ve dirençsiz mermi yörüngelerini karşılaştıran, ileri Euler entegrasyonu ve analitik çözümler kullanan sayısal bir simülasyon. Marmara Üniversitesi Bilimsel Programlama dersi final projesi olarak geliştirilmiştir.

pythonnumpyphysicsnumerical-methods Team: Schrödinger's Siths — Berkay Yılmaz · Ahmet Ali Akkurt · Livanur Çelik
§1 — Theory §1 — Teori

Physical Model Fiziksel Model

A projectile of mass $m$ is launched from the origin with initial speed $v_0$ at angle $\theta$ above the horizontal. Two forces act on it: uniform gravitational acceleration $\vec{g}$ pointing downward, and a linear drag force proportional to and opposing the velocity vector.

The linear drag model assumes $\vec{F}_d = -k\vec{v}$, where $k$ is the drag coefficient in $[\text{kg/s}]$. This is a good approximation for slow, small objects in viscous media (low Reynolds number). For high-speed projectiles in air, a quadratic model ($F \propto v^2$) would be more appropriate — but the linear case keeps the math tractable and clearly demonstrates how drag modifies trajectories.

$m$ kütleli bir mermi, orijinden $v_0$ başlangıç hızıyla yatayla $\theta$ açı yapacak şekilde fırlatılır. Üzerine iki kuvvet etki eder: aşağı yönlü düzgün yerçekimi ivmesi $\vec{g}$ ve hız vektörüne oransal ve zıt yönlü doğrusal sürükleme kuvveti.

Doğrusal sürükleme modeli $\vec{F}_d = -k\vec{v}$ kabul eder; burada $k$, sürükleme katsayısı olup birimi $[\text{kg/s}]$'dir. Bu, viskoz ortamlarda yavaş ve küçük cisimler için (düşük Reynolds sayısı) iyi bir yaklaşımdır. Havadaki yüksek hızlı mermiler için kuadratik model ($F \propto v^2$) daha gerçekçi olur — ancak doğrusal durum matematiği basit tutar ve sürüklemenin yörüngeleri nasıl değiştirdiğini açıkça gösterir.

Newton's Second Law Newton'un İkinci Yasası

Applying $\vec{F} = m\vec{a}$ with gravity and linear drag: Yerçekimi ve doğrusal sürükleme ile $\vec{F} = m\vec{a}$ uygulandığında:

$$m\vec{a} = m\vec{g} - k\vec{v}$$
Net force = gravity + drag Net kuvvet = yerçekimi + sürükleme

Dividing both sides by $m$ and defining $\gamma = k/m \;[\text{s}^{-1}]$: Her iki tarafı $m$'ye bölüp $\gamma = k/m \;[\text{s}^{-1}]$ tanımlayarak:

$$\vec{a} = \vec{g} - \frac{k}{m}\vec{v} = \vec{g} - \gamma\vec{v}$$

Decomposition into Components Bileşenlere Ayırma

Writing $\vec{a} = (\ddot{x}, \ddot{y})$, $\vec{v} = (\dot{x}, \dot{y})$, and $\vec{g} = (0, -g)$: $\vec{a} = (\ddot{x}, \ddot{y})$, $\vec{v} = (\dot{x}, \dot{y})$ ve $\vec{g} = (0, -g)$ yazarak:

$$\hat{x}: \quad \ddot{x} = 0 - \gamma\dot{x} \;\;\Longrightarrow\;\; \ddot{x} + \gamma\dot{x} = 0$$
Horizontal — first-order linear ODE in $v_x = \dot{x}$ Yatay — $v_x = \dot{x}$ cinsinden birinci mertebe lineer ODE
$$\hat{y}: \quad \ddot{y} = -g - \gamma\dot{y} \;\;\Longrightarrow\;\; \ddot{y} + \gamma\dot{y} = -g$$
Vertical — nonhomogeneous first-order linear ODE in $v_y = \dot{y}$ Düşey — $v_y = \dot{y}$ cinsinden homojen olmayan birinci mertebe lineer ODE

Solving the Horizontal Equation Yatay Denklemin Çözümü

Substituting $u = v_x = \dot{x}$ gives the separable ODE $\dot{u} = -\gamma u$: $u = v_x = \dot{x}$ dönüşümüyle ayrılabilir $\dot{u} = -\gamma u$ ODE'si elde edilir:

$$\frac{du}{u} = -\gamma\,dt \;\;\xrightarrow{\int}\;\; \ln u = -\gamma t + C$$ $$\Longrightarrow\;\; v_x(t) = v_{x0}\,e^{-\gamma t} \quad\text{where}\; v_{x0} = v_0\cos\theta$$

Integrating once more for position: Konum için bir kez daha integre ederek:

$$x(t) = \int_0^t v_{x0}\,e^{-\gamma\tau}\,d\tau = \frac{v_{x0}}{\gamma}\left(1 - e^{-\gamma t}\right)$$
As $t \to \infty$, $x \to v_{x0}/\gamma$ — the terminal horizontal range $t \to \infty$ iken $x \to v_{x0}/\gamma$ — terminal yatay menzil

Solving the Vertical Equation Düşey Denklemin Çözümü

With $u = v_y$, we have $\dot{u} + \gamma u = -g$. The integrating factor is $\mu = e^{\gamma t}$: $u = v_y$ ile $\dot{u} + \gamma u = -g$ elde edilir. İntegral çarpanı $\mu = e^{\gamma t}$:

$$\frac{d}{dt}\!\left(u\,e^{\gamma t}\right) = -g\,e^{\gamma t}$$ $$u\,e^{\gamma t} = -\frac{g}{\gamma}\,e^{\gamma t} + C \;\;\Longrightarrow\;\; v_y(t) = Ce^{-\gamma t} - \frac{g}{\gamma}$$

Applying $v_y(0) = v_{y0} = v_0\sin\theta$ gives $C = v_{y0} + g/\gamma$: $v_y(0) = v_{y0} = v_0\sin\theta$ başlangıç koşulu ile $C = v_{y0} + g/\gamma$ bulunur:

$$v_y(t) = \left(v_{y0} + \frac{g}{\gamma}\right) e^{-\gamma t} - \frac{g}{\gamma}$$

Integrating for position with $y(0)=0$: $y(0)=0$ ile konumu integre ederek:

$$y(t) = -\frac{g}{\gamma}t + \frac{1}{\gamma}\!\left(v_{y0} + \frac{g}{\gamma}\right)\!\left(1 - e^{-\gamma t}\right)$$
Terminal velocity: $v_\text{term} = \lim_{t\to\infty} v_y = -g/\gamma = -mg/k$ Terminal hız: $v_\text{term} = \lim_{t\to\infty} v_y = -g/\gamma = -mg/k$

Quick Reference Hızlı Başvuru Tablosu

QuantityBüyüklük No DragSürüklemesiz With Linear DragDoğrusal Sürüklemeli
$v_x(t)$$v_0 \cos\theta$$v_0 \cos\theta \; e^{-\gamma t}$
$v_y(t)$$v_0 \sin\theta - gt$$(v_0 \sin\theta + g/\gamma)\,e^{-\gamma t} - g/\gamma$
$x(t)$$v_0 \cos\theta \cdot t$$\frac{v_0 \cos\theta}{\gamma}(1 - e^{-\gamma t})$
RangeMenzil$v_0^2 \sin 2\theta / g$No closed formKapalı form yok
$v_\text{term}$N/A$mg/k$
NoteNot In the no-drag case, total mechanical energy is conserved ($E = \text{KE} + \text{PE} = \text{const}$). With drag, energy is continuously dissipated as heat: $dE/dt = -k|\vec{v}|^2 < 0$. Sürüklemesiz durumda toplam mekanik enerji korunur ($E = \text{KE} + \text{PE} = \text{sabit}$). Sürüklemeli durumda enerji sürekli olarak ısıya dönüşür: $dE/dt = -k|\vec{v}|^2 < 0$.
§1.1 — Default Parameters §1.1 — Varsayılan Parametreler
SymbolSembol ValueDeğer DescriptionAçıklama
m5.0 kgProjectile massMermi kütlesi
k0.1 kg/sLinear drag coefficientDoğrusal sürükleme katsayısı
g9.81 m/s²Gravitational accelerationYerçekimi ivmesi
v₀50.0 m/sInitial speedBaşlangıç hızı
θ15°Launch angleFırlatma açısı
Δt0.01 sIntegration time stepEntegrasyon zaman adımı
§2 — Code §2 — Kod

Numerical Method: Forward Euler Sayısal Yöntem: İleri Euler

While closed-form solutions exist for linear drag, we integrate numerically using Euler's method. This serves as a foundation for extending to more complex models (quadratic drag, wind, spin) where analytical solutions are unavailable.

Doğrusal sürükleme için kapalı form çözümler mevcut olsa da, Euler yöntemiyle sayısal olarak entegre ediyoruz. Bu, analitik çözümlerin bulunmadığı daha karmaşık modellere (kuadratik sürükleme, rüzgar, spin) genişletmek için bir temel oluşturur.

$$v_x^{(n+1)} = v_x^{(n)} - \gamma \, v_x^{(n)} \, \Delta t \qquad v_y^{(n+1)} = v_y^{(n)} - \left(g + \gamma \, v_y^{(n)}\right) \Delta t$$ $$x^{(n+1)} = x^{(n)} + v_x^{(n)} \, \Delta t \qquad y^{(n+1)} = y^{(n)} + v_y^{(n)} \, \Delta t$$
First-order explicit scheme — $\mathcal{O}(\Delta t)$ local truncation error Birinci derece açık şema — $\mathcal{O}(\Delta t)$ yerel kesme hatası
StabilityKararlılık Forward Euler is conditionally stable. We need $\Delta t < 2/\gamma$. With defaults ($\gamma = 0.02\;\text{s}^{-1}$, $\Delta t = 0.01\;\text{s}$), $\Delta t \cdot \gamma = 0.0002 \ll 2$. Safe. İleri Euler koşullu kararlıdır. $\Delta t < 2/\gamma$ gereklidir. Varsayılanlarla ($\gamma = 0.02\;\text{s}^{-1}$, $\Delta t = 0.01\;\text{s}$), $\Delta t \cdot \gamma = 0.0002 \ll 2$. Güvenli.

Data StructuresVeri Yapıları

projectile_motion.pyPython
@dataclass
class SimulationParams:
    v0: float = 50.0        # initial velocity [m/s]
    angle_deg: float = 15.0 # launch angle [degrees]
    k: float = 0.1          # linear drag coefficient [kg/s]
    m: float = 5.0          # mass [kg]
    g: float = 9.81         # gravitational acceleration [m/s²]
    dt: float = 0.01        # time step [s]


@dataclass
class TrajectoryData:
    t: np.ndarray     # time array
    x: np.ndarray     # horizontal position
    y: np.ndarray     # vertical position
    vx: np.ndarray    # horizontal velocity
    vy: np.ndarray    # vertical velocity
    v: np.ndarray     # total speed
    ke: np.ndarray    # kinetic energy
    pe: np.ndarray    # potential energy
    te: np.ndarray    # total mechanical energy

Core Physics EngineFizik Motoru

projectile_motion.py — calculate_trajectory()Python
def calculate_trajectory(params: SimulationParams) -> tuple[TrajectoryData, TrajectoryData]:
    """Euler integration. Returns (with_drag, no_drag) trajectories."""
    angle_rad = np.radians(params.angle_deg)
    vx0 = params.v0 * np.cos(angle_rad)
    vy0 = params.v0 * np.sin(angle_rad)
    gamma = params.k / params.m  # drag-to-mass ratio [1/s]

    max_steps = int(params.t_max / params.dt) + 1
    t_arr = np.zeros(max_steps)
    x_arr, y_arr = np.zeros(max_steps), np.zeros(max_steps)
    vx_arr, vy_arr = np.zeros(max_steps), np.zeros(max_steps)
    vx_arr[0], vy_arr[0] = vx0, vy0

    for i in range(1, max_steps):
        t_arr[i] = i * params.dt
        # LINEAR drag: F_drag = -k * v
        ax = -gamma * vx_arr[i - 1]
        ay = -params.g - gamma * vy_arr[i - 1]

        vx_arr[i] = vx_arr[i - 1] + ax * params.dt
        vy_arr[i] = vy_arr[i - 1] + ay * params.dt
        x_arr[i] = x_arr[i - 1] + vx_arr[i - 1] * params.dt
        y_arr[i] = y_arr[i - 1] + vy_arr[i - 1] * params.dt

        if y_arr[i] < 0:
            break

Project StructureProje Yapısı

file treeShell
.
├── projectile_motion.py   # simulation engine, plotting, animation
├── requirements.txt       # numpy, matplotlib
├── README.md
├── static_overview.png
├── sweep_angles.png
├── drag_vs_distance.png
└── trajectory_animation.gif

Installation & UsageKurulum ve Kullanım

terminalBash
git clone https://github.com/berkayilmaaz/Projectile-Motion-with-Linear-Drag.git
cd Projectile-Motion-with-Linear-Drag
pip install -r requirements.txt

python projectile_motion.py
§3 — Results§3 — Sonuçlar

Live SimulationCanlı Simülasyon

Watch the projectile in real time. Blue = with drag, dashed red = no drag. Mermiyi gerçek zamanlı izleyin. Mavi = sürüklemeli, kesikli kırmızı = sürüklemesiz.

t = 0.00s

Static DashboardStatik Grafik Paneli

§3.1 — Parameter Sweeps§3.1 — Parametre Taramaları

Each sweep varies one parameter while holding others at defaults. Dashed = no-drag reference. Her taramada bir parametre değişirken diğerleri varsayılan değerde tutulur. Kesikli çizgi = sürüklemesiz referans.

§3.2 — Energy Dissipation§3.2 — Enerji Kayıpları

Without drag, mechanical energy is perfectly conserved. With drag, KE is continuously converted to heat. Sürüklemesiz durumda mekanik enerji tamamen korunur. Sürüklemeli durumda kinetik enerji sürekli ısıya dönüşür.

Drag Force vs. DistanceSürükleme Kuvveti – Mesafe İlişkisi

§4 — Interactive Simulator§4 — İnteraktif Simülatör

Try It YourselfKendiniz Deneyin

50 m/s
15°
0.10 kg/s
5.0 kg
9.81 m/s²
§5 — Conclusion§5 — Sonuç

ConclusionSonuç

This project demonstrates how even a simple linear drag model significantly alters projectile motion compared to the idealized case. Linear drag reduces both range and maximum height, the horizontal velocity decays exponentially, and the trajectory is no longer a symmetric parabola. Energy analysis confirms monotonic total energy decrease, with the dissipated energy going to heat.

The forward Euler scheme provides accurate results when $\Delta t \cdot \gamma \ll 1$. Possible extensions include quadratic drag ($F \propto v^2$), wind effects, Magnus force, 3D trajectories, and adaptive time-stepping.

Bu proje, basit bir doğrusal sürükleme modelinin bile idealleştirilmiş duruma kıyasla mermi hareketini önemli ölçüde değiştirdiğini göstermektedir. Doğrusal sürükleme hem menzili hem de maksimum yüksekliği azaltır, yatay hız üstel olarak azalır ve yörünge artık simetrik bir parabol değildir. Enerji analizi, toplam enerjinin monoton olarak azaldığını ve kaybedilen enerjinin ısıya dönüştüğünü doğrular.

İleri Euler şeması $\Delta t \cdot \gamma \ll 1$ olduğunda doğru sonuçlar verir. Olası genişletmeler: kuadratik sürükleme ($F \propto v^2$), rüzgar etkileri, Magnus kuvveti, 3B yörüngeler ve uyarlanabilir zaman adımı.

Schrödinger's Siths

Schrödinger's Siths

Research Group — Marmara University, Department of PhysicsAraştırma Grubu — Marmara Üniversitesi, Fizik Bölümü

Berkay Yılmaz
Berkay Yılmaz
Project LeadProje Sorumlusu
berkayyilmaz20@marun.edu.tr
Ahmet Ali Akkurt
Ahmet Ali Akkurt
DeveloperGeliştirici
ahmetakkurt@marun.edu.tr
Livanur Çelik
Livanur Çelik
DeveloperGeliştirici
livanurcelik@marun.edu.tr