transportations_library 0.1.11

A comprehensive Rust-based library implementing transportation engineering methodologies (e.g. the Highway Capacity Manual (HCM)) with Python bindings.
Documentation
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import transportations_library as tl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "length = 0.0\n",
    "avg_speed = 0.0\n",
    "hor_class = 0\n",
    "design_rad = 0.0\n",
    "sup_ele = 0.0\n",
    "central_angle = 0.0\n",
    "subsegment = tl.SubSegment(length=length, avg_speed=avg_speed, hor_class=hor_class, design_rad=design_rad, sup_ele=sup_ele, central_angle=central_angle)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0\n"
     ]
    }
   ],
   "source": [
    "print(subsegment.get_length())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "passing_type = 0\n",
    "length = 1.5\n",
    "grade = 0.0\n",
    "spl = 40.0\n",
    "is_hc = False\n",
    "volume = 1000\n",
    "volume_op = 1500\n",
    "flow_rate = 0.0\n",
    "flow_rate_o = 0.0\n",
    "capacity = 0\n",
    "ffs = 0.0\n",
    "avg_speed = 0.0\n",
    "vertical_class = 1\n",
    "py_subsegments = []\n",
    "phf = 0.95\n",
    "phv = 5.0\n",
    "pf = 0.0\n",
    "fd = 0.0\n",
    "fd_mid = 0.0\n",
    "hor_class = 0\n",
    "\n",
    "segment = tl.Segment(passing_type=passing_type, length=length, grade=grade, spl=spl, is_hc=is_hc, volume=volume, volume_op=volume_op, flow_rate=flow_rate, flow_rate_o=flow_rate_o, capacity=capacity, ffs=ffs, avg_speed=avg_speed, vertical_class=vertical_class, py_subsegments=py_subsegments, phf=phf, phv=phv, pf=pf, fd=fd, fd_mid=fd_mid, hor_class=hor_class)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.5\n"
     ]
    }
   ],
   "source": [
    "print(segment.get_length())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "py_segments = [segment]\n",
    "lane_width = 12.0\n",
    "shoulder_width = 6.0\n",
    "apd = 2\n",
    "pmhvfl = 0.4\n",
    "l_de = 0.0\n",
    "\n",
    "twolanehighways = tl.TwoLaneHighways(py_segments=py_segments, lane_width=lane_width, shoulder_width=shoulder_width, apd=apd, pmhvfl=pmhvfl, l_de=l_de)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Free-flow speed (mi/hr) = 44.933499999999995\n",
      "Average speed = 41.94343777139106\n",
      "Percent followers in the analysis direction (%) = 76.13974601789013\n",
      "Follower density (followers/mi) = 19.108376740194227\n",
      "LOS = E\n"
     ]
    }
   ],
   "source": [
    "seg_num = 0\n",
    "_, _, capacity = twolanehighways.determine_demand_flow(seg_num)\n",
    "ffs = twolanehighways.determine_free_flow_speed(seg_num)\n",
    "s, _ = twolanehighways.estimate_average_speed(seg_num)\n",
    "pf = twolanehighways.estimate_percent_followers(seg_num)\n",
    "fd = twolanehighways.determine_follower_density_pc_pz(seg_num)\n",
    "\n",
    "los = twolanehighways.determine_segment_los(0, s, int(capacity))\n",
    "\n",
    "print(f'Free-flow speed (mi/hr) = {ffs}')\n",
    "print(f'Average speed = {s}')\n",
    "print(f'Percent followers in the analysis direction (%) = {pf}')\n",
    "print(f'Follower density (followers/mi) = {fd}')\n",
    "print(f'LOS = {los}')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "transportations-library",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}