{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "93105cb8-8c9e-4cbd-bba2-247a1edbf816",
   "metadata": {},
   "outputs": [],
   "source": [
    "import cantera as ct"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "be0e455e-3bfb-4b48-a1ed-cbde1bb5e682",
   "metadata": {},
   "outputs": [],
   "source": [
    "water = ct.Water()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "361b4982-1a59-4369-a0e4-a618d4845ea3",
   "metadata": {},
   "outputs": [],
   "source": [
    "T_steel_1 = 30 + 273.15"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cd341049-8485-415e-b1ff-d2ee07dc473b",
   "metadata": {},
   "source": [
    "가스 온도, 대기압 상태"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "266db3c4-d24d-47e8-b928-e334f868291f",
   "metadata": {},
   "outputs": [],
   "source": [
    "water.TP = T_steel_1, ct.one_atm"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "566dd07e-62ac-47f4-b132-00087f43033f",
   "metadata": {},
   "source": [
    "수분 비율 (상대 습도 100%)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "8ac2070d-3b56-4541-a585-85dff3dff252",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.25783176282218023"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "water.P_sat / ct.one_atm"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "53825117-7e7f-4ce3-81d3-770b03ce0495",
   "metadata": {},
   "source": [
    "가스 온도, 포화수증기압, 완전 건조 상태"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "cd50fed0-5c76-4662-86dd-9510c30a4b3c",
   "metadata": {},
   "outputs": [],
   "source": [
    "water.TPQ = T_steel_1, water.P_sat, 1."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "69c402e1-e463-4771-af98-85ab2fcc4f42",
   "metadata": {},
   "source": [
    "상대습도(%) = 수분량 / 상대습도100%수분량"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "3fbc23c5-30ae-4502-b444-eb8f321b48c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "41.08331755965965"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "100 * 69 / (water.density * 1000)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ffb9d39b-bdea-4db3-b9a8-a3c22e530ee5",
   "metadata": {},
   "source": [
    "수분비율(부피, %) = 상대습도 100% 수분 부피비 * 상대습도"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "807f6d98-c030-42bc-9b94-dce04c4cf187",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10.592584188990477"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "100 * (water.P_sat / ct.one_atm) * (69 / (water.density * 1000))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7f9634b2-80fd-4967-aac6-2e09e7ee69bf",
   "metadata": {},
   "source": [
    "노점 (온도) 주어진 수증기압이 P_sat 이 되는 온도"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "31b116eb-351b-46b8-b083-36cf0281c31b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "edc85180-df3d-4057-ac27-08f1f5f78e12",
   "metadata": {},
   "outputs": [],
   "source": [
    "def prop_from_water_mass (Tgas, mass_g):\n",
    "\n",
    "    water.TP = Tgas, ct.one_atm\n",
    "\n",
    "    # 수분 비율 (상대 습도 100%)\n",
    "    vapor_volume_percent_max = water.P_sat / ct.one_atm\n",
    "\n",
    "    water.TPQ = Tgas, water.P_sat, 1.\n",
    "\n",
    "    # 상대습도(%) = 수분량 / 상대습도100%수분량\n",
    "    rh_percent = 100 * mass_g / (water.density * 1000)\n",
    "\n",
    "    # 수분비율(부피, %) = 상대습도 100% 수분 부피비 * 상대습도\n",
    "    vapor_volume_percent = 100 * (water.P_sat / ct.one_atm) * (mass_g / (water.density * 1000))\n",
    "    \n",
    "    return rh_percent, vapor_volume_percent, vapor_volume_percent_max"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "bc890402-7c41-49d8-93c7-24821fbf49c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "def prop_from_water_ratio (Tgas, ratio):\n",
    "\n",
    "    water.TP = Tgas, ct.one_atm\n",
    "\n",
    "    # 수분 비율 (상대 습도 100%)\n",
    "    vapor_volume_percent_max = water.P_sat / ct.one_atm\n",
    "\n",
    "    water.TPQ = Tgas, water.P_sat, 1.\n",
    "\n",
    "    # 상대습도(%) = 수분 비율 / 상대습도100% 수분 비율\n",
    "    rh_percent = 100 * ratio / vapor_volume_percent_max\n",
    "    \n",
    "    # 수분량 = 상대습도(%) * 상대습도100%수분량\n",
    "    mass_g = (water.density * 1000) * rh_percent / 100\n",
    "    \n",
    "    return rh_percent, mass_g, water.density * 1000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "2defc509-8fd8-49c1-8c12-a8cd0575a84d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(41.08331755965965, 10.592584188990477, 0.25783176282218023)"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prop_from_water_mass(66 + 273.15, 69)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "2d72cec1-5073-4900-b11f-f98422db3999",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(24.28933637550805, 4.995824898547489, 0.20567976091701654)"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prop_from_water_mass(61 + 273.15, 33)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "550806e9-e80d-4989-af33-92e5335c620e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(34.906482822316434, 58.62592063657547, 167.95138294223878)"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prop_from_water_ratio(66 + 273.15, 0.09)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "c20c915b-10bd-46ec-98c2-a900a1f34523",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(16044.359373460262, 21798.20194091713, 135.86208980692973)"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prop_from_water_ratio(61 + 273.15, 33)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "7224b67e-4fe2-4397-a49b-bd5f15ebe9f7",
   "metadata": {},
   "outputs": [],
   "source": [
    "water.TQ = 66 + 273.15, 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "bf2ba9af-f053-4c2e-891c-e689e9b46d80",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "66.0"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "water.T - 273.15"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "837b897f-0bff-47a8-9e3c-230dcb70bee9",
   "metadata": {},
   "outputs": [],
   "source": [
    "water.PQ = water.P * 0.34906482822316434, 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "7ef3b923-592a-4987-af5d-5795a23c5f4b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9119.250000000226"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "water.P_sat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "f802c772-3994-45a4-9cf9-5351d5046eb8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "317.21061256432915"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "water.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "9f0ee57a-5e88-4ba6-accf-ab581bb2458d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "44.060612564329176"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "_ - 273.15"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5554a487-c670-486c-b0de-c9ca6d46ea42",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.9.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
