Skip to content

Commit

Permalink
renamed polarizability model to pmodel
Browse files Browse the repository at this point in the history
  • Loading branch information
wolearyc committed Sep 26, 2024
1 parent 4c67d49 commit 7aa554b
Show file tree
Hide file tree
Showing 32 changed files with 61 additions and 61 deletions.
16 changes: 8 additions & 8 deletions docs/source/generated/ramannoodle.polarizability.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@ Subpackages
.. toctree::
:maxdepth: 4

ramannoodle.polarizability.torch
ramannoodle.pmodel.torch

Submodules
----------

ramannoodle.polarizability.abstract module
ramannoodle.pmodel.abstract module
------------------------------------------

.. automodule:: ramannoodle.polarizability.abstract
.. automodule:: ramannoodle.pmodel.abstract
:members:
:undoc-members:
:show-inheritance:

ramannoodle.polarizability.art module
ramannoodle.pmodel.art module
-------------------------------------

.. automodule:: ramannoodle.polarizability.art
.. automodule:: ramannoodle.pmodel.art
:members:
:undoc-members:
:show-inheritance:

ramannoodle.polarizability.interpolation module
ramannoodle.pmodel.interpolation module
-----------------------------------------------

.. automodule:: ramannoodle.polarizability.interpolation
.. automodule:: ramannoodle.pmodel.interpolation
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: ramannoodle.polarizability
.. automodule:: ramannoodle.pmodel
:members:
:undoc-members:
:show-inheritance:
18 changes: 9 additions & 9 deletions docs/source/generated/ramannoodle.polarizability.torch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@ polarizability.torch
Submodules
----------

ramannoodle.polarizability.torch.dataset module
ramannoodle.pmodel.torch.dataset module
-----------------------------------------------

.. automodule:: ramannoodle.polarizability.torch.dataset
.. automodule:: ramannoodle.pmodel.torch.dataset
:members:
:undoc-members:
:show-inheritance:

ramannoodle.polarizability.torch.gnn module
ramannoodle.pmodel.torch.gnn module
-------------------------------------------

.. automodule:: ramannoodle.polarizability.torch.gnn
.. automodule:: ramannoodle.pmodel.torch.gnn
:members:
:undoc-members:
:show-inheritance:

ramannoodle.polarizability.torch.train module
ramannoodle.pmodel.torch.train module
---------------------------------------------

.. automodule:: ramannoodle.polarizability.torch.train
.. automodule:: ramannoodle.pmodel.torch.train
:members:
:undoc-members:
:show-inheritance:

ramannoodle.polarizability.torch.utils module
ramannoodle.pmodel.torch.utils module
---------------------------------------------

.. automodule:: ramannoodle.polarizability.torch.utils
.. automodule:: ramannoodle.pmodel.torch.utils
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: ramannoodle.polarizability.torch
.. automodule:: ramannoodle.pmodel.torch
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/source/generated/ramannoodle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Subpackages

ramannoodle.dynamics
ramannoodle.io
ramannoodle.polarizability
ramannoodle.pmodel
ramannoodle.spectrum
ramannoodle.structure

Expand Down
6 changes: 3 additions & 3 deletions docs/source/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ With the atomic dynamics in hand, answering question (2) is conceptually straigh

Unfortunately, the need to calculate so many polarizabilities can make Raman spectrum calculations very computationally costly. These costs can quickly balloon, especially when treating large and/or complex systems. This ultimately makes conventional Raman spectrum calculations impractical for many of the most interesting and technologically relevant materials.

**Ramannoodle's primary purpose is to reduce the computational cost of first principles Raman calculations.** It accomplishes this by providing efficient polarizability models. For example, :class:`~ramannoodle.polarizability.art.ARTModel` and :class:`~ramannoodle.polarizability.interpolation.InterpolationModel` leverage structural symmetries to greatly reduce the number of required first principles polarizability calculations. We hope that current and future versions of this API will make computing Raman spectra simpler and, consequently, make Raman spectroscopy a more powerful characterization tool.
**Ramannoodle's primary purpose is to reduce the computational cost of first principles Raman calculations.** It accomplishes this by providing efficient polarizability models. For example, :class:`~ramannoodle.pmodel.art.ARTModel` and :class:`~ramannoodle.pmodel.interpolation.InterpolationModel` leverage structural symmetries to greatly reduce the number of required first principles polarizability calculations. We hope that current and future versions of this API will make computing Raman spectra simpler and, consequently, make Raman spectroscopy a more powerful characterization tool.

