{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7.28 Checking for Choked Flow Conditions in a Control Valve"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Given the data from example 7.27, with a FL of 0.9.\n",
    "Confirm that choke will not occur in the control valve."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(18.966081253330014 <Unit('pound_force_per_square_inch')>,\n",
       " 70.8 <Unit('pound_force_per_square_inch')>)"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from fluids.units import *\n",
    "Psat = 4.75*u.psi\n",
    "Pc = 3198*u.psi\n",
    "P1 = 80.6*u.psi\n",
    "P2 = 70.8*u.psi\n",
    "\n",
    "P2_choke = control_valve_choke_P_l(Psat=Psat, Pc=Pc, FL=0.9, P1=P1)\n",
    "\n",
    "ratio = (P2/P2_choke).to_base_units()\n",
    "assert ratio.magnitude > 1\n",
    "\n",
    "P2_choke.to(u.psi), P2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can calculate the choke pressure directly thanks to the nice ISA equations.\n",
    "With `control_valve_choke_P_l`, we calculate the downstream pressure required for choke flow to form.\n",
    "So long as P2 is larger than the choke pressure, no choke will occur.\n",
    "\n",
    "Crane gives two solutions, one complicated and not necessary, and one that works on the same equation as `control_valve_choke_P_l`. Crane calculates `FLP` to use with that equation but only `FL` is supposed to be used, so they get a choke pressure of 20.8 psi instead of 19 psi here."
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
