{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Calculation of free energy of evaporization"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from pygromos.files.forcefield.gromos.gromosff import GromosFF\n",
    "from pygromos.files.gromos_system.gromos_system import Gromos_System\n",
    "from pygromos.simulations.approaches.hvap_calculation.hvap_calculation import Hvap_calculation\n",
    "from pygromos.data.simulation_parameters_templates import template_sd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "work_dir=os.getcwd()+\"/example_files/Hvap_files/\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ff = GromosFF(name=\"54A7\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "groSys = Gromos_System(work_folder=work_dir+\"init/\", system_name=\"Hvap_test\", in_smiles=\"O\", in_residue_list=[\"H2O\"],\n",
    "                       auto_convert=True, forcefield=ff, in_imd_path=template_sd)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "hvap_sys=Hvap_calculation(input_system=groSys, work_folder=work_dir+\"hvap\", forcefield=ff, system_name=\"test\", useGromosPlsPls=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "hvap_sys.create_liq()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# reduce number of steps for demonstration purposes\n",
    "hvap_sys.imd_gas_eq.STEP.NSTLIM = 10\n",
    "hvap_sys.imd_gas_sd.STEP.NSTLIM = 100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "hvap_sys.run_gas()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# reduce number of steps for demonstration purposes\n",
    "hvap_sys.imd_liq_eq.STEP.NSTLIM = 10\n",
    "hvap_sys.imd_liq_md.STEP.NSTLIM = 100\n",
    "hvap_sys.imd_liq_md.WRITETRAJ.NTWE = 40"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "hvap_sys.run_liq()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "hvap_sys.calc_hvap()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "b1b7b2ea43b8e767316eee98e01335d045804d2d47db68b6a5827e187ee91a7e"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 ('pygro2')",
   "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.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}