{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Inference using CGCNN Model"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this notebook we show how to perform inference using GT4SD and CGCNN-based models. The current existing models (algorithm_version=v0) and the sample dataset have been obtained from the [official CGCNN repository](https://github.com/txie-93/cgcnn)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Formation Energy\n",
    "\n",
    "This method predicts the formation energy per atom using the CGCNN framework (unit eV/atom)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gt4sd.properties.crystals.core import FormationEnergyParameters, FormationEnergy\n",
    "\n",
    "model_parameters = FormationEnergyParameters(algorithm_version=\"v0\")\n",
    "model = FormationEnergy(model_parameters)\n",
    "\n",
    "model(input=\"cgcnn-sample\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Absolute Energy\n",
    "\n",
    "This method predicts the absolute energy of crystals using the CGCNN framework (unit eV/atom)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gt4sd.properties.crystals.core import AbsoluteEnergy, AbsoluteEnergyParameters\n",
    "\n",
    "model_parameters = AbsoluteEnergyParameters(algorithm_version=\"v0\")\n",
    "model = AbsoluteEnergy(model_parameters)\n",
    "\n",
    "model(input=\"cgcnn-sample\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Band Gap\n",
    "\n",
    "This method predicts the band gap of crystals using the CGCNN framework (unit eV)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gt4sd.properties.crystals.core import BandGapParameters, BandGap\n",
    "\n",
    "model_parameters = BandGapParameters(algorithm_version=\"v0\")\n",
    "model = BandGap(model_parameters)\n",
    "\n",
    "model(input=\"cgcnn-sample\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Fermi Energy\n",
    "\n",
    "This method predicts the Fermi energy of crystals using the CGCNN framework (unit eV/atom)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gt4sd.properties.crystals.core import FermiEnergyParameters, FermiEnergy\n",
    "\n",
    "model_parameters = FermiEnergyParameters(algorithm_version=\"v0\")\n",
    "model = FermiEnergy(model_parameters)\n",
    "\n",
    "model(input=\"cgcnn-sample\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Bulk Moduli\n",
    "\n",
    "This method predicts the bulk moduli of crystals using the CGCNN framework (unit log(GPa))."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gt4sd.properties.crystals.core import BulkModuliParameters, BulkModuli\n",
    "\n",
    "model_parameters = BulkModuliParameters(algorithm_version=\"v0\")\n",
    "model = BulkModuli(model_parameters)\n",
    "\n",
    "model(input=\"cgcnn-sample\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Shear Moduli\n",
    "\n",
    "This method predicts the shear moduli of crystals using the CGCNN framework (unit log(GPa))."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gt4sd.properties.crystals.core import ShearModuliParameters, ShearModuli\n",
    "\n",
    "model_parameters = ShearModuliParameters(algorithm_version=\"v0\")\n",
    "model = ShearModuli(model_parameters)\n",
    "\n",
    "model(input=\"cgcnn-sample\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Poisson Ratio\n",
    "\n",
    "This method predicts the poisson ratio of crystals using the CGCNN framework."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gt4sd.properties.crystals.core import PoissonRatioParameters, PoissonRatio\n",
    "\n",
    "model_parameters = PoissonRatioParameters(algorithm_version=\"v0\")\n",
    "model = PoissonRatio(model_parameters)\n",
    "\n",
    "model(input=\"cgcnn-sample\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Metal-Semiconductor classifier\n",
    "\n",
    "This method predicts if the provided crystals are metal (1) or semiconductors (0) using the CGCNN framework."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gt4sd.properties.crystals.core import MetalSemiconductorClassifierParameters, MetalSemiconductorClassifier\n",
    "\n",
    "model_parameters = MetalSemiconductorClassifierParameters(algorithm_version=\"v0\")\n",
    "model = MetalSemiconductorClassifier(model_parameters)\n",
    "\n",
    "model(input=\"cgcnn-sample\")"
   ]
  }
 ],
 "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.8.15"
  },
  "vscode": {
   "interpreter": {
    "hash": "7f6df040e92be56c42e1ba5ffdd58832f97e24eff2af0498cbc88845f2e95a48"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}