Installation
------------
Expand Down Expand Up @@ -44,8 +44,8 @@ The following gives an overview of the modules available in ramannoodle.
:synopsis:
:no-index:

4. :mod:`ramannoodle.polarizability`
.. automodule:: ramannoodle.polarizability
4. :mod:`ramannoodle.pmodel`
.. automodule:: ramannoodle.pmodel
:synopsis:
:no-index:

Expand Down
10 changes: 5 additions & 5 deletions docs/source/notebooks/basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"id": "d7da690f-f4db-4509-8c89-014e7a49c83b",
"metadata": {},
"source": [
"We will be computing TiO2's Raman spectrum using data available in `tests/data/TiO2` (see [Github repo](https://github.com/wolearyc/ramannoodle)). We will be basing this spectrum on frozen phonon calculations and use [InterpolationModel](../generated/ramannoodle.polarizability.html#module-ramannoodle.polarizability.interpolation.InterpolationModel) to estimate polarizabilities.\n",
"We will be computing TiO2's Raman spectrum using data available in `tests/data/TiO2` (see [Github repo](https://github.com/wolearyc/ramannoodle)). We will be basing this spectrum on frozen phonon calculations and use [InterpolationModel](../generated/ramannoodle.pmodel.html#module-ramannoodle.pmodel.interpolation.InterpolationModel) to estimate polarizabilities.\n",
"\n",
"### Setup\n",
"\n",
Expand Down Expand Up @@ -93,7 +93,7 @@
}
],
"source": [
"from ramannoodle.polarizability.interpolation import InterpolationModel\n",
"from ramannoodle.pmodel.interpolation import InterpolationModel\n",
"\n",
"# Read a reference (minimum) structure.\n",
"ref_structure = vasp_io.outcar.read_ref_structure(f\"{data_dir}/ref_eps_OUTCAR\")\n",
Expand Down Expand Up @@ -123,7 +123,7 @@
"\n",
"Atom 5's displacement along the x-axis is a degree of freedom (DOF) of the system. Convince yourself that TiO2 structure contains many DOFs that are **symmetrically equivalent** to this DOF.\n",
"\n",
" [InterpolationModel](../generated/ramannoodle.polarizability.html#module-ramannoodle.polarizability.interpolation.InterpolationModel)'s key assumption is that every DOF modulates the polarizability independently. The module estimates this modulation using an interpolation around each DOF. We need to \"add\" each DOF to `model`, specifying specific displacements as well as polarizabilities for these displacements (which we calculate using VASP). Internally, the model will handle all symmetry considerations. "
" [InterpolationModel](../generated/ramannoodle.pmodel.html#module-ramannoodle.pmodel.interpolation.InterpolationModel)'s key assumption is that every DOF modulates the polarizability independently. The module estimates this modulation using an interpolation around each DOF. We need to \"add\" each DOF to `model`, specifying specific displacements as well as polarizabilities for these displacements (which we calculate using VASP). Internally, the model will handle all symmetry considerations. "
]
},
{
Expand Down Expand Up @@ -441,9 +441,9 @@
"id": "14cbffbc",
"metadata": {},
"source": [
"And there you have it! Using ramannoodle's [InterpolationModel](../generated/ramannoodle.polarizability.html#module-ramannoodle.polarizability.interpolation.InterpolationModel), we calculated a full Raman spectrum for TiO2 using data from just a handful of polarizability calculations.\n",
"And there you have it! Using ramannoodle's [InterpolationModel](../generated/ramannoodle.pmodel.html#module-ramannoodle.pmodel.interpolation.InterpolationModel), we calculated a full Raman spectrum for TiO2 using data from just a handful of polarizability calculations.\n",
"\n",
"Next, we will introduce [ARTModel](../generated/ramannoodle.polarizability.html#module-ramannoodle.polarizability.art.ARTModel) and give a more complete overview of ramannoodle's workflow: [Full workflow](../notebooks/full-workflow.html)"
"Next, we will introduce [ARTModel](../generated/ramannoodle.pmodel.html#module-ramannoodle.pmodel.art.ARTModel) and give a more complete overview of ramannoodle's workflow: [Full workflow](../notebooks/full-workflow.html)"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions docs/source/notebooks/full-workflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
"source": [
"This notebook outlines a complete ramannoodle workflow and is, as always, available on [Github](https://github.com/wolearyc/ramannoodle/blob/main/docs/source/notebooks/full-workflow.ipynb). \n",
"\n",
"Here, we will use [ARTModel](../generated/ramannoodle.polarizability.html#module-ramannoodle.polarizability.art.ARTModel), a flavor of [InterpolationModel](../generated/ramannoodle.polarizability.html#module-ramannoodle.polarizability.interpolation.InterpolationModel), to again calculate TiO2's Raman spectrum. ARTModel uses \"atomic Raman tensors\" to predict polarizabilities, but is ultimately an InterpolationModel where\n",
"Here, we will use [ARTModel](../generated/ramannoodle.pmodel.html#module-ramannoodle.pmodel.art.ARTModel), a flavor of [InterpolationModel](../generated/ramannoodle.pmodel.html#module-ramannoodle.pmodel.interpolation.InterpolationModel), to again calculate TiO2's Raman spectrum. ARTModel uses \"atomic Raman tensors\" to predict polarizabilities, but is ultimately an InterpolationModel where\n",
"\n",
"1. All degrees of freedom (DOFs) are single atom displacements.\n",
"2. All interpolations are first-order.\n",
"3. Only two polarizabilities are used to construct each interpolation.\n",
"\n",
"Under these conditions, we dub each DOF polarizability interpolation (or more precisely, the derivative of the interpolation) as an **atomic Raman tensor**, or ART.\n",
"\n",
"Although [ARTModel](../generated/ramannoodle.polarizability.html#module-ramannoodle.polarizability.art.ARTModel) dictates that each DOF is a single atom displacement, we are free to choose the three orthogonal directions of the atom displacements. This means there are an infinite number of valid DOFs! Ultimately, the chosen atomic DOFs depends on user preference as well as the research question at hand. Still, wise choice of atomic DOFs can significantly reduce the cost of Raman calculations. \n",
"Although [ARTModel](../generated/ramannoodle.pmodel.html#module-ramannoodle.pmodel.art.ARTModel) dictates that each DOF is a single atom displacement, we are free to choose the three orthogonal directions of the atom displacements. This means there are an infinite number of valid DOFs! Ultimately, the chosen atomic DOFs depends on user preference as well as the research question at hand. Still, wise choice of atomic DOFs can significantly reduce the cost of Raman calculations. \n",
"\n",
"Regardless of how we choose our DOFs, we want to be sure that our DOFs are **valid** before carrying out expensive polarizability calculations and feeding the results into [ARTModel](../generated/ramannoodle.polarizability.html#module-ramannoodle.polarizability.art.ARTModel). To check our DOFs, we use **dummy models**. Essentially, we will build up a polarizability model in the usual way, except we instruct the model to internally generate \"dummy polarizabilities\". Although a dummy model cannot be used to predict polarizabilities (and therefore cannot be used to compute Raman spectra), it allows us to perform a dry run before we expend our valuable computational resources.\n",
"Regardless of how we choose our DOFs, we want to be sure that our DOFs are **valid** before carrying out expensive polarizability calculations and feeding the results into [ARTModel](../generated/ramannoodle.pmodel.html#module-ramannoodle.pmodel.art.ARTModel). To check our DOFs, we use **dummy models**. Essentially, we will build up a polarizability model in the usual way, except we instruct the model to internally generate \"dummy polarizabilities\". Although a dummy model cannot be used to predict polarizabilities (and therefore cannot be used to compute Raman spectra), it allows us to perform a dry run before we expend our valuable computational resources.\n",
"\n",
"We'll begin with some imports and some customizations to matplotlib. "
]
Expand Down Expand Up @@ -106,7 +106,7 @@
}
],
"source": [
"from ramannoodle.polarizability.art import ARTModel\n",
"from ramannoodle.pmodel.art import ARTModel\n",
"\n",
"model = ARTModel(ref_structure=ref_structure, \n",
" ref_polarizability = np.zeros((3,3)), \n",
Expand Down
6 changes: 3 additions & 3 deletions docs/source/notebooks/machine-learning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"outputs": [],
"source": [
"import torch\n",
"from ramannoodle.polarizability.torch.gnn import PotGNN\n",
"from ramannoodle.pmodel.torch.gnn import PotGNN\n",
"ref_structure = vasp_io.poscar.read_ref_structure(\"../../../test/data/TiO2/POSCAR\")\n",
"\n",
"model = PotGNN(\n",
Expand Down Expand Up @@ -228,7 +228,7 @@
}
],
"source": [
"from ramannoodle.polarizability.torch.train import train_single_epoch\n",
"from ramannoodle.pmodel.torch.train import train_single_epoch\n",
"\n",
"loss_function = torch.nn.MSELoss()\n",
"optimizer = torch.optim.Adam(model.parameters(), lr=0.02)\n",
Expand Down Expand Up @@ -271,7 +271,7 @@
}
],
"source": [
"from ramannoodle.polarizability.torch.train import train_single_epoch\n",
"from ramannoodle.pmodel.torch.train import train_single_epoch\n",
"\n",
"loss_function = torch.nn.MSELoss()\n",
"optimizer = torch.optim.Adam(model.parameters(), lr=0.0001)\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/source/notebooks/masking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"source": [
"This tutorial explores some of ramannoodle's masking features. These features are useful when analyzing simulated Raman spectra. \n",
"\n",
" [InterpolationModel](../generated/ramannoodle.polarizability.html#module-ramannoodle.polarizability.interpolation.InterpolationModel), as well it's subclasses (such as [ARTModel](../generated/ramannoodle.polarizability.html#module-ramannoodle.polarizability.art.ARTModel)), can be modified by \"masking\" specified degrees of freedom (DOFs). When a DOF is masked, it is excluded when calculating polarizabilities and therefore will not be accounted for when calculating Raman spectra. Raman spectra computed with masking should be regarded as *partial Raman spectra*. By choosing the masks wisely, quite a bit can be learned about which atom (or groups of atoms) correspond to which features in the simulated Raman spectra."
" [InterpolationModel](../generated/ramannoodle.pmodel.html#module-ramannoodle.pmodel.interpolation.InterpolationModel), as well it's subclasses (such as [ARTModel](../generated/ramannoodle.pmodel.html#module-ramannoodle.pmodel.art.ARTModel)), can be modified by \"masking\" specified degrees of freedom (DOFs). When a DOF is masked, it is excluded when calculating polarizabilities and therefore will not be accounted for when calculating Raman spectra. Raman spectra computed with masking should be regarded as *partial Raman spectra*. By choosing the masks wisely, quite a bit can be learned about which atom (or groups of atoms) correspond to which features in the simulated Raman spectra."
]
},
{
Expand Down Expand Up @@ -54,7 +54,7 @@
"source": [
"### Setup of model\n",
"\n",
"We will be computing TiO2's Raman spectrum using data available in `tests/data/TiO2` (see [Github repo](https://github.com/wolearyc/ramannoodle)). We will be basing this spectrum on frozen phonon calculations and use [ARTModel](../generated/ramannoodle.polarizability.html#module-ramannoodle.polarizability.art.ARTModel) to estimate polarizabilities."
"We will be computing TiO2's Raman spectrum using data available in `tests/data/TiO2` (see [Github repo](https://github.com/wolearyc/ramannoodle)). We will be basing this spectrum on frozen phonon calculations and use [ARTModel](../generated/ramannoodle.pmodel.html#module-ramannoodle.pmodel.art.ARTModel) to estimate polarizabilities."
]
},
{
Expand All @@ -65,7 +65,7 @@
"outputs": [],
"source": [
"import ramannoodle.io.vasp as vasp_io\n",
"from ramannoodle.polarizability.art import ARTModel\n",
"from ramannoodle.pmodel.art import ARTModel\n",
"\n",
"data_dir = \"../../../test/data/TiO2\"\n",
"# phonon_OUTCAR contains phonons (duh) as well as the reference TiO2 structure.\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/notebooks/molecular-dynamics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
],
"source": [
"import ramannoodle.io.vasp as vasp_io\n",
"from ramannoodle.polarizability.interpolation import InterpolationModel\n",
"from ramannoodle.pmodel.interpolation import InterpolationModel\n",
"\n",
"data_dir = \"../../../test/data/TiO2\"\n",
"ref_structure = vasp_io.poscar.read_ref_structure(f\"{data_dir}/POSCAR\")\n",
Expand Down
2 changes: 1 addition & 1 deletion ramannoodle/dynamics/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from abc import ABC, abstractmethod

from ramannoodle.polarizability.abstract import PolarizabilityModel
from ramannoodle.pmodel.abstract import PolarizabilityModel
from ramannoodle.spectrum.abstract import RamanSpectrum


Expand Down
2 changes: 1 addition & 1 deletion ramannoodle/dynamics/phonon.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from ramannoodle.dynamics.abstract import Dynamics
from ramannoodle.constants import RAMAN_TENSOR_CENTRAL_DIFFERENCE
from ramannoodle.polarizability.abstract import PolarizabilityModel
from ramannoodle.pmodel.abstract import PolarizabilityModel
from ramannoodle.spectrum.raman import PhononRamanSpectrum
from ramannoodle.exceptions import verify_ndarray_shape

Expand Down
2 changes: 1 addition & 1 deletion ramannoodle/dynamics/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from numpy.typing import NDArray

from ramannoodle.dynamics.abstract import Dynamics
from ramannoodle.polarizability.abstract import PolarizabilityModel
from ramannoodle.pmodel.abstract import PolarizabilityModel
from ramannoodle.exceptions import verify_ndarray_shape, get_type_error
from ramannoodle.spectrum.raman import MDRamanSpectrum
from ramannoodle.structure.utils import apply_pbc
Expand Down
2 changes: 1 addition & 1 deletion ramannoodle/io/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

TORCH_PRESENT = True
try:
from ramannoodle.polarizability.torch.dataset import PolarizabilityDataset
from ramannoodle.pmodel.torch.dataset import PolarizabilityDataset
except UserError:
TORCH_PRESENT = False

Expand Down
2 changes: 1 addition & 1 deletion ramannoodle/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

TORCH_PRESENT = True
try:
from ramannoodle.polarizability.torch.dataset import PolarizabilityDataset
from ramannoodle.pmodel.torch.dataset import PolarizabilityDataset
except UserError:
TORCH_PRESENT = False

Expand Down
2 changes: 1 addition & 1 deletion ramannoodle/io/vasp/outcar.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ramannoodle.structure.reference import ReferenceStructure

try:
from ramannoodle.polarizability.torch.dataset import PolarizabilityDataset
from ramannoodle.pmodel.torch.dataset import PolarizabilityDataset
except UserError:
pass

Expand Down
2 changes: 1 addition & 1 deletion ramannoodle/io/vasp/vasprun.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ramannoodle.structure.reference import ReferenceStructure

try:
from ramannoodle.polarizability.torch.dataset import PolarizabilityDataset
from ramannoodle.pmodel.torch.dataset import PolarizabilityDataset
except UserError:
pass

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from tabulate import tabulate

from ramannoodle.constants import ANSICOLORS
from ramannoodle.polarizability.interpolation import InterpolationModel
from ramannoodle.pmodel.interpolation import InterpolationModel
from ramannoodle.exceptions import (
get_type_error,
get_shape_error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from scipy.interpolate import make_interp_spline, BSpline

from ramannoodle.constants import ANSICOLORS
from ramannoodle.polarizability.abstract import PolarizabilityModel
from ramannoodle.pmodel.abstract import PolarizabilityModel
from ramannoodle.structure.utils import calc_displacement
from ramannoodle.structure.symmetry_utils import (
is_orthogonal_to_all,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import torch
from torch import Tensor
from torch.utils.data import Dataset
import ramannoodle.polarizability.torch.utils as rn_torch_utils
import ramannoodle.pmodel.torch.utils as rn_torch_utils
except ModuleNotFoundError as exc:
raise get_torch_missing_error() from exc

Expand Down
Loading

0 comments on commit 7aa554b

Please sign in to comment